Re: [FFmpeg-devel] [GSOC] [PATCH] TensorFlow backend introduction for DNN module

2018-05-31 Thread Guo, Yejun
Did you try to build ffmpeg with TENSORFLOW_BACKEND enabled, and run it without 
TF library?  This case is possible when an end user install pre-built package 
on a machine without TF library.

In function init, the logic is to fall back to cpu path (DNN_NATIVE) if unable 
to load tensorflow backend. While in function ff_get_dnn_module, it has no 
chance to 'return NULL'.

static av_cold int init(AVFilterContext* context)
{
SRCNNContext* srcnn_context = context->priv;

#ifdef TENSORFLOW_BACKEND
srcnn_context->dnn_module = ff_get_dnn_module(DNN_TF);
if (!srcnn_context->dnn_module){
av_log(context, AV_LOG_INFO, "could not load tensorflow backend, using 
native backend instead\n");
srcnn_context->dnn_module = ff_get_dnn_module(DNN_NATIVE);
}
#else
srcnn_context->dnn_module = ff_get_dnn_module(DNN_NATIVE);
#endif



DNNModule* ff_get_dnn_module(DNNBackendType backend_type)
{
...
case DNN_TF:
#ifdef TENSORFLOW_BACKEND
//add a runtime check here, possible?
dnn_module->load_model = _dnn_load_model_tf;
dnn_module->load_default_model = _dnn_load_default_model_tf;
dnn_module->execute_model = _dnn_execute_model_tf;
dnn_module->free_model = _dnn_free_model_tf;
#else
av_freep(dnn_module);
return NULL;
#endif



Thanks
Yejun (郭叶军)

-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Sergey 
Lavrushkin
Sent: Thursday, May 31, 2018 11:01 PM
To: FFmpeg development discussions and patches 
Cc: Pedro Arthur 
Subject: [FFmpeg-devel] [GSOC] [PATCH] TensorFlow backend introduction for DNN 
module

Hello,

This patch introduces TensorFlow backend for DNN inference module.
This backend uses TensorFlow binary models and requires from model to have the 
operation named 'x' as an input operation and the operation named 'y' as an 
output operation. Models are executed using libtensorflow.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2] avformat/hlsenc: reimplement randomize of hls use av_get_random_seed

2018-05-31 Thread Steven Liu
---
 configure|  1 -
 libavformat/hlsenc.c | 31 ++-
 2 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/configure b/configure
index 22eeca22a5..a3d0f5837a 100755
--- a/configure
+++ b/configure
@@ -3127,7 +3127,6 @@ fifo_muxer_deps="threads"
 flac_demuxer_select="flac_parser"
 hds_muxer_select="flv_muxer"
 hls_muxer_select="mpegts_muxer"
-hls_muxer_suggest="gcrypt openssl"
 image2_alias_pix_demuxer_select="image2_demuxer"
 image2_brender_pix_demuxer_select="image2_demuxer"
 ipod_muxer_select="mov_muxer"
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 2268f898b0..3012b2a727 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -27,12 +27,6 @@
 #include 
 #endif
 
-#if CONFIG_GCRYPT
-#include 
-#elif CONFIG_OPENSSL
-#include 
-#endif
-
 #include "libavutil/avassert.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/parseutils.h"
@@ -569,18 +563,16 @@ fail:
 return ret;
 }
 
-static int randomize(uint8_t *buf, int len)
+
+static void randomize(uint8_t *buf, int len)
 {
-#if CONFIG_GCRYPT
-gcry_randomize(buf, len, GCRY_VERY_STRONG_RANDOM);
-return 0;
-#elif CONFIG_OPENSSL
-if (RAND_bytes(buf, len))
-return 0;
-#else
-return AVERROR(ENOSYS);
-#endif
-return AVERROR(EINVAL);
+uint32_t tmp_number[4];
+int i = 0;
+
+for (i = 0; i < 4; i++)
+tmp_number[i] = av_get_random_seed();
+
+memcpy(buf, tmp_number, len);
 }
 
 static int do_encrypt(AVFormatContext *s, VariantStream *vs)
@@ -633,10 +625,7 @@ static int do_encrypt(AVFormatContext *s, VariantStream 
*vs)
 
 if (!*hls->key_string) {
 if (!hls->key) {
-if ((ret = randomize(key, sizeof(key))) < 0) {
-av_log(s, AV_LOG_ERROR, "Cannot generate a strong random 
key\n");
-return ret;
-}
+randomize(key, sizeof(key));
 } else {
 memcpy(key, hls->key, sizeof(key));
 }
-- 
2.15.1 (Apple Git-101)



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


Re: [FFmpeg-devel] [PATCH] lavfi: add opencl tonemap filter.

2018-05-31 Thread Song, Ruiling


> -Original Message-
> From: Song, Ruiling
> Sent: Tuesday, May 29, 2018 4:47 PM
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: RE: [FFmpeg-devel] [PATCH] lavfi: add opencl tonemap filter.
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > Of myp...@gmail.com
> > Sent: Tuesday, May 29, 2018 3:40 PM
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH] lavfi: add opencl tonemap filter.
> >
> > 2018-05-29 13:54 GMT+08:00 Ruiling Song :
> > > This filter does HDR(HDR10/HLG) to SDR conversion with tone-mapping.
> > >
> > > An example command to use this filter with vaapi codecs:
> > > FFMPEG -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device
> \
> > > opencl=ocl@va -hwaccel vaapi -hwaccel_device va -
> > hwaccel_output_format \
> > > vaapi -i INPUT -filter_hw_device ocl -filter_complex \
> > >
> '[0:v]hwmap,tonemap_opencl=t=bt2020:tonemap=linear:format=p010[x1];
> > \
> > > [x1]hwmap=derive_device=vaapi:reverse=1' -c:v hevc_vaapi -profile 2
> > OUTPUT
> > >
> > > v2:
> > > add peak detection.
> > >
> > > Signed-off-by: Ruiling Song 
> > > +static int tonemap_opencl_config_output(AVFilterLink *outlink)
> > > +{
> > > +AVFilterContext *avctx = outlink->src;
> > > +TonemapOpenCLContext *s = avctx->priv;
> > > +int ret;
> > > +if (s->format == AV_PIX_FMT_NONE)
> > > +av_log(avctx, AV_LOG_WARNING, "format not set, use default
> > format NV12\n");
> >  I think we can give a default format with AV_PIX_FMT_NV12 in
> > tonemap_opencl_options[] for this case
> > and I think now we only support NV12/P010 output in current implement.
> Sounds good.
Hi Jun,

I realized that if I default it to NV12 in the table, I would have no chance to 
catch whether user
already passed in a format or not. In fact, I still prefer user explicitly 
passed in the format that they want (10bit or 8bit).
If user did not choose a format, I would generate a warning message that 
default was used.
Does this make sense?

Thanks!
Ruiling

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


Re: [FFmpeg-devel] libavutil/encryption_info: Allow multiple init info.

2018-05-31 Thread Jacob Trimble
On Thu, May 31, 2018 at 9:40 AM Jacob Trimble  wrote:
>
> On Fri, May 25, 2018 at 6:13 PM Michael Niedermayer
>  wrote:
> >
> > [...]
> >
> > > Added fix for issue found by Chrome's ClusterFuzz 
> > > (http://crbug.com/846662).
> >
> > this belongs in a seperate patch unless its a bug specific to the code added
> > with this patch
> >
>
> Ok.  Now this patch depends on
> http://ffmpeg.org/pipermail/ffmpeg-devel/2018-May/230782.html.
>

Noticed some bugs when integrating it.

> > [...]
> >
> > --
> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > I have often repented speaking, but never of holding my tongue.
> > -- Xenocrates
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
From ea52a1264787256a2c92bc162d217b98e1b39e23 Mon Sep 17 00:00:00 2001
From: Jacob Trimble 
Date: Mon, 23 Apr 2018 10:33:58 -0700
Subject: [PATCH] libavutil/encryption_info: Allow multiple init info.

It is possible for there to be multiple encryption init info structure.
For example, to support multiple key systems or in key rotation.  This
changes the AVEncryptionInitInfo struct to be a linked list so there
can be multiple structs without breaking ABI.

Signed-off-by: Jacob Trimble 
---
 libavutil/encryption_info.c | 153 
 libavutil/encryption_info.h |   5 ++
 2 files changed, 109 insertions(+), 49 deletions(-)

diff --git a/libavutil/encryption_info.c b/libavutil/encryption_info.c
index a48ded922c..00f7d0fde0 100644
--- a/libavutil/encryption_info.c
+++ b/libavutil/encryption_info.c
@@ -162,13 +162,16 @@ uint8_t *av_encryption_info_add_side_data(const AVEncryptionInfo *info, size_t *
 }
 
 // The format of the AVEncryptionInitInfo side data:
-// u32be system_id_size
-// u32be num_key_ids
-// u32be key_id_size
-// u32be data_size
-// u8[system_id_size] system_id
-// u8[key_id_size][num_key_id] key_ids
-// u8[data_size] data
+// u32be init_info_count
+// {
+//   u32be system_id_size
+//   u32be num_key_ids
+//   u32be key_id_size
+//   u32be data_size
+//   u8[system_id_size] system_id
+//   u8[key_id_size][num_key_id] key_ids
+//   u8[data_size] data
+// }[init_info_count]
 
 #define FF_ENCRYPTION_INIT_INFO_EXTRA 16
 
@@ -217,6 +220,7 @@ void av_encryption_init_info_free(AVEncryptionInitInfo *info)
 for (i = 0; i < info->num_key_ids; i++) {
 av_free(info->key_ids[i]);
 }
+av_encryption_init_info_free(info->next);
 av_free(info->system_id);
 av_free(info->key_ids);
 av_free(info->data);
@@ -227,72 +231,123 @@ void av_encryption_init_info_free(AVEncryptionInitInfo *info)
 AVEncryptionInitInfo *av_encryption_init_info_get_side_data(
 const uint8_t *side_data, size_t side_data_size)
 {
-AVEncryptionInitInfo *info;
-uint64_t system_id_size, num_key_ids, key_id_size, data_size, i;
+// |ret| tracks the front of the list, |info| tracks the back.
+AVEncryptionInitInfo *ret = NULL, *info, *temp_info;
+uint64_t system_id_size, num_key_ids, key_id_size, data_size, i, j;
+uint64_t init_info_count;
 
-if (!side_data || side_data_size < FF_ENCRYPTION_INIT_INFO_EXTRA)
+if (!side_data || side_data_size < 4)
 return NULL;
 
-system_id_size = AV_RB32(side_data);
-num_key_ids = AV_RB32(side_data + 4);
-key_id_size = AV_RB32(side_data + 8);
-data_size = AV_RB32(side_data + 12);
+init_info_count = AV_RB32(side_data);
+side_data += 4;
+side_data_size -= 4;
+for (i = 0; i < init_info_count; i++) {
+if (side_data_size < FF_ENCRYPTION_INIT_INFO_EXTRA) {
+av_encryption_init_info_free(ret);
+return NULL;
+}
 
-// UINT32_MAX + UINT32_MAX + UINT32_MAX * UINT32_MAX == UINT64_MAX
-if (side_data_size - FF_ENCRYPTION_INIT_INFO_EXTRA < system_id_size + data_size + num_key_ids * key_id_size)
-return NULL;
+system_id_size = AV_RB32(side_data);
+num_key_ids = AV_RB32(side_data + 4);
+key_id_size = AV_RB32(side_data + 8);
+data_size = AV_RB32(side_data + 12);
 
-info = av_encryption_init_info_alloc(system_id_size, num_key_ids, key_id_size, data_size);
-if (!info)
-return NULL;
+// UINT32_MAX + UINT32_MAX + UINT32_MAX * UINT32_MAX == UINT64_MAX
+if (side_data_size - FF_ENCRYPTION_INIT_INFO_EXTRA < system_id_size + data_size + num_key_ids * key_id_size) {
+av_encryption_init_info_free(ret);
+return NULL;
+}
+side_data += FF_ENCRYPTION_INIT_INFO_EXTRA;
+side_data_size -= FF_ENCRYPTION_INIT_INFO_EXTRA;
+
+temp_info = av_encryption_init_info_alloc(system_id_size, num_key_ids, key_id_size, data_size);
+if (!temp_info) {
+av_encryption_init_info_free(ret);
+return NULL;
+}
+if (i == 0) {
+info = ret = temp_info;
+} else {
+ 

Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Set st->start_time for video streams explicitly.

2018-05-31 Thread Sasi Inguva
Pls find attached, the correctly signed patch
Thanks.

On Thu, May 31, 2018 at 4:14 PM Sasi Inguva  wrote:

> Sorry. Forgot to attach the file. Pls find it attached. Also resending the
> patch signed with correct email address
>
> On Thu, May 31, 2018 at 2:14 PM Michael Niedermayer 
> wrote:
>
>> On Tue, May 29, 2018 at 03:39:40PM -0700, Sasi Inguva wrote:
>> > If start_time is not set, ffmpeg takes the duration from the global
>> > movie instead of the per stream duration.
>> > Signed-off-by: Sasi Inguva > >
>> > ---
>> >  libavformat/mov.c| 20 +---
>> >  tests/fate/mov.mak   |  4 +++
>> >  tests/ref/fate/mov-neg-firstpts-discard  |  2 +-
>> >  tests/ref/fate/mov-stream-shorter-than-movie | 33 
>> >  4 files changed, 54 insertions(+), 5 deletions(-)
>> >  create mode 100644 tests/ref/fate/mov-stream-shorter-than-movie
>>
>> i may have missed a link to a sample file
>>
>> fate-suite//mov/mov_stream_shorter_than_movie.mov: No such file or
>> directory
>> make: *** [fate-mov-stream-shorter-than-movie] Error 1
>>
>>
>>
>>
>> [...]
>> --
>> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>>
>> It is dangerous to be right in matters on which the established
>> authorities
>> are wrong. -- Voltaire
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>
From ba2feb04ef1ca94f7e1972e23c84c2acde93bf68 Mon Sep 17 00:00:00 2001
From: Sasi Inguva 
Date: Tue, 29 May 2018 15:36:07 -0700
Subject: [PATCH] lavf/mov.c: Set st->start_time for video streams explicitly.

If start_time is not set, ffmpeg takes the duration from the global
movie instead of the per stream duration.
Signed-off-by: Sasi Inguva 
---
 libavformat/mov.c| 20 +---
 tests/fate/mov.mak   |  4 +++
 tests/ref/fate/mov-neg-firstpts-discard  |  2 +-
 tests/ref/fate/mov-stream-shorter-than-movie | 33 
 4 files changed, 54 insertions(+), 5 deletions(-)
 create mode 100644 tests/ref/fate/mov-stream-shorter-than-movie

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f2a540ad50..1915be5fb5 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3672,11 +3672,15 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
 
 // If the minimum pts turns out to be greater than zero after fixing the index, then we subtract the
 // dts by that amount to make the first pts zero.
-if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && msc->min_corrected_pts > 0) {
-av_log(mov->fc, AV_LOG_DEBUG, "Offset DTS by %"PRId64" to make first pts zero.\n", msc->min_corrected_pts);
-for (i = 0; i < st->nb_index_entries; ++i) {
-st->index_entries[i].timestamp -= msc->min_corrected_pts;
+if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+if (msc->min_corrected_pts > 0) {
+av_log(mov->fc, AV_LOG_DEBUG, "Offset DTS by %"PRId64" to make first pts zero.\n", msc->min_corrected_pts);
+for (i = 0; i < st->nb_index_entries; ++i) {
+st->index_entries[i].timestamp -= msc->min_corrected_pts;
+}
 }
+// Start time should be equal to zero or the duration of any empty edits.
+st->start_time = empty_edits_sum_duration;
 }
 
 // Update av stream length, if it ends up shorter than the track's media duration
@@ -4012,6 +4016,14 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
 mov_fix_index(mov, st);
 }
 
+// Update start time of the stream.
+if (st->start_time == AV_NOPTS_VALUE && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->nb_index_entries > 0) {
+st->start_time = st->index_entries[0].timestamp + sc->dts_shift;
+if (sc->ctts_data) {
+st->start_time += sc->ctts_data[0].duration;
+}
+}
+
 mov_estimate_video_delay(mov, st);
 }
 
diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index eadee3abfa..c1d399e5c0 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -16,6 +16,7 @@ FATE_MOV = fate-mov-3elist \
fate-mov-frag-overlap \
fate-mov-bbi-elst-starts-b \
fate-mov-neg-firstpts-discard-frames \
+	   fate-mov-stream-shorter-than-movie \
 
 FATE_MOV_FFPROBE = fate-mov-neg-firstpts-discard \
fate-mov-aac-2048-priming \
@@ -88,6 +89,9 @@ fate-mov-neg-firstpts-discard: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entri
 # Makes sure that expected frames are generated for mov_neg_first_pts_discard.mov with -vsync 1
 fate-mov-neg-firstpts-discard-frames: CMD = framemd5 -flags +bitexact -i $(TARGET_SAMPLES)/mov/mov_neg_first_pts_discard.mov -vsync 1
 
+# Makes sure that no frame is dropped/duplicated with fps filter due to start_time / duration miscalculations.
+fate-mov-stream-shorter-than-movie: CMD = framemd5 -flags 

[FFmpeg-devel] [PATCH] lavf/mov.c: Fix timestamps to be strictly monotonic for video also.

2018-05-31 Thread isasi-at-google . com
From: Sasi Inguva 

Using same timestamp for multiple packets confuses clients like Ffms2
while seeking to a packet with specific timestamp.

Signed-off-by: Sasi Inguva 
---
 libavformat/mov.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index cb6f3a45de..39d21e6e1c 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3554,7 +3554,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
 edit_list_dts_counter -= packet_skip_samples;
 if (edit_list_start_encountered == 0)  {
 edit_list_start_encountered = 1;
-// Make timestamps strictly monotonically increasing 
for audio, by rewriting timestamps for
+// Make timestamps strictly monotonically increasing, 
by rewriting timestamps for
 // discarded packets.
 if (frame_duration_buffer) {
 fix_index_entry_timestamps(st, 
st->nb_index_entries, edit_list_dts_counter,
@@ -3568,7 +3568,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
 flags |= AVINDEX_DISCARD_FRAME;
 av_log(mov->fc, AV_LOG_DEBUG, "drop a frame at curr_cts: 
%"PRId64" @ %"PRId64"\n", curr_cts, index);
 
-if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && 
edit_list_start_encountered == 0) {
+if (edit_list_start_encountered == 0) {
 num_discarded_begin++;
 frame_duration_buffer = 
av_realloc(frame_duration_buffer,
num_discarded_begin 
* sizeof(int64_t));
@@ -3579,7 +3579,8 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
 frame_duration_buffer[num_discarded_begin - 1] = 
frame_duration;
 
 // Increment skip_samples for the first non-zero audio 
edit list
-if (first_non_zero_audio_edit > 0 && 
st->codecpar->codec_id != AV_CODEC_ID_VORBIS) {
+if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
+first_non_zero_audio_edit > 0 && 
st->codecpar->codec_id != AV_CODEC_ID_VORBIS) {
 st->skip_samples += frame_duration;
 }
 }
@@ -3594,7 +3595,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
 edit_list_start_encountered = 1;
 // Make timestamps strictly monotonically increasing for 
audio, by rewriting timestamps for
 // discarded packets.
-if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && 
frame_duration_buffer) {
+if (frame_duration_buffer) {
 fix_index_entry_timestamps(st, st->nb_index_entries, 
edit_list_dts_counter,
frame_duration_buffer, 
num_discarded_begin);
 av_freep(_duration_buffer);
-- 
2.17.0.rc1.321.gba9d0f2565-goog

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


[FFmpeg-devel] [PATCH v2] avformat/movenc: properly handle cover image codecs

2018-05-31 Thread Timo Teräs
Find codec tag for attached images using appropriate list of
supported image formats.

This fixes writing the cover image to m4v/m4a and other container
formats that do not allow these codecs as a track.

Signed-off-by: Timo Teräs 
---
This replaces the previous patch:
 PATCH] [RFC] avformat/movenc: support covert images for ipod muxer

It appears that query_codec() is used only to figure out which stream
to select as the default copy stream. Fixing it properly for movenc
attached pictures is difficult, as the stream disposition would need
to be passed through the call stack. Additionally, it would make sense
to rewrite the selection logic open_output_file() to not use APIC
special tag and be based on the input/output dispositions.

So this just adds proper handling of the codecs in mov_init() phase
which fixes most of the usability issues.

Please backport to 4.0 stable branch too.

Changes in v2:
 - map the codec to the actual covr image tag value and
   use that when writing the cover image instead of doing
   a new switch over the codec

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

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 7e616e866f..4ba90135df 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1557,10 +1557,20 @@ static int mov_get_codec_tag(AVFormatContext *s, 
MOVTrack *track)
 return tag;
 }
 
+static const AVCodecTag codec_cover_image_tags[] = {
+{ AV_CODEC_ID_MJPEG,  0xD },
+{ AV_CODEC_ID_PNG,0xE },
+{ AV_CODEC_ID_BMP,0x1B },
+{ AV_CODEC_ID_NONE, 0 },
+};
+
 static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
 {
 int tag;
 
+if (track->st->disposition & AV_DISPOSITION_ATTACHED_PIC)
+return ff_codec_get_tag(codec_cover_image_tags, track->par->codec_id);
+
 if (track->mode == MODE_MP4 || track->mode == MODE_PSP)
 tag = track->par->codec_tag;
 else if (track->mode == MODE_ISM)
@@ -3429,7 +3439,7 @@ static int mov_write_covr(AVIOContext *pb, 
AVFormatContext *s)
 {
 MOVMuxContext *mov = s->priv_data;
 int64_t pos = 0;
-int i, type;
+int i;
 
 for (i = 0; i < s->nb_streams; i++) {
 MOVTrack *trk = >tracks[i];
@@ -3439,22 +3449,6 @@ static int mov_write_covr(AVIOContext *pb, 
AVFormatContext *s)
 trk->cover_image.size <= 0)
 continue;
 
-switch (st->codecpar->codec_id) {
-case AV_CODEC_ID_MJPEG:
-type = 0xD;
-break;
-case AV_CODEC_ID_PNG:
-type = 0xE;
-break;
-case AV_CODEC_ID_BMP:
-type = 0x1B;
-break;
-default:
-av_log(s, AV_LOG_ERROR, "unsupported codec_id (0x%x) for cover",
-   st->codecpar->codec_id);
-continue;
-}
-
 if (!pos) {
 pos = avio_tell(pb);
 avio_wb32(pb, 0);
@@ -3462,7 +3456,7 @@ static int mov_write_covr(AVIOContext *pb, 
AVFormatContext *s)
 }
 avio_wb32(pb, 16 + trk->cover_image.size);
 ffio_wfourcc(pb, "data");
-avio_wb32(pb, type);
+avio_wb32(pb, trk->tag);
 avio_wb32(pb , 0);
 avio_write(pb, trk->cover_image.data, trk->cover_image.size);
 }
-- 
2.17.0

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


Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Set st->start_time for video streams explicitly.

2018-05-31 Thread Sasi Inguva
Sorry. Forgot to attach the file. Pls find it attached. Also resending the
patch signed with correct email address

On Thu, May 31, 2018 at 2:14 PM Michael Niedermayer 
wrote:

> On Tue, May 29, 2018 at 03:39:40PM -0700, Sasi Inguva wrote:
> > If start_time is not set, ffmpeg takes the duration from the global
> > movie instead of the per stream duration.
> > Signed-off-by: Sasi Inguva 
> > ---
> >  libavformat/mov.c| 20 +---
> >  tests/fate/mov.mak   |  4 +++
> >  tests/ref/fate/mov-neg-firstpts-discard  |  2 +-
> >  tests/ref/fate/mov-stream-shorter-than-movie | 33 
> >  4 files changed, 54 insertions(+), 5 deletions(-)
> >  create mode 100644 tests/ref/fate/mov-stream-shorter-than-movie
>
> i may have missed a link to a sample file
>
> fate-suite//mov/mov_stream_shorter_than_movie.mov: No such file or
> directory
> make: *** [fate-mov-stream-shorter-than-movie] Error 1
>
>
>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> It is dangerous to be right in matters on which the established authorities
> are wrong. -- Voltaire
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


mov_stream_shorter_than_movie.mov
Description: QuickTime movie
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/movenc: properly handle cover image codecs

2018-05-31 Thread Timo Teräs
Find codec tag for attached images using appropriate list of
supported image formats.

This fixes writing the cover image to m4v/m4a and other container
formats that do not allow these codecs as a track.

Signed-off-by: Timo Teräs 
---
This replaces the previous patch:
 PATCH] [RFC] avformat/movenc: support covert images for ipod muxer

It appears that query_codec() is used only to figure out which stream
to select as the default copy stream. Fixing it properly for movenc
attached pictures is difficult, as the stream disposition would need
to be passed through the call stack. Additionally, it would make sense
to rewrite the selection logic open_output_file() to not use APIC
special tag and be based on the input/output dispositions.

So this just adds proper handling of the codecs in mov_init() phase
which fixes most of the usability issues.

Please backport to 4.0 stable branch too.

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

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 7e616e866f..8c370ee7b9 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1557,10 +1557,20 @@ static int mov_get_codec_tag(AVFormatContext *s, 
MOVTrack *track)
 return tag;
 }
 
+static const AVCodecTag codec_cover_image_tags[] = {
+{ AV_CODEC_ID_MJPEG,  MKTAG('A','P','I','C') },
+{ AV_CODEC_ID_PNG,MKTAG('A','P','I','C') },
+{ AV_CODEC_ID_BMP,MKTAG('A','P','I','C') },
+{ AV_CODEC_ID_NONE, 0 },
+};
+
 static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
 {
 int tag;
 
+if (track->st->disposition & AV_DISPOSITION_ATTACHED_PIC)
+return ff_codec_get_tag(codec_cover_image_tags, track->par->codec_id);
+
 if (track->mode == MODE_MP4 || track->mode == MODE_PSP)
 tag = track->par->codec_tag;
 else if (track->mode == MODE_ISM)
-- 
2.17.0

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


Re: [FFmpeg-devel] qt-faststart bug near 4GB

2018-05-31 Thread Michael Niedermayer
On Thu, May 31, 2018 at 10:11:38AM +, Eran Kornblau wrote:
> > 
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
> > Eran Kornblau
> > Sent: Friday, May 25, 2018 4:40 PM
> > To: FFmpeg development discussions and patches 
> > Subject: [FFmpeg-devel] qt-faststart bug near 4GB
> > 
> > Hi all,
> > 
> > We encountered a rather extreme edge case with qt-faststart - we transcoded 
> > some video with ffmpeg, and the offset of the last video frame in the 
> > resulting mp4 was slightly less than 4GB.
> > Since it was less than 4GB, ffmpeg used an 'stco' atom and not a 'co64' 
> > atom.
> > When we ran qt-faststart on this file, it added the moov atom size to all 
> > offsets in the 'stco' atom, causing an overflow in the offsets of the 
> > frames close to the end of the file. The end of the video was therefore 
> > corrupt and could not be played.
> > I think the solution here is to 'upgrade' the 'stco' atom to 'co64' if such 
> > an edge case happens. However, looking at the code of qt-faststart, I see 
> > that it doesn't actually parse the atom tree, but rather looks for the 
> > strings 'stco' / 'co64'. Changing 'stco' to 'co64' requires updating the 
> > size of all the atom in which it's contained (moov, trak, mdia etc.) 
> > Therefore, such a change would probably be more of a rewrite of this 
> > utility than a patch, so wanted to check whether anyone has any thoughts on 
> > this before I start writing...
> > 
> Attaching the patch for this issue.
> As expected, it required significant changes... hope you will like it :)
> 
> Thanks!
> 
> Eran 

about the AV_WB* macros, i like them alot :)
but this seems not to apply cleanly:

Applying: qt-faststart - stco offset bug fix
Using index info to reconstruct a base tree...
M   tools/qt-faststart.c
Falling back to patching base and 3-way merge...
Auto-merging tools/qt-faststart.c
CONFLICT (content): Merge conflict in tools/qt-faststart.c
error: Failed to merge in the changes.
Patch failed at 0001 qt-faststart - stco offset bug fix
Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/8] ffserver.c: rename ReadInfo.in_filename to ReadInfo.in_uri

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ffserver.c b/ffserver.c
index 44306b1..b80a7f8 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -45,7 +45,7 @@
 struct ReadInfo {
 struct PublisherContext *pub;
 AVFormatContext *ifmt_ctx;
-char *in_filename;
+char *input_uri;
 };
 
 struct WriteInfo {
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 2/8] ffserver: Implement lua config file reader

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 configreader.c | 230 +
 configreader.h |  47 
 2 files changed, 277 insertions(+)
 create mode 100644 configreader.c
 create mode 100644 configreader.h

diff --git a/configreader.c b/configreader.c
new file mode 100644
index 000..88bba26
--- /dev/null
+++ b/configreader.c
@@ -0,0 +1,230 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "configreader.h"
+#include "httpd.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+const char *stream_format_names[] = { "mkv" };
+
+static struct HTTPDConfig *parsed_configs = NULL;
+
+void stream_free(struct StreamConfig *stream)
+{
+av_freep(>stream_name);
+av_freep(>input_uri);
+av_freep(>formats);
+}
+
+void config_free(struct HTTPDConfig *config)
+{
+int i;
+av_freep(>server_name);
+av_freep(>bind_address);
+if (config->streams) {
+for (i = 0; i < config->nb_streams; i++)
+stream_free(>streams[i]);
+av_freep(>streams);
+}
+}
+
+void config_dump(struct HTTPDConfig *config, FILE *stream) {
+int i, j;
+fprintf(stream, "==\nserver name: %s\nbind_address: %s\nport: 
%d\nnb_streams: %d\n",
+config->server_name, config->bind_address, config->port, 
config->nb_streams);
+for (i = 0; i < config->nb_streams; i++) {
+fprintf(stream, "--\nstream_name: %s\ninput: %s\nformats: ",
+config->streams[i].stream_name, config->streams[i].input_uri);
+for (j = 0; j < config->streams[i].nb_formats; j++) {
+fprintf(stream, "%s ", 
stream_format_names[config->streams[i].formats[j]]);
+}
+fprintf(stream, "\n");
+}
+}
+
+int configs_parse(lua_State *L)
+{
+int nb_configs = 0;
+int nb_streams = 0;
+int nb_formats = 0;
+int index = 0;
+const char *key;
+struct HTTPDConfig *config;
+struct StreamConfig *stream;
+
+luaL_checktype(L, -1, LUA_TTABLE);
+lua_pushnil(L);
+
+// iterate servers
+while (lua_next(L, -2) != 0) {
+nb_configs++;
+parsed_configs = av_realloc(parsed_configs, nb_configs * sizeof(struct 
HTTPDConfig));
+if (!parsed_configs) {
+return luaL_error(L, "Error could not allocate memory for 
configs");
+}
+luaL_checktype(L, -2, LUA_TSTRING);
+luaL_checktype(L, -1, LUA_TTABLE);
+config = _configs[nb_configs - 1];
+config->server_name = NULL;
+config->bind_address = NULL;
+config->port = -1;
+config->accept_timeout = 1000;
+config->streams = NULL;
+config->nb_streams = 0;
+
+config->server_name = av_strdup(lua_tostring(L, -2));
+if (!config->server_name) {
+return luaL_error(L, "Error could not allocate server name 
string");
+}
+lua_pushnil(L);
+// iterate server properties
+nb_streams = 0;
+while(lua_next(L, -2) != 0) {
+luaL_checktype(L, -2, LUA_TSTRING);
+key = lua_tostring(L, -2);
+if (!strncmp("bind_address", key, 12)) {
+config->bind_address = av_strdup(lua_tostring(L, -1));
+if (!config->bind_address) {
+return luaL_error(L, "Error could not allocate bind 
address string");
+}
+} else if (!strncmp("port", key, 4)) {
+config->port = (int) lua_tonumber(L, -1);
+} else {
+// keys that are not "bind_address" or "port" are streams
+luaL_checktype(L, -1, LUA_TTABLE);
+
+nb_streams++;
+config->streams = av_realloc(config->streams, nb_streams * 
sizeof(struct StreamConfig));
+if (!config->streams) {
+return luaL_error(L, "Error could not allocate memory for 
streams");
+}
+stream = >streams[nb_streams - 1];
+stream->input_uri = NULL;
+stream->formats = NULL;
+stream->nb_formats = 0;
+stream->stream_name = av_strdup(lua_tostring(L, -2));
+if (!stream->stream_name) {
+

[FFmpeg-devel] [PATCH 5/8] publisher.h: Add stream_name to PublisherContext

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 publisher.c | 3 ++-
 publisher.h | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/publisher.c b/publisher.c
index 1123056..2e96f2f 100644
--- a/publisher.c
+++ b/publisher.c
@@ -93,11 +93,12 @@ void client_push_segment(struct Client *c, struct Segment 
*seg)
 client_set_state(c, WRITABLE);
 }
 
-void publisher_init(struct PublisherContext **pub)
+void publisher_init(struct PublisherContext **pub, char *stream_name)
 {
 int i;
 struct PublisherContext *pc = (struct PublisherContext*) 
av_malloc(sizeof(struct PublisherContext));
 pc->nb_threads = 8;
+pc->stream_name = stream_name;
 pc->current_segment_id = -1;
 pc->shutdown = 0;
 pc->buffer = av_fifo_alloc_array(sizeof(struct Segment), MAX_SEGMENTS);
diff --git a/publisher.h b/publisher.h
index 97b745d..e25c33d 100644
--- a/publisher.h
+++ b/publisher.h
@@ -73,6 +73,7 @@ struct PublisherContext {
 int nb_threads;
 int current_segment_id;
 int shutdown; // indicate shutdown, gracefully close client connections 
and files and exit
+char *stream_name;
 };
 
 /**
@@ -101,8 +102,9 @@ void client_set_state(struct Client *c, enum State state);
  * Allocate and initialize a PublisherContext
  *
  * @param pub pointer to a pointer to a PublisherContext. It will be allocated 
and initialized.
+ * @param stream_name string containing the name of the stream.
  */
-void publisher_init(struct PublisherContext **pub);
+void publisher_init(struct PublisherContext **pub, char *stream_name);
 
 /**
  * Push a Segment to a PublisherContext.
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 6/8] ffserver.c: Add config file reading

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 248 ++---
 1 file changed, 172 insertions(+), 76 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index b80a7f8..1363cdc 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -38,6 +38,7 @@
 #include "segment.h"
 #include "publisher.h"
 #include "httpd.h"
+#include "configreader.h"
 
 #define BUFFER_SECS 30
 #define LISTEN_TIMEOUT_MSEC 1000
@@ -54,9 +55,11 @@ struct WriteInfo {
 };
 
 struct AcceptInfo {
-struct PublisherContext *pub;
+struct PublisherContext **pubs;
 struct HTTPDInterface *httpd;
-AVFormatContext *ifmt_ctx;
+AVFormatContext **ifmt_ctxs;
+struct HTTPDConfig *config;
+int nb_pub; /* number of publishers (streams) equal to number of ifmt_ctx 
*/
 };
 
 
@@ -286,52 +289,77 @@ void *accept_thread(void *arg)
 {
 struct AcceptInfo *info = (struct AcceptInfo*) arg;
 struct FFServerInfo *ffinfo = NULL;
+struct PublisherContext *pub;
 char status[4096];
+char *stream_name;
 struct HTTPClient *client = NULL;
 void *server = NULL;
 AVIOContext *client_ctx = NULL;
 AVFormatContext *ofmt_ctx = NULL;
+AVFormatContext *ifmt_ctx;
 unsigned char *avio_buffer;
 AVOutputFormat *ofmt;
 AVDictionary *mkvopts = NULL;
 AVStream *in_stream, *out_stream;
 int ret, i, reply_code;
-struct HTTPDConfig config = {
-.bind_address = "0",
-.port = 8080,
-.accept_timeout = LISTEN_TIMEOUT_MSEC,
-};
-
-info->httpd->init(, config);
-
-
+int shutdown;
+struct HTTPDConfig *config = info->config;
+
+info->httpd->init(, *config);
+
 for (;;) {
-if (info->pub->shutdown)
+shutdown = 1;
+for (i = 0; i < config->nb_streams; i++) {
+if (info->pubs[i] && !info->pubs[i]->shutdown)
+shutdown = 0;
+}
+if (shutdown)
 break;
-publisher_gen_status_json(info->pub, status);
-av_log(server, AV_LOG_INFO, status);
+for (i = 0; i < config->nb_streams; i++) {
+publisher_gen_status_json(info->pubs[i], status);
+av_log(server, AV_LOG_INFO, status);
+}
 client = NULL;
 av_log(server, AV_LOG_DEBUG, "Accepting new clients.\n");
 reply_code = 200;
-if (publisher_reserve_client(info->pub)) {
-av_log(client, AV_LOG_WARNING, "No more client slots free, 
Returning 503.\n");
-reply_code = 503;
-}
-
+
 if ((ret = info->httpd->accept(server, , reply_code)) < 0) {
 if (ret == HTTPD_LISTEN_TIMEOUT) {
-publisher_cancel_reserve(info->pub);
 continue;
 } else if (ret == HTTPD_CLIENT_ERROR) {
 info->httpd->close(server, client);
 }
 av_log(server, AV_LOG_WARNING, "Error during accept, retrying.\n");
-publisher_cancel_reserve(info->pub);
 continue;
 }
-
+
+pub = NULL;
+ifmt_ctx = NULL;
+for (i = 0; i < config->nb_streams; i++) {
+stream_name = info->pubs[i]->stream_name;
+//   skip leading '/'  ---v
+if(!strncmp(client->resource + 1, stream_name, 
strlen(stream_name))) {
+pub = info->pubs[i];
+ifmt_ctx = info->ifmt_ctxs[i];
+break;
+}
+}
+
+if (!pub || !ifmt_ctx) {
+av_log(client_ctx, AV_LOG_WARNING, "No suitable publisher found 
for resource: %s.\n",
+client->resource ? 
client->resource : "(null)");
+reply_code = 404;
+}
+
+
+if (pub && ifmt_ctx && publisher_reserve_client(pub)) {
+av_log(client_ctx, AV_LOG_WARNING, "No more client slots free, 
Returning 503.\n");
+reply_code = 503;
+}
+
 if (reply_code != 200) {
-publisher_cancel_reserve(info->pub);
+if (pub && ifmt_ctx)
+publisher_cancel_reserve(pub);
 info->httpd->close(server, client);
 continue;
 }
@@ -344,7 +372,7 @@ void *accept_thread(void *arg)
 client_ctx = avio_alloc_context(avio_buffer, AV_BUFSIZE, 1, ffinfo, 
NULL, _write, NULL);
 if (!client_ctx) {
 av_log(client, AV_LOG_ERROR, "Could not allocate output format 
context.\n");
-publisher_cancel_reserve(info->pub);
+publisher_cancel_reserve(pub);
 info->httpd->close(server, client);
 av_free(client_ctx->buffer);
 avio_context_free(_ctx);
@@ -354,7 +382,7 @@ void *accept_thread(void *arg)
 avformat_alloc_output_context2(_ctx, NULL, "matroska", NULL);
 if (!ofmt_ctx) {
 av_log(client, AV_LOG_ERROR, "Could not allocate output format 
context.\n");
-publisher_cancel_reserve(info->pub);
+

[FFmpeg-devel] [PATCH] ffserver.c: Add ability to stream audio-only files.

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
Change from previous patch: More natural way to check if
AUDIO_ONLY_SEGMENT_SECONDS has elapsed since last cut.

 ffserver.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index 288f8a1..0278bc8 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -42,6 +42,7 @@
 
 #define BUFFER_SECS 30
 #define LISTEN_TIMEOUT_MSEC 1000
+#define AUDIO_ONLY_SEGMENT_SECONDS 2
 
 struct ReadInfo {
 struct PublisherContext *pub;
@@ -76,8 +77,9 @@ void *read_thread(void *arg)
 AVFormatContext *ifmt_ctx = info->ifmt_ctx;
 int ret, i;
 int video_idx = -1;
+int audio_only = 0;
 int id = 0;
-int64_t pts, now, start;
+int64_t pts, now, start, last_cut = 0;
 int64_t *ts;
 struct Segment *seg = NULL;
 AVPacket pkt;
@@ -99,10 +101,8 @@ void *read_thread(void *arg)
 break;
 }
 }
-if (video_idx == -1) {
-av_log(ifmt_ctx, AV_LOG_ERROR, "No video stream found.\n");
-goto end;
-}
+if (video_idx == -1)
+audio_only = 1;
 
 
 // All information needed to start segmenting the file is gathered now.
@@ -141,8 +141,9 @@ void *read_thread(void *arg)
 now = av_gettime_relative() - start;
 }
 
-// keyframe or first Segment
-if ((pkt.flags & AV_PKT_FLAG_KEY && pkt.stream_index == video_idx) || 
!seg) {
+// keyframe or first Segment or audio_only and more than 
AUDIO_ONLY_SEGMENT_SECONDS passed since last cut
+if ((pkt.flags & AV_PKT_FLAG_KEY && pkt.stream_index == video_idx) || 
!seg ||
+(audio_only && pts - last_cut >= AUDIO_ONLY_SEGMENT_SECONDS * 
AV_TIME_BASE)) {
 if (seg) {
 segment_close(seg);
 publisher_push_segment(info->pub, seg);
@@ -150,6 +151,7 @@ void *read_thread(void *arg)
 publish(info->pub);
 av_log(NULL, AV_LOG_DEBUG, "Published new segment.\n");
 }
+last_cut = pts;
 segment_init(, ifmt_ctx);
 if (!seg) {
 av_log(NULL, AV_LOG_ERROR, "Segment initialization failed, 
shutting down.\n");
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 8/8] doc: Update Documentation.txt and add sample config as supplement

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 Documentation.txt | 17 -
 sample_config.lua | 28 
 2 files changed, 36 insertions(+), 9 deletions(-)
 create mode 100644 sample_config.lua

diff --git a/Documentation.txt b/Documentation.txt
index 9a7f0bf..c8fef11 100644
--- a/Documentation.txt
+++ b/Documentation.txt
@@ -67,16 +67,15 @@ struct HTTPDInterface {
 Usage
 -
 
-Currently streams can be supplied as a stream through stdin or any ffmpeg-
-compatible URI, e.g. files or network locations. Examples:
+To use ffserver, a config file has to be created that defines what streams to
+read and where to serve them. A sample config is supplied as sample_config.lua.
+This sample config defines two servers with a total of three streams. The first
+server serves two streams on all interfaces on port 8080, while the second
+server serves one stream on 127.0.0.1. The streams can be received by
+requesting the configured stream name as the GET parameter in the HTTP request.
+In the sample config, this would be 
"http://:8080/default_stream"
+for the first stream.
 
-cat somefile.mkv | ./ffserver
-
-./ffserver somefile.mkv
-
-./ffserver http://somehost/somefile.mkv
-
-This will start reading the file and open port 8080 for HTTP client 
connections.
 The stream is read in real time from whatever resource it is retrieved.
 Currently a maximum of 16 clients is implemented.
 
diff --git a/sample_config.lua b/sample_config.lua
new file mode 100644
index 000..a5e6192
--- /dev/null
+++ b/sample_config.lua
@@ -0,0 +1,28 @@
+-- Sample configuration file for ffserver
+-- Contains all settings
+settings = {
+-- A server instance
+default_server = {
+-- Server settings
+bind_address = "0.0.0.0",
+port = 8080,
+-- Stream settings
+default_stream = {
+input = "default.mkv",
+formats = { "mkv" }, -- later possible: { "mkv", "hls", "dash" }
+},
+other_stream = {
+input = "other_file.mkv",
+formats = { "mkv" }
+}
+},
+-- Another server instance
+other_server = {
+bind_address = "127.0.0.1",
+port = 8081,
+default_restream = {
+input = "yet_another_file.mkv",
+formats = { "mkv" }
+}
+}
+}
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 1/8] ffserver.c: Fix timestamp handling, still creates new clusters for mp4 files, but result is playable

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index 39e1c32..44306b1 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -79,9 +79,7 @@ void *read_thread(void *arg)
 struct Segment *seg = NULL;
 AVPacket pkt;
 AVStream *in_stream;
-AVRational tb;
-tb.num = 1;
-tb.den = AV_TIME_BASE;
+AVRational tb = {1, AV_TIME_BASE};
 AVStream *stream;
 AVCodecParameters *params;
 enum AVMediaType type;
@@ -133,7 +131,7 @@ void *read_thread(void *arg)
 pkt.pos = -1;
 
 // current pts
-pts = pkt.pts; //av_rescale_q(pkt.pts, in_stream->time_base, tb);
+pts = pkt.pts;
 
 // current stream "uptime"
 now = av_gettime_relative() - start;
@@ -200,6 +198,7 @@ void write_segment(struct Client *c)
 struct Segment *seg;
 int ret;
 int pkt_count = 0;
+AVRational tb = {1, AV_TIME_BASE};
 pthread_mutex_lock(>buffer_lock);
 if (av_fifo_size(c->buffer) > 0) {
 AVFormatContext *fmt_ctx;
@@ -249,8 +248,13 @@ void write_segment(struct Client *c)
 if (ret < 0)
 break;
 
-pkt.dts = seg->ts[pkt_count];
-pkt.pts = seg->ts[pkt_count+1];
+pkt.dts = av_rescale_q_rnd(seg->ts[pkt_count], tb,
+
c->ofmt_ctx->streams[pkt.stream_index]->time_base,
+   
AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
+pkt.pts = av_rescale_q_rnd(seg->ts[pkt_count+1], tb,
+
c->ofmt_ctx->streams[pkt.stream_index]->time_base,
+   
AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
+pkt.pos = -1;
 pkt_count += 2;
 ret = av_write_frame(c->ofmt_ctx, );
 av_packet_unref();
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 4/8] httpd.h: Adapt structs to config file

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 httpd.h | 17 +
 1 file changed, 17 insertions(+)

diff --git a/httpd.h b/httpd.h
index 6fb91bd..25cbe11 100644
--- a/httpd.h
+++ b/httpd.h
@@ -26,11 +26,28 @@
 
 #include "publisher.h"
 
+/* Supported stream formats, for now only matroska */
+enum StreamFormat {
+FMT_MATROSKA = 0,
+FMT_NB,
+};
+
+/* Stream Config struct */
+struct StreamConfig {
+char *stream_name;
+char *input_uri;
+enum StreamFormat *formats;
+int nb_formats;
+};
+
 /* HTTPD Config struct */
 struct HTTPDConfig {
+char *server_name;
 char *bind_address;
 int port;
 int accept_timeout;
+struct StreamConfig *streams;
+int nb_streams;
 };
 
 /* HTTPClient struct, this information is shared between ffserver and the 
httpd implementation */
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 18/22] segment.c: Don't cast return value of av_malloc()

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 segment.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/segment.c b/segment.c
index 72c4663..6c74b72 100644
--- a/segment.c
+++ b/segment.c
@@ -81,7 +81,7 @@ int segment_write(void *opaque, unsigned char *buf, int 
buf_size)
 {
 struct Segment *seg = (struct Segment*) opaque;
 seg->size += buf_size;
-seg->buf = (unsigned char*) av_realloc(seg->buf, seg->size);
+seg->buf = av_realloc(seg->buf, seg->size);
 if (!seg->buf) {
 av_log(NULL, AV_LOG_ERROR, "Could not grow segment.\n");
 return AVERROR(ENOMEM);
@@ -127,7 +127,7 @@ void segment_init(struct Segment **seg_p, AVFormatContext 
*fmt)
 seg->ts = NULL;
 seg->ts_len = 0;
 seg->buf = NULL;
-seg->avio_buffer = (unsigned char*) av_malloc(AV_BUFSIZE);
+seg->avio_buffer = av_malloc(AV_BUFSIZE);
 if (!seg->avio_buffer) {
 av_log(NULL, AV_LOG_ERROR, "Could not allocate segment 
avio_buffer.\n");
 av_free(seg);
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 19/22] httpd.h: make comments doxygen

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 httpd.h | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/httpd.h b/httpd.h
index fb1337d..83535e0 100644
--- a/httpd.h
+++ b/httpd.h
@@ -52,11 +52,12 @@ struct HTTPDConfig {
 
 /** HTTPClient struct, this information is shared between ffserver and the 
httpd implementation */
 struct HTTPClient {
-/* the method requested by the client, this field has to be set and freed 
by the httpd implementation */
+/** the method requested by the client, this field has to be set and freed 
by the httpd implementation */
 char *method;
-/* the resource requested by the client, this field has to be set and 
freed by the httpd implementation */
+/** the resource requested by the client, this field has to be set and 
freed by the httpd implementation */
 char *resource;
-void *httpd_data; // httpd implementation specific data
+/** httpd implementation specific data */
+void *httpd_data;
 };
 
 /** HTTPDInterface that an httpd implementation must provide */
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 20/22] ffserver.c: make comment doxygen

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ffserver.c b/ffserver.c
index 8a24397..288f8a1 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -59,7 +59,7 @@ struct AcceptInfo {
 struct HTTPDInterface *httpd;
 AVFormatContext **ifmt_ctxs;
 struct HTTPDConfig *config;
-int nb_pub; /* number of publishers (streams) equal to number of ifmt_ctx 
*/
+int nb_pub; /** number of publishers (streams) equal to number of ifmt_ctx 
*/
 };
 
 
-- 
2.16.2

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


[FFmpeg-devel] FFserver config file support

2018-05-31 Thread Stephan Holljes
This patchset includes minor fixes mentioned in the last review round.
  - remove unneeded null-checks before calling av_free()
  - use av_freep() where useful
  - simplify AVRational assignment

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


[FFmpeg-devel] [PATCH 22/22] publisher.c: Remove unsupported logging context

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 publisher.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/publisher.c b/publisher.c
index 9374c41..56d1e24 100644
--- a/publisher.c
+++ b/publisher.c
@@ -271,7 +271,7 @@ void publish(struct PublisherContext *pub)
 for (i = 0; i < MAX_CLIENTS; i++) {
 switch(pub->clients[i].state) {
 case BUFFER_FULL:
-av_log(pub, AV_LOG_WARNING, "Dropping segment for client 
%d, buffer full.\n", i);
+av_log(NULL, AV_LOG_WARNING, "Dropping segment for client 
%d, buffer full.\n", i);
 continue;
 case WAIT:
 case WRITABLE:
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 21/22] lavfhttpd.c: Remove superfluous null-checks before av_free()

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 lavfhttpd.c | 12 
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/lavfhttpd.c b/lavfhttpd.c
index 9f56620..bc856af 100644
--- a/lavfhttpd.c
+++ b/lavfhttpd.c
@@ -95,10 +95,8 @@ int lavfhttpd_accept(void *server, struct HTTPClient 
**client, int reply_code)
 av_log(client_ctx, AV_LOG_WARNING, "Failed to set reply_code: 
%s.\n", av_err2str(ret));
 }
 }
-if (client_http->method)
-av_free(client_http->method);
-if (client_http->resource)
-av_free(client_http->resource);
+av_free(client_http->method);
+av_free(client_http->resource);
 client_http->method = av_strdup(method);
 client_http->resource = av_strdup(resource);
 av_free(method);
@@ -141,10 +139,8 @@ void lavfhttpd_close(void *server, struct HTTPClient 
*client)
 {
 AVIOContext *client_ctx = (AVIOContext*) client->httpd_data;
 avio_close(client_ctx);
-if (client->method)
-av_free(client->method);
-if (client->resource)
-av_free(client->resource);
+av_free(client->method);
+av_free(client->resource);
 av_free(client);
 }
 
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 16/22] lavfhttpd.c: Detect disconnected clients through amount of bytes written.

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 lavfhttpd.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/lavfhttpd.c b/lavfhttpd.c
index b1e8819..9f56620 100644
--- a/lavfhttpd.c
+++ b/lavfhttpd.c
@@ -120,8 +120,14 @@ int lavfhttpd_accept(void *server, struct HTTPClient 
**client, int reply_code)
 int lavfhttpd_write(void *server, struct HTTPClient *client, const unsigned 
char *buf, int size)
 {
 AVIOContext *client_ctx = (AVIOContext*) client->httpd_data;
+int64_t old_written = client_ctx->written;
+int64_t actual_written;
 avio_write(client_ctx, buf, size);
 avio_flush(client_ctx);
+actual_written = client_ctx->written - old_written;
+if (actual_written < size) {
+return AVERROR_EOF;
+}
 return size;
 }
 
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 15/22] ffserver.c: Simplify error handling in server creation.

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 36 +++-
 1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index 6f76c3e..fd8cadd 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -534,13 +534,12 @@ void *run_server(void *arg) {
 pubs = av_mallocz_array(config->nb_streams, sizeof(struct 
PublisherContext*));
 if (!pubs) {
 av_log(NULL, AV_LOG_ERROR, "Could not allocate publishers\n");
-return NULL;
+goto error_cleanup;
 }
 ifmt_ctxs = av_mallocz_array(config->nb_streams, sizeof(AVFormatContext*));
 if (!ifmt_ctxs) {
 av_log(NULL, AV_LOG_ERROR, "Could not allocate input format 
contexts.\n");
-av_free(pubs);
-return NULL;
+goto error_cleanup;
 }
 
 av_log_set_level(AV_LOG_INFO);
@@ -554,36 +553,22 @@ void *run_server(void *arg) {
 rinfos = av_mallocz_array(config->nb_streams, sizeof(struct ReadInfo));
 if (!rinfos) {
 av_log(NULL, AV_LOG_ERROR, "Could not allocate read infos.\n");
-av_free(pubs);
-av_free(ifmt_ctxs);
-return NULL;
+goto error_cleanup;
 }
 winfos_p = av_mallocz_array(config->nb_streams, sizeof(struct WriteInfo*));
 if (!winfos_p) {
 av_log(NULL, AV_LOG_ERROR, "Could not allocate write info 
pointers.\n");
-av_free(pubs);
-av_free(ifmt_ctxs);
-av_free(rinfos);
-return NULL;
+goto error_cleanup;
 }
 r_threads = av_mallocz_array(config->nb_streams, sizeof(pthread_t));
 if (!r_threads) {
 av_log(NULL, AV_LOG_ERROR, "Could not allocate read thread 
handles.\n");
-av_free(pubs);
-av_free(ifmt_ctxs);
-av_free(rinfos);
-av_free(winfos_p);
-return NULL;
+goto error_cleanup;
 }
 w_threads_p = av_mallocz_array(config->nb_streams, sizeof(pthread_t*));
 if (!w_threads_p) {
 av_log(NULL, AV_LOG_ERROR, "Could not allocate write thread handle 
pointers.\n");
-av_free(pubs);
-av_free(ifmt_ctxs);
-av_free(rinfos);
-av_free(winfos_p);
-av_free(r_threads);
-return NULL;
+goto error_cleanup;
 }
 
 for (stream_index = 0; stream_index < config->nb_streams; stream_index++) {
@@ -671,6 +656,15 @@ end:
 av_free(ifmt_ctxs);
 
 return NULL;
+
+error_cleanup:
+av_free(rinfos);
+av_free(winfos_p);
+av_free(r_threads);
+av_free(w_threads_p);
+av_free(pubs);
+av_free(ifmt_ctxs);
+return NULL;
 }
 
 int main(int argc, char *argv[])
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 17/22] ffserver.c: Don't cast return value of av_malloc()

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ffserver.c b/ffserver.c
index fd8cadd..8a24397 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -222,7 +222,7 @@ void write_segment(struct Client *c)
 return;
 }
 
-avio_buffer = (unsigned char*) av_malloc(AV_BUFSIZE);
+avio_buffer = av_malloc(AV_BUFSIZE);
 if (!avio_buffer) {
 av_log(fmt_ctx, AV_LOG_ERROR, "Could not allocate avio_buffer\n");
 avformat_free_context(fmt_ctx);
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 12/22] ffserver.c: Replace sizeof(struct ...) with sizeof(var) where useful.

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index 50d61e5..c6e8516 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -210,7 +210,7 @@ void write_segment(struct Client *c)
 struct SegmentReadInfo info;
 unsigned char *avio_buffer;
 
-av_fifo_generic_peek(c->buffer, , sizeof(struct Segment*), NULL);
+av_fifo_generic_peek(c->buffer, , sizeof(seg), NULL);
 pthread_mutex_unlock(>buffer_lock);
 c->current_segment_id = seg->id;
 info.buf = seg->buf;
@@ -288,7 +288,7 @@ void write_segment(struct Client *c)
 avformat_close_input(_ctx);
 avio_context_free(_ctx);
 pthread_mutex_lock(>buffer_lock);
-av_fifo_drain(c->buffer, sizeof(struct Segment*));
+av_fifo_drain(c->buffer, sizeof(seg));
 pthread_mutex_unlock(>buffer_lock);
 segment_unref(seg);
 client_set_state(c, WRITABLE);
@@ -385,7 +385,7 @@ void *accept_thread(void *arg)
 info->httpd->close(server, client);
 continue;
 }
-ffinfo = av_malloc(sizeof(struct FFServerInfo));
+ffinfo = av_malloc(sizeof(*ffinfo));
 if (!ffinfo) {
 av_log(NULL, AV_LOG_ERROR, "Could not allocate FFServerInfo 
struct.\n");
 publisher_cancel_reserve(pub);
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 14/22] ffserver.c: Add some logging contexts.

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index c6e8516..6f76c3e 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -224,14 +224,14 @@ void write_segment(struct Client *c)
 
 avio_buffer = (unsigned char*) av_malloc(AV_BUFSIZE);
 if (!avio_buffer) {
-av_log(NULL, AV_LOG_ERROR, "Could not allocate avio_buffer\n");
+av_log(fmt_ctx, AV_LOG_ERROR, "Could not allocate avio_buffer\n");
 avformat_free_context(fmt_ctx);
 client_disconnect(c, 0);
 return;
 }
 avio_ctx = avio_alloc_context(avio_buffer, AV_BUFSIZE, 0, , 
_read, NULL, NULL);
 if (!avio_ctx) {
-av_log(NULL, AV_LOG_ERROR, "Could not allocate avio_ctx\n");
+av_log(fmt_ctx, AV_LOG_ERROR, "Could not allocate avio_ctx\n");
 avformat_free_context(fmt_ctx);
 av_free(avio_buffer);
 client_disconnect(c, 0);
@@ -380,14 +380,14 @@ void *accept_thread(void *arg)
 
 avio_buffer = av_malloc(AV_BUFSIZE);
 if (!avio_buffer) {
-av_log(NULL, AV_LOG_ERROR, "Could not allocate output format 
context.\n");
+av_log(client_ctx, AV_LOG_ERROR, "Could not allocate output format 
context.\n");
 publisher_cancel_reserve(pub);
 info->httpd->close(server, client);
 continue;
 }
 ffinfo = av_malloc(sizeof(*ffinfo));
 if (!ffinfo) {
-av_log(NULL, AV_LOG_ERROR, "Could not allocate FFServerInfo 
struct.\n");
+av_log(client_ctx, AV_LOG_ERROR, "Could not allocate FFServerInfo 
struct.\n");
 publisher_cancel_reserve(pub);
 info->httpd->close(server, client);
 continue;
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 13/22] lavfhttpd.c: simplify av_malloc() for client_http

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 lavfhttpd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lavfhttpd.c b/lavfhttpd.c
index d094d65..b1e8819 100644
--- a/lavfhttpd.c
+++ b/lavfhttpd.c
@@ -76,7 +76,7 @@ int lavfhttpd_accept(void *server, struct HTTPClient 
**client, int reply_code)
 }
 client_ctx->seekable = 0;
 ret2 = HTTPD_OK;
-client_http = av_malloc(sizeof(struct HTTPClient));
+client_http = av_malloc(sizeof(*client_http));
 if (!client_http) {
 av_log(server, AV_LOG_ERROR, "Could not allocate http client.\n");
 return HTTPD_OTHER_ERROR;
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 11/22] ffserver.c/segment.c: set *seg_p to NULL in case of allocation failure and check it

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 4 
 segment.c  | 1 +
 2 files changed, 5 insertions(+)

diff --git a/ffserver.c b/ffserver.c
index 3abf5f8..50d61e5 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -151,6 +151,10 @@ void *read_thread(void *arg)
 av_log(NULL, AV_LOG_DEBUG, "Published new segment.\n");
 }
 segment_init(, ifmt_ctx);
+if (!seg) {
+av_log(NULL, AV_LOG_ERROR, "Segment initialization failed, 
shutting down.\n");
+goto end;
+}
 seg->id = id++;
 av_log(NULL, AV_LOG_DEBUG, "Starting new segment, id: %d\n", 
seg->id);
 }
diff --git a/segment.c b/segment.c
index 986aeb5..72c4663 100644
--- a/segment.c
+++ b/segment.c
@@ -116,6 +116,7 @@ void segment_init(struct Segment **seg_p, AVFormatContext 
*fmt)
 struct Segment *seg = (struct Segment*) av_malloc(sizeof(struct Segment));
 if (!seg) {
 av_log(fmt, AV_LOG_ERROR, "Could not allocate segment.\n");
+*seg_p = NULL;
 return;
 }
 
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 10/22] httpd.h: Make comments doxygen comments

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 httpd.h | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/httpd.h b/httpd.h
index 25cbe11..fb1337d 100644
--- a/httpd.h
+++ b/httpd.h
@@ -26,13 +26,13 @@
 
 #include "publisher.h"
 
-/* Supported stream formats, for now only matroska */
+/** Supported stream formats, for now only matroska */
 enum StreamFormat {
 FMT_MATROSKA = 0,
 FMT_NB,
 };
 
-/* Stream Config struct */
+/** Stream Config struct */
 struct StreamConfig {
 char *stream_name;
 char *input_uri;
@@ -40,7 +40,7 @@ struct StreamConfig {
 int nb_formats;
 };
 
-/* HTTPD Config struct */
+/** HTTPD Config struct */
 struct HTTPDConfig {
 char *server_name;
 char *bind_address;
@@ -50,7 +50,7 @@ struct HTTPDConfig {
 int nb_streams;
 };
 
-/* HTTPClient struct, this information is shared between ffserver and the 
httpd implementation */
+/** HTTPClient struct, this information is shared between ffserver and the 
httpd implementation */
 struct HTTPClient {
 /* the method requested by the client, this field has to be set and freed 
by the httpd implementation */
 char *method;
@@ -59,7 +59,7 @@ struct HTTPClient {
 void *httpd_data; // httpd implementation specific data
 };
 
-/* HTTPDInterface that an httpd implementation must provide */
+/** HTTPDInterface that an httpd implementation must provide */
 struct HTTPDInterface {
 int (*init)  (void **server, struct HTTPDConfig config);
 int (*free)  (void *server);
@@ -70,6 +70,6 @@ struct HTTPDInterface {
 void (*shutdown)(void *server);
 };
 
-/* Current HTTPDInterface implementation using lavformat */
+/** Current HTTPDInterface implementation using lavformat */
 extern struct HTTPDInterface lavfhttpd;
 #endif
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 07/22] lavfhttpd.c: Add allocation failure check.

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 lavfhttpd.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/lavfhttpd.c b/lavfhttpd.c
index 3cf9958..5488e14 100644
--- a/lavfhttpd.c
+++ b/lavfhttpd.c
@@ -74,6 +74,10 @@ int lavfhttpd_accept(void *server, struct HTTPClient 
**client, int reply_code)
 client_ctx->seekable = 0;
 ret2 = HTTPD_OK;
 client_http = av_malloc(sizeof(struct HTTPClient));
+if (!client_http) {
+av_log(server, AV_LOG_ERROR, "Could not allocate http client.\n");
+return HTTPD_OTHER_ERROR;
+}
 client_http->method = NULL;
 client_http->resource = NULL;
 client_http->httpd_data = client_ctx;
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 08/22] ffserver.c: Simplify codec_type access in read_thread

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index ddb3e6f..3abf5f8 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -84,8 +84,6 @@ void *read_thread(void *arg)
 AVStream *in_stream;
 AVRational tb = {1, AV_TIME_BASE};
 AVStream *stream;
-AVCodecParameters *params;
-enum AVMediaType type;
 
 if ((ret = avformat_find_stream_info(ifmt_ctx, NULL)) < 0) {
 av_log(ifmt_ctx, AV_LOG_ERROR, "Could not get input stream info.\n");
@@ -96,9 +94,7 @@ void *read_thread(void *arg)
 for (i = 0; i < ifmt_ctx->nb_streams; i++) {
 av_log(ifmt_ctx, AV_LOG_DEBUG, "Checking stream %d\n", i);
 stream = ifmt_ctx->streams[i];
-params = stream->codecpar;
-type = params->codec_type;
-if (type == AVMEDIA_TYPE_VIDEO) {
+if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
 video_idx = i;
 break;
 }
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 04/22] ffserver.c: Check allocations

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 87 +-
 1 file changed, 81 insertions(+), 6 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index fe84b2e..ddb3e6f 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -223,12 +223,25 @@ void write_segment(struct Client *c)
 }
 
 avio_buffer = (unsigned char*) av_malloc(AV_BUFSIZE);
+if (!avio_buffer) {
+av_log(NULL, AV_LOG_ERROR, "Could not allocate avio_buffer\n");
+avformat_free_context(fmt_ctx);
+client_disconnect(c, 0);
+return;
+}
 avio_ctx = avio_alloc_context(avio_buffer, AV_BUFSIZE, 0, , 
_read, NULL, NULL);
-
+if (!avio_ctx) {
+av_log(NULL, AV_LOG_ERROR, "Could not allocate avio_ctx\n");
+avformat_free_context(fmt_ctx);
+av_free(avio_buffer);
+client_disconnect(c, 0);
+return;
+}
 fmt_ctx->pb = avio_ctx;
 ret = avformat_open_input(_ctx, NULL, seg->ifmt, NULL);
 if (ret < 0) {
 av_log(avio_ctx, AV_LOG_ERROR, "Could not open input\n");
+avformat_close_input(_ctx);
 av_free(avio_ctx->buffer);
 avio_context_free(_ctx);
 client_disconnect(c, 0);
@@ -238,6 +251,7 @@ void write_segment(struct Client *c)
 ret = avformat_find_stream_info(fmt_ctx, NULL);
 if (ret < 0) {
 av_log(fmt_ctx, AV_LOG_ERROR, "Could not find stream 
information\n");
+avformat_close_input(_ctx);
 av_free(avio_ctx->buffer);
 avio_context_free(_ctx);
 client_disconnect(c, 0);
@@ -270,9 +284,8 @@ void write_segment(struct Client *c)
 return;
 }
 }
-avformat_close_input(_ctx);
 av_free(avio_ctx->buffer);
-avformat_free_context(fmt_ctx);
+avformat_close_input(_ctx);
 avio_context_free(_ctx);
 pthread_mutex_lock(>buffer_lock);
 av_fifo_drain(c->buffer, sizeof(struct Segment*));
@@ -366,13 +379,25 @@ void *accept_thread(void *arg)
 }
 
 avio_buffer = av_malloc(AV_BUFSIZE);
+if (!avio_buffer) {
+av_log(NULL, AV_LOG_ERROR, "Could not allocate output format 
context.\n");
+publisher_cancel_reserve(pub);
+info->httpd->close(server, client);
+continue;
+}
 ffinfo = av_malloc(sizeof(struct FFServerInfo));
+if (!ffinfo) {
+av_log(NULL, AV_LOG_ERROR, "Could not allocate FFServerInfo 
struct.\n");
+publisher_cancel_reserve(pub);
+info->httpd->close(server, client);
+continue;
+}
 ffinfo->httpd = info->httpd;
 ffinfo->client = client;
 ffinfo->server = server;
 client_ctx = avio_alloc_context(avio_buffer, AV_BUFSIZE, 1, ffinfo, 
NULL, _write, NULL);
 if (!client_ctx) {
-av_log(client, AV_LOG_ERROR, "Could not allocate output format 
context.\n");
+av_log(NULL, AV_LOG_ERROR, "Could not allocate output format 
context.\n");
 publisher_cancel_reserve(pub);
 info->httpd->close(server, client);
 av_free(client_ctx->buffer);
@@ -382,7 +407,7 @@ void *accept_thread(void *arg)
 }
 avformat_alloc_output_context2(_ctx, NULL, "matroska", NULL);
 if (!ofmt_ctx) {
-av_log(client, AV_LOG_ERROR, "Could not allocate output format 
context.\n");
+av_log(client_ctx, AV_LOG_ERROR, "Could not allocate output format 
context.\n");
 publisher_cancel_reserve(pub);
 info->httpd->close(server, client);
 avformat_free_context(ofmt_ctx);
@@ -507,7 +532,16 @@ void *run_server(void *arg) {
 pthread_t **w_threads_p;
 
 pubs = av_mallocz_array(config->nb_streams, sizeof(struct 
PublisherContext*));
+if (!pubs) {
+av_log(NULL, AV_LOG_ERROR, "Could not allocate publishers\n");
+return NULL;
+}
 ifmt_ctxs = av_mallocz_array(config->nb_streams, sizeof(AVFormatContext*));
+if (!ifmt_ctxs) {
+av_log(NULL, AV_LOG_ERROR, "Could not allocate input format 
contexts.\n");
+av_free(pubs);
+return NULL;
+}
 
 av_log_set_level(AV_LOG_INFO);
 
@@ -518,9 +552,39 @@ void *run_server(void *arg) {
 ainfo.config = config;
 
 rinfos = av_mallocz_array(config->nb_streams, sizeof(struct ReadInfo));
+if (!rinfos) {
+av_log(NULL, AV_LOG_ERROR, "Could not allocate read infos.\n");
+av_free(pubs);
+av_free(ifmt_ctxs);
+return NULL;
+}
 winfos_p = av_mallocz_array(config->nb_streams, sizeof(struct WriteInfo*));
+if (!winfos_p) {
+av_log(NULL, AV_LOG_ERROR, "Could not allocate write info 
pointers.\n");
+av_free(pubs);
+av_free(ifmt_ctxs);
+av_free(rinfos);
+return 

[FFmpeg-devel] [PATCH 03/22] ffserver.c: Fix indentation (replace tabs by spaces) and cosmetics

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index 9b28fdc..fe84b2e 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -152,7 +152,7 @@ void *read_thread(void *arg)
 publisher_push_segment(info->pub, seg);
 av_log(NULL, AV_LOG_DEBUG, "New segment pushed.\n");
 publish(info->pub);
-   av_log(NULL, AV_LOG_DEBUG, "Published new 
segment.\n");
+av_log(NULL, AV_LOG_DEBUG, "Published new segment.\n");
 }
 segment_init(, ifmt_ctx);
 seg->id = id++;
@@ -337,8 +337,9 @@ void *accept_thread(void *arg)
 ifmt_ctx = NULL;
 for (i = 0; i < config->nb_streams; i++) {
 stream_name = info->pubs[i]->stream_name;
-//   skip leading '/'  ---v
-if(!strncmp(client->resource + 1, stream_name, 
strlen(stream_name))) {
+//   skip leading '/'  ---v
+if (client->resource && strlen(client->resource)
+&& !strncmp(client->resource + 1, stream_name, 
strlen(stream_name))) {
 pub = info->pubs[i];
 ifmt_ctx = info->ifmt_ctxs[i];
 break;
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 06/22] segment.c: Add allocation failure checks.

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 segment.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/segment.c b/segment.c
index c40d1ad..986aeb5 100644
--- a/segment.c
+++ b/segment.c
@@ -82,6 +82,10 @@ int segment_write(void *opaque, unsigned char *buf, int 
buf_size)
 struct Segment *seg = (struct Segment*) opaque;
 seg->size += buf_size;
 seg->buf = (unsigned char*) av_realloc(seg->buf, seg->size);
+if (!seg->buf) {
+av_log(NULL, AV_LOG_ERROR, "Could not grow segment.\n");
+return AVERROR(ENOMEM);
+}
 memcpy(seg->buf + seg->size - buf_size, buf, buf_size);
 return buf_size;
 }
@@ -110,6 +114,10 @@ void segment_init(struct Segment **seg_p, AVFormatContext 
*fmt)
 int i;
 AVStream *in_stream, *out_stream;
 struct Segment *seg = (struct Segment*) av_malloc(sizeof(struct Segment));
+if (!seg) {
+av_log(fmt, AV_LOG_ERROR, "Could not allocate segment.\n");
+return;
+}
 
 seg->ifmt = av_find_input_format("matroska");
 seg->fmt_ctx = NULL;
@@ -119,10 +127,28 @@ void segment_init(struct Segment **seg_p, AVFormatContext 
*fmt)
 seg->ts_len = 0;
 seg->buf = NULL;
 seg->avio_buffer = (unsigned char*) av_malloc(AV_BUFSIZE);
+if (!seg->avio_buffer) {
+av_log(NULL, AV_LOG_ERROR, "Could not allocate segment 
avio_buffer.\n");
+av_free(seg);
+return;
+}
 pthread_mutex_init(>nb_read_lock, NULL);
 seg->io_ctx = avio_alloc_context(seg->avio_buffer, AV_BUFSIZE, 1, seg, 
NULL, _write, NULL);
+if (!seg->io_ctx) {
+av_log(NULL, AV_LOG_ERROR, "Could not allocate segment io context.\n");
+av_free(seg->avio_buffer);
+av_free(seg);
+return;
+}
 seg->io_ctx->seekable = 0;
 avformat_alloc_output_context2(>fmt_ctx, NULL, "matroska", NULL);
+if (!seg->fmt_ctx) {
+av_log(seg->io_ctx, AV_LOG_ERROR, "Could not allocate segment output 
context.\n");
+av_free(seg->avio_buffer);
+av_free(seg->io_ctx);
+av_free(seg);
+return;
+}
 if ((ret = av_opt_set_int(seg->fmt_ctx, "flush_packets", 1, 
AV_OPT_SEARCH_CHILDREN)) < 0) {
 av_log(seg->fmt_ctx, AV_LOG_WARNING, "Could not set flush_packets!\n");
 }
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 09/22] lavfhttpd.c: Free client context if allocated but an error occured

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 lavfhttpd.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lavfhttpd.c b/lavfhttpd.c
index 5488e14..d094d65 100644
--- a/lavfhttpd.c
+++ b/lavfhttpd.c
@@ -66,10 +66,13 @@ int lavfhttpd_accept(void *server, struct HTTPClient 
**client, int reply_code)
 int reply_code2 = reply_code;
 char *method, *resource;
 if ((ret = avio_accept(server_ctx, _ctx)) < 0) {
-if (ret == AVERROR(ETIMEDOUT))
+if (ret == AVERROR(ETIMEDOUT)) {
 return HTTPD_LISTEN_TIMEOUT;
-else
+} else {
+if (client_ctx)
+avio_context_free(_ctx);
 return HTTPD_OTHER_ERROR;
+}
 }
 client_ctx->seekable = 0;
 ret2 = HTTPD_OK;
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 05/22] publisher.c: Add allocation failure checks.

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 publisher.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/publisher.c b/publisher.c
index 2e96f2f..9374c41 100644
--- a/publisher.c
+++ b/publisher.c
@@ -97,17 +97,37 @@ void publisher_init(struct PublisherContext **pub, char 
*stream_name)
 {
 int i;
 struct PublisherContext *pc = (struct PublisherContext*) 
av_malloc(sizeof(struct PublisherContext));
+if (!pc) {
+av_log(NULL, AV_LOG_ERROR, "Could not allocate publisher context.\n");
+return;
+}
 pc->nb_threads = 8;
 pc->stream_name = stream_name;
 pc->current_segment_id = -1;
 pc->shutdown = 0;
 pc->buffer = av_fifo_alloc_array(sizeof(struct Segment), MAX_SEGMENTS);
+if (!pc->buffer) {
+av_log(NULL, AV_LOG_ERROR, "Could not allocate publisher buffer.\n");
+av_free(pc);
+return;
+}
 pc->fs_buffer = av_fifo_alloc_array(sizeof(struct Segment), MAX_SEGMENTS);
+if (!pc->fs_buffer) {
+av_log(NULL, AV_LOG_ERROR, "Could not allocate publisher fast-start 
buffer.\n");
+av_fifo_free(pc->buffer);
+av_free(pc);
+return;
+}
 pthread_mutex_init(>buffer_lock, NULL);
 pthread_mutex_init(>fs_buffer_lock, NULL);
 for (i = 0; i < MAX_CLIENTS; i++) {
 struct Client *c = >clients[i];
 c->buffer = av_fifo_alloc_array(sizeof(struct Segment), MAX_SEGMENTS);
+if (!c->buffer) {
+av_log(NULL, AV_LOG_ERROR, "Could not allocate client buffer.\n");
+publisher_free(pc);
+return;
+}
 c->ofmt_ctx = NULL;
 c->ffinfo = NULL;
 c->id = i;
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 02/22] ffserver.c: Check pthread_create for thread creation failure

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 34 ++
 1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index 116c399..9b28fdc 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -554,21 +554,35 @@ void *run_server(void *arg) {
 for (i = 0; i < pub->nb_threads; i++) {
 winfos[i].pub = pub;
 winfos[i].thread_id = i;
-pthread_create(_threads[i], NULL, write_thread, 
_p[stream_index][i]);
+ret = pthread_create(_threads[i], NULL, write_thread, 
_p[stream_index][i]);
+if (ret != 0) {
+pub->shutdown = 1;
+goto end;
+}
 }
 w_threads_p[stream_index] = w_threads;
-pthread_create(_thread, NULL, read_thread, [stream_index]);
+ret = pthread_create(_thread, NULL, read_thread, 
[stream_index]);
+if (ret != 0) {
+pub->shutdown = 1;
+goto end;
+}
 r_threads[stream_index] = r_thread;
 }
 
 
 //pthread_create(_thread, NULL, accept_thread, );
 accept_thread();
+
+end:
 for (stream_index = 0; stream_index < config->nb_streams; stream_index++) {
-pthread_join(r_threads[stream_index], NULL);
+// in case of thread creation failure this might NULL
+if (r_threads[stream_index])
+pthread_join(r_threads[stream_index], NULL);
 if (pubs[stream_index]) {
 for (i = 0; i < pubs[stream_index]->nb_threads; i++) {
-pthread_join(w_threads_p[stream_index][i], NULL);
+// might also be NULL because of thread creation failure
+if (w_threads_p[stream_index][i])
+pthread_join(w_threads_p[stream_index][i], NULL);
 }
 }
 av_free(winfos_p[stream_index]);
@@ -592,7 +606,7 @@ int main(int argc, char *argv[])
 struct HTTPDConfig *configs;
 int nb_configs;
 pthread_t *server_threads;
-int i;
+int i, ret;
 
 if (argc < 2) {
 printf("Usage: %s config.lua\n", argv[0]);
@@ -606,12 +620,16 @@ int main(int argc, char *argv[])
 }
 server_threads = av_mallocz_array(nb_configs, sizeof(pthread_t));
 for (i = 0; i < nb_configs; i++) {
-config_dump(configs + i);
-pthread_create(_threads[i], NULL, run_server, configs + i);
+config_dump(configs + i, stderr);
+ret = pthread_create(_threads[i], NULL, run_server, configs + 
i);
+if (ret != 0) {
+server_threads[i] = 0;
+}
 }
 
 for (i = 0; i < nb_configs; i++) {
-pthread_join(server_threads[i], NULL);
+if (server_threads[i])
+pthread_join(server_threads[i], NULL);
 config_free(configs + i);
 }
 av_free(configs);
-- 
2.16.2

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


[FFmpeg-devel] [PATCH 01/22] ffserver.c: Replace av_malloc with av_mallocz_array

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 ffserver.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index 1363cdc..116c399 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -505,8 +505,8 @@ void *run_server(void *arg) {
 pthread_t *r_threads;
 pthread_t **w_threads_p;
 
-pubs = av_mallocz(config->nb_streams * sizeof(struct PublisherContext*));
-ifmt_ctxs = av_mallocz(config->nb_streams * sizeof(AVFormatContext*));
+pubs = av_mallocz_array(config->nb_streams, sizeof(struct 
PublisherContext*));
+ifmt_ctxs = av_mallocz_array(config->nb_streams, sizeof(AVFormatContext*));
 
 av_log_set_level(AV_LOG_INFO);
 
@@ -516,10 +516,10 @@ void *run_server(void *arg) {
 ainfo.httpd = 
 ainfo.config = config;
 
-rinfos = av_mallocz(config->nb_streams * sizeof(struct ReadInfo));
-winfos_p = av_mallocz(config->nb_streams * sizeof(struct WriteInfo*));
-r_threads = av_mallocz(config->nb_streams * sizeof(pthread_t));
-w_threads_p = av_mallocz(config->nb_streams * sizeof(pthread_t*));
+rinfos = av_mallocz_array(config->nb_streams, sizeof(struct ReadInfo));
+winfos_p = av_mallocz_array(config->nb_streams, sizeof(struct WriteInfo*));
+r_threads = av_mallocz_array(config->nb_streams, sizeof(pthread_t));
+w_threads_p = av_mallocz_array(config->nb_streams, sizeof(pthread_t*));
 
 for (stream_index = 0; stream_index < config->nb_streams; stream_index++) {
 struct PublisherContext *pub = NULL;
@@ -545,8 +545,8 @@ void *run_server(void *arg) {
 
 rinfos[stream_index] = rinfo;
 
-w_threads = av_malloc(sizeof(pthread_t) * pub->nb_threads);
-winfos = av_malloc(sizeof(struct WriteInfo) * pub->nb_threads);
+w_threads = av_mallocz_array(pub->nb_threads, sizeof(pthread_t));
+winfos = av_mallocz_array(pub->nb_threads, sizeof(struct WriteInfo));
 
 w_threads_p[stream_index] = w_threads;
 winfos_p[stream_index] = winfos;
@@ -604,7 +604,7 @@ int main(int argc, char *argv[])
 printf("No valid configurations parsed.\n");
 return 1;
 }
-server_threads = av_malloc(nb_configs * sizeof(pthread_t));
+server_threads = av_mallocz_array(nb_configs, sizeof(pthread_t));
 for (i = 0; i < nb_configs; i++) {
 config_dump(configs + i);
 pthread_create(_threads[i], NULL, run_server, configs + i);
-- 
2.16.2

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


[FFmpeg-devel] FFserver refactor and bugfixes

2018-05-31 Thread Stephan Holljes
This patch series got a bit larger than I hoped, but there were quite
some more things to fix. Also a number of these commits are of cosmetic
nature.


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


[FFmpeg-devel] [PATCH 7/8] Makefile: Update Makefile

2018-05-31 Thread Stephan Holljes
Signed-off-by: Stephan Holljes 
---
 Makefile | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index fbecdeb..83bc4e0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,11 @@
 all: ffserver
 LAV_FLAGS = $(shell pkg-config --libs --cflags libavformat libavcodec 
libavutil)
+LUA_FLAGS = $(shell pkg-config --libs --cflags lua5.3)
 CFLAGS=-fsanitize=address -fsanitize=undefined
 # LAV_FLAGS = -L/usr/local/lib -lavcodec -lavformat -lavutil
 
-ffserver: segment.o publisher.o lavfhttpd.o ffserver.c
-   cc -g -Wall $(CFLAGS) $(LAV_FLAGS) -lpthread -o ffserver segment.o 
publisher.o lavfhttpd.o ffserver.c
+ffserver: segment.o publisher.o lavfhttpd.o configreader.o ffserver.c
+   cc -g -Wall $(CFLAGS) $(LAV_FLAGS) $(LUA_FLAGS) -lpthread -o ffserver 
segment.o publisher.o lavfhttpd.o configreader.o ffserver.c
 
 segment.o: segment.c segment.h
cc -g -Wall $(CFLAGS) $(LAV_FLAGS) -lpthread -c segment.c
@@ -15,5 +16,7 @@ publisher.o: publisher.c publisher.h
 lavfhttpd.o: lavfhttpd.c httpd.h
cc -g -Wall $(CFLAGS) $(LAV_FLAGS) -lpthread -c lavfhttpd.c
 
+configreader.o: configreader.c configreader.h httpd.h
+   cc -g -Wall $(CFLAGS) $(LAV_FLAGS) $(LUA_FLAGS) -c configreader.c
 clean:
rm -f *.o ffserver
-- 
2.16.2

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


Re: [FFmpeg-devel] [PATCH] Limited timecode support for lavd/decklink

2018-05-31 Thread Devin Heitmueller
> 
> I'd rather see a new AVPacketSideData type which will contain the timecode as 
> a string, so you can set it frame-by-frame.

For what it’s worth, this is what I’ve done on the decklink output side.  I’ve 
introduced a new side data type and I’m able to decode timecodes provided in 
H.264 streams and output them as SDI VANC (i.e. continuous output of timecodes 
as opposed to just the first timecode).

I just haven’t gotten to doing the capture side yet.  It’s on my TODO list 
though.

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


Re: [FFmpeg-devel] [PATCH] Limited timecode support for lavd/decklink

2018-05-31 Thread Marton Balint



On Thu, 31 May 2018, Jonathan Morley wrote:

Thank you for the clarification, Dave. It might be that the Blackmagic 
approach to collecting timecode doesn’t work for that one source because 
it is in the horizontal space (HANC) instead of the vertical (VANC). I 
am not sure. Sadly I don’t think my solution is all encompassing, but it 
does seem to help in enough cases I would like to get it integrated with 
master.


I am still a bit thrown about the initial “Unable to set timecode” 
error, but believe it to be initialization related. I will wait to hear 
back from Marton on my overall approach and see what I can do to clean 
that up.


av_dict_set returns < 0 on error, so the condition seems wrong.



As for the other error message my plan is to demote that to a debug.


That is a good idea.

On the other hand, I believe the usefulness of this is in its current form 
is still very limited, because typically the first few frames are NoSignal 
frames, how the end user supposed to know which frame is the one with the 
first valid timecode?


I'd rather see a new AVPacketSideData type which will contain the timecode 
as a string, so you can set it frame-by-frame.


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


Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Set st->start_time for video streams explicitly.

2018-05-31 Thread Michael Niedermayer
On Tue, May 29, 2018 at 03:39:40PM -0700, Sasi Inguva wrote:
> If start_time is not set, ffmpeg takes the duration from the global
> movie instead of the per stream duration.
> Signed-off-by: Sasi Inguva 
> ---
>  libavformat/mov.c| 20 +---
>  tests/fate/mov.mak   |  4 +++
>  tests/ref/fate/mov-neg-firstpts-discard  |  2 +-
>  tests/ref/fate/mov-stream-shorter-than-movie | 33 
>  4 files changed, 54 insertions(+), 5 deletions(-)
>  create mode 100644 tests/ref/fate/mov-stream-shorter-than-movie

i may have missed a link to a sample file 

fate-suite//mov/mov_stream_shorter_than_movie.mov: No such file or directory
make: *** [fate-mov-stream-shorter-than-movie] Error 1




[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Limited timecode support for lavd/decklink

2018-05-31 Thread Jonathan Morley
Thank you for the clarification, Dave. It might be that the Blackmagic approach 
to collecting timecode doesn’t work for that one source because it is in the 
horizontal space (HANC) instead of the vertical (VANC). I am not sure. Sadly I 
don’t think my solution is all encompassing, but it does seem to help in enough 
cases I would like to get it integrated with master.

I am still a bit thrown about the initial “Unable to set timecode” error, but 
believe it to be initialization related. I will wait to hear back from Marton 
on my overall approach and see what I can do to clean that up.

As for the other error message my plan is to demote that to a debug.

Thanks,
Jon

> On May 31, 2018, at 1:17 PM, Dave Rice  wrote:
> 
> Hi Jonathan,
> 
>> On May 31, 2018, at 3:56 PM, Jonathan Morley > > wrote:
>> 
>> Well that is helpful information if not a bit disappointing. Perhaps if I 
>> use the SDK calls to get the individual timecode components _and_ check the 
>> drop frame flag I can reassemble what the GetString() method on the 
>> IDeckLinkTimecode class is supposed to provide.
> 
> I tried with another NDF tape and it worked appropriately. So I do have a 
> capture with NDF and another capture with DF timecode as intended. I am still 
> uncertain what’s wrong with the first NDF that I reported before but I’m 
> supposing it’s an issue with that tape rather than your work.
> 
> Here’s the output of the capture of the new NDF tape, note that I’m still 
> getting the "Unable to set timecode” even though the timecode is set.
> 
> ./ffmpeg -timecode_format vitc2 -f decklink -draw_bars 0 -audio_input 
> embedded -video_input sdi -format_code ntsc -channels 8 -raw_format yuv422p10 
> -i "UltraStudio 3D" -c:v v210 -c:a aac maybendf.mov
> ffmpeg version N-91200-g1616b1be5a Copyright (c) 2000-2018 the FFmpeg 
> developers
>  built with Apple LLVM version 9.0.0 (clang-900.0.38)
>  configuration: --enable-nonfree --enable-decklink 
> --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/include
>  libavutil  56. 18.102 / 56. 18.102
>  libavcodec 58. 19.104 / 58. 19.104
>  libavformat58. 17.100 / 58. 17.100
>  libavdevice58.  4.100 / 58.  4.100
>  libavfilter 7. 24.100 /  7. 24.100
>  libswscale  5.  2.100 /  5.  2.100
>  libswresample   3.  2.100 /  3.  2.100
> [decklink @ 0x7fdd75800a00] Found Decklink mode 720 x 486 with rate 29.97(i)
> [decklink @ 0x7fdd75800a00] Unable to set timecode
> Guessed Channel Layout for Input Stream #0.0 : 7.1
> Input #0, decklink, from 'UltraStudio 3D':
>  Duration: N/A, start: 0.00, bitrate: 229869 kb/s
>Stream #0:0: Audio: pcm_s16le, 48000 Hz, 7.1, s16, 6144 kb/s
>Stream #0:1: Video: v210 (V210 / 0x30313256), yuv422p10le(bottom first), 
> 720x486, 223725 kb/s, 29.97 fps, 29.97 tbr, 1000k tbn, 1000k tbc
>Metadata:
>  timecode: 03:48:55:26
> Stream mapping:
>  Stream #0:1 -> #0:0 (v210 (native) -> v210 (native))
>  Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
> Press [q] to stop, [?] for help
> Output #0, mov, to 'maybendf.mov':
>  Metadata:
>encoder : Lavf58.17.100
>Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p10le(bottom coded 
> first (swapped)), 720x486, q=2-31, 223725 kb/s, 0.03 fps, 30k tbn, 29.97 tbc
>Metadata:
>  timecode: 03:48:55:26
>  encoder : Lavc58.19.104 v210
>Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 7.1, fltp, 469 
> kb/s
>Metadata:
>  encoder : Lavc58.19.104 aac
> frame=   48 fps= 34 q=-0.0 Lsize=   43745kB time=00:00:01.56 
> bitrate=228505.8kbits/s speed=1.12x
> video:43740kB audio:2kB subtitle:0kB other streams:0kB global headers:0kB 
> muxing overhead: 0.007146%
> [aac @ 0x7fdd77801e00] Qavg: 65536.000
> 
>> I will add that to the next patch, but it might be a minute before I get to 
>> it. Thank you again for taking a look.
>> 
>> I guess we got really lucky in our use case.
>> 
>> Thanks,
>> Jon
>> 
>>> On May 31, 2018, at 12:39 PM, Dave Rice >> > wrote:
>>> 
>>> Hi Jonathan,
>>> 
 On May 31, 2018, at 11:41 AM, Jonathan Morley >>>  >> wrote:
 
 Thank you very much, Dave. I am really curious about the df vs ndf since 
 the Blackmagic SDK call I am making doesn’t have any arguments for 
 specifying that kind of distinction. It simply returns what it finds in 
 the SDI stream.
>>> 
>>> I know have a tape known to be NDF and a tape known to be DF. The messages 
>>> I sent before were from DF tapes. When I tried a NDF tape, I get the 
>>> "Unable to find timecode” warning repeatedly and no timecode on the output 
>>> file.
>>> 
>>> ./ffmpeg -timecode_format vitc2 -f decklink -draw_bars 0 -audio_input 
>>> embedded -video_input sdi -format_code ntsc -channels 8 -raw_format 
>>> yuv422p10 -i "UltraStudio 3D" -c:v v210 -c:a aac 

Re: [FFmpeg-devel] [GSOC][PATCH] lavc/cfhd:IP frame decoding (inverse 3d transform) introduced

2018-05-31 Thread Kieran Kunhya
Hi

On Thu, 31 May 2018 at 12:25 Gagandeep Singh 
wrote:

> ---
>  libavcodec/cfhd.c | 462
> ++
>  libavcodec/cfhd.h |  15 +-
>  2 files changed, 411 insertions(+), 66 deletions(-)
>
> diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
> index 051d210355..c0cd25a95e 100644
> --- a/libavcodec/cfhd.c
> +++ b/libavcodec/cfhd.c
> @@ -41,12 +41,15 @@
>  #define ALPHA_COMPAND_GAIN 9400
>
>  enum CFHDParam {
> +TransformType=  10,
>  ChannelCount =  12,
>  SubbandCount =  14,
> +Pframe   =  19,
>

PFrame


>  ImageWidth   =  20,
>  ImageHeight  =  21,
>  LowpassPrecision =  35,
>  SubbandNumber=  48,
> +EncodingMethod   =  52,
>  Quantization =  53,
>  ChannelNumber=  62,
>  SampleFlags  =  68,
> @@ -84,6 +87,11 @@ static void init_peak_table_defaults(CFHDContext *s)
>
>  static void init_frame_defaults(CFHDContext *s)
>  {
> +s->sample_type   = 0;
> +s->transform_type= 0;
> +s->num_frames= 0;
> +s->Pframe= 0;
> +s->first_wavelet = 0;
>  s->coded_width   = 0;
>  s->coded_height  = 0;
>  s->cropped_height= 0;
> @@ -103,8 +111,10 @@ static void init_frame_defaults(CFHDContext *s)
>  }
>
>  /* TODO: merge with VLC tables or use LUT */
> -static inline int dequant_and_decompand(int level, int quantisation, int
> codebook)
> +static inline int dequant_and_decompand(int level, int quantisation, int
> codebook, int lossless)
>  {
> +if (lossless)
> +return level;
>  if (codebook == 0 || codebook == 1) {
>  int64_t abslevel = abs(level);
>  if (level < 264)
> @@ -193,16 +203,21 @@ static inline void filter(int16_t *output, ptrdiff_t
> out_stride,
>  }
>  }
>
> -static inline void interlaced_vertical_filter(int16_t *output, int16_t
> *low, int16_t *high,
> - int width, int linesize, int plane)
> +static inline void temporal_inverse_filter(int16_t *output, int16_t *low,
> int16_t *high,
> + int width, int linesize, int
> temporal_for_highpass)
>  {
>  int i;
>  int16_t even, odd;
>  for (i = 0; i < width; i++) {
>  even = (low[i] - high[i])/2;
>  odd  = (low[i] + high[i])/2;
> -output[i]= av_clip_uintp2(even, 10);
> -output[i + linesize] = av_clip_uintp2(odd, 10);
> +if (!temporal_for_highpass) {
> +output[i]= av_clip_uintp2(even, 10);
> +output[i + linesize] = av_clip_uintp2(odd, 10);
> +} else {
> +low[i]  = even;
> +high[i] = odd;
> +}
>  }
>  }
>  static void horiz_filter(int16_t *output, int16_t *low, int16_t *high,
> @@ -261,6 +276,7 @@ static int alloc_buffers(AVCodecContext *avctx)
>
>  for (i = 0; i < planes; i++) {
>  int w8, h8, w4, h4, w2, h2;
> +int16_t *frame2;
>  int width  = i ? avctx->width  >> chroma_x_shift : avctx->width;
>  int height = i ? avctx->height >> chroma_y_shift : avctx->height;
>  ptrdiff_t stride = FFALIGN(width  / 8, 8) * 8;
> @@ -277,28 +293,85 @@ static int alloc_buffers(AVCodecContext *avctx)
>  w2 = w4 * 2;
>  h2 = h4 * 2;
>
> -s->plane[i].idwt_buf =
> -av_mallocz_array(height * stride,
> sizeof(*s->plane[i].idwt_buf));
> -s->plane[i].idwt_tmp =
> -av_malloc_array(height * stride,
> sizeof(*s->plane[i].idwt_tmp));
> -if (!s->plane[i].idwt_buf || !s->plane[i].idwt_tmp)
> -return AVERROR(ENOMEM);
> -
> -s->plane[i].subband[0] = s->plane[i].idwt_buf;
> -s->plane[i].subband[1] = s->plane[i].idwt_buf + 2 * w8 * h8;
> -s->plane[i].subband[2] = s->plane[i].idwt_buf + 1 * w8 * h8;
> -s->plane[i].subband[3] = s->plane[i].idwt_buf + 3 * w8 * h8;
> -s->plane[i].subband[4] = s->plane[i].idwt_buf + 2 * w4 * h4;
> -s->plane[i].subband[5] = s->plane[i].idwt_buf + 1 * w4 * h4;
> -s->plane[i].subband[6] = s->plane[i].idwt_buf + 3 * w4 * h4;
> -s->plane[i].subband[7] = s->plane[i].idwt_buf + 2 * w2 * h2;
> -s->plane[i].subband[8] = s->plane[i].idwt_buf + 1 * w2 * h2;
> -s->plane[i].subband[9] = s->plane[i].idwt_buf + 3 * w2 * h2;
> -
> -for (j = 0; j < DWT_LEVELS; j++) {
> -for (k = 0; k < FF_ARRAY_ELEMS(s->plane[i].band[j]); k++) {
> -s->plane[i].band[j][k].a_width  = w8 << j;
> -s->plane[i].band[j][k].a_height = h8 << j;
> +if (s->transform_type == 0) {
> +s->plane[i].idwt_buf =
> +av_mallocz_array(height * stride,
> sizeof(*s->plane[i].idwt_buf));
> +s->plane[i].idwt_tmp =
> +av_malloc_array(height * stride,
> sizeof(*s->plane[i].idwt_tmp));
> +if (!s->plane[i].idwt_buf || !s->plane[i].idwt_tmp)
> +return AVERROR(ENOMEM);

Re: [FFmpeg-devel] [PATCH] Limited timecode support for lavd/decklink

2018-05-31 Thread Dave Rice
Hi Jonathan,

> On May 31, 2018, at 3:56 PM, Jonathan Morley  wrote:
> 
> Well that is helpful information if not a bit disappointing. Perhaps if I use 
> the SDK calls to get the individual timecode components _and_ check the drop 
> frame flag I can reassemble what the GetString() method on the 
> IDeckLinkTimecode class is supposed to provide.

I tried with another NDF tape and it worked appropriately. So I do have a 
capture with NDF and another capture with DF timecode as intended. I am still 
uncertain what’s wrong with the first NDF that I reported before but I’m 
supposing it’s an issue with that tape rather than your work.

Here’s the output of the capture of the new NDF tape, note that I’m still 
getting the "Unable to set timecode” even though the timecode is set.

./ffmpeg -timecode_format vitc2 -f decklink -draw_bars 0 -audio_input embedded 
-video_input sdi -format_code ntsc -channels 8 -raw_format yuv422p10 -i 
"UltraStudio 3D" -c:v v210 -c:a aac maybendf.mov
ffmpeg version N-91200-g1616b1be5a Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.38)
  configuration: --enable-nonfree --enable-decklink 
--extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/include
  libavutil  56. 18.102 / 56. 18.102
  libavcodec 58. 19.104 / 58. 19.104
  libavformat58. 17.100 / 58. 17.100
  libavdevice58.  4.100 / 58.  4.100
  libavfilter 7. 24.100 /  7. 24.100
  libswscale  5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
[decklink @ 0x7fdd75800a00] Found Decklink mode 720 x 486 with rate 29.97(i)
[decklink @ 0x7fdd75800a00] Unable to set timecode
Guessed Channel Layout for Input Stream #0.0 : 7.1
Input #0, decklink, from 'UltraStudio 3D':
  Duration: N/A, start: 0.00, bitrate: 229869 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, 7.1, s16, 6144 kb/s
Stream #0:1: Video: v210 (V210 / 0x30313256), yuv422p10le(bottom first), 
720x486, 223725 kb/s, 29.97 fps, 29.97 tbr, 1000k tbn, 1000k tbc
Metadata:
  timecode: 03:48:55:26
Stream mapping:
  Stream #0:1 -> #0:0 (v210 (native) -> v210 (native))
  Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, mov, to 'maybendf.mov':
  Metadata:
encoder : Lavf58.17.100
Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p10le(bottom coded 
first (swapped)), 720x486, q=2-31, 223725 kb/s, 0.03 fps, 30k tbn, 29.97 tbc
Metadata:
  timecode: 03:48:55:26
  encoder : Lavc58.19.104 v210
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 7.1, fltp, 469 
kb/s
Metadata:
  encoder : Lavc58.19.104 aac
frame=   48 fps= 34 q=-0.0 Lsize=   43745kB time=00:00:01.56 
bitrate=228505.8kbits/s speed=1.12x
video:43740kB audio:2kB subtitle:0kB other streams:0kB global headers:0kB 
muxing overhead: 0.007146%
[aac @ 0x7fdd77801e00] Qavg: 65536.000

> I will add that to the next patch, but it might be a minute before I get to 
> it. Thank you again for taking a look.
> 
> I guess we got really lucky in our use case.
> 
> Thanks,
> Jon
> 
>> On May 31, 2018, at 12:39 PM, Dave Rice  wrote:
>> 
>> Hi Jonathan,
>> 
>>> On May 31, 2018, at 11:41 AM, Jonathan Morley >> > wrote:
>>> 
>>> Thank you very much, Dave. I am really curious about the df vs ndf since 
>>> the Blackmagic SDK call I am making doesn’t have any arguments for 
>>> specifying that kind of distinction. It simply returns what it finds in the 
>>> SDI stream.
>> 
>> I know have a tape known to be NDF and a tape known to be DF. The messages I 
>> sent before were from DF tapes. When I tried a NDF tape, I get the "Unable 
>> to find timecode” warning repeatedly and no timecode on the output file.
>> 
>> ./ffmpeg -timecode_format vitc2 -f decklink -draw_bars 0 -audio_input 
>> embedded -video_input sdi -format_code ntsc -channels 8 -raw_format 
>> yuv422p10 -i "UltraStudio 3D" -c:v v210 -c:a aac devlin5.mov
>> ffmpeg version N-91200-g1616b1be5a Copyright (c) 2000-2018 the FFmpeg 
>> developers
>> built with Apple LLVM version 9.0.0 (clang-900.0.38)
>> configuration: --enable-nonfree --enable-decklink 
>> --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/include
>> libavutil  56. 18.102 / 56. 18.102
>> libavcodec 58. 19.104 / 58. 19.104
>> libavformat58. 17.100 / 58. 17.100
>> libavdevice58.  4.100 / 58.  4.100
>> libavfilter 7. 24.100 /  7. 24.100
>> libswscale  5.  2.100 /  5.  2.100
>> libswresample   3.  2.100 /  3.  2.100
>> [decklink @ 0x7f9f6680] Found Decklink mode 720 x 486 with rate 29.97(i)
>> [decklink @ 0x7f9f6680] Unable to find timecode.
>>   Last message repeated 5 times
>> Guessed Channel Layout for Input Stream #0.0 : 7.1
>> Input #0, decklink, from 'UltraStudio 3D':
>> Duration: N/A, start: 0.00, bitrate: 229869 kb/s
>>   Stream #0:0: Audio: pcm_s16le, 48000 Hz, 7.1, s16, 6144 kb/s
>>   Stream #0:1: 

[FFmpeg-devel] [PATCH] avfilter: add crossover filter

2018-05-31 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi   |  17 +++
 libavfilter/Makefile   |   1 +
 libavfilter/af_crossover.c | 343 +
 libavfilter/allfilters.c   |   1 +
 4 files changed, 362 insertions(+)
 create mode 100644 libavfilter/af_crossover.c

diff --git a/doc/filters.texi b/doc/filters.texi
index fb131670c7..e3ade147ee 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -2565,6 +2565,23 @@ Set input gain. Default is 0.9.
 Set output gain. Default is 1.
 @end table
 
+@section crossover
+Split audio stream into several bands.
+
+This filter splits audio stream into two or more frequency ranges.
+Summing all streams back will give flat output.
+
+The filter accepts the following options:
+
+@table @option
+@item split
+Set split frequencies. Those must be positive and increasing.
+
+@item order
+Set filter order, can be @var{2nd}, @var{4th} or @var{8th}.
+Default is @var{4th}.
+@end table
+
 @section crystalizer
 Simple algorithm to expand audio dynamic range.
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 3201cbeacf..4d82d6597d 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -89,6 +89,7 @@ OBJS-$(CONFIG_CHORUS_FILTER) += af_chorus.o 
generate_wave_table.
 OBJS-$(CONFIG_COMPAND_FILTER)+= af_compand.o
 OBJS-$(CONFIG_COMPENSATIONDELAY_FILTER)  += af_compensationdelay.o
 OBJS-$(CONFIG_CROSSFEED_FILTER)  += af_crossfeed.o
+OBJS-$(CONFIG_CROSSOVER_FILTER)  += af_crossover.o
 OBJS-$(CONFIG_CRYSTALIZER_FILTER)+= af_crystalizer.o
 OBJS-$(CONFIG_DCSHIFT_FILTER)+= af_dcshift.o
 OBJS-$(CONFIG_DRMETER_FILTER)+= af_drmeter.o
diff --git a/libavfilter/af_crossover.c b/libavfilter/af_crossover.c
new file mode 100644
index 00..59f8352c2b
--- /dev/null
+++ b/libavfilter/af_crossover.c
@@ -0,0 +1,343 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Crossover filter
+ *
+ * Split an audio stream into several bands.
+ */
+
+#include "libavutil/attributes.h"
+#include "libavutil/avstring.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/internal.h"
+#include "libavutil/opt.h"
+
+#include "audio.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+
+#define MAX_SPLITS 8
+#define MAX_BANDS MAX_SPLITS + 1
+
+typedef struct BiquadContext {
+double a0, a1, a2;
+double b1, b2;
+double i1, i2;
+double o1, o2;
+} BiquadContext;
+
+typedef struct CrossoverChannel {
+BiquadContext lp[MAX_BANDS][4];
+BiquadContext hp[MAX_BANDS][4];
+} CrossoverChannel;
+
+typedef struct CrossoverContext {
+const AVClass *class;
+
+char *splits_str;
+int order;
+
+int filter_count;
+int nb_splits;
+float *splits;
+
+CrossoverChannel *xover;
+} CrossoverContext;
+
+#define OFFSET(x) offsetof(CrossoverContext, x)
+#define AF AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
+
+static const AVOption crossover_options[] = {
+{ "split", "set split frequencies", OFFSET(splits_str), 
AV_OPT_TYPE_STRING, {.str="500"}, 0, 0, AF },
+{ "order", "set order", OFFSET(order),  AV_OPT_TYPE_INT,   
 {.i64=1}, 0, 2, AF, "m" },
+{ "2nd",   "2nd order", 0,  AV_OPT_TYPE_CONST, 
 {.i64=0}, 0, 0, AF, "m" },
+{ "4th",   "4th order", 0,  AV_OPT_TYPE_CONST, 
 {.i64=1}, 0, 0, AF, "m" },
+{ "8th",   "8th order", 0,  AV_OPT_TYPE_CONST, 
 {.i64=2}, 0, 0, AF, "m" },
+{ NULL }
+};
+
+AVFILTER_DEFINE_CLASS(crossover);
+
+static av_cold int init(AVFilterContext *ctx)
+{
+CrossoverContext *s = ctx->priv;
+char *p, *arg, *saveptr = NULL;
+int i, ret = 0;
+
+s->splits = av_calloc(MAX_SPLITS, sizeof(*s->splits));
+if (!s->splits)
+return AVERROR(ENOMEM);
+
+p = s->splits_str;
+for (i = 0; i < MAX_SPLITS; i++) {
+float freq;
+
+if (!(arg = av_strtok(p, " |", )))
+break;
+
+p = NULL;
+
+ret = sscanf(arg, "%f", );
+
+if (freq <= 0) {
+av_log(ctx, AV_LOG_ERROR, "Frequency %f must be positive 
number.\n", freq);
+

Re: [FFmpeg-devel] [PATCH] Limited timecode support for lavd/decklink

2018-05-31 Thread Jonathan Morley
Well that is helpful information if not a bit disappointing. Perhaps if I use 
the SDK calls to get the individual timecode components _and_ check the drop 
frame flag I can reassemble what the GetString() method on the 
IDeckLinkTimecode class is supposed to provide.

I will add that to the next patch, but it might be a minute before I get to it. 
Thank you again for taking a look.

I guess we got really lucky in our use case.

Thanks,
Jon

> On May 31, 2018, at 12:39 PM, Dave Rice  wrote:
> 
> Hi Jonathan,
> 
>> On May 31, 2018, at 11:41 AM, Jonathan Morley > > wrote:
>> 
>> Thank you very much, Dave. I am really curious about the df vs ndf since the 
>> Blackmagic SDK call I am making doesn’t have any arguments for specifying 
>> that kind of distinction. It simply returns what it finds in the SDI stream.
> 
> I know have a tape known to be NDF and a tape known to be DF. The messages I 
> sent before were from DF tapes. When I tried a NDF tape, I get the "Unable to 
> find timecode” warning repeatedly and no timecode on the output file.
> 
> ./ffmpeg -timecode_format vitc2 -f decklink -draw_bars 0 -audio_input 
> embedded -video_input sdi -format_code ntsc -channels 8 -raw_format yuv422p10 
> -i "UltraStudio 3D" -c:v v210 -c:a aac devlin5.mov
> ffmpeg version N-91200-g1616b1be5a Copyright (c) 2000-2018 the FFmpeg 
> developers
>  built with Apple LLVM version 9.0.0 (clang-900.0.38)
>  configuration: --enable-nonfree --enable-decklink 
> --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/include
>  libavutil  56. 18.102 / 56. 18.102
>  libavcodec 58. 19.104 / 58. 19.104
>  libavformat58. 17.100 / 58. 17.100
>  libavdevice58.  4.100 / 58.  4.100
>  libavfilter 7. 24.100 /  7. 24.100
>  libswscale  5.  2.100 /  5.  2.100
>  libswresample   3.  2.100 /  3.  2.100
> [decklink @ 0x7f9f6680] Found Decklink mode 720 x 486 with rate 29.97(i)
> [decklink @ 0x7f9f6680] Unable to find timecode.
>Last message repeated 5 times
> Guessed Channel Layout for Input Stream #0.0 : 7.1
> Input #0, decklink, from 'UltraStudio 3D':
>  Duration: N/A, start: 0.00, bitrate: 229869 kb/s
>Stream #0:0: Audio: pcm_s16le, 48000 Hz, 7.1, s16, 6144 kb/s
>Stream #0:1: Video: v210 (V210 / 0x30313256), yuv422p10le(bottom first), 
> 720x486, 223725 kb/s, 29.97 fps, 29.97 tbr, 1000k tbn, 1000k tbc
> Stream mapping:
>  Stream #0:1 -> #0:0 (v210 (native) -> v210 (native))
>  Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
> Press [q] to stop, [?] for help
> Output #0, mov, to 'devlin5.mov':
>  Metadata:
>encoder : Lavf58.17.100
>Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p10le(bottom coded 
> first (swapped)), 720x486, q=2-31, 223725 kb/s, 29.97 fps, 30k tbn, 29.97 tbc
>Metadata:
>  encoder : Lavc58.19.104 v210
>Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 7.1, fltp, 469 
> kb/s
>Metadata:
>  encoder : Lavc58.19.104 aac
> [decklink @ 0x7f9f6680] Unable to find timecode.
>Last message repeated 15 times
> [decklink @ 0x7f9f6680] Unable to find timecode.0:00.70 
> bitrate=200517.8kbits/s speed= 1.4x
>Last message repeated 14 times
> [decklink @ 0x7f9f6680] Unable to find timecode.0:01.20 
> bitrate=211246.0kbits/s speed= 1.2x
>Last message repeated 14 times
> [decklink @ 0x7f9f6680] Unable to find timecode.0:01.70 
> bitrate=214431.3kbits/s speed=1.13x
>Last message repeated 14 times
> [decklink @ 0x7f9f6680] Unable to find timecode.0:02.20 
> bitrate=217121.0kbits/s speed= 1.1x
>Last message repeated 14 times
> [decklink @ 0x7f9f6680] Unable to find timecode.0:02.70 
> bitrate=221142.3kbits/s speed=1.07x
>Last message repeated 14 times
> [decklink @ 0x7f9f6680] Unable to find timecode.0:03.20 
> bitrate=221288.2kbits/s speed=1.06x
> 
> So when inputing DF this appears to work while Media Express gets it wrong by 
> writing the timecode with a NDF flag.
> However when inputing NDF no timecode is communicated.
> 
> I ran this to check if somehow I was called the wrong timecode 
> 
> for i in rp188vitc rp188vitc2 rp188ltc rp188any vitc vitc2 serial ; do echo 
> -n "${i}: " ; ./ffprobe -v quiet -timecode_format "$i" -f decklink -draw_bars 
> 0 -audio_input embedded -video_input sdi -format_code ntsc -channels 8 
> -raw_format yuv422p10 -i "UltraStudio 3D" -select_streams v -show_entries 
> stream_tags=timecode -of default=nw=1:nk=1 ; echo ; done
> 
> rp188vitc: 
> rp188vitc2: 
> rp188ltc: 
> rp188any: 
> vitc: 
> vitc2: 
> serial: 
> 
> I may try to find another NDF tape to make sure this isn’t a fluke.
> 
>> And when I skimmed the movenc timecode handling it doesn’t seem to make any 
>> assumptions or changes either.
> 
> I’ve replicated it with Matroska which simply moves the timecode into 
> metadata as a string.
> 
>> Please keep me posted. Meanwhile I will look into what could be causing all 

Re: [FFmpeg-devel] [PATCH] Limited timecode support for lavd/decklink

2018-05-31 Thread Dave Rice
Hi Jonathan,

> On May 31, 2018, at 11:41 AM, Jonathan Morley  wrote:
> 
> Thank you very much, Dave. I am really curious about the df vs ndf since the 
> Blackmagic SDK call I am making doesn’t have any arguments for specifying 
> that kind of distinction. It simply returns what it finds in the SDI stream.

I know have a tape known to be NDF and a tape known to be DF. The messages I 
sent before were from DF tapes. When I tried a NDF tape, I get the "Unable to 
find timecode” warning repeatedly and no timecode on the output file.

./ffmpeg -timecode_format vitc2 -f decklink -draw_bars 0 -audio_input embedded 
-video_input sdi -format_code ntsc -channels 8 -raw_format yuv422p10 -i 
"UltraStudio 3D" -c:v v210 -c:a aac devlin5.mov
ffmpeg version N-91200-g1616b1be5a Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.38)
  configuration: --enable-nonfree --enable-decklink 
--extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/include
  libavutil  56. 18.102 / 56. 18.102
  libavcodec 58. 19.104 / 58. 19.104
  libavformat58. 17.100 / 58. 17.100
  libavdevice58.  4.100 / 58.  4.100
  libavfilter 7. 24.100 /  7. 24.100
  libswscale  5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
[decklink @ 0x7f9f6680] Found Decklink mode 720 x 486 with rate 29.97(i)
[decklink @ 0x7f9f6680] Unable to find timecode.
Last message repeated 5 times
Guessed Channel Layout for Input Stream #0.0 : 7.1
Input #0, decklink, from 'UltraStudio 3D':
  Duration: N/A, start: 0.00, bitrate: 229869 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, 7.1, s16, 6144 kb/s
Stream #0:1: Video: v210 (V210 / 0x30313256), yuv422p10le(bottom first), 
720x486, 223725 kb/s, 29.97 fps, 29.97 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:1 -> #0:0 (v210 (native) -> v210 (native))
  Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, mov, to 'devlin5.mov':
  Metadata:
encoder : Lavf58.17.100
Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p10le(bottom coded 
first (swapped)), 720x486, q=2-31, 223725 kb/s, 29.97 fps, 30k tbn, 29.97 tbc
Metadata:
  encoder : Lavc58.19.104 v210
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 7.1, fltp, 469 
kb/s
Metadata:
  encoder : Lavc58.19.104 aac
[decklink @ 0x7f9f6680] Unable to find timecode.
Last message repeated 15 times
[decklink @ 0x7f9f6680] Unable to find timecode.0:00.70 
bitrate=200517.8kbits/s speed= 1.4x
Last message repeated 14 times
[decklink @ 0x7f9f6680] Unable to find timecode.0:01.20 
bitrate=211246.0kbits/s speed= 1.2x
Last message repeated 14 times
[decklink @ 0x7f9f6680] Unable to find timecode.0:01.70 
bitrate=214431.3kbits/s speed=1.13x
Last message repeated 14 times
[decklink @ 0x7f9f6680] Unable to find timecode.0:02.20 
bitrate=217121.0kbits/s speed= 1.1x
Last message repeated 14 times
[decklink @ 0x7f9f6680] Unable to find timecode.0:02.70 
bitrate=221142.3kbits/s speed=1.07x
Last message repeated 14 times
[decklink @ 0x7f9f6680] Unable to find timecode.0:03.20 
bitrate=221288.2kbits/s speed=1.06x

So when inputing DF this appears to work while Media Express gets it wrong by 
writing the timecode with a NDF flag.
However when inputing NDF no timecode is communicated.

I ran this to check if somehow I was called the wrong timecode 

for i in rp188vitc rp188vitc2 rp188ltc rp188any vitc vitc2 serial ; do echo -n 
"${i}: " ; ./ffprobe -v quiet -timecode_format "$i" -f decklink -draw_bars 0 
-audio_input embedded -video_input sdi -format_code ntsc -channels 8 
-raw_format yuv422p10 -i "UltraStudio 3D" -select_streams v -show_entries 
stream_tags=timecode -of default=nw=1:nk=1 ; echo ; done

rp188vitc: 
rp188vitc2: 
rp188ltc: 
rp188any: 
vitc: 
vitc2: 
serial: 

I may try to find another NDF tape to make sure this isn’t a fluke.

> And when I skimmed the movenc timecode handling it doesn’t seem to make any 
> assumptions or changes either.

I’ve replicated it with Matroska which simply moves the timecode into metadata 
as a string.

> Please keep me posted. Meanwhile I will look into what could be causing all 
> the error chatter.

Thanks!

> Thanks,
> Jon
> 
>> On May 31, 2018, at 7:59 AM, Dave Rice  wrote:
>> 
>> 
>>> On May 31, 2018, at 5:49 AM, Jonathan Morley  wrote:
>>> 
>>> Please take a look at my latest patches.
>>> 
>>> NOTE: I no longer have the hardware to test this work!
>> 
>> I tested these patches with an Ultrastudio 3D.
>> 
>> I find that in some cases it provides the “Unable to set timecode” warning 
>> although it does provide the timecode value. Such as:
>> 
>> ./ffmpeg -timecode_format vitc -f decklink -draw_bars 0 -audio_input 
>> embedded -video_input sdi -format_code ntsc -channels 8 -raw_format 
>> yuv422p10 -i "UltraStudio 3D" -c:v v210 -c:a aac signs.mov
>> ffmpeg 

Re: [FFmpeg-devel] [PATCH] doc/ffmpeg - rewrite Stream Selection chapter

2018-05-31 Thread Lou Logan
On Wed, May 30, 2018, at 9:56 PM, Gyan Doshi wrote:
>
> Can you run this on the server to check if subsubheadings are rendered?

I'm fairly confident it will since @subheading also works online for 
developer.html, but not locally. However, this shouldn't be blocking your patch 
since it is an independent issue. I may take a look later as I haven't ruled 
out a PEBKAC yet, but it would be helpful if others can try to see if it is 
duplicated:

  cd ffmpeg
  ./configure --disable-all
  makeinfo --html -I doc --no-split -D config-not-all --init-file=doc/t2h.pm 
--output ~/developer.html doc/developer.texi

Then open ~/developer.html and search for "You must not commit code which 
breaks FFmpeg!" or any other subheading.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] libavformat/mov: Fix heap buffer overflow.

2018-05-31 Thread Jacob Trimble
Found by Chrome's ClusterFuzz: https://crbug.com/847060

Signed-off-by: Jacob Trimble 
---
 libavformat/mov.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f2a540ad50..08cc382a68 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5895,7 +5895,7 @@ static int mov_read_senc(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return AVERROR(ENOMEM);
 
 for (i = 0; i < sample_count; i++) {
-unsigned int min_samples = FFMIN(FFMAX(i, 1024 * 1024), sample_count);
+unsigned int min_samples = FFMIN(FFMAX(i + 1, 1024 * 1024), 
sample_count);
 encrypted_samples = 
av_fast_realloc(encryption_index->encrypted_samples, _size,
 min_samples * 
sizeof(*encrypted_samples));
 if (encrypted_samples) {
@@ -5949,7 +5949,7 @@ static int mov_parse_auxiliary_info(MOVContext *c, 
MOVStreamContext *sc, AVIOCon
 }
 
 for (i = 0; i < sample_count && !pb->eof_reached; i++) {
-unsigned int min_samples = FFMIN(FFMAX(i, 1024 * 1024), sample_count);
+unsigned int min_samples = FFMIN(FFMAX(i + 1, 1024 * 1024), 
sample_count);
 encrypted_samples = 
av_fast_realloc(encryption_index->encrypted_samples, _size,
 min_samples * 
sizeof(*encrypted_samples));
 if (!encrypted_samples) {
@@ -6110,7 +6110,7 @@ static int mov_read_saio(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return AVERROR(ENOMEM);
 
 for (i = 0; i < entry_count && !pb->eof_reached; i++) {
-unsigned int min_offsets = FFMIN(FFMAX(i, 1024), entry_count);
+unsigned int min_offsets = FFMIN(FFMAX(i + 1, 1024), entry_count);
 auxiliary_offsets = av_fast_realloc(
 encryption_index->auxiliary_offsets, _size,
 min_offsets * sizeof(*auxiliary_offsets));
-- 
2.17.0.921.gf22659ad46-goog

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


Re: [FFmpeg-devel] [PATCH 3/5] Renamed reinterlace to tinterlace

2018-05-31 Thread Thomas Mundt
Hi,

2018-05-30 16:10 GMT+02:00 Vasile Toncu :

> Hello,
>
> I've sent a wrong version in the previous email for patch 3. Please
> ignore. This is the corect one.


the compiler warnings are gone, but fate-filter-pixfmts-tinterlace_pad
still fails.
Why do you replace the usage of draw utils for generating the black lines
in pad mode?
It´s not necessary for the relicensing since I implemented their usage in
vf_tintelace:
https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/58ca446672fec10e851b820ce7df64bd2d1f3a70

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


Re: [FFmpeg-devel] libavutil/encryption_info: Allow multiple init info.

2018-05-31 Thread Jacob Trimble
On Fri, May 25, 2018 at 6:13 PM Michael Niedermayer
 wrote:
>
> [...]
>
> > Added fix for issue found by Chrome's ClusterFuzz (http://crbug.com/846662).
>
> this belongs in a seperate patch unless its a bug specific to the code added
> with this patch
>

Ok.  Now this patch depends on
http://ffmpeg.org/pipermail/ffmpeg-devel/2018-May/230782.html.

> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> I have often repented speaking, but never of holding my tongue.
> -- Xenocrates
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
From 468958a26c1df8f599925038518ca4dae90de0f7 Mon Sep 17 00:00:00 2001
From: Jacob Trimble 
Date: Mon, 23 Apr 2018 10:33:58 -0700
Subject: [PATCH] libavutil/encryption_info: Allow multiple init info.

It is possible for there to be multiple encryption init info structure.
For example, to support multiple key systems or in key rotation.  This
changes the AVEncryptionInitInfo struct to be a linked list so there
can be multiple structs without breaking ABI.

Signed-off-by: Jacob Trimble 
---
 libavutil/encryption_info.c | 148 
 libavutil/encryption_info.h |   5 ++
 2 files changed, 104 insertions(+), 49 deletions(-)

diff --git a/libavutil/encryption_info.c b/libavutil/encryption_info.c
index a48ded922c..4675ceccf6 100644
--- a/libavutil/encryption_info.c
+++ b/libavutil/encryption_info.c
@@ -162,13 +162,16 @@ uint8_t *av_encryption_info_add_side_data(const AVEncryptionInfo *info, size_t *
 }
 
 // The format of the AVEncryptionInitInfo side data:
-// u32be system_id_size
-// u32be num_key_ids
-// u32be key_id_size
-// u32be data_size
-// u8[system_id_size] system_id
-// u8[key_id_size][num_key_id] key_ids
-// u8[data_size] data
+// u32be init_info_count
+// {
+//   u32be system_id_size
+//   u32be num_key_ids
+//   u32be key_id_size
+//   u32be data_size
+//   u8[system_id_size] system_id
+//   u8[key_id_size][num_key_id] key_ids
+//   u8[data_size] data
+// }[init_info_count]
 
 #define FF_ENCRYPTION_INIT_INFO_EXTRA 16
 
@@ -217,6 +220,7 @@ void av_encryption_init_info_free(AVEncryptionInitInfo *info)
 for (i = 0; i < info->num_key_ids; i++) {
 av_free(info->key_ids[i]);
 }
+av_encryption_init_info_free(info->next);
 av_free(info->system_id);
 av_free(info->key_ids);
 av_free(info->data);
@@ -227,72 +231,118 @@ void av_encryption_init_info_free(AVEncryptionInitInfo *info)
 AVEncryptionInitInfo *av_encryption_init_info_get_side_data(
 const uint8_t *side_data, size_t side_data_size)
 {
-AVEncryptionInitInfo *info;
-uint64_t system_id_size, num_key_ids, key_id_size, data_size, i;
+AVEncryptionInitInfo *ret = NULL, *info;
+uint64_t system_id_size, num_key_ids, key_id_size, data_size, i, j;
+uint64_t init_info_count;
 
-if (!side_data || side_data_size < FF_ENCRYPTION_INIT_INFO_EXTRA)
+if (!side_data || side_data_size < 4)
 return NULL;
 
-system_id_size = AV_RB32(side_data);
-num_key_ids = AV_RB32(side_data + 4);
-key_id_size = AV_RB32(side_data + 8);
-data_size = AV_RB32(side_data + 12);
+init_info_count = AV_RB32(side_data);
+side_data += 4;
+side_data_size -= 4;
+for (i = 0; i < init_info_count; i++) {
+if (side_data_size < FF_ENCRYPTION_INIT_INFO_EXTRA) {
+av_encryption_init_info_free(ret);
+return NULL;
+}
 
-// UINT32_MAX + UINT32_MAX + UINT32_MAX * UINT32_MAX == UINT64_MAX
-if (side_data_size - FF_ENCRYPTION_INIT_INFO_EXTRA < system_id_size + data_size + num_key_ids * key_id_size)
-return NULL;
+system_id_size = AV_RB32(side_data);
+num_key_ids = AV_RB32(side_data + 4);
+key_id_size = AV_RB32(side_data + 8);
+data_size = AV_RB32(side_data + 12);
 
-info = av_encryption_init_info_alloc(system_id_size, num_key_ids, key_id_size, data_size);
-if (!info)
-return NULL;
+// UINT32_MAX + UINT32_MAX + UINT32_MAX * UINT32_MAX == UINT64_MAX
+if (side_data_size - FF_ENCRYPTION_INIT_INFO_EXTRA < system_id_size + data_size + num_key_ids * key_id_size) {
+av_encryption_init_info_free(ret);
+return NULL;
+}
+side_data += FF_ENCRYPTION_INIT_INFO_EXTRA;
+side_data_size -= FF_ENCRYPTION_INIT_INFO_EXTRA;
 
-memcpy(info->system_id, side_data + 16, system_id_size);
-side_data += system_id_size + 16;
-for (i = 0; i < num_key_ids; i++) {
-  memcpy(info->key_ids[i], side_data, key_id_size);
-  side_data += key_id_size;
+info = av_encryption_init_info_alloc(system_id_size, num_key_ids, key_id_size, data_size);
+if (!info) {
+av_encryption_init_info_free(ret);
+return NULL;
+}
+info->next = ret;
+ret = info;
+
+memcpy(info->system_id, side_data, 

[FFmpeg-devel] [PATCH] libavutil/encryption_info: Add NULL checks.

2018-05-31 Thread Jacob Trimble
Found by Chrome's ClusterFuzz: http://crbug.com/846662.

Signed-off-by: Jacob Trimble 
---
 libavutil/encryption_info.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavutil/encryption_info.c b/libavutil/encryption_info.c
index 20a752d6b4..a48ded922c 100644
--- a/libavutil/encryption_info.c
+++ b/libavutil/encryption_info.c
@@ -64,6 +64,8 @@ AVEncryptionInfo *av_encryption_info_clone(const 
AVEncryptionInfo *info)
 {
 AVEncryptionInfo *ret;
 
+if (!info)
+return NULL;
 ret = av_encryption_info_alloc(info->subsample_count, info->key_id_size, 
info->iv_size);
 if (!ret)
 return NULL;
@@ -127,7 +129,7 @@ uint8_t *av_encryption_info_add_side_data(const 
AVEncryptionInfo *info, size_t *
 uint8_t *buffer, *cur_buffer;
 uint32_t i;
 
-if (UINT32_MAX - FF_ENCRYPTION_INFO_EXTRA < info->key_id_size ||
+if (!info || !size || UINT32_MAX - FF_ENCRYPTION_INFO_EXTRA < 
info->key_id_size ||
 UINT32_MAX - FF_ENCRYPTION_INFO_EXTRA - info->key_id_size < 
info->iv_size ||
 (UINT32_MAX - FF_ENCRYPTION_INFO_EXTRA - info->key_id_size - 
info->iv_size) / 8 < info->subsample_count) {
 return NULL;
@@ -260,7 +262,8 @@ uint8_t *av_encryption_init_info_add_side_data(const 
AVEncryptionInitInfo *info,
 uint8_t *buffer, *cur_buffer;
 uint32_t i, max_size;
 
-if (UINT32_MAX - FF_ENCRYPTION_INIT_INFO_EXTRA < info->system_id_size ||
+if (!info || !side_data_size ||
+UINT32_MAX - FF_ENCRYPTION_INIT_INFO_EXTRA < info->system_id_size ||
 UINT32_MAX - FF_ENCRYPTION_INIT_INFO_EXTRA - info->system_id_size < 
info->data_size) {
 return NULL;
 }
-- 
2.17.0.921.gf22659ad46-goog

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


Re: [FFmpeg-devel] [PATCH] Limited timecode support for lavd/decklink

2018-05-31 Thread Jonathan Morley
Hi Dave,

I took a closer look at these messages. I can see why the “Unable to find 
timecode” messages are repeated. That is sort of correctly reporting that the 
current video stream does not have a valid timecode, however reporting it as an 
error seems unnecessary. How would changing it to a debug message sound?

As for the “Unable to set timecode” I am still not sure how that could happen 
unless the way I am testing for the uninitialized ctx->first_tc is 
inconsistent. I will have to hear back from Marton I believe.

Thanks,
Jon

> On May 31, 2018, at 7:59 AM, Dave Rice  wrote:
> 
> 
>> On May 31, 2018, at 5:49 AM, Jonathan Morley  wrote:
>> 
>> Please take a look at my latest patches.
>> 
>> NOTE: I no longer have the hardware to test this work!
> 
> I tested these patches with an Ultrastudio 3D.
> 
> I find that in some cases it provides the “Unable to set timecode” warning 
> although it does provide the timecode value. Such as:
> 
> ./ffmpeg -timecode_format vitc -f decklink -draw_bars 0 -audio_input embedded 
> -video_input sdi -format_code ntsc -channels 8 -raw_format yuv422p10 -i 
> "UltraStudio 3D" -c:v v210 -c:a aac signs.mov
> ffmpeg version N-91200-g1616b1be5a Copyright (c) 2000-2018 the FFmpeg 
> developers
>  built with Apple LLVM version 9.0.0 (clang-900.0.38)
>  configuration: --enable-nonfree --enable-decklink 
> --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/include
>  libavutil  56. 18.102 / 56. 18.102
>  libavcodec 58. 19.104 / 58. 19.104
>  libavformat58. 17.100 / 58. 17.100
>  libavdevice58.  4.100 / 58.  4.100
>  libavfilter 7. 24.100 /  7. 24.100
>  libswscale  5.  2.100 /  5.  2.100
>  libswresample   3.  2.100 /  3.  2.100
> [decklink @ 0x7f8711802600] Found Decklink mode 720 x 486 with rate 29.97(i)
> [decklink @ 0x7f8711802600] Unable to set timecode
> Guessed Channel Layout for Input Stream #0.0 : 7.1
> Input #0, decklink, from 'UltraStudio 3D':
>  Duration: N/A, start: 0.00, bitrate: 229869 kb/s
>Stream #0:0: Audio: pcm_s16le, 48000 Hz, 7.1, s16, 6144 kb/s
>Stream #0:1: Video: v210 (V210 / 0x30313256), yuv422p10le(bottom first), 
> 720x486, 223725 kb/s, 29.97 fps, 29.97 tbr, 1000k tbn, 1000k tbc
>Metadata:
>  timecode: 00:59:53;25
> Stream mapping:
>  Stream #0:1 -> #0:0 (v210 (native) -> v210 (native))
>  Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
> Press [q] to stop, [?] for help
> Output #0, mov, to 'signs.mov':
>  Metadata:
>encoder : Lavf58.17.100
>Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p10le(bottom coded 
> first (swapped)), 720x486, q=2-31, 223725 kb/s, 0.03 fps, 30k tbn, 29.97 tbc
>Metadata:
>  timecode: 00:59:53;25
>  encoder : Lavc58.19.104 v210
>Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 7.1, fltp, 469 
> kb/s
>Metadata:
>  encoder : Lavc58.19.104 aac
> frame=  407 fps= 30 q=-0.0 Lsize=  371576kB time=00:00:13.54 
> bitrate=224697.2kbits/s speed=1.01x
> video:370879kB audio:685kB subtitle:0kB other streams:0kB global headers:0kB 
> muxing overhead: 0.003177%
> [aac @ 0x7f8711805800] Qavg: 30894.625
> 
> Another comment is that if I start the recording with ffmpeg before I play 
> through a source I get spammed with timecode errors such as:
> 
> ./ffmpeg -timecode_format vitc -f decklink -draw_bars 0 -audio_input embedded 
> -video_input sdi -format_code ntsc -channels 8 -raw_format yuv422p10 -i 
> "UltraStudio 3D" -c:v v210 -c:a aac notplaying.mov
> ffmpeg version N-91200-g1616b1be5a Copyright (c) 2000-2018 the FFmpeg 
> developers
>  built with Apple LLVM version 9.0.0 (clang-900.0.38)
>  configuration: --enable-nonfree --enable-decklink 
> --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/include
>  libavutil  56. 18.102 / 56. 18.102
>  libavcodec 58. 19.104 / 58. 19.104
>  libavformat58. 17.100 / 58. 17.100
>  libavdevice58.  4.100 / 58.  4.100
>  libavfilter 7. 24.100 /  7. 24.100
>  libswscale  5.  2.100 /  5.  2.100
>  libswresample   3.  2.100 /  3.  2.100
> [decklink @ 0x7fe313803000] Found Decklink mode 720 x 486 with rate 29.97(i)
> [decklink @ 0x7fe313803000] Unable to find timecode.
>Last message repeated 5 times
> Guessed Channel Layout for Input Stream #0.0 : 7.1
> Input #0, decklink, from 'UltraStudio 3D':
>  Duration: N/A, start: 0.00, bitrate: 229869 kb/s
>Stream #0:0: Audio: pcm_s16le, 48000 Hz, 7.1, s16, 6144 kb/s
>Stream #0:1: Video: v210 (V210 / 0x30313256), yuv422p10le(bottom first), 
> 720x486, 223725 kb/s, 29.97 fps, 29.97 tbr, 1000k tbn, 1000k tbc
> Stream mapping:
>  Stream #0:1 -> #0:0 (v210 (native) -> v210 (native))
>  Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
> Press [q] to stop, [?] for help
> Output #0, mov, to 'notplaying.mov':
>  Metadata:
>encoder : Lavf58.17.100
>Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p10le(bottom coded 
> first (swapped)), 720x486, 

Re: [FFmpeg-devel] [GSOC][PATCH] lavc/cfhd:IP frame decoding (inverse 3d transform) introduced

2018-05-31 Thread Gagandeep Singh
On Thu, May 31, 2018 at 4:55 PM, Gagandeep Singh 
wrote:

> ---
>  libavcodec/cfhd.c | 462 ++
> 
>  libavcodec/cfhd.h |  15 +-
>  2 files changed, 411 insertions(+), 66 deletions(-)
>
> diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
> index 051d210355..c0cd25a95e 100644
> --- a/libavcodec/cfhd.c
> +++ b/libavcodec/cfhd.c
> @@ -41,12 +41,15 @@
>  #define ALPHA_COMPAND_GAIN 9400
>
>  enum CFHDParam {
> +TransformType=  10,
>  ChannelCount =  12,
>  SubbandCount =  14,
> +Pframe   =  19,
>  ImageWidth   =  20,
>  ImageHeight  =  21,
>  LowpassPrecision =  35,
>  SubbandNumber=  48,
> +EncodingMethod   =  52,
>  Quantization =  53,
>  ChannelNumber=  62,
>  SampleFlags  =  68,
> @@ -84,6 +87,11 @@ static void init_peak_table_defaults(CFHDContext *s)
>
>  static void init_frame_defaults(CFHDContext *s)
>  {
> +s->sample_type   = 0;
> +s->transform_type= 0;
> +s->num_frames= 0;
> +s->Pframe= 0;
> +s->first_wavelet = 0;
>  s->coded_width   = 0;
>  s->coded_height  = 0;
>  s->cropped_height= 0;
> @@ -103,8 +111,10 @@ static void init_frame_defaults(CFHDContext *s)
>  }
>
>  /* TODO: merge with VLC tables or use LUT */
> -static inline int dequant_and_decompand(int level, int quantisation, int
> codebook)
> +static inline int dequant_and_decompand(int level, int quantisation, int
> codebook, int lossless)
>  {
> +if (lossless)
> +return level;
>  if (codebook == 0 || codebook == 1) {
>  int64_t abslevel = abs(level);
>  if (level < 264)
> @@ -193,16 +203,21 @@ static inline void filter(int16_t *output, ptrdiff_t
> out_stride,
>  }
>  }
>
> -static inline void interlaced_vertical_filter(int16_t *output, int16_t
> *low, int16_t *high,
> - int width, int linesize, int plane)
> +static inline void temporal_inverse_filter(int16_t *output, int16_t
> *low, int16_t *high,
> + int width, int linesize, int
> temporal_for_highpass)
>  {
>  int i;
>  int16_t even, odd;
>  for (i = 0; i < width; i++) {
>  even = (low[i] - high[i])/2;
>  odd  = (low[i] + high[i])/2;
> -output[i]= av_clip_uintp2(even, 10);
> -output[i + linesize] = av_clip_uintp2(odd, 10);
> +if (!temporal_for_highpass) {
> +output[i]= av_clip_uintp2(even, 10);
> +output[i + linesize] = av_clip_uintp2(odd, 10);
> +} else {
> +low[i]  = even;
> +high[i] = odd;
> +}
>  }
>  }
>  static void horiz_filter(int16_t *output, int16_t *low, int16_t *high,
> @@ -261,6 +276,7 @@ static int alloc_buffers(AVCodecContext *avctx)
>
>  for (i = 0; i < planes; i++) {
>  int w8, h8, w4, h4, w2, h2;
> +int16_t *frame2;
>  int width  = i ? avctx->width  >> chroma_x_shift : avctx->width;
>  int height = i ? avctx->height >> chroma_y_shift : avctx->height;
>  ptrdiff_t stride = FFALIGN(width  / 8, 8) * 8;
> @@ -277,28 +293,85 @@ static int alloc_buffers(AVCodecContext *avctx)
>  w2 = w4 * 2;
>  h2 = h4 * 2;
>
> -s->plane[i].idwt_buf =
> -av_mallocz_array(height * stride,
> sizeof(*s->plane[i].idwt_buf));
> -s->plane[i].idwt_tmp =
> -av_malloc_array(height * stride,
> sizeof(*s->plane[i].idwt_tmp));
> -if (!s->plane[i].idwt_buf || !s->plane[i].idwt_tmp)
> -return AVERROR(ENOMEM);
> -
> -s->plane[i].subband[0] = s->plane[i].idwt_buf;
> -s->plane[i].subband[1] = s->plane[i].idwt_buf + 2 * w8 * h8;
> -s->plane[i].subband[2] = s->plane[i].idwt_buf + 1 * w8 * h8;
> -s->plane[i].subband[3] = s->plane[i].idwt_buf + 3 * w8 * h8;
> -s->plane[i].subband[4] = s->plane[i].idwt_buf + 2 * w4 * h4;
> -s->plane[i].subband[5] = s->plane[i].idwt_buf + 1 * w4 * h4;
> -s->plane[i].subband[6] = s->plane[i].idwt_buf + 3 * w4 * h4;
> -s->plane[i].subband[7] = s->plane[i].idwt_buf + 2 * w2 * h2;
> -s->plane[i].subband[8] = s->plane[i].idwt_buf + 1 * w2 * h2;
> -s->plane[i].subband[9] = s->plane[i].idwt_buf + 3 * w2 * h2;
> -
> -for (j = 0; j < DWT_LEVELS; j++) {
> -for (k = 0; k < FF_ARRAY_ELEMS(s->plane[i].band[j]); k++) {
> -s->plane[i].band[j][k].a_width  = w8 << j;
> -s->plane[i].band[j][k].a_height = h8 << j;
> +if (s->transform_type == 0) {
> +s->plane[i].idwt_buf =
> +av_mallocz_array(height * stride,
> sizeof(*s->plane[i].idwt_buf));
> +s->plane[i].idwt_tmp =
> +av_malloc_array(height * stride,
> sizeof(*s->plane[i].idwt_tmp));
> +if (!s->plane[i].idwt_buf || !s->plane[i].idwt_tmp)
> +return AVERROR(ENOMEM);
> +

Re: [FFmpeg-devel] [INFO]AMD D3D11 to OpenCL interop extension for NV12 and P010 textures - split planes

2018-05-31 Thread Mironov, Mikhail
> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Alexander Kravchenko
> Sent: May 27, 2018 11:19 AM
> To: 'FFmpeg development discussions and patches'  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [INFO]AMD D3D11 to OpenCL interop extension
> for NV12 and P010 textures - split planes
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> > Of Mark Thompson
> > Sent: Sunday, May 27, 2018 3:29 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [INFO]AMD D3D11 to OpenCL interop
> > extension for NV12 and P010 textures - split planes
> >
> > On 27/05/18 07:57, Alexander Kravchenko wrote:
> > > сб, 26 мая 2018 г. в 19:45, Mark Thompson :
> > >
> > >> On 24/05/18 15:26, Mironov, Mikhail wrote:
> > >>> AMD has published OpenCL extension which allows split D3D11
> > >>> texture
> > >> interoped as a single 2D image into two 2D images representing Y
> > >> and UV planes.
> > >>>
> > >>
> https://www.khronos.org/registry/OpenCL/extensions/amd/cl_amd_plana
> > >> r_
> > >> yuv.txt
> > >>
> > >> Nice!  That looks like exactly what we want :)
> > >>
> > >> Is there any timeline for when this will be available in released 
> > >> drivers?
> > >>
> > > Hi Mark.
> > > This extension was implemented while ago, so it can be used now.
> >
> > I have what claims to be the most recent version of the Radeon drivers
> > (18.5.1, driver version 18.10.16, OpenCL version 24.20.11016.4
> > - I don't know which of these is relevant), and it gives me:
> >
> > Platform extensions:
> > cl_khr_icd cl_khr_d3d10_sharing cl_khr_d3d11_sharing
> > cl_khr_dx9_media_sharing cl_amd_event_callback cl_amd_offline_devices
> >
> > Device extensions:
> > cl_khr_fp64 cl_amd_fp64 cl_khr_global_int32_base_atomics
> > cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics
> > cl_khr_local_int32_extended_atomics cl_khr_int64_base_atomics
> > cl_khr_int64_extended_atomics cl_khr_3d_image_writes
> > cl_khr_byte_addressable_store cl_khr_gl_sharing cl_khr_gl_depth_images
> > cl_amd_device_attribute_query cl_amd_vec3 cl_amd_printf
> > cl_amd_media_ops cl_amd_media_ops2 cl_amd_popcnt
> cl_khr_d3d10_sharing
> > cl_khr_d3d11_sharing cl_khr_dx9_media_sharing
> > cl_khr_image2d_from_buffer cl_khr_spir cl_khr_subgroups
> > cl_khr_gl_event cl_khr_depth_images cl_khr_mipmap_image
> > cl_khr_mipmap_image_writes cl_amd_liquid_flash
> >
> > which doesn't include this extension?
> >
> 
> 
> Hi Mark,
> 
> It does include the extension.
> Extension was implemented while ago (years ago), but wasn't officially
> published till now.
> 
> Probably the extension is still not enumerated in device/platform extensions
> list Any way it can be used now.
> 
> 
> Thanks,
> Alexander
> 

Since it was a private extension it is not visible as device extension but if 
one asks for the function pointer it is there. The implementation was done 3-4 
years ago, I can dig the driver eversion if needed.
I will check with developer if he plans to expose it in device extension list.
Mikhail

> ___
> 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] Limited timecode support for lavd/decklink

2018-05-31 Thread Jonathan Morley
Thank you very much, Dave. I am really curious about the df vs ndf since the 
Blackmagic SDK call I am making doesn’t have any arguments for specifying that 
kind of distinction. It simply returns what it finds in the SDI stream. And 
when I skimmed the movenc timecode handling it doesn’t seem to make any 
assumptions or changes either.

Please keep me posted. Meanwhile I will look into what could be causing all the 
error chatter.

Thanks,
Jon

> On May 31, 2018, at 7:59 AM, Dave Rice  wrote:
> 
> 
>> On May 31, 2018, at 5:49 AM, Jonathan Morley  wrote:
>> 
>> Please take a look at my latest patches.
>> 
>> NOTE: I no longer have the hardware to test this work!
> 
> I tested these patches with an Ultrastudio 3D.
> 
> I find that in some cases it provides the “Unable to set timecode” warning 
> although it does provide the timecode value. Such as:
> 
> ./ffmpeg -timecode_format vitc -f decklink -draw_bars 0 -audio_input embedded 
> -video_input sdi -format_code ntsc -channels 8 -raw_format yuv422p10 -i 
> "UltraStudio 3D" -c:v v210 -c:a aac signs.mov
> ffmpeg version N-91200-g1616b1be5a Copyright (c) 2000-2018 the FFmpeg 
> developers
>  built with Apple LLVM version 9.0.0 (clang-900.0.38)
>  configuration: --enable-nonfree --enable-decklink 
> --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/include
>  libavutil  56. 18.102 / 56. 18.102
>  libavcodec 58. 19.104 / 58. 19.104
>  libavformat58. 17.100 / 58. 17.100
>  libavdevice58.  4.100 / 58.  4.100
>  libavfilter 7. 24.100 /  7. 24.100
>  libswscale  5.  2.100 /  5.  2.100
>  libswresample   3.  2.100 /  3.  2.100
> [decklink @ 0x7f8711802600] Found Decklink mode 720 x 486 with rate 29.97(i)
> [decklink @ 0x7f8711802600] Unable to set timecode
> Guessed Channel Layout for Input Stream #0.0 : 7.1
> Input #0, decklink, from 'UltraStudio 3D':
>  Duration: N/A, start: 0.00, bitrate: 229869 kb/s
>Stream #0:0: Audio: pcm_s16le, 48000 Hz, 7.1, s16, 6144 kb/s
>Stream #0:1: Video: v210 (V210 / 0x30313256), yuv422p10le(bottom first), 
> 720x486, 223725 kb/s, 29.97 fps, 29.97 tbr, 1000k tbn, 1000k tbc
>Metadata:
>  timecode: 00:59:53;25
> Stream mapping:
>  Stream #0:1 -> #0:0 (v210 (native) -> v210 (native))
>  Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
> Press [q] to stop, [?] for help
> Output #0, mov, to 'signs.mov':
>  Metadata:
>encoder : Lavf58.17.100
>Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p10le(bottom coded 
> first (swapped)), 720x486, q=2-31, 223725 kb/s, 0.03 fps, 30k tbn, 29.97 tbc
>Metadata:
>  timecode: 00:59:53;25
>  encoder : Lavc58.19.104 v210
>Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 7.1, fltp, 469 
> kb/s
>Metadata:
>  encoder : Lavc58.19.104 aac
> frame=  407 fps= 30 q=-0.0 Lsize=  371576kB time=00:00:13.54 
> bitrate=224697.2kbits/s speed=1.01x
> video:370879kB audio:685kB subtitle:0kB other streams:0kB global headers:0kB 
> muxing overhead: 0.003177%
> [aac @ 0x7f8711805800] Qavg: 30894.625
> 
> Another comment is that if I start the recording with ffmpeg before I play 
> through a source I get spammed with timecode errors such as:
> 
> ./ffmpeg -timecode_format vitc -f decklink -draw_bars 0 -audio_input embedded 
> -video_input sdi -format_code ntsc -channels 8 -raw_format yuv422p10 -i 
> "UltraStudio 3D" -c:v v210 -c:a aac notplaying.mov
> ffmpeg version N-91200-g1616b1be5a Copyright (c) 2000-2018 the FFmpeg 
> developers
>  built with Apple LLVM version 9.0.0 (clang-900.0.38)
>  configuration: --enable-nonfree --enable-decklink 
> --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/include
>  libavutil  56. 18.102 / 56. 18.102
>  libavcodec 58. 19.104 / 58. 19.104
>  libavformat58. 17.100 / 58. 17.100
>  libavdevice58.  4.100 / 58.  4.100
>  libavfilter 7. 24.100 /  7. 24.100
>  libswscale  5.  2.100 /  5.  2.100
>  libswresample   3.  2.100 /  3.  2.100
> [decklink @ 0x7fe313803000] Found Decklink mode 720 x 486 with rate 29.97(i)
> [decklink @ 0x7fe313803000] Unable to find timecode.
>Last message repeated 5 times
> Guessed Channel Layout for Input Stream #0.0 : 7.1
> Input #0, decklink, from 'UltraStudio 3D':
>  Duration: N/A, start: 0.00, bitrate: 229869 kb/s
>Stream #0:0: Audio: pcm_s16le, 48000 Hz, 7.1, s16, 6144 kb/s
>Stream #0:1: Video: v210 (V210 / 0x30313256), yuv422p10le(bottom first), 
> 720x486, 223725 kb/s, 29.97 fps, 29.97 tbr, 1000k tbn, 1000k tbc
> Stream mapping:
>  Stream #0:1 -> #0:0 (v210 (native) -> v210 (native))
>  Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
> Press [q] to stop, [?] for help
> Output #0, mov, to 'notplaying.mov':
>  Metadata:
>encoder : Lavf58.17.100
>Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p10le(bottom coded 
> first (swapped)), 720x486, q=2-31, 223725 kb/s, 29.97 fps, 30k tbn, 29.97 tbc
>Metadata:
>  encoder : 

Re: [FFmpeg-devel] [PATCH] Limited timecode support for lavd/decklink

2018-05-31 Thread Dave Rice

> On May 31, 2018, at 5:49 AM, Jonathan Morley  wrote:
> 
> Please take a look at my latest patches.
> 
> NOTE: I no longer have the hardware to test this work!

I tested these patches with an Ultrastudio 3D.

I find that in some cases it provides the “Unable to set timecode” warning 
although it does provide the timecode value. Such as:

./ffmpeg -timecode_format vitc -f decklink -draw_bars 0 -audio_input embedded 
-video_input sdi -format_code ntsc -channels 8 -raw_format yuv422p10 -i 
"UltraStudio 3D" -c:v v210 -c:a aac signs.mov
ffmpeg version N-91200-g1616b1be5a Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.38)
  configuration: --enable-nonfree --enable-decklink 
--extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/include
  libavutil  56. 18.102 / 56. 18.102
  libavcodec 58. 19.104 / 58. 19.104
  libavformat58. 17.100 / 58. 17.100
  libavdevice58.  4.100 / 58.  4.100
  libavfilter 7. 24.100 /  7. 24.100
  libswscale  5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
[decklink @ 0x7f8711802600] Found Decklink mode 720 x 486 with rate 29.97(i)
[decklink @ 0x7f8711802600] Unable to set timecode
Guessed Channel Layout for Input Stream #0.0 : 7.1
Input #0, decklink, from 'UltraStudio 3D':
  Duration: N/A, start: 0.00, bitrate: 229869 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, 7.1, s16, 6144 kb/s
Stream #0:1: Video: v210 (V210 / 0x30313256), yuv422p10le(bottom first), 
720x486, 223725 kb/s, 29.97 fps, 29.97 tbr, 1000k tbn, 1000k tbc
Metadata:
  timecode: 00:59:53;25
Stream mapping:
  Stream #0:1 -> #0:0 (v210 (native) -> v210 (native))
  Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, mov, to 'signs.mov':
  Metadata:
encoder : Lavf58.17.100
Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p10le(bottom coded 
first (swapped)), 720x486, q=2-31, 223725 kb/s, 0.03 fps, 30k tbn, 29.97 tbc
Metadata:
  timecode: 00:59:53;25
  encoder : Lavc58.19.104 v210
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 7.1, fltp, 469 
kb/s
Metadata:
  encoder : Lavc58.19.104 aac
frame=  407 fps= 30 q=-0.0 Lsize=  371576kB time=00:00:13.54 
bitrate=224697.2kbits/s speed=1.01x
video:370879kB audio:685kB subtitle:0kB other streams:0kB global headers:0kB 
muxing overhead: 0.003177%
[aac @ 0x7f8711805800] Qavg: 30894.625

Another comment is that if I start the recording with ffmpeg before I play 
through a source I get spammed with timecode errors such as:

./ffmpeg -timecode_format vitc -f decklink -draw_bars 0 -audio_input embedded 
-video_input sdi -format_code ntsc -channels 8 -raw_format yuv422p10 -i 
"UltraStudio 3D" -c:v v210 -c:a aac notplaying.mov
ffmpeg version N-91200-g1616b1be5a Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.38)
  configuration: --enable-nonfree --enable-decklink 
--extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/include
  libavutil  56. 18.102 / 56. 18.102
  libavcodec 58. 19.104 / 58. 19.104
  libavformat58. 17.100 / 58. 17.100
  libavdevice58.  4.100 / 58.  4.100
  libavfilter 7. 24.100 /  7. 24.100
  libswscale  5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
[decklink @ 0x7fe313803000] Found Decklink mode 720 x 486 with rate 29.97(i)
[decklink @ 0x7fe313803000] Unable to find timecode.
Last message repeated 5 times
Guessed Channel Layout for Input Stream #0.0 : 7.1
Input #0, decklink, from 'UltraStudio 3D':
  Duration: N/A, start: 0.00, bitrate: 229869 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, 7.1, s16, 6144 kb/s
Stream #0:1: Video: v210 (V210 / 0x30313256), yuv422p10le(bottom first), 
720x486, 223725 kb/s, 29.97 fps, 29.97 tbr, 1000k tbn, 1000k tbc
Stream mapping:
  Stream #0:1 -> #0:0 (v210 (native) -> v210 (native))
  Stream #0:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
Output #0, mov, to 'notplaying.mov':
  Metadata:
encoder : Lavf58.17.100
Stream #0:0: Video: v210 (v210 / 0x30313276), yuv422p10le(bottom coded 
first (swapped)), 720x486, q=2-31, 223725 kb/s, 29.97 fps, 30k tbn, 29.97 tbc
Metadata:
  encoder : Lavc58.19.104 v210
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 7.1, fltp, 469 
kb/s
Metadata:
  encoder : Lavc58.19.104 aac
[decklink @ 0x7fe313803000] Unable to find timecode.
Last message repeated 14 times
[decklink @ 0x7fe313803000] Unable to find timecode.0:00.66 
bitrate=210543.0kbits/s speed=1.33x
Last message repeated 14 times
[decklink @ 0x7fe313803000] Unable to find timecode.0:01.16 
bitrate=217281.3kbits/s speed=1.17x
Last message repeated 14 times
[decklink @ 0x7fe313803000] Unable to find timecode.0:01.66 
bitrate=218719.7kbits/s speed=1.11x
Last message repeated 

Re: [FFmpeg-devel] Patch: Replace quotes for inline asm detection.

2018-05-31 Thread John Cox
>On 5/30/2018 10:32 PM, Michael Niedermayer wrote:
>> On Wed, May 30, 2018 at 09:48:51AM -0700, Frank Liberato wrote:
>>> Please find attached a one line patch:
>>>
>>>
 Commit 8c893aa3cd5 removed quotes that were required to detect
 inline asm in clank:

 check_insn armv5te qadd r0, r0, r0
 .../test.c:1:34: error: expected string literal in 'asm'
 void foo(void){ __asm__ volatile(qadd r0, r0, r0); }

 The correct code is:

 void foo(void){ __asm__ volatile("qadd r0, r0, r0"); }
>>>
>>>
>>> Thanks
>>> Frank
>> 
>>>  configure |2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>> 2d51797903ad2f3cab321e72bf5e7209116c3dae  
>>> 0001-Replace-quotes-for-inline-asm-detection.patch
>>> From 58c96127b6f1510b956b2280049d1c3778e3cab4 Mon Sep 17 00:00:00 2001
>>> From: "liber...@chromium.org" 
>>> Date: Tue, 29 May 2018 11:35:04 -0700
>>> Subject: [PATCH] Replace quotes for inline asm detection.
>>>
>>> Commit 8c893aa3cd5 removed quotes that were required to detect
>>> inline asm in clank:
>>>
>>> check_insn armv5te qadd r0, r0, r0
>>> .../test.c:1:34: error: expected string literal in 'asm'
>>> void foo(void){ __asm__ volatile(qadd r0, r0, r0); }
>>>
>>> The correct code is:
>>>
>>> void foo(void){ __asm__ volatile("qadd r0, r0, r0"); }
>>> ---
>>>  configure | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/configure b/configure
>>> index 22eeca22a5..4dbee8d349 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -1040,7 +1040,7 @@ EOF
>>>  
>>>  check_insn(){
>>>  log check_insn "$@"
>>> -check_inline_asm ${1}_inline "$2"
>>> +check_inline_asm ${1}_inline "\"$2\""
>>>  check_as ${1}_external "$2"
>>>  }
>> 
>> This seems to break my arm qemu build:
>
>That'd be because vf_amplify is calling av_clip_uintp2() with a non
>immediate value. The arm optimized function makes an immediate value as
>second argument a requirement, so av_clip_uintp2_c() should be used
>there instead.
>
>This means 3c56d673418/8c893aa3cd5 broke detection of arm inline asm
>features for your qemu builds as well, and this patch restores that
>functionality.
>
>> 
>> In file included from src/libavutil/intmath.h:30:0,
>>  from src/libavutil/common.h:106,
>>  from src/libavutil/avutil.h:296,
>>  from src/libavutil/imgutils.h:30,
>>  from src/libavfilter/vf_amplify.c:21:
>> src/libavutil/arm/intmath.h: In function ‘amplify_frame’:
>> src/libavutil/arm/intmath.h:77:5: warning: asm operand 2 probably doesn’t 
>> match constraints [enabled by default]
>> src/libavutil/arm/intmath.h:77:5: error: impossible constraint in ‘asm’
>> make: *** [libavfilter/vf_amplify.o] Error 1
>> make: *** Waiting for unfinished jobs
>> src/libavfilter/src_movie.c: In function ‘open_stream’:
>> src/libavfilter/src_movie.c:175:5: warning: ‘refcounted_frames’ is 
>> deprecated (declared at src/libavcodec/avcodec.h:2345) 
>> [-Wdeprecated-declarations]
>> src/libavfilter/src_movie.c: In function ‘movie_push_frame’:
>> src/libavfilter/src_movie.c:529:9: warning: ‘avcodec_decode_video2’ is 
>> deprecated (declared at src/libavcodec/avcodec.h:4756) 
>> [-Wdeprecated-declarations]
>> src/libavfilter/src_movie.c:532:9: warning: ‘avcodec_decode_audio4’ is 
>> deprecated (declared at src/libavcodec/avcodec.h:4707) 
>> [-Wdeprecated-declarations]
>> src/libavfilter/vaf_spectrumsynth.c: In function ‘try_push_frame’:
>> src/libavfilter/vaf_spectrumsynth.c:429:12: warning: ‘end’ may be used 
>> uninitialized in this function [-Wuninitialized]
>> src/libavfilter/vaf_spectrumsynth.c:428:14: warning: ‘start’ may be used 
>> uninitialized in this function [-Wuninitialized]
>> src/libavfilter/vaf_spectrumsynth.c: In function ‘try_push_frames’:
>> src/libavfilter/vaf_spectrumsynth.c:437:9: warning: ‘ret’ may be used 
>> uninitialized in this function [-Wuninitialized]
>> 
>> arm-linux-gnueabi-gcc-4.6 (Debian 4.6.3-15) 4.6.3

master is now patched s.t. these should compile with HAVE_ARMV6_INLINE
set

Regards

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


[FFmpeg-devel] [PATCH] [RFC] avformat/movenc: support covert images for ipod muxer

2018-05-31 Thread Timo Teräs
Add avformat_query_codec() to special handle 'APIC' tag in
output format .codec_tag list in addition to .query_codec.

Advertise codecs for cover image with 'APIC' tag in ipod
muxer.

Signed-off-by: Timo Teräs 
---
This makes writing cover images to m4a files to work.

However, I was trying to understand how the APIC tag works. It seems
to affect mostly selection of the default input stream for given
output stream in ffmpeg_opt.c:open_output_file().

The whole APIC tag concept was implemented in mp3 muxer originally.
And there it seems to make sense since images can be as attachments
only.

However, mp4 allows video both as a main stream or as an attachment
(to be displayed as cover image), it might make more sense to check
codecs against different list when AV_DISPOSITION_ATTACHED_PIC is set.

So I am wondering if it's more sensible (instead of this patch) to
add a new avformat_query_codec2() helper that gets the stream
disposition (or perhaps modify avformat_query_codec() since it's
used exactly once in ffmpeg_opt.c; though this would be ABI change).
Additionally do one or more of the following:
- update AVOutputFormat.query_codec() to receive the stream disposition too
- add AVOutputFormat.codec_tag to have special values to indicate
  that the list applies to specific stream dispostion only

Perhaps after the above changes ffmpeg_opt.c:open_output_file() can
be updated to have logic that does not depend on APIC special tag,
but instead uses only the disposition flags of input and output streams.
This would allow to remove the APIC "kludge" tag.

Thoughts?

 libavformat/movenc.c |  9 -
 libavformat/utils.c  | 10 +++---
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 7e616e866f..0e6706555c 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6769,6 +6769,13 @@ static const AVCodecTag codec_f4v_tags[] = {
 { AV_CODEC_ID_NONE, 0 },
 };
 
+static const AVCodecTag codec_cover_image_tags[] = {
+{ AV_CODEC_ID_MJPEG,  MKTAG('A','P','I','C') },
+{ AV_CODEC_ID_PNG,MKTAG('A','P','I','C') },
+{ AV_CODEC_ID_BMP,MKTAG('A','P','I','C') },
+{ AV_CODEC_ID_NONE, 0 },
+};
+
 #if CONFIG_MOV_MUXER
 MOV_CLASS(mov)
 AVOutputFormat ff_mov_muxer = {
@@ -6891,7 +6898,7 @@ AVOutputFormat ff_ipod_muxer = {
 .write_trailer = mov_write_trailer,
 .deinit= mov_free,
 .flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | 
AVFMT_TS_NEGATIVE,
-.codec_tag = (const AVCodecTag* const []){ codec_ipod_tags, 0 },
+.codec_tag = (const AVCodecTag* const []){ codec_ipod_tags, 
codec_cover_image_tags, 0 },
 .check_bitstream   = mov_check_bitstream,
 .priv_class= _muxer_class,
 };
diff --git a/libavformat/utils.c b/libavformat/utils.c
index c9cdd2b470..ffa6eb2a8a 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4946,9 +4946,13 @@ int avformat_query_codec(const AVOutputFormat *ofmt, 
enum AVCodecID codec_id,
 unsigned int codec_tag;
 if (ofmt->query_codec)
 return ofmt->query_codec(codec_id, std_compliance);
-else if (ofmt->codec_tag)
-return !!av_codec_get_tag2(ofmt->codec_tag, codec_id, _tag);
-else if (codec_id == ofmt->video_codec ||
+else if (ofmt->codec_tag) {
+if (!av_codec_get_tag2(ofmt->codec_tag, codec_id, _tag))
+  return 0;
+if (codec_tag == MKTAG('A','P','I','C'))
+  return codec_tag;
+return 1;
+} else if (codec_id == ofmt->video_codec ||
  codec_id == ofmt->audio_codec ||
  codec_id == ofmt->subtitle_codec ||
  codec_id == ofmt->data_codec)
-- 
2.17.0

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


Re: [FFmpeg-devel] [PATCH] use av_clip_uintp2_c where clip is variable

2018-05-31 Thread Paul B Mahol
On 5/31/18, John Cox  wrote:
> Hi
>
> I enclose a patch that changes av_clip_uintp2 to av_clip_uintp2_c where
> the bit depth is variable.  This fixes compilation issues if
> HAVE_ARMV6_INLINE is 1 and therefore allows arm inline detection to be
> fixed too.
>
> Regards
>
> John Cox
>

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


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: reimplement randomize of hls use av_get_random_seed

2018-05-31 Thread James Almer
On 5/31/2018 1:41 AM, Steven Liu wrote:
> for support use the mbedtls
> 
> Signed-off-by: Steven Liu 
> ---
>  libavformat/hlsenc.c | 22 +++---
>  1 file changed, 7 insertions(+), 15 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 9c06551ea6..17b464f540 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -569,18 +569,13 @@ fail:
>  return ret;
>  }
>  > -static int randomize(uint8_t *buf, int len)
> +
> +static void randomize(uint8_t *buf, int len)
>  {
> -#if CONFIG_GCRYPT
> -gcry_randomize(buf, len, GCRY_VERY_STRONG_RANDOM);
> -return 0;
> -#elif CONFIG_OPENSSL
> -if (RAND_bytes(buf, len))
> -return 0;
> -#else
> -return AVERROR(ENOSYS);
> -#endif
> -return AVERROR(EINVAL);

You should also remove the header includes and the relevant configure
dependencies for openssl and gcrypt if you're removing these chunks.

> +uint32_t tmp_number[2];
> +tmp_number[0] = av_get_random_seed();
> +tmp_number[1] = av_get_random_seed();
> +memcpy(buf, iv, len);

/home/jamrial/ffmpeg/libavformat/hlsenc.c:577:17: error: 'iv' undeclared
(first use in this function); did you mean 'div'?
 memcpy(buf, iv, len);
 ^~
 div
/home/jamrial/ffmpeg/libavformat/hlsenc.c:577:17: note: each undeclared
identifier is reported only once for each function it appears in
/home/jamrial/ffmpeg/libavformat/hlsenc.c:574:14: warning: variable
'tmp_number' set but not used [-Wunused-but-set-variable]
 uint32_t tmp_number[2];
  ^~
make: *** [/home/jamrial/ffmpeg/ffbuild/common.mak:60:
libavformat/hlsenc.o] Error 1

>  }
>  
>  static int do_encrypt(AVFormatContext *s, VariantStream *vs)
> @@ -633,10 +628,7 @@ static int do_encrypt(AVFormatContext *s, VariantStream 
> *vs)
>  
>  if (!*hls->key_string) {
>  if (!hls->key) {
> -if ((ret = randomize(key, sizeof(key))) < 0) {
> -av_log(s, AV_LOG_ERROR, "Cannot generate a strong random 
> key\n");
> -return ret;
> -}
> +randomize(key, sizeof(key));

sizeof(key) is 16, yet you're filling only eight bytes of random data
using av_get_random_seed().

>  } else {
>  memcpy(key, hls->key, sizeof(key));
>  }
> 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] use av_clip_uintp2_c where clip is variable

2018-05-31 Thread John Cox
Hi

I enclose a patch that changes av_clip_uintp2 to av_clip_uintp2_c where
the bit depth is variable.  This fixes compilation issues if
HAVE_ARMV6_INLINE is 1 and therefore allows arm inline detection to be
fixed too.

Regards

John Cox


variable_clip.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [GSOC][PATCH] lavc/cfhd:IP frame decoding (inverse 3d transform) introduced

2018-05-31 Thread Gagandeep Singh
---
 libavcodec/cfhd.c | 462 ++
 libavcodec/cfhd.h |  15 +-
 2 files changed, 411 insertions(+), 66 deletions(-)

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index 051d210355..c0cd25a95e 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -41,12 +41,15 @@
 #define ALPHA_COMPAND_GAIN 9400
 
 enum CFHDParam {
+TransformType=  10,
 ChannelCount =  12,
 SubbandCount =  14,
+Pframe   =  19,
 ImageWidth   =  20,
 ImageHeight  =  21,
 LowpassPrecision =  35,
 SubbandNumber=  48,
+EncodingMethod   =  52,
 Quantization =  53,
 ChannelNumber=  62,
 SampleFlags  =  68,
@@ -84,6 +87,11 @@ static void init_peak_table_defaults(CFHDContext *s)
 
 static void init_frame_defaults(CFHDContext *s)
 {
+s->sample_type   = 0;
+s->transform_type= 0;
+s->num_frames= 0;
+s->Pframe= 0;
+s->first_wavelet = 0;
 s->coded_width   = 0;
 s->coded_height  = 0;
 s->cropped_height= 0;
@@ -103,8 +111,10 @@ static void init_frame_defaults(CFHDContext *s)
 }
 
 /* TODO: merge with VLC tables or use LUT */
-static inline int dequant_and_decompand(int level, int quantisation, int 
codebook)
+static inline int dequant_and_decompand(int level, int quantisation, int 
codebook, int lossless)
 {
+if (lossless)
+return level;
 if (codebook == 0 || codebook == 1) {
 int64_t abslevel = abs(level);
 if (level < 264)
@@ -193,16 +203,21 @@ static inline void filter(int16_t *output, ptrdiff_t 
out_stride,
 }
 }
 
-static inline void interlaced_vertical_filter(int16_t *output, int16_t *low, 
int16_t *high,
- int width, int linesize, int plane)
+static inline void temporal_inverse_filter(int16_t *output, int16_t *low, 
int16_t *high,
+ int width, int linesize, int temporal_for_highpass)
 {
 int i;
 int16_t even, odd;
 for (i = 0; i < width; i++) {
 even = (low[i] - high[i])/2;
 odd  = (low[i] + high[i])/2;
-output[i]= av_clip_uintp2(even, 10);
-output[i + linesize] = av_clip_uintp2(odd, 10);
+if (!temporal_for_highpass) {
+output[i]= av_clip_uintp2(even, 10);
+output[i + linesize] = av_clip_uintp2(odd, 10);
+} else {
+low[i]  = even;
+high[i] = odd;
+}
 }
 }
 static void horiz_filter(int16_t *output, int16_t *low, int16_t *high,
@@ -261,6 +276,7 @@ static int alloc_buffers(AVCodecContext *avctx)
 
 for (i = 0; i < planes; i++) {
 int w8, h8, w4, h4, w2, h2;
+int16_t *frame2;
 int width  = i ? avctx->width  >> chroma_x_shift : avctx->width;
 int height = i ? avctx->height >> chroma_y_shift : avctx->height;
 ptrdiff_t stride = FFALIGN(width  / 8, 8) * 8;
@@ -277,28 +293,85 @@ static int alloc_buffers(AVCodecContext *avctx)
 w2 = w4 * 2;
 h2 = h4 * 2;
 
-s->plane[i].idwt_buf =
-av_mallocz_array(height * stride, sizeof(*s->plane[i].idwt_buf));
-s->plane[i].idwt_tmp =
-av_malloc_array(height * stride, sizeof(*s->plane[i].idwt_tmp));
-if (!s->plane[i].idwt_buf || !s->plane[i].idwt_tmp)
-return AVERROR(ENOMEM);
-
-s->plane[i].subband[0] = s->plane[i].idwt_buf;
-s->plane[i].subband[1] = s->plane[i].idwt_buf + 2 * w8 * h8;
-s->plane[i].subband[2] = s->plane[i].idwt_buf + 1 * w8 * h8;
-s->plane[i].subband[3] = s->plane[i].idwt_buf + 3 * w8 * h8;
-s->plane[i].subband[4] = s->plane[i].idwt_buf + 2 * w4 * h4;
-s->plane[i].subband[5] = s->plane[i].idwt_buf + 1 * w4 * h4;
-s->plane[i].subband[6] = s->plane[i].idwt_buf + 3 * w4 * h4;
-s->plane[i].subband[7] = s->plane[i].idwt_buf + 2 * w2 * h2;
-s->plane[i].subband[8] = s->plane[i].idwt_buf + 1 * w2 * h2;
-s->plane[i].subband[9] = s->plane[i].idwt_buf + 3 * w2 * h2;
-
-for (j = 0; j < DWT_LEVELS; j++) {
-for (k = 0; k < FF_ARRAY_ELEMS(s->plane[i].band[j]); k++) {
-s->plane[i].band[j][k].a_width  = w8 << j;
-s->plane[i].band[j][k].a_height = h8 << j;
+if (s->transform_type == 0) {
+s->plane[i].idwt_buf =
+av_mallocz_array(height * stride, 
sizeof(*s->plane[i].idwt_buf));
+s->plane[i].idwt_tmp =
+av_malloc_array(height * stride, 
sizeof(*s->plane[i].idwt_tmp));
+if (!s->plane[i].idwt_buf || !s->plane[i].idwt_tmp)
+return AVERROR(ENOMEM);
+} else if (s->transform_type == 2) {
+s->plane[i].idwt_buf =
+av_mallocz_array(2 * height * stride, 
sizeof(*s->plane[i].idwt_buf));
+s->plane[i].idwt_tmp =
+av_malloc_array(height * stride, 
sizeof(*s->plane[i].idwt_tmp));
+if 

Re: [FFmpeg-devel] qt-faststart bug near 4GB

2018-05-31 Thread Eran Kornblau
> 
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Eran 
> Kornblau
> Sent: Friday, May 25, 2018 4:40 PM
> To: FFmpeg development discussions and patches 
> Subject: [FFmpeg-devel] qt-faststart bug near 4GB
> 
> Hi all,
> 
> We encountered a rather extreme edge case with qt-faststart - we transcoded 
> some video with ffmpeg, and the offset of the last video frame in the 
> resulting mp4 was slightly less than 4GB.
> Since it was less than 4GB, ffmpeg used an 'stco' atom and not a 'co64' atom.
> When we ran qt-faststart on this file, it added the moov atom size to all 
> offsets in the 'stco' atom, causing an overflow in the offsets of the frames 
> close to the end of the file. The end of the video was therefore corrupt and 
> could not be played.
> I think the solution here is to 'upgrade' the 'stco' atom to 'co64' if such 
> an edge case happens. However, looking at the code of qt-faststart, I see 
> that it doesn't actually parse the atom tree, but rather looks for the 
> strings 'stco' / 'co64'. Changing 'stco' to 'co64' requires updating the size 
> of all the atom in which it's contained (moov, trak, mdia etc.) Therefore, 
> such a change would probably be more of a rewrite of this utility than a 
> patch, so wanted to check whether anyone has any thoughts on this before I 
> start writing...
> 
Attaching the patch for this issue.
As expected, it required significant changes... hope you will like it :)

Thanks!

Eran 


0001-qt-faststart-stco-offset-bug-fix.patch
Description: 0001-qt-faststart-stco-offset-bug-fix.patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] qt-faststart - optimize the offset change loop

2018-05-31 Thread Eran Kornblau
> On Wed, May 30, 2018 at 05:39:50AM +, Eran Kornblau wrote:
> > > 
> > > 
> > > -Original Message-
> > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On 
> > > Behalf Of Michael Niedermayer
> > > Sent: Wednesday, May 30, 2018 12:37 AM
> > > To: FFmpeg development discussions and patches 
> > > 
> > > Subject: Re: [FFmpeg-devel] [PATCH 2/2] qt-faststart - optimize the 
> > > offset change loop
> > > 
> > > > +*ptr++ = (current_offset >> 56) & 0xFF;
> > > > +*ptr++ = (current_offset >> 48) & 0xFF;
> > > > +*ptr++ = (current_offset >> 40) & 0xFF;
> > > > +*ptr++ = (current_offset >> 32) & 0xFF;
> > > > +*ptr++ = (current_offset >> 24) & 0xFF;
> > > > +*ptr++ = (current_offset >> 16) & 0xFF;
> > > > +*ptr++ = (current_offset >>  8) & 0xFF;
> > > > +*ptr++ = (current_offset >>  0) & 0xFF;
> > > 
> > > can this be simplfified with
> > > libavcodec/bytestream.h, libavutil/intreadwrite.h or similar ?
> > > 
> > > [...]
> > > 
> > 
> > Yes, I can change it to AV_WB32/AV_WB64, but at the moment this 
> > utility is completely stand-alone - it does not depend on anything from 
> > ffmpeg, so maybe it's better to keep it this way.
> 
> well, i surely wont insist but these should not add dependancies just use 
> inline functions and macros from headers I think it does no harm to use these 
> as it doesnt add a depency at link
> 
Right, but it does add a dependency on configure, since intreadwrite.h includes 
libavutil/avconfig.h.
I don't think it's too important, but currently I can pull only qt-faststart.c 
and run: gcc qt-faststart.c -o qt-faststart, which can be convenient.
Anyway, let's table this patch, as I've just completed the larger patch for the 
issue I originally encountered (stco offset overflow).
In the larger patch I locally defined AV_WB32/64, as I had to do this in 
multiple places.

Thanks

Eran

> 
> [...]
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> Awnsering whenever a program halts or runs forever is On a turing machine, in 
> general impossible (turings halting problem).
> On any real computer, always possible as a real computer has a finite number 
> of states N, and will either halt in less than N cycles or never halt.
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Limited timecode support for lavd/decklink

2018-05-31 Thread Jonathan Morley
Please take a look at my latest patches.

NOTE: I no longer have the hardware to test this work!

On Wed, May 30, 2018 at 11:04 AM, Marton Balint  wrote:

>
>
> On Tue, 29 May 2018, Jonathan Morley wrote:
>
> Thank you Marton, That makes sense to me, but can you please clarify which
>> context is the most appropriate to use?
>>
>
> Just put it in decklink_ctx in the Status section.
>
> Don't forget to free it in ff_decklink_read_close.
>
>
> Regards,
> Marton
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


0001-lavd-decklink_common-Move-DECKLINK_-string-functions.patch
Description: Binary data


0002-lavd-decklink-Capture-first-valid-timecode-to-metada.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavfilter/boxblur_opencl filter.

2018-05-31 Thread Song, Ruiling


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Danil Iashchenko
> Sent: Tuesday, May 29, 2018 4:44 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Danil Iashchenko 
> Subject: [FFmpeg-devel] [PATCH] libavfilter/boxblur_opencl filter.
> 
> Add opencl version of boxblur filter.
> Behaves like existing libavfilter/boxblur filter.
> 
> Resubmitting patch because I used unnecessary variable inside kernels. Now
> it's fixed.
> 
> ---
>  configure   |   1 +
>  libavfilter/Makefile|   2 +
>  libavfilter/allfilters.c|   1 +
>  libavfilter/opencl/boxblur.cl   |  53 +
>  libavfilter/opencl_source.h |   1 +
>  libavfilter/vf_boxblur_opencl.c | 468
> 
>  6 files changed, 526 insertions(+)
>  create mode 100644 libavfilter/opencl/boxblur.cl
>  create mode 100644 libavfilter/vf_boxblur_opencl.c
> 
> diff --git a/configure b/configure
> index e52f8f8..f8a2487 100755
> --- a/configure
> +++ b/configure
> @@ -3302,6 +3302,7 @@ avgblur_opencl_filter_deps="opencl"
>  azmq_filter_deps="libzmq"
>  blackframe_filter_deps="gpl"
>  boxblur_filter_deps="gpl"
> +boxblur_opencl_filter_deps="opencl"
>  bs2b_filter_deps="libbs2b"
>  colormatrix_filter_deps="gpl"
>  convolution_opencl_filter_deps="opencl"
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index c68ef05..97afdef 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -153,6 +153,8 @@ OBJS-$(CONFIG_BLACKDETECT_FILTER)+=
> vf_blackdetect.o
>  OBJS-$(CONFIG_BLACKFRAME_FILTER) += vf_blackframe.o
>  OBJS-$(CONFIG_BLEND_FILTER)  += vf_blend.o framesync.o
>  OBJS-$(CONFIG_BOXBLUR_FILTER)+= vf_boxblur.o
> +OBJS-$(CONFIG_BOXBLUR_OPENCL_FILTER) += vf_boxblur_opencl.o
> opencl.o \
> + opencl/boxblur.o
>  OBJS-$(CONFIG_BWDIF_FILTER)  += vf_bwdif.o
>  OBJS-$(CONFIG_CHROMAKEY_FILTER)  += vf_chromakey.o
>  OBJS-$(CONFIG_CIESCOPE_FILTER)   += vf_ciescope.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index b44093d..97d92a0 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -146,6 +146,7 @@ extern AVFilter ff_vf_blackdetect;
>  extern AVFilter ff_vf_blackframe;
>  extern AVFilter ff_vf_blend;
>  extern AVFilter ff_vf_boxblur;
> +extern AVFilter ff_vf_boxblur_opencl;
>  extern AVFilter ff_vf_bwdif;
>  extern AVFilter ff_vf_chromakey;
>  extern AVFilter ff_vf_ciescope;
> diff --git a/libavfilter/opencl/boxblur.cl b/libavfilter/opencl/boxblur.cl
> new file mode 100644
> index 000..9ecb441
> --- /dev/null
> +++ b/libavfilter/opencl/boxblur.cl
> @@ -0,0 +1,53 @@
> +/*
> + * Copyright (c) 2018 Danil Iashchenko
> + *
> + * 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
> + */
> +
> +__kernel void boxblur_horiz(__write_only image2d_t dst,
> +__read_only  image2d_t src,
> +int rad)
> +{
> +const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
> +   CLK_ADDRESS_CLAMP_TO_EDGE   |
> +   CLK_FILTER_NEAREST);
> +
> +int2   loc = (int2)(get_global_id(0), get_global_id(1));
> +float4 acc = (float4)(0,0,0,0);
> +
> +for (int w = loc.x - rad; w < loc.x + rad + 1; w++) {
> +acc += read_imagef(src, sampler, (int2)(w, loc.y));
> +}
> +write_imagef(dst, loc, acc / (rad * 2 + 1));
> +}
> +
> +__kernel void boxblur_vertic(__write_only image2d_t dst,
> + __read_only  image2d_t src,
> + int radv)
> +{
> +const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
> +   CLK_ADDRESS_CLAMP_TO_EDGE   |
> +   CLK_FILTER_NEAREST);
> +
> +int2   loc = (int2)(get_global_id(0), get_global_id(1));
> +float4 acc = (float4)(0,0,0,0);
> +
> +for (int h = loc.y - radv; h < loc.y + radv + 1; h++) {
> +acc += read_imagef(src, sampler, (int2)(loc.x, h));
> +}
> +write_imagef(dst, loc, acc / (radv * 2 + 1));
> +}
> diff --git 

[FFmpeg-devel] FFmpeg developer hire

2018-05-31 Thread Andy Eastbury | Projection Artworks
Hi

Have followed the link from the consulting page as we need to hire someone!

We need a little help with the final bits of code so we can finalise our 
software build.

We are looking for someone with C++ and FFmpeg experience to assist.
We have the basic player built but need some assistance to complete and have it 
functioning correctly.
Media Player Specification

We require an FFMPEG based media player to load the video, play the video at 
the correct frame rate and play audio at the correct sample rate. The video 
just needs to play it's full length and continuously loop. At the moment we 
have a basic MediaPlayer class that could be modified or replaced. This places 
the video as a texture for a mesh, the functionality here is already built 
however any recommendations on improvements or optimizations would be 
appreciated.
We'd also like a method of keeping multiple players on the network as closely 
in sync as possible. We're aware there may be hardware limitations for exact 
frame syncing (we'll be running the app on a small windows player and will not 
have gen-lock).
The specification for the synchronization would be to send a multicast message 
out to other players on the network which would then reply. One player will be 
specified as the server and the others as clients. The server will then stream 
the current frame number over the local network and the clients would be 
expected to keep as close to this frame as possible.

Can you let me know your availability and rates

Thanks

Andy


Andy Eastbury
Retail Projects Manager

D: +44 (0) 203 829 9900
T: +44 (0) 203 130 0740
E: andy.eastb...@projectionartworks.com
W: www.projectionartworks.com
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [RFC] libfdk_aac license

2018-05-31 Thread Mark Harris
>> "The Fraunhofer AAC library is licensed under a license incompatible to

s/to/with/

>>   the GPL. Therefore, for GPL builds, you have to pass
>>   @code{--enable-nonfree} to configure to use it. To the best of our
>>   knowledge, it is compatible with the LGPL" ?

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