Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix memleak in hlsenc

2017-01-05 Thread Steven Liu
2017-01-05 15:47 GMT+08:00 Bodecs Bela :

>
>
> 2017.01.05. 1:20 keltezéssel, Steven Liu írta:
>
>> fix CID: 1398364 Resource leak
>> refine the code of the new options
>>
>> Signed-off-by: Steven Liu 
>> ---
>>   libavformat/hlsenc.c | 21 +
>>   1 file changed, 13 insertions(+), 8 deletions(-)
>>
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index 808a797..feeb853 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -446,11 +446,18 @@ static int hls_append_segment(struct
>> AVFormatContext *s, HLSContext *hls, double
>>   if ((hls->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE |
>> HLS_SECOND_LEVEL_SEGMENT_DURATION)) &&
>>   strlen(hls->current_segment_final_filename_fmt)) {
>>   char * old_filename = av_strdup(hls->avf->filename);  // %%s
>> will be %s after strftime
>> +if (!old_filename) {
>> +av_free(en);
>> +return AVERROR(ENOMEM);
>> +}
>>   av_strlcpy(hls->avf->filename, 
>> hls->current_segment_final_filename_fmt,
>> sizeof(hls->avf->filename));
>> +char * filename = av_strdup(hls->avf->filename);  // %%s will
>> be %s after strftime
>> +if (!filename) {
>> +av_free(old_filename);
>> +av_free(en);
>> +return AVERROR(ENOMEM);
>> +}
>>   if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_SIZE) {
>> -char * filename = av_strdup(hls->avf->filename);  // %%s
>> will be %s after strftime
>> -if (!filename)
>> -return AVERROR(ENOMEM);
>>   if (replace_int_data_in_filename(hls->avf->filename,
>> sizeof(hls->avf->filename),
>>   filename, 's', pos + size) < 1) {
>>   av_log(hls, AV_LOG_ERROR,
>> @@ -459,14 +466,11 @@ static int hls_append_segment(struct
>> AVFormatContext *s, HLSContext *hls, double
>>  filename);
>>   av_free(filename);
>>   av_free(old_filename);
>> +av_free(en);
>>   return AVERROR(EINVAL);
>>   }
>> -av_free(filename);
>>   }
>>   if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_DURATION) {
>> -char * filename = av_strdup(hls->avf->filename);  // %%t
>> will be %t after strftime
>> -if (!filename)
>> -return AVERROR(ENOMEM);
>>   if (replace_int_data_in_filename(hls->avf->filename,
>> sizeof(hls->avf->filename),
>>   filename, 't',  (int64_t)round(100 * duration)) <
>> 1) {
>>   av_log(hls, AV_LOG_ERROR,
>> @@ -475,10 +479,11 @@ static int hls_append_segment(struct
>> AVFormatContext *s, HLSContext *hls, double
>>  filename);
>>   av_free(filename);
>>   av_free(old_filename);
>> +av_free(en);
>>   return AVERROR(EINVAL);
>>   }
>> -av_free(filename);
>>   }
>> +av_free(filename);
>>   ff_rename(old_filename, hls->avf->filename, hls);
>>   av_free(old_filename);
>>   }
>>
> if you remove av_strdup after if branch,  this way if
>
> HLS_SECOND_LEVEL_SEGMENT_SIZE and HLS_SECOND_LEVEL_SEGMENT_DURATION also
> set, only later one will applied because filename will be the original one
> in second if branch.
>
> bb
>
>
> new patch update.

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


0001-avformat-hlsenc-fix-memleak-in-hlsenc.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix memleak in hlsenc

2017-01-05 Thread Bodecs Bela



2017.01.05. 9:43 keltezéssel, Steven Liu írta:

2017-01-05 15:47 GMT+08:00 Bodecs Bela :



2017.01.05. 1:20 keltezéssel, Steven Liu írta:


fix CID: 1398364 Resource leak
refine the code of the new options

Signed-off-by: Steven Liu 
---
   libavformat/hlsenc.c | 21 +
   1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 808a797..feeb853 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -446,11 +446,18 @@ static int hls_append_segment(struct
AVFormatContext *s, HLSContext *hls, double
   if ((hls->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE |
HLS_SECOND_LEVEL_SEGMENT_DURATION)) &&
   strlen(hls->current_segment_final_filename_fmt)) {
   char * old_filename = av_strdup(hls->avf->filename);  // %%s
will be %s after strftime
+if (!old_filename) {
+av_free(en);
+return AVERROR(ENOMEM);
+}
   av_strlcpy(hls->avf->filename, 
hls->current_segment_final_filename_fmt,
sizeof(hls->avf->filename));
+char * filename = av_strdup(hls->avf->filename);  // %%s will
be %s after strftime
+if (!filename) {
+av_free(old_filename);
+av_free(en);
+return AVERROR(ENOMEM);
+}
   if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_SIZE) {
-char * filename = av_strdup(hls->avf->filename);  // %%s
will be %s after strftime
-if (!filename)
-return AVERROR(ENOMEM);
   if (replace_int_data_in_filename(hls->avf->filename,
sizeof(hls->avf->filename),
   filename, 's', pos + size) < 1) {
   av_log(hls, AV_LOG_ERROR,
@@ -459,14 +466,11 @@ static int hls_append_segment(struct
AVFormatContext *s, HLSContext *hls, double
  filename);
   av_free(filename);
   av_free(old_filename);
+av_free(en);
   return AVERROR(EINVAL);
   }
-av_free(filename);
   }
   if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_DURATION) {
-char * filename = av_strdup(hls->avf->filename);  // %%t
will be %t after strftime
-if (!filename)
-return AVERROR(ENOMEM);
   if (replace_int_data_in_filename(hls->avf->filename,
sizeof(hls->avf->filename),
   filename, 't',  (int64_t)round(100 * duration)) <
1) {
   av_log(hls, AV_LOG_ERROR,
@@ -475,10 +479,11 @@ static int hls_append_segment(struct
AVFormatContext *s, HLSContext *hls, double
  filename);
   av_free(filename);
   av_free(old_filename);
+av_free(en);
   return AVERROR(EINVAL);
   }
-av_free(filename);
   }
+av_free(filename);
   ff_rename(old_filename, hls->avf->filename, hls);
   av_free(old_filename);
   }


if you remove av_strdup after if branch,  this way if

HLS_SECOND_LEVEL_SEGMENT_SIZE and HLS_SECOND_LEVEL_SEGMENT_DURATION also
set, only later one will applied because filename will be the original one
in second if branch.

bb


new patch update.

yes, it os ok now, thank you.

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



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


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


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix memleak in hlsenc

2017-01-05 Thread Steven Liu
2017-01-05 16:58 GMT+08:00 Bodecs Bela :

>
>
> 2017.01.05. 9:43 keltezéssel, Steven Liu írta:
>
>> 2017-01-05 15:47 GMT+08:00 Bodecs Bela :
>>
>>
>>> 2017.01.05. 1:20 keltezéssel, Steven Liu írta:
>>>
>>> fix CID: 1398364 Resource leak
 refine the code of the new options

 Signed-off-by: Steven Liu 
 ---
libavformat/hlsenc.c | 21 +
1 file changed, 13 insertions(+), 8 deletions(-)

 diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
 index 808a797..feeb853 100644
 --- a/libavformat/hlsenc.c
 +++ b/libavformat/hlsenc.c
 @@ -446,11 +446,18 @@ static int hls_append_segment(struct
 AVFormatContext *s, HLSContext *hls, double
if ((hls->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE |
 HLS_SECOND_LEVEL_SEGMENT_DURATION)) &&
strlen(hls->current_segment_final_filename_fmt)) {
char * old_filename = av_strdup(hls->avf->filename);  // %%s
 will be %s after strftime
 +if (!old_filename) {
 +av_free(en);
 +return AVERROR(ENOMEM);
 +}
av_strlcpy(hls->avf->filename,
 hls->current_segment_final_filename_fmt,
 sizeof(hls->avf->filename));
 +char * filename = av_strdup(hls->avf->filename);  // %%s will
 be %s after strftime
 +if (!filename) {
 +av_free(old_filename);
 +av_free(en);
 +return AVERROR(ENOMEM);
 +}
if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_SIZE) {
 -char * filename = av_strdup(hls->avf->filename);  // %%s
 will be %s after strftime
 -if (!filename)
 -return AVERROR(ENOMEM);
if (replace_int_data_in_filename(hls->avf->filename,
 sizeof(hls->avf->filename),
filename, 's', pos + size) < 1) {
av_log(hls, AV_LOG_ERROR,
 @@ -459,14 +466,11 @@ static int hls_append_segment(struct
 AVFormatContext *s, HLSContext *hls, double
   filename);
av_free(filename);
av_free(old_filename);
 +av_free(en);
return AVERROR(EINVAL);
}
 -av_free(filename);
}
if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_DURATION) {
 -char * filename = av_strdup(hls->avf->filename);  // %%t
 will be %t after strftime
 -if (!filename)
 -return AVERROR(ENOMEM);
if (replace_int_data_in_filename(hls->avf->filename,
 sizeof(hls->avf->filename),
filename, 't',  (int64_t)round(100 * duration)) <
 1) {
av_log(hls, AV_LOG_ERROR,
 @@ -475,10 +479,11 @@ static int hls_append_segment(struct
 AVFormatContext *s, HLSContext *hls, double
   filename);
av_free(filename);
av_free(old_filename);
 +av_free(en);
return AVERROR(EINVAL);
}
 -av_free(filename);
}
 +av_free(filename);
ff_rename(old_filename, hls->avf->filename, hls);
av_free(old_filename);
}

 if you remove av_strdup after if branch,  this way if
>>>
>>> HLS_SECOND_LEVEL_SEGMENT_SIZE and HLS_SECOND_LEVEL_SEGMENT_DURATION also
>>> set, only later one will applied because filename will be the original
>>> one
>>> in second if branch.
>>>
>>> bb
>>>
>>>
>>> new patch update.
>>>
>> yes, it os ok now, thank you.
>
> applied!


Thanks

>
>> ___
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel@ffmpeg.org
>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>>
>>>
>>> ___
>>> ffmpeg-devel mailing list
>>> ffmpeg-devel@ffmpeg.org
>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>>
>>
> ___
> ffmpeg-devel 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 17/17] lavfi/buffersink: move to the new design.

2017-01-05 Thread Nicolas George
Le nonidi 9 nivôse, an CCXXV, Nicolas George a écrit :
> Signed-off-by: Nicolas George 
> ---
>  libavfilter/buffersink.c | 214 
> +--
>  1 file changed, 56 insertions(+), 158 deletions(-)
> 
> 
> Minor changes to accomodate the previous changes. Since diff is not very
> smart about it, better read the code than the patch.

This patch and the previous one still lack a review.

For convenience, here is an excerpt of the file after the patch
containing the parts that are mostly rewritten and unreadable with diff.

Regards,

-- 
  Nicolas George
int attribute_align_arg av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame)
{
return av_buffersink_get_frame_flags(ctx, frame, 0);
}

static int return_or_keep_frame(BufferSinkContext *buf, AVFrame *out, AVFrame *in, int flags)
{
if ((flags & AV_BUFFERSINK_FLAG_PEEK)) {
buf->peeked_frame = in;
return out ? av_frame_ref(out, in) : 0;
} else {
av_assert1(out);
buf->peeked_frame = NULL;
av_frame_move_ref(out, in);
av_frame_free(&in);
return 0;
}
}

static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, int samples)
{
BufferSinkContext *buf = ctx->priv;
AVFilterLink *inlink = ctx->inputs[0];
int status, ret;
AVFrame *cur_frame;
int64_t pts;

if (buf->peeked_frame)
return return_or_keep_frame(buf, frame, buf->peeked_frame, flags);

while (1) {
ret = samples ? ff_inlink_consume_samples(inlink, samples, samples, &cur_frame) :
ff_inlink_consume_frame(inlink, &cur_frame);
if (ret < 0) {
return ret;
} else if (ret) {
/* TODO return the frame instead of copying it */
return return_or_keep_frame(buf, frame, cur_frame, flags);
} else if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
return status;
} else if ((flags & AV_BUFFERSINK_FLAG_NO_REQUEST)) {
return AVERROR(EAGAIN);
} else if (inlink->frame_wanted_out) {
ret = ff_filter_graph_run_once(ctx->graph);
if (ret < 0)
return ret;
} else {
ff_inlink_request_frame(inlink);
}
}
}

int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
{
return get_frame_internal(ctx, frame, flags, ctx->inputs[0]->min_samples);
}

int attribute_align_arg av_buffersink_get_samples(AVFilterContext *ctx,
  AVFrame *frame, int nb_samples)
{
return get_frame_internal(ctx, frame, 0, nb_samples);
}

/* snip av_a?buffersink_params_alloc() */

static av_cold int common_init(AVFilterContext *ctx)
{
BufferSinkContext *buf = ctx->priv;

buf->warning_limit = 100;
return 0;
}

static int activate(AVFilterContext *ctx)
{
BufferSinkContext *buf = ctx->priv;

if (buf->warning_limit &&
ff_framequeue_queued_frames(&ctx->inputs[0]->fifo) >= buf->warning_limit) {
av_log(ctx, AV_LOG_WARNING,
   "%d buffers queued in %s, something may be wrong.\n",
   buf->warning_limit,
   (char *)av_x_if_null(ctx->name, ctx->filter->name));
buf->warning_limit *= 10;
}

/* The frame is queued, the rest is up to get_frame_internal */
return 0;
}


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


Re: [FFmpeg-devel] [PATCH] nvenc: Make AUD optional for h264_nvenc and hevc_nvenc

2017-01-05 Thread Yogender Gupta
>> There is BUG in Nvidia NVENC when you use AUD for H264 with B-frames, it 
>> will return corrupted stream, because NVIDIA is inserting AUD type 0 
>> (I-frame) before B-frames instead of AUD type 7 (any-frame).

Thanks for bringing this to notice. We have added a fix in the Nvidia driver 
and the newer driver releases will insert the correct AUD type.

Thanks,
Yogender

---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avformat/hlsenc: typo in default localtime pattern

2017-01-05 Thread Bodecs Bela

Dear All,

in hlsenc.c at get_default_pattern_localtime_fmt function the default 
pattern contains

%Y%m%d%H%I%S but the original intention was %Y%m%d%H%M%S
Please apply this patch.


thank you,

Bela Bodecs


>From 9a11e116ad50bae635ce7c16821975b3d584ddc7 Mon Sep 17 00:00:00 2001
From: Bela Bodecs 
Date: Thu, 5 Jan 2017 11:19:33 +0100
Subject: [PATCH] avformat/hlsenc: typo in default localtime pattern

in get_default_pattern_localtime_fmt the default pattern contains
%Y%m%d%H%I%S but the original intention was %Y%m%d%H%M%S

Signed-off-by: Bela Bodecs 
---
 libavformat/hlsenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 808a797..ac744a5 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -944,7 +944,7 @@ static const char * get_default_pattern_localtime_fmt(void)
 struct tm *p, tmbuf;
 p = localtime_r(&t, &tmbuf);
 // no %s support when strftime returned error or left format string unchanged
-return (!strftime(b, sizeof(b), "%s", p) || !strcmp(b, "%s")) ? "-%Y%m%d%H%I%S.ts" : "-%s.ts";
+return (!strftime(b, sizeof(b), "%s", p) || !strcmp(b, "%s")) ? "-%Y%m%d%H%M%S.ts" : "-%s.ts";
 }
 
 static int hls_write_header(AVFormatContext *s)
-- 
2.5.3.windows.1

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


Re: [FFmpeg-devel] [PATCH 17/17] lavfi/buffersink: move to the new design.

2017-01-05 Thread Rostislav Pehlivanov
On 5 January 2017 at 10:27, Nicolas George  wrote:

> Le nonidi 9 nivôse, an CCXXV, Nicolas George a écrit :
> > Signed-off-by: Nicolas George 
> > ---
> >  libavfilter/buffersink.c | 214 +-
> -
> >  1 file changed, 56 insertions(+), 158 deletions(-)
> >
> >
> > Minor changes to accomodate the previous changes. Since diff is not very
> > smart about it, better read the code than the patch.
>
> This patch and the previous one still lack a review.
>
> For convenience, here is an excerpt of the file after the patch
> containing the parts that are mostly rewritten and unreadable with diff.
>
> Regards,
>
> --
>   Nicolas George
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
Thanks, the excerpt looks fine to me.

btw, there's apparently been a regression w.r.t. EOF handling which wm4
hasn't told you about yet, not sure which commit introduced it though:

https://github.com/mpv-player/mpv/commit/43386a7c92e14e56abdebfd4ed9335794c795f2b
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 5/5] lavfi: use an audio frame pool for each link of the filtergraph

2017-01-05 Thread Matthieu Bouron
---
 libavfilter/audio.c | 50 --
 1 file changed, 36 insertions(+), 14 deletions(-)

diff --git a/libavfilter/audio.c b/libavfilter/audio.c
index a18be89293..5996f607b2 100644
--- a/libavfilter/audio.c
+++ b/libavfilter/audio.c
@@ -27,6 +27,9 @@
 #include "avfilter.h"
 #include "internal.h"
 
+#define BUFFER_ALIGN 0
+
+
 AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
 {
 return ff_get_audio_buffer(link->dst->outputs[0], nb_samples);
@@ -34,29 +37,48 @@ AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int 
nb_samples)
 
 AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
 {
-AVFrame *frame = av_frame_alloc();
+AVFrame *frame = NULL;
 int channels = link->channels;
-int ret;
 
 av_assert0(channels == 
av_get_channel_layout_nb_channels(link->channel_layout) || 
!av_get_channel_layout_nb_channels(link->channel_layout));
 
+if (!link->frame_pool) {
+link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels,
+nb_samples, link->format, 
BUFFER_ALIGN);
+if (!link->frame_pool)
+return NULL;
+} else {
+int pool_channels = 0;
+int pool_nb_samples = 0;
+int pool_align = 0;
+enum AVSampleFormat pool_format = AV_SAMPLE_FMT_NONE;
+
+if (ff_frame_pool_get_audio_config(link->frame_pool,
+   &pool_channels, &pool_nb_samples,
+   &pool_format, &pool_align) < 0) {
+return NULL;
+}
+
+if (pool_channels != channels || pool_nb_samples < nb_samples ||
+pool_format != link->format || pool_align != BUFFER_ALIGN) {
+
+ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
+link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, 
channels,
+nb_samples, 
link->format, BUFFER_ALIGN);
+if (!link->frame_pool)
+return NULL;
+}
+}
+
+frame = ff_frame_pool_get(link->frame_pool);
 if (!frame)
 return NULL;
 
-frame->nb_samples = nb_samples;
-frame->format = link->format;
-av_frame_set_channels(frame, link->channels);
+frame->nb_samples = nb_samples;
 frame->channel_layout = link->channel_layout;
-frame->sample_rate= link->sample_rate;
-ret = av_frame_get_buffer(frame, 0);
-if (ret < 0) {
-av_frame_free(&frame);
-return NULL;
-}
-
-av_samples_set_silence(frame->extended_data, 0, nb_samples, channels,
-   link->format);
+frame->sample_rate = link->sample_rate;
 
+av_samples_set_silence(frame->extended_data, 0, nb_samples, channels, 
link->format);
 
 return frame;
 }
-- 
2.11.0

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


[FFmpeg-devel] Add audio support to lavfi/framepool

2017-01-05 Thread Matthieu Bouron
Patchset updated and rebased on master with the following minor changes:
  * add av_assert0 in ff_frame_pool_get_{audio,video}_config
  * FFFramePool.type declared as enum AVMediaType instead of int

I was not able to reproduce the issue Michael had with the following command 
line:
ffmpeg -f lavfi -i testsrc -vcodec libxvid -vframes 2  out.mov

The end goal of having lavfi/framepool support audio, despite the really minor
performance gain, is to provide a framepool API that could be shared between
lavc/utils.c and libavfilter with a few code interations over the FFFramePool
code.

Please comment,
Matthieu

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


[FFmpeg-devel] [PATCH 4/5] lavfi/framepool: cosmetic style fixes

2017-01-05 Thread Matthieu Bouron
---
 libavfilter/framepool.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
index 74235d4886..e1f1e2cc41 100644
--- a/libavfilter/framepool.c
+++ b/libavfilter/framepool.c
@@ -220,9 +220,8 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool)
 break;
 
 frame->buf[i] = av_buffer_pool_get(pool->pools[i]);
-if (!frame->buf[i]) {
+if (!frame->buf[i])
 goto fail;
-}
 
 frame->data[i] = frame->buf[i]->data;
 }
@@ -233,9 +232,8 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool)
 pool->format == AV_PIX_FMT_PAL8 ? AV_PIX_FMT_BGR8 : 
pool->format;
 
 av_assert0(frame->data[1] != NULL);
-if (avpriv_set_systematic_pal2((uint32_t *)frame->data[1], format) 
< 0) {
+if (avpriv_set_systematic_pal2((uint32_t *)frame->data[1], format) 
< 0)
 goto fail;
-}
 }
 
 frame->extended_data = frame->data;
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 2/5] lavfi/framepool: add audio support

2017-01-05 Thread Matthieu Bouron
---
 libavfilter/framepool.c | 109 
 libavfilter/framepool.h |  36 +++-
 2 files changed, 144 insertions(+), 1 deletion(-)

diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
index 36c6e8fd04..588dcb6da2 100644
--- a/libavfilter/framepool.c
+++ b/libavfilter/framepool.c
@@ -20,6 +20,7 @@
 
 #include "framepool.h"
 #include "libavutil/avassert.h"
+#include "libavutil/avutil.h"
 #include "libavutil/buffer.h"
 #include "libavutil/frame.h"
 #include "libavutil/imgutils.h"
@@ -28,8 +29,18 @@
 
 struct FFFramePool {
 
+enum AVMediaType type;
+
+/* video */
 int width;
 int height;
+
+/* audio */
+int planes;
+int channels;
+int nb_samples;
+
+/* common */
 int format;
 int align;
 int linesize[4];
@@ -54,6 +65,7 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* 
(*alloc)(int size),
 if (!pool)
 return NULL;
 
+pool->type = AVMEDIA_TYPE_VIDEO;
 pool->width = width;
 pool->height = height;
 pool->format = format;
@@ -104,6 +116,44 @@ fail:
 return NULL;
 }
 
+FFFramePool *ff_frame_pool_audio_init(AVBufferRef* (*alloc)(int size),
+  int channels,
+  int nb_samples,
+  enum AVSampleFormat format,
+  int align)
+{
+int ret, planar;
+FFFramePool *pool;
+
+pool = av_mallocz(sizeof(FFFramePool));
+if (!pool)
+return NULL;
+
+planar = av_sample_fmt_is_planar(format);
+
+pool->type = AVMEDIA_TYPE_AUDIO;
+pool->planes = planar ? channels : 1;
+pool->channels = channels;
+pool->nb_samples = nb_samples;
+pool->format = format;
+pool->align = align;
+
+ret = av_samples_get_buffer_size(&pool->linesize[0], channels,
+ nb_samples, format, 0);
+if (ret < 0)
+goto fail;
+
+pool->pools[0] = av_buffer_pool_init(pool->linesize[0], NULL);
+if (!pool->pools[0])
+goto fail;
+
+return pool;
+
+fail:
+ff_frame_pool_uninit(&pool);
+return NULL;
+}
+
 int ff_frame_pool_get_video_config(FFFramePool *pool,
int *width,
int *height,
@@ -113,6 +163,8 @@ int ff_frame_pool_get_video_config(FFFramePool *pool,
 if (!pool)
 return AVERROR(EINVAL);
 
+av_assert0(pool->type == AVMEDIA_TYPE_VIDEO);
+
 *width = pool->width;
 *height = pool->height;
 *format = pool->format;
@@ -121,6 +173,24 @@ int ff_frame_pool_get_video_config(FFFramePool *pool,
 return 0;
 }
 
+int ff_frame_pool_get_audio_config(FFFramePool *pool,
+   int *channels,
+   int *nb_samples,
+   enum AVSampleFormat *format,
+   int *align)
+{
+if (!pool)
+return AVERROR(EINVAL);
+
+av_assert0(pool->type == AVMEDIA_TYPE_AUDIO);
+
+*channels = pool->channels;
+*nb_samples = pool->nb_samples;
+*format = pool->format;
+*align = pool->align;
+
+return 0;
+}
 
 AVFrame *ff_frame_pool_get(FFFramePool *pool)
 {
@@ -133,6 +203,8 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool)
 return NULL;
 }
 
+switch(pool->type) {
+case AVMEDIA_TYPE_VIDEO:
 desc = av_pix_fmt_desc_get(pool->format);
 if (!desc) {
 goto fail;
@@ -167,6 +239,43 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool)
 }
 
 frame->extended_data = frame->data;
+break;
+case AVMEDIA_TYPE_AUDIO:
+frame->nb_samples = pool->nb_samples;
+av_frame_set_channels(frame, pool->channels);
+frame->format = pool->format;
+frame->linesize[0] = pool->linesize[0];
+
+if (pool->planes > AV_NUM_DATA_POINTERS) {
+frame->extended_data = av_mallocz_array(pool->planes,
+
sizeof(*frame->extended_data));
+frame->nb_extended_buf = pool->planes - AV_NUM_DATA_POINTERS;
+frame->extended_buf = av_mallocz_array(frame->nb_extended_buf,
+   
sizeof(*frame->extended_buf));
+if (!frame->extended_data || !frame->extended_buf)
+goto fail;
+} else {
+frame->extended_data = frame->data;
+av_assert0(frame->nb_extended_buf == 0);
+}
+
+for (i = 0; i < FFMIN(pool->planes, AV_NUM_DATA_POINTERS); i++) {
+frame->buf[i] = av_buffer_pool_get(pool->pools[0]);
+if (!frame->buf[i])
+goto fail;
+frame->extended_data[i] = frame->data[i] = frame->buf[i]->data;
+}
+for (i = 0; i < frame->nb_extended_buf; i++) {
+frame->extended_buf[i] = av_buffer_pool_get(pool->pools[0]);
+if (!frame->extended_buf[i])
+g

[FFmpeg-devel] [PATCH 3/5] lavfi/framepool: re-indent after previous commit

2017-01-05 Thread Matthieu Bouron
---
 libavfilter/framepool.c | 54 -
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
index 588dcb6da2..74235d4886 100644
--- a/libavfilter/framepool.c
+++ b/libavfilter/framepool.c
@@ -205,41 +205,41 @@ AVFrame *ff_frame_pool_get(FFFramePool *pool)
 
 switch(pool->type) {
 case AVMEDIA_TYPE_VIDEO:
-desc = av_pix_fmt_desc_get(pool->format);
-if (!desc) {
-goto fail;
-}
+desc = av_pix_fmt_desc_get(pool->format);
+if (!desc) {
+goto fail;
+}
 
-frame->width = pool->width;
-frame->height = pool->height;
-frame->format = pool->format;
+frame->width = pool->width;
+frame->height = pool->height;
+frame->format = pool->format;
 
-for (i = 0; i < 4; i++) {
-frame->linesize[i] = pool->linesize[i];
-if (!pool->pools[i])
-break;
+for (i = 0; i < 4; i++) {
+frame->linesize[i] = pool->linesize[i];
+if (!pool->pools[i])
+break;
 
-frame->buf[i] = av_buffer_pool_get(pool->pools[i]);
-if (!frame->buf[i]) {
-goto fail;
-}
+frame->buf[i] = av_buffer_pool_get(pool->pools[i]);
+if (!frame->buf[i]) {
+goto fail;
+}
 
-frame->data[i] = frame->buf[i]->data;
-}
+frame->data[i] = frame->buf[i]->data;
+}
 
-if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
-desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
-enum AVPixelFormat format =
-pool->format == AV_PIX_FMT_PAL8 ? AV_PIX_FMT_BGR8 : pool->format;
+if (desc->flags & AV_PIX_FMT_FLAG_PAL ||
+desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
+enum AVPixelFormat format =
+pool->format == AV_PIX_FMT_PAL8 ? AV_PIX_FMT_BGR8 : 
pool->format;
 
-av_assert0(frame->data[1] != NULL);
-if (avpriv_set_systematic_pal2((uint32_t *)frame->data[1], format) < 
0) {
-goto fail;
+av_assert0(frame->data[1] != NULL);
+if (avpriv_set_systematic_pal2((uint32_t *)frame->data[1], format) 
< 0) {
+goto fail;
+}
 }
-}
 
-frame->extended_data = frame->data;
-break;
+frame->extended_data = frame->data;
+break;
 case AVMEDIA_TYPE_AUDIO:
 frame->nb_samples = pool->nb_samples;
 av_frame_set_channels(frame, pool->channels);
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 1/5] lavfi/framepool: rename FFVideoFramePool to FFFramePool

2017-01-05 Thread Matthieu Bouron
---
 libavfilter/avfilter.c  |  2 +-
 libavfilter/avfilter.h  |  4 ++--
 libavfilter/framepool.c | 24 
 libavfilter/framepool.h | 32 
 libavfilter/video.c | 20 ++--
 5 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 0020ee163a..12f12d1406 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -179,7 +179,7 @@ void avfilter_link_free(AVFilterLink **link)
 
 av_frame_free(&(*link)->partial_buf);
 ff_framequeue_free(&(*link)->fifo);
-ff_video_frame_pool_uninit((FFVideoFramePool**)&(*link)->video_frame_pool);
+ff_frame_pool_uninit((FFFramePool**)&(*link)->frame_pool);
 
 av_freep(link);
 }
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 828b270b6c..02df8a3632 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -531,9 +531,9 @@ struct AVFilterLink {
 int64_t frame_count_in, frame_count_out;
 
 /**
- * A pointer to a FFVideoFramePool struct.
+ * A pointer to a FFFramePool struct.
  */
-void *video_frame_pool;
+void *frame_pool;
 
 /**
  * True if a frame is currently wanted on the output of this filter.
diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
index 6df574ea41..36c6e8fd04 100644
--- a/libavfilter/framepool.c
+++ b/libavfilter/framepool.c
@@ -26,7 +26,7 @@
 #include "libavutil/mem.h"
 #include "libavutil/pixfmt.h"
 
-struct FFVideoFramePool {
+struct FFFramePool {
 
 int width;
 int height;
@@ -37,20 +37,20 @@ struct FFVideoFramePool {
 
 };
 
-FFVideoFramePool *ff_video_frame_pool_init(AVBufferRef* (*alloc)(int size),
-   int width,
-   int height,
-   enum AVPixelFormat format,
-   int align)
+FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(int size),
+  int width,
+  int height,
+  enum AVPixelFormat format,
+  int align)
 {
 int i, ret;
-FFVideoFramePool *pool;
+FFFramePool *pool;
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format);
 
 if (!desc)
 return NULL;
 
-pool = av_mallocz(sizeof(FFVideoFramePool));
+pool = av_mallocz(sizeof(FFFramePool));
 if (!pool)
 return NULL;
 
@@ -100,11 +100,11 @@ FFVideoFramePool *ff_video_frame_pool_init(AVBufferRef* 
(*alloc)(int size),
 return pool;
 
 fail:
-ff_video_frame_pool_uninit(&pool);
+ff_frame_pool_uninit(&pool);
 return NULL;
 }
 
-int ff_video_frame_pool_get_config(FFVideoFramePool *pool,
+int ff_frame_pool_get_video_config(FFFramePool *pool,
int *width,
int *height,
enum AVPixelFormat *format,
@@ -122,7 +122,7 @@ int ff_video_frame_pool_get_config(FFVideoFramePool *pool,
 }
 
 
-AVFrame *ff_video_frame_pool_get(FFVideoFramePool *pool)
+AVFrame *ff_frame_pool_get(FFFramePool *pool)
 {
 int i;
 AVFrame *frame;
@@ -174,7 +174,7 @@ fail:
 return NULL;
 }
 
-void ff_video_frame_pool_uninit(FFVideoFramePool **pool)
+void ff_frame_pool_uninit(FFFramePool **pool)
 {
 int i;
 
diff --git a/libavfilter/framepool.h b/libavfilter/framepool.h
index 2a6c9e8636..4824824894 100644
--- a/libavfilter/framepool.h
+++ b/libavfilter/framepool.h
@@ -25,11 +25,11 @@
 #include "libavutil/frame.h"
 
 /**
- * Video frame pool. This structure is opaque and not meant to be accessed
- * directly. It is allocated with ff_video_frame_pool_init() and freed with
- * ff_video_frame_pool_uninit().
+ * Frame pool. This structure is opaque and not meant to be accessed
+ * directly. It is allocated with ff_frame_pool_init() and freed with
+ * ff_frame_pool_uninit().
  */
-typedef struct FFVideoFramePool FFVideoFramePool;
+typedef struct FFFramePool FFFramePool;
 
 /**
  * Allocate and initialize a video frame pool.
@@ -41,21 +41,21 @@ typedef struct FFVideoFramePool FFVideoFramePool;
  * @param height height of each frame in this pool
  * @param format format of each frame in this pool
  * @param align buffers alignement of each frame in this pool
- * @return newly created video frame pool on success, NULL on error.
+ * @return newly created frame pool on success, NULL on error.
  */
-FFVideoFramePool *ff_video_frame_pool_init(AVBufferRef* (*alloc)(int size),
-   int width,
-   int height,
-   enum AVPixelFormat format,
-   int align);
+FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(int size),
+  int width,
+  

Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: typo in default localtime pattern

2017-01-05 Thread Steven Liu
2017-01-05 18:39 GMT+08:00 Bodecs Bela :

> Dear All,
>
> in hlsenc.c at get_default_pattern_localtime_fmt function the default
> pattern contains
> %Y%m%d%H%I%S but the original intention was %Y%m%d%H%M%S
> Please apply this patch.
>
>
> thank you,
>
> Bela Bodecs
>
>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> Signed-off-by: Bela Bodecs 
---
 libavformat/hlsenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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


[FFmpeg-devel] [PATCH] doc/muxers/hlsenc: typo hls_flag: discont_starts => discont_start

2017-01-05 Thread Bodecs Bela

Dear All,

in doc/muxers/hlsenc, there is a  typo in hls_flags section: 
discont_starts instead of   discont_start



best regards,

Bela Bodecs

>From d6c3375508750886bc7edf82b5282c93e70a8e62 Mon Sep 17 00:00:00 2001
From: Bela Bodecs 
Date: Thu, 5 Jan 2017 13:21:13 +0100
Subject: [PATCH] doc/muxers/hlsenc: typo hls_flag: discont_starts =>
 discont_start

Signed-off-by: Bela Bodecs 
---
 doc/muxers.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index b4a107c..351cd8c 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -567,7 +567,7 @@ and remove the @code{#EXT-X-ENDLIST} from the old segment list.
 Round the duration info in the playlist file segment info to integer
 values, instead of using floating point.
 
-@item discont_starts
+@item discont_start
 Add the @code{#EXT-X-DISCONTINUITY} tag to the playlist, before the
 first segment's information.
 
-- 
2.5.3.windows.1

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


Re: [FFmpeg-devel] [PATCH] doc/muxers/hlsenc: typo hls_flag: discont_starts => discont_start

2017-01-05 Thread Steven Liu
2017-01-05 20:25 GMT+08:00 Bodecs Bela :

> Dear All,
>
> in doc/muxers/hlsenc, there is a  typo in hls_flags section:
> discont_starts instead of   discont_start
>
>
> best regards,
>
> Bela Bodecs
>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> looks ok,
but i'm not the doc maintainer :-)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/5] lavfi/framepool: rename FFVideoFramePool to FFFramePool

2017-01-05 Thread Michael Niedermayer
On Thu, Jan 05, 2017 at 12:11:32PM +0100, Matthieu Bouron wrote:
> ---
>  libavfilter/avfilter.c  |  2 +-
>  libavfilter/avfilter.h  |  4 ++--
>  libavfilter/framepool.c | 24 
>  libavfilter/framepool.h | 32 
>  libavfilter/video.c | 20 ++--
>  5 files changed, 41 insertions(+), 41 deletions(-)

LGTM

thx

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

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf


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


Re: [FFmpeg-devel] Add audio support to lavfi/framepool

2017-01-05 Thread Michael Niedermayer
On Thu, Jan 05, 2017 at 12:11:31PM +0100, Matthieu Bouron wrote:
> Patchset updated and rebased on master with the following minor changes:
>   * add av_assert0 in ff_frame_pool_get_{audio,video}_config
>   * FFFramePool.type declared as enum AVMediaType instead of int
> 
> I was not able to reproduce the issue Michael had with the following command 
> line:
> ffmpeg -f lavfi -i testsrc -vcodec libxvid -vframes 2  out.mov

cant reproduce it anymore with the new patchset, maybe it was something
unreated too ...

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

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable


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


Re: [FFmpeg-devel] [PATCH 4/5] lavfi/framepool: cosmetic style fixes

2017-01-05 Thread Michael Niedermayer
On Thu, Jan 05, 2017 at 12:11:35PM +0100, Matthieu Bouron wrote:
> ---
>  libavfilter/framepool.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)

LGTM

thx

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

Democracy is the form of government in which you can choose your dictator


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


Re: [FFmpeg-devel] [PATCH 3/5] lavfi/framepool: re-indent after previous commit

2017-01-05 Thread Michael Niedermayer
On Thu, Jan 05, 2017 at 12:11:34PM +0100, Matthieu Bouron wrote:
> ---
>  libavfilter/framepool.c | 54 
> -
>  1 file changed, 27 insertions(+), 27 deletions(-)

LGTM

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


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


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix Explicit null dereferenced in hlsenc

2017-01-05 Thread Michael Niedermayer
On Thu, Jan 05, 2017 at 08:28:56AM +0800, Steven Liu wrote:
> CID: 1398228
> Passing null pointer dirname to strlen, which dereferences it.
> 
> Signed-off-by: Steven Liu 
> ---
>  libavformat/hlsenc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 808a797..3c6490a 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -285,8 +285,8 @@ static int hls_delete_old_segments(HLSContext *hls) {
>   path, strerror(errno));
>  }
>  
> -if (segment->sub_filename[0] != '\0') {
> -sub_path_size = strlen(dirname) + strlen(segment->sub_filename) 
> + 1;
> +if ((segment->sub_filename[0] != '\0')) {

> +sub_path_size = (!dirname) ? (strlen(segment->sub_filename) + 1) 
> : (strlen(dirname) + strlen(segment->sub_filename) + 1);

simpler:
sub_path_size = strlen(segment->sub_filename) + 1 + (dirname ? strlen(dirname) 
: 0);


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.


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


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix Explicit null dereferenced

2017-01-05 Thread Michael Niedermayer
On Thu, Jan 05, 2017 at 08:40:56AM +0800, Steven Liu wrote:
> CID: 1323076
> Passing null pointer loc to avformat_new_stream, which dereferences it

>  fix: because the vtt_oc maybe have not value, so fix it.

hmm

i think:
this is wrong:
hls->vtt_oformat = av_guess_format("webvtt", NULL, NULL);
if (!hls->oformat) {
above checks the wrong value

then vtt_oformat should be non null


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

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway


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


Re: [FFmpeg-devel] [PATCH] avformat/test/fifo_muxer: add check for FailingMuxerPacketData alloc

2017-01-05 Thread Michael Niedermayer
On Thu, Jan 05, 2017 at 10:45:23AM +0800, Steven Liu wrote:
> CID: 1396257
> Signed-off-by: Steven Liu 
> ---
>  libavformat/tests/fifo_muxer.c | 3 +++
>  1 file changed, 3 insertions(+)

LGTM

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are best at talking, realize last or never when they are wrong.


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


[FFmpeg-devel] [PATCH 1/2] libavformat/avio: Add avio_get_dyn_buf function

2017-01-05 Thread Soft Works
This commit adds the avio_get_dyn_buf function which allows accessing the
content of a DynBuffer without destroying it.

This is required in matroskaenc for preliminary writing (correct) mkv headers.

Context for this change is fixing regression bug #5977.
---
 libavformat/avio.h| 12 
 libavformat/aviobuf.c | 17 +
 2 files changed, 29 insertions(+)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index b1ce1d1..f2b9a6f 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -704,6 +704,18 @@ int avio_closep(AVIOContext **s);
 int avio_open_dyn_buf(AVIOContext **s);
 
 /**
+ * Return the written size and a pointer to the buffer. 
+ * The AVIOContext stream is left intact.
+ * The buffer must NOT be freed. 
+ * No padding is added to the buffer.
+ *
+ * @param s IO context
+ * @param pbuffer pointer to a byte buffer
+ * @return the length of the byte buffer
+ */
+int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
+
+/**
  * Return the written size and a pointer to the buffer. The buffer
  * must be freed with av_free().
  * Padding of AV_INPUT_BUFFER_PADDING_SIZE is added to the buffer.
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 134d627..bf7e5f8 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -1277,6 +1277,23 @@ int ffio_open_dyn_packet_buf(AVIOContext **s, int 
max_packet_size)
 return url_open_dyn_buf_internal(s, max_packet_size);
 }
 
+int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
+{
+DynBuffer *d;
+
+if (!s) {
+*pbuffer = NULL;
+return 0;
+}
+
+avio_flush(s);
+
+d = s->opaque;
+*pbuffer = d->buffer;
+
+return d->size;
+}
+
 int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
 {
 DynBuffer *d;
-- 
2.10.2.windows.1

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


[FFmpeg-devel] [PATCH 2/2] avformat/matroskaenc: Regression fix for invalid MKV headers

2017-01-05 Thread Soft Works
The following three commits created a regression by writing initially
invalid mkv headers:

650e17d88b63b5aca6e0a43483e89e64b0f7d2dd avformat/matroskaenc: write a
CRC32 element on Tags
3bcadf822711720ff0f8d14db71ae47cdf97e652 avformat/matroskaenc: write a
CRC32 element on Info
ee888cfbe777cd2916a3548c750e433ab8f8e6a5 avformat/matroskaenc: postpone
writing the Tracks master

Symptoms:

- You can no longer playback a file that is still processed by ffmpeg,
e.g. VLC fails playback
- You can no longer stream a file to a client while if is still being
processed
- Various diagnosing tools show header errors or incomplete headers
(e.g. ffprobe, mediainfo, mkvalidator)

Note: The symptoms do not apply to completed files or ffmpeg runs that
were interrupted with 'q'

Cause:

The mentioned commits made changes in a way that some header elements
are only partially written in
mkv_write_header, leaving the header in an invalid state. Only in
mkv_write_trailer, these elements
are finished correctly, but that does only occur at the end of the
process.

Regression:

Before these commits were applied, mkv headers have always been valid,
even before completion of ffmpeg.
This has worked reliably over many versions of ffmpeg, to it was an
obvious regression.

Bugtracker:

This issue has been recorded as #5977 which is resolved by this patch

Patch:

The patch adds a new function 'end_ebml_master_crc32_preliminary' that
preliminarily finishes the ebl
element without destroying the buffer. The buffer can be used to update
the ebml element later during
mkv_write_trailer. But most important: mkv_write_header finishes with a
valid mkv header again.
---
 libavformat/matroskaenc.c | 28 +---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 827d755..27d83a6 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -367,6 +367,28 @@ static void end_ebml_master_crc32(AVIOContext *pb, 
AVIOContext **dyn_cp, Matrosk
 *dyn_cp = NULL;
 }
 
+/**
+* Complete ebml master whithout destroying the buffer, allowing for later 
updates
+*/
+static void end_ebml_master_crc32_preliminary(AVIOContext *pb, AVIOContext 
**dyn_cp, MatroskaMuxContext *mkv,
+ebml_master master)
+{
+uint8_t *buf, crc[4];
+int size, skip = 0;
+
+if (pb->seekable) {
+
+size = avio_get_dyn_buf(*dyn_cp, &buf);
+if (mkv->write_crc && mkv->mode != MODE_WEBM) {
+skip = 6; /* Skip reserved 6-byte long void element from the 
dynamic buffer. */
+AV_WL32(crc, av_crc(av_crc_get_table(AV_CRC_32_IEEE_LE), 
UINT32_MAX, buf + skip, size - skip) ^ UINT32_MAX);
+put_ebml_binary(pb, EBML_ID_CRC32, crc, sizeof(crc));
+}
+avio_write(pb, buf + skip, size - skip);
+end_ebml_master(pb, master);
+}
+}
+
 static void put_xiph_size(AVIOContext *pb, int size)
 {
 ffio_fill(pb, 255, size / 255);
@@ -1309,7 +1331,7 @@ static int mkv_write_tracks(AVFormatContext *s)
 }
 
 if (pb->seekable && !mkv->is_live)
-put_ebml_void(pb, avio_tell(mkv->tracks_bc));
+end_ebml_master_crc32_preliminary(pb, &mkv->tracks_bc, mkv, 
mkv->tracks_master);
 else
 end_ebml_master_crc32(pb, &mkv->tracks_bc, mkv, mkv->tracks_master);
 
@@ -1554,7 +1576,7 @@ static int mkv_write_tags(AVFormatContext *s)
 
 if (mkv->tags.pos) {
 if (s->pb->seekable && !mkv->is_live)
-put_ebml_void(s->pb, avio_tell(mkv->tags_bc));
+end_ebml_master_crc32_preliminary(s->pb, &mkv->tags_bc, mkv, 
mkv->tags);
 else
 end_ebml_master_crc32(s->pb, &mkv->tags_bc, mkv, mkv->tags);
 }
@@ -1811,7 +1833,7 @@ static int mkv_write_header(AVFormatContext *s)
 }
 }
 if (s->pb->seekable && !mkv->is_live)
-put_ebml_void(s->pb, avio_tell(pb));
+end_ebml_master_crc32_preliminary(s->pb, &mkv->info_bc, mkv, 
mkv->info);
 else
 end_ebml_master_crc32(s->pb, &mkv->info_bc, mkv, mkv->info);
 pb = s->pb;
-- 
2.10.2.windows.1




0003-avformat-matroskaenc-Regression-fix-for-invalid-MKV-.patch
Description: 0003-avformat-matroskaenc-Regression-fix-for-invalid-MKV-.patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avcodec: add QDMC decoder

2017-01-05 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 Changelog  |   1 +
 doc/general.texi   |   1 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/qdmc.c  | 817 +
 5 files changed, 821 insertions(+)
 create mode 100644 libavcodec/qdmc.c

diff --git a/Changelog b/Changelog
index aff9ab0..e09bf20 100644
--- a/Changelog
+++ b/Changelog
@@ -12,6 +12,7 @@ version :
 - 16.8 floating point pcm decoder
 - 24.0 floating point pcm decoder
 - Apple Pixlet decoder
+- QDMC audio decoder
 
 version 3.2:
 - libopenmpt demuxer
diff --git a/doc/general.texi b/doc/general.texi
index 084c0a1..a13a8fc 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1048,6 +1048,7 @@ following image formats are supported:
 @item PCM unsigned 32-bit little-endian  @tab  X  @tab  X
 @item PCM Zork   @tab @tab  X
 @item QCELP / PureVoice  @tab @tab  X
+@item QDesign Music Codec 1  @tab @tab  X
 @item QDesign Music Codec 2  @tab @tab  X
 @tab There are still some distortions.
 @item RealAudio 1.0 (14.4K)  @tab  X  @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 58feb31..44e416e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -466,6 +466,7 @@ OBJS-$(CONFIG_QCELP_DECODER)   += qcelpdec.o
 \
   celp_filters.o acelp_vectors.o \
   acelp_filters.o
 OBJS-$(CONFIG_QDM2_DECODER)+= qdm2.o
+OBJS-$(CONFIG_QDMC_DECODER)+= qdmc.o
 OBJS-$(CONFIG_QDRAW_DECODER)   += qdrw.o
 OBJS-$(CONFIG_QPEG_DECODER)+= qpeg.o
 OBJS-$(CONFIG_QTRLE_DECODER)   += qtrle.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 678f54a..4540ef7 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -449,6 +449,7 @@ void avcodec_register_all(void)
 REGISTER_DECODER(PAF_AUDIO, paf_audio);
 REGISTER_DECODER(QCELP, qcelp);
 REGISTER_DECODER(QDM2,  qdm2);
+REGISTER_DECODER(QDMC,  qdmc);
 REGISTER_ENCDEC (RA_144,ra_144);
 REGISTER_DECODER(RA_288,ra_288);
 REGISTER_DECODER(RALF,  ralf);
diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c
new file mode 100644
index 000..5559db3
--- /dev/null
+++ b/libavcodec/qdmc.c
@@ -0,0 +1,817 @@
+/*
+ * QDMC compatible decoder
+ * Copyright (c) 2017 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+#include 
+
+#define BITSTREAM_READER_LE
+
+#include "libavutil/channel_layout.h"
+
+#include "avcodec.h"
+#include "get_bits.h"
+#include "internal.h"
+#include "fft.h"
+
+typedef struct QDMCTone {
+uint8_t mode;
+uint8_t phase;
+uint8_t offset;
+int16_t freq;
+int16_t amplitude;
+} QDMCTone;
+
+typedef struct QDMCContext {
+AVCodecContext *avctx;
+
+uint8_t frame_bits;
+int band_index;
+int frame_size;
+int subframe_size;
+int fft_offset;
+int buffer_offset;
+float *buffer_ptr;
+int nb_channels;
+
+int group_size;
+int checksum_size;
+
+uint8_t noise[2][19][16];
+QDMCTone tones[5][8192];
+int nb_tones[5];
+int cur_tone[5];
+float alt_sin[5][31];
+float fft_buffer[4][8192 * 2];
+float noise2_buffer[4096 * 2];
+float noise_buffer[4096 * 2];
+int rndval;
+
+DECLARE_ALIGNED(32, FFTComplex, cmplx)[2][512];
+float buffer[2 * 32768];
+
+FFTContext fft_ctx;
+} QDMCContext;
+
+static float sin_table[512];
+static VLC vtable[6];
+
+static const unsigned code_prefix[] = {
+0x0, 0x1, 0x2, 0x3, 0x4, 0x6, 0x8, 0xA,
+0xC, 0x10, 0x14, 0x18, 0x1C, 0x24, 0x2C, 0x34,
+0x3C, 0x4C, 0x5C, 0x6C, 0x7C, 0x9C, 0xBC, 0xDC,
+0xFC, 0x13C, 0x17C, 0x1BC, 0x1FC, 0x27C, 0x2FC, 0x37C,
+0x3FC, 0x4FC, 0x5FC, 0x6FC, 0x7FC, 0x9FC, 0xBFC, 0xDFC,
+0xFFC, 0x13FC, 0x17FC, 0x1BFC, 0x1FFC, 0x27FC, 0x2FFC, 0x37FC,
+0x3FFC, 0x4FFC, 0x5FFC, 0x6FFC, 0x7FFC, 0x9FFC, 0xBFFC, 0xDFFC,
+0xFFFC, 0x13FFC, 0x17FFC, 0x1BFFC, 0x1FFFC, 0x27FFC, 0x2FFFC, 0x37FFC,
+0x3FFFC
+};
+
+static const float amplitude_tab[64] = {
+1.1875f, 1.68359380f, 2.3750f, 3.36718750f

Re: [FFmpeg-devel] [PATCH] avcodec: add QDMC decoder

2017-01-05 Thread James Almer
On 1/5/2017 3:34 PM, Paul B Mahol wrote:
> diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c
> new file mode 100644
> index 000..5559db3
> --- /dev/null
> +++ b/libavcodec/qdmc.c
> @@ -0,0 +1,817 @@
> +/*
> + * QDMC compatible decoder
> + * Copyright (c) 2017 Paul B Mahol
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include 
> +#include 
> +#include 
> +
> +#define BITSTREAM_READER_LE
> +
> +#include "libavutil/channel_layout.h"
> +
> +#include "avcodec.h"
> +#include "get_bits.h"
> +#include "internal.h"
> +#include "fft.h"
> +
> +typedef struct QDMCTone {
> +uint8_t mode;
> +uint8_t phase;
> +uint8_t offset;
> +int16_t freq;
> +int16_t amplitude;
> +} QDMCTone;
> +
> +typedef struct QDMCContext {
> +AVCodecContext *avctx;
> +
> +uint8_t frame_bits;
> +int band_index;
> +int frame_size;
> +int subframe_size;
> +int fft_offset;
> +int buffer_offset;
> +float *buffer_ptr;
> +int nb_channels;
> +
> +int group_size;
> +int checksum_size;
> +
> +uint8_t noise[2][19][16];
> +QDMCTone tones[5][8192];
> +int nb_tones[5];
> +int cur_tone[5];
> +float alt_sin[5][31];
> +float fft_buffer[4][8192 * 2];
> +float noise2_buffer[4096 * 2];
> +float noise_buffer[4096 * 2];
> +int rndval;
> +
> +DECLARE_ALIGNED(32, FFTComplex, cmplx)[2][512];
> +float buffer[2 * 32768];
> +
> +FFTContext fft_ctx;
> +} QDMCContext;
> +
> +static float sin_table[512];
> +static VLC vtable[6];

Why are these not part of QDMCContext?

[...]

> +
> +static av_cold int qdmc_init_static_data(QDMCContext *s)
> +{
> +static int done;
> +int i, ret;
> +
> +if (done)
> +return 0;
> +
> +ret = ff_init_vlc_sparse(&vtable[0], 12, 
> FF_ARRAY_ELEMS(noise_value_bits),
> + noise_value_bits, 1, 1, noise_value_codes, 2, 
> 2, noise_value_symbols, 1, 1, INIT_VLC_LE);
> +if (ret < 0)
> +return ret;
> +ret = ff_init_vlc_sparse(&vtable[1], 10, 
> FF_ARRAY_ELEMS(noise_segment_length_bits),
> + noise_segment_length_bits, 1, 1, 
> noise_segment_length_codes, 2, 2,
> + noise_segment_length_symbols, 1, 1, 
> INIT_VLC_LE);
> +if (ret < 0)
> +return ret;
> +ret = ff_init_vlc_sparse(&vtable[2], 13, FF_ARRAY_ELEMS(amplitude_bits),
> + amplitude_bits, 1, 1, amplitude_codes, 2, 2, 
> NULL, 0, 0, INIT_VLC_LE);
> +if (ret < 0)
> +return ret;
> +ret = ff_init_vlc_sparse(&vtable[3], 18, FF_ARRAY_ELEMS(freq_diff_bits),
> + freq_diff_bits, 1, 1, freq_diff_codes, 4, 4, 
> NULL, 0, 0, INIT_VLC_LE);
> +if (ret < 0)
> +return ret;
> +ret = ff_init_vlc_sparse(&vtable[4], 8, 
> FF_ARRAY_ELEMS(amplitude_diff_bits),
> + amplitude_diff_bits, 1, 1, 
> amplitude_diff_codes, 1, 1, NULL, 0, 0, INIT_VLC_LE);
> +if (ret < 0)
> +return ret;
> +ret = ff_init_vlc_sparse(&vtable[5], 6, FF_ARRAY_ELEMS(phase_diff_bits),
> + phase_diff_bits, 1, 1, phase_diff_codes, 1, 1, 
> NULL, 0, 0, INIT_VLC_LE);
> +if (ret < 0)
> +return ret;
> +
> +for (i = 0; i < 512; i++)
> +sin_table[i] = sin(2 * i * M_PI * 0.001953125);

These constants should be float.

> +
> +done = 1;
> +
> +return 0;
> +}

[...]

> +static av_cold int qdmc_decode_init(AVCodecContext *avctx)
> +{
> +QDMCContext *s = avctx->priv_data;
> +uint8_t *extradata;
> +int extradata_size, fft_size, fft_order, ret, size, g, j, x;
> +
> +if ((ret = qdmc_init_static_data(s)) < 0)
> +return ret;
> +
> +if (!avctx->extradata || (avctx->extradata_size < 48)) {
> +av_log(avctx, AV_LOG_ERROR, "extradata missing or truncated\n");
> +return AVERROR_INVALIDDATA;
> +}
> +
> +extradata  = avctx->extradata;
> +extradata_size = avctx->extradata_size;
> +
> +while (extradata_size > 8) {
> +if (!memcmp(extradata, "frmaQDMC", 8))
> +break;
> +extradata++;
> +extradata_size--;

Use bytestream.h instead. It will simplify this function a lot.

> +}
> +
> +if

Re: [FFmpeg-devel] [PATCH] avcodec: add QDMC decoder

2017-01-05 Thread Paul B Mahol
On 1/5/17, James Almer  wrote:
> On 1/5/2017 3:34 PM, Paul B Mahol wrote:
>> diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c
>> new file mode 100644
>> index 000..5559db3
>> --- /dev/null
>> +++ b/libavcodec/qdmc.c
>> @@ -0,0 +1,817 @@
>> +/*
>> + * QDMC compatible decoder
>> + * Copyright (c) 2017 Paul B Mahol
>> + *
>> + * This file is part of FFmpeg.
>> + *
>> + * FFmpeg is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU Lesser General Public
>> + * License as published by the Free Software Foundation; either
>> + * version 2.1 of the License, or (at your option) any later version.
>> + *
>> + * FFmpeg is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with FFmpeg; if not, write to the Free Software
>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
>> 02110-1301 USA
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define BITSTREAM_READER_LE
>> +
>> +#include "libavutil/channel_layout.h"
>> +
>> +#include "avcodec.h"
>> +#include "get_bits.h"
>> +#include "internal.h"
>> +#include "fft.h"
>> +
>> +typedef struct QDMCTone {
>> +uint8_t mode;
>> +uint8_t phase;
>> +uint8_t offset;
>> +int16_t freq;
>> +int16_t amplitude;
>> +} QDMCTone;
>> +
>> +typedef struct QDMCContext {
>> +AVCodecContext *avctx;
>> +
>> +uint8_t frame_bits;
>> +int band_index;
>> +int frame_size;
>> +int subframe_size;
>> +int fft_offset;
>> +int buffer_offset;
>> +float *buffer_ptr;
>> +int nb_channels;
>> +
>> +int group_size;
>> +int checksum_size;
>> +
>> +uint8_t noise[2][19][16];
>> +QDMCTone tones[5][8192];
>> +int nb_tones[5];
>> +int cur_tone[5];
>> +float alt_sin[5][31];
>> +float fft_buffer[4][8192 * 2];
>> +float noise2_buffer[4096 * 2];
>> +float noise_buffer[4096 * 2];
>> +int rndval;
>> +
>> +DECLARE_ALIGNED(32, FFTComplex, cmplx)[2][512];
>> +float buffer[2 * 32768];
>> +
>> +FFTContext fft_ctx;
>> +} QDMCContext;
>> +
>> +static float sin_table[512];
>> +static VLC vtable[6];
>
> Why are these not part of QDMCContext?

They are static, never change, so having it part of context wastes
memory, with duplicate tables for each instance of decoder.

>
> [...]
>
>> +
>> +static av_cold int qdmc_init_static_data(QDMCContext *s)
>> +{
>> +static int done;
>> +int i, ret;
>> +
>> +if (done)
>> +return 0;
>> +
>> +ret = ff_init_vlc_sparse(&vtable[0], 12,
>> FF_ARRAY_ELEMS(noise_value_bits),
>> + noise_value_bits, 1, 1, noise_value_codes,
>> 2, 2, noise_value_symbols, 1, 1, INIT_VLC_LE);
>> +if (ret < 0)
>> +return ret;
>> +ret = ff_init_vlc_sparse(&vtable[1], 10,
>> FF_ARRAY_ELEMS(noise_segment_length_bits),
>> + noise_segment_length_bits, 1, 1,
>> noise_segment_length_codes, 2, 2,
>> + noise_segment_length_symbols, 1, 1,
>> INIT_VLC_LE);
>> +if (ret < 0)
>> +return ret;
>> +ret = ff_init_vlc_sparse(&vtable[2], 13,
>> FF_ARRAY_ELEMS(amplitude_bits),
>> + amplitude_bits, 1, 1, amplitude_codes, 2, 2,
>> NULL, 0, 0, INIT_VLC_LE);
>> +if (ret < 0)
>> +return ret;
>> +ret = ff_init_vlc_sparse(&vtable[3], 18,
>> FF_ARRAY_ELEMS(freq_diff_bits),
>> + freq_diff_bits, 1, 1, freq_diff_codes, 4, 4,
>> NULL, 0, 0, INIT_VLC_LE);
>> +if (ret < 0)
>> +return ret;
>> +ret = ff_init_vlc_sparse(&vtable[4], 8,
>> FF_ARRAY_ELEMS(amplitude_diff_bits),
>> + amplitude_diff_bits, 1, 1,
>> amplitude_diff_codes, 1, 1, NULL, 0, 0, INIT_VLC_LE);
>> +if (ret < 0)
>> +return ret;
>> +ret = ff_init_vlc_sparse(&vtable[5], 6,
>> FF_ARRAY_ELEMS(phase_diff_bits),
>> + phase_diff_bits, 1, 1, phase_diff_codes, 1,
>> 1, NULL, 0, 0, INIT_VLC_LE);
>> +if (ret < 0)
>> +return ret;
>> +
>> +for (i = 0; i < 512; i++)
>> +sin_table[i] = sin(2 * i * M_PI * 0.001953125);
>
> These constants should be float.

ok

>
>> +
>> +done = 1;
>> +
>> +return 0;
>> +}
>
> [...]
>
>> +static av_cold int qdmc_decode_init(AVCodecContext *avctx)
>> +{
>> +QDMCContext *s = avctx->priv_data;
>> +uint8_t *extradata;
>> +int extradata_size, fft_size, fft_order, ret, size, g, j, x;
>> +
>> +if ((ret = qdmc_init_static_data(s)) < 0)
>> +return ret;
>> +
>> +if (!avctx->extradata || (avctx->extradata_size < 48)) {
>> +av_log(avctx, AV_LOG_ERROR, "extradata missing or truncated\n");
>> +return AVERROR_INVALIDDATA;
>> +}
>> +
>> +extrad

Re: [FFmpeg-devel] [PATCH 17/17] lavfi/buffersink: move to the new design.

2017-01-05 Thread Nicolas George
Le sextidi 16 nivôse, an CCXXV, Rostislav Pehlivanov a écrit :
> Thanks, the excerpt looks fine to me.

Thanks for the review. One to go.

> btw, there's apparently been a regression w.r.t. EOF handling which wm4
> hasn't told you about yet, not sure which commit introduced it though:
> 
> https://github.com/mpv-player/mpv/commit/43386a7c92e14e56abdebfd4ed9335794c795f2b

Could you perhaps test if the current series (which needs also the "make
avfilterlink private series" to apply cleanly) fixes it?

If not, can you tell me exactly how to reproduce the issue?

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] avcodec: add QDMC decoder

2017-01-05 Thread Lou Logan
On Thu,  5 Jan 2017 19:34:44 +0100, Paul B Mahol wrote:

[...]
> +++ b/libavcodec/qdmc.c
[...]

libavcodec/qdmc.c: In function ‘qdmc_decode_frame’:
libavcodec/qdmc.c:463:39: warning: array subscript is above array bounds 
[-Warray-bounds]
 s->noise[ch][band][idx] = lastval + k * (newval - lastval) 
/ len - 1;
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] mov: support for multiple edits and cenc decryption

2017-01-05 Thread Eran Kornblau
Hi all,

We found today that this change:
https://github.com/FFmpeg/FFmpeg/commit/ca6cae73db207f17a0d5507609de12842d8f0ca3
can break the decryption of MP4s encrypted with common encryption.

I would like to submit a patch for that, but wanted to consult first about the 
best approach.

The problem is that following this change the frames may not be traversed 
sequentially from the beginning.
The issue we are currently experiencing is that the first audio frame gets 
removed by mov_fix_index,
but the same issue will occur if there are frames that are duplicated or 
dropped in the middle of the stream.

The reason this breaks the decryption is that sc->cenc.auxiliary_info_pos 
should be pointing to the auxiliary
info (=the encryption iv, in case of audio) of the next frame to be read. It is 
initialized to the first frame in
mov_read_senc, incremented on every frame in cenc_filter, and updated in 
mov_seek_auxiliary_info in case
of seek.
What happens here is that auxiliary_info_pos remains pointing to the first 
frame in the track, but due to the
edit list, that is not the same frame as st->index_entries[0]. So the frames 
get decrypted with wrong IVs,
and we get invalid data.

I'm considering a few options for solving this:

1.   The specific case we're currently experiencing (frames removed from 
the beginning of the track)
can be easily solved by updating auxiliary_info_pos as part of mov_fix_index. 
However, this solution
won't work for more complex edit lists (e.g. gaps in the middle).

2.   Build a new auxiliary info buffer that will match the order of the 
frames following the edit list.
For example, if some frames were removed from the beginning of the stream, this 
new buffer
will be a suffix of the original buffer. If some frames were duplicated, this 
new buffer will have
their auxiliary info duplicated as well.

3.   Add a field to AVIndexEntry that will retain the original index of the 
frame in the MP4 file.
So, for example, if a frame was removed from the beginning, 
st->index_entries[0].index will
be 1 instead of 0. With this info, it will be possible to detect a frame index 
discontinuity in
cenc_filter and recalculate the auxiliary info position accordingly.

4.   Add a new array to MOVStreamContext that will retain the ranges of 
frame indexes following
the edit list, e.g. if the edit list takes frames 30..60 and then 100..150, the 
array will have 2 records
(30,60), (100, 150). This array will be built in mov_fix_index, and will be 
used by cenc_filter.

The pros/cons as I see it -

1.   Pros: simple, cons: no support for complex edit lists

2.   Cons: seems more complicated, and less efficient than the other 
solutions

3.   Pros: simple, cons: makes AVIndexEntry larger (and it seems care has 
been taken to keep this
struct to the minimum...)

4.   Pros: very low memory footprint, cons: slightly more complex than #3

Personally, I'm leaning toward #4, but any comments are welcome

Thank you

Eran

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


Re: [FFmpeg-devel] [PATCH] avcodec: add QDMC decoder

2017-01-05 Thread James Almer
On 1/5/2017 4:13 PM, Paul B Mahol wrote:
>>> +static float sin_table[512];
>>> +static VLC vtable[6];
>> Why are these not part of QDMCContext?
> They are static, never change, so having it part of context wastes
> memory, with duplicate tables for each instance of decoder.

Then i think it might be a better idea call qdmc_init_static_data()
using AVCodec.init_static_data() instead of from within AVCodec.init().
It's what other decoders seem to do for this.

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


[FFmpeg-devel] [PATCH] avcodec: add QDMC decoder

2017-01-05 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 Changelog  |   1 +
 doc/general.texi   |   1 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/qdmc.c  | 789 +
 5 files changed, 793 insertions(+)
 create mode 100644 libavcodec/qdmc.c

diff --git a/Changelog b/Changelog
index aff9ab0..e09bf20 100644
--- a/Changelog
+++ b/Changelog
@@ -12,6 +12,7 @@ version :
 - 16.8 floating point pcm decoder
 - 24.0 floating point pcm decoder
 - Apple Pixlet decoder
+- QDMC audio decoder
 
 version 3.2:
 - libopenmpt demuxer
diff --git a/doc/general.texi b/doc/general.texi
index 084c0a1..a13a8fc 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1048,6 +1048,7 @@ following image formats are supported:
 @item PCM unsigned 32-bit little-endian  @tab  X  @tab  X
 @item PCM Zork   @tab @tab  X
 @item QCELP / PureVoice  @tab @tab  X
+@item QDesign Music Codec 1  @tab @tab  X
 @item QDesign Music Codec 2  @tab @tab  X
 @tab There are still some distortions.
 @item RealAudio 1.0 (14.4K)  @tab  X  @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 58feb31..44e416e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -466,6 +466,7 @@ OBJS-$(CONFIG_QCELP_DECODER)   += qcelpdec.o
 \
   celp_filters.o acelp_vectors.o \
   acelp_filters.o
 OBJS-$(CONFIG_QDM2_DECODER)+= qdm2.o
+OBJS-$(CONFIG_QDMC_DECODER)+= qdmc.o
 OBJS-$(CONFIG_QDRAW_DECODER)   += qdrw.o
 OBJS-$(CONFIG_QPEG_DECODER)+= qpeg.o
 OBJS-$(CONFIG_QTRLE_DECODER)   += qtrle.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 678f54a..4540ef7 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -449,6 +449,7 @@ void avcodec_register_all(void)
 REGISTER_DECODER(PAF_AUDIO, paf_audio);
 REGISTER_DECODER(QCELP, qcelp);
 REGISTER_DECODER(QDM2,  qdm2);
+REGISTER_DECODER(QDMC,  qdmc);
 REGISTER_ENCDEC (RA_144,ra_144);
 REGISTER_DECODER(RA_288,ra_288);
 REGISTER_DECODER(RALF,  ralf);
diff --git a/libavcodec/qdmc.c b/libavcodec/qdmc.c
new file mode 100644
index 000..06b4e4e
--- /dev/null
+++ b/libavcodec/qdmc.c
@@ -0,0 +1,789 @@
+/*
+ * QDMC compatible decoder
+ * Copyright (c) 2017 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+#include 
+
+#define BITSTREAM_READER_LE
+
+#include "libavutil/channel_layout.h"
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "get_bits.h"
+#include "internal.h"
+#include "fft.h"
+
+typedef struct QDMCTone {
+uint8_t mode;
+uint8_t phase;
+uint8_t offset;
+int16_t freq;
+int16_t amplitude;
+} QDMCTone;
+
+typedef struct QDMCContext {
+AVCodecContext *avctx;
+
+uint8_t frame_bits;
+int band_index;
+int frame_size;
+int subframe_size;
+int fft_offset;
+int buffer_offset;
+int nb_channels;
+int checksum_size;
+
+uint8_t noise[2][19][16];
+QDMCTone tones[5][8192];
+int nb_tones[5];
+int cur_tone[5];
+float alt_sin[5][31];
+float fft_buffer[4][8192 * 2];
+float noise2_buffer[4096 * 2];
+float noise_buffer[4096 * 2];
+float buffer[2 * 32768];
+float *buffer_ptr;
+int rndval;
+
+DECLARE_ALIGNED(32, FFTComplex, cmplx)[2][512];
+FFTContext fft_ctx;
+} QDMCContext;
+
+static float sin_table[512];
+static VLC vtable[6];
+
+static const unsigned code_prefix[] = {
+0x0, 0x1, 0x2, 0x3, 0x4, 0x6, 0x8, 0xA,
+0xC, 0x10, 0x14, 0x18, 0x1C, 0x24, 0x2C, 0x34,
+0x3C, 0x4C, 0x5C, 0x6C, 0x7C, 0x9C, 0xBC, 0xDC,
+0xFC, 0x13C, 0x17C, 0x1BC, 0x1FC, 0x27C, 0x2FC, 0x37C,
+0x3FC, 0x4FC, 0x5FC, 0x6FC, 0x7FC, 0x9FC, 0xBFC, 0xDFC,
+0xFFC, 0x13FC, 0x17FC, 0x1BFC, 0x1FFC, 0x27FC, 0x2FFC, 0x37FC,
+0x3FFC, 0x4FFC, 0x5FFC, 0x6FFC, 0x7FFC, 0x9FFC, 0xBFFC, 0xDFFC,
+0xFFFC, 0x13FFC, 0x17FFC, 0x1BFFC, 0x1FFFC, 0x27FFC, 0x2FFFC, 0x37FFC,
+0x3FFFC
+};
+
+static const float amplitude_tab[64] = {
+1.1875f, 1.68359380f, 2.3750f, 3.36718750f

Re: [FFmpeg-devel] [PATCH 1/4] dxva2: make ff_dxva2_get_surface() static and rename it

2017-01-05 Thread Michael Niedermayer
On Wed, Jan 04, 2017 at 02:36:41PM +0100, Steve Lhomme wrote:
> ---
>  libavcodec/dxva2.c  | 8 
>  libavcodec/dxva2_internal.h | 2 --
>  2 files changed, 4 insertions(+), 6 deletions(-)

applied

PS: it seems this was posted over a month ago with no reviewes or
comments, is some co-maintainer needed for this ?

thx

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

Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.


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


Re: [FFmpeg-devel] [PATCH] doc/muxers/hlsenc: typo hls_flag: discont_starts => discont_start

2017-01-05 Thread Michael Niedermayer
On Thu, Jan 05, 2017 at 08:56:09PM +0800, Steven Liu wrote:
> 2017-01-05 20:25 GMT+08:00 Bodecs Bela :
> 
> > Dear All,
> >
> > in doc/muxers/hlsenc, there is a  typo in hls_flags section:
> > discont_starts instead of   discont_start
> >
> >
> > best regards,
> >
> > Bela Bodecs
> >
> >
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > looks ok,
> but i'm not the doc maintainer :-)

i think you can commit such simple changes ...

but applied

thx

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

Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.


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


Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: fix Explicit null dereferenced in hlsenc

2017-01-05 Thread Steven Liu
2017-01-06 1:53 GMT+08:00 Michael Niedermayer :

> On Thu, Jan 05, 2017 at 08:28:56AM +0800, Steven Liu wrote:
> > CID: 1398228
> > Passing null pointer dirname to strlen, which dereferences it.
> >
> > Signed-off-by: Steven Liu 
> > ---
> >  libavformat/hlsenc.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> > index 808a797..3c6490a 100644
> > --- a/libavformat/hlsenc.c
> > +++ b/libavformat/hlsenc.c
> > @@ -285,8 +285,8 @@ static int hls_delete_old_segments(HLSContext *hls)
> {
> >   path, strerror(errno));
> >  }
> >
> > -if (segment->sub_filename[0] != '\0') {
> > -sub_path_size = strlen(dirname) +
> strlen(segment->sub_filename) + 1;
> > +if ((segment->sub_filename[0] != '\0')) {
>
> > +sub_path_size = (!dirname) ? (strlen(segment->sub_filename)
> + 1) : (strlen(dirname) + strlen(segment->sub_filename) + 1);
>
> simpler:
> sub_path_size = strlen(segment->sub_filename) + 1 + (dirname ?
> strlen(dirname) : 0);


>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> There will always be a question for which you do not know the correct
> answer.
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> From 57ae94a3c0fced20464d9ae351efc977d964be38 Mon Sep 17 00:00:00 2001
From: Steven Liu 
Date: Fri, 6 Jan 2017 06:29:12 +0800
Subject: [PATCH] avformat/hlsenc: fix Explicit null dereferenced in hlsenc

CID: 1398228
Passing null pointer dirname to strlen, which dereferences it.

Reviewed-by: Michael Niedermayer 
Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 920987f..eeb450a 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -285,8 +285,8 @@ static int hls_delete_old_segments(HLSContext *hls) {
  path, strerror(errno));
 }

-if (segment->sub_filename[0] != '\0') {
-sub_path_size = strlen(dirname) +
strlen(segment->sub_filename) + 1;
+if ((segment->sub_filename[0] != '\0')) {
+sub_path_size = strlen(segment->sub_filename) + 1 + (dirname ?
strlen(dirname) : 0);
 sub_path = av_malloc(sub_path_size);
 if (!sub_path) {
 ret = AVERROR(ENOMEM);
-- 
2.10.1.382.ga23ca1b.dirty






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


Re: [FFmpeg-devel] [PATCH 2/2] imdct15: replace the FFT with a faster PFA FFT algorithm

2017-01-05 Thread Rostislav Pehlivanov
On 4 January 2017 at 22:45, Rostislav Pehlivanov 
wrote:

>
>
> On 4 January 2017 at 14:14, Peter Barfuss  wrote:
>
>> First off, many thanks.
>>
>> > +const int inv_1 = l_ptwo << ((4 - b_ptwo) & 3);
>> > +const int inv_2 = 0xeeef & ((1U << b_ptwo) - 1);
>>
>> It would be nice to add a comment here that the expression for inv_1
>> is (2^b_ptwo)^-1 mod 15 and inv_2 is 15^-1 mod 2^b_ptwo. (A general
>> PFA FFT would need to use extended Euclidean algorithm here, but
>> because both cases are fixed, it simplifies to these expressions. I
>> have a sketch of a proof (basically solving the relevant diophantine
>> equation you get) in case anyone is nervous, though it's easy to
>> verify by hand for 1 < b_ptwo < 18, which are all the cases that
>> ffmpeg's power-of-two FFT currently supports).
>>
>> Rest of patch seems good.
>>
>> -Peter
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>
> Done
>
> Also I didn't like how s->exptab[20].re needed a negative sign so I
> removed it
> and moved the subtraction to the 5-point FFT, just so you know.
>
>
> I'll push both patches tomorrow evening if no one else has anything to say.
>


Applied,

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


Re: [FFmpeg-devel] [PATCH 1/2] imdct15: remove the AArch64 assembly

2017-01-05 Thread Rostislav Pehlivanov
On 4 January 2017 at 10:16, Rostislav Pehlivanov 
wrote:

> Prep work for the next commit, which will add a new FFT algorithm
> which makes the iMDCT over 3x faster than it is currently (standalone,
> the FFT is with some framesizes over 10x faster).
>
> The new FFT algorithm uses the already thouroughly SIMD'd power of two
> FFT which already has SIMD for AArch64, so users of that platform will
> still see an improvement.
>
> The previous FFT+SIMD was barely 2.5x faster than the C versions on these
> platforms.
>
> Signed-off-by: Rostislav Pehlivanov 
> ---
>  libavcodec/aarch64/Makefile   |   2 -
>  libavcodec/aarch64/imdct15_init.c |  46 ---
>  libavcodec/aarch64/imdct15_neon.S | 647 --
> 
>  libavcodec/imdct15.c  |   3 -
>  libavcodec/imdct15.h  |   3 -
>  5 files changed, 701 deletions(-)
>  delete mode 100644 libavcodec/aarch64/imdct15_init.c
>  delete mode 100644 libavcodec/aarch64/imdct15_neon.S
>
> diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
> index b7bb898713..5593863a75 100644
> --- a/libavcodec/aarch64/Makefile
> +++ b/libavcodec/aarch64/Makefile
> @@ -6,7 +6,6 @@ OBJS-$(CONFIG_H264DSP)  +=
> aarch64/h264dsp_init_aarch64.o
>  OBJS-$(CONFIG_H264PRED) += aarch64/h264pred_init.o
>  OBJS-$(CONFIG_H264QPEL) += aarch64/h264qpel_init_aarch64.
> o
>  OBJS-$(CONFIG_HPELDSP)  += aarch64/hpeldsp_init_aarch64.o
> -OBJS-$(CONFIG_IMDCT15)  += aarch64/imdct15_init.o
>  OBJS-$(CONFIG_MPEGAUDIODSP) += aarch64/mpegaudiodsp_init.o
>  OBJS-$(CONFIG_NEON_CLOBBER_TEST)+= aarch64/neontest.o
>  OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp_init.o
> @@ -35,7 +34,6 @@ NEON-OBJS-$(CONFIG_H264PRED)+=
> aarch64/h264pred_neon.o
>  NEON-OBJS-$(CONFIG_H264QPEL)+= aarch64/h264qpel_neon.o
>  \
> aarch64/hpeldsp_neon.o
>  NEON-OBJS-$(CONFIG_HPELDSP) += aarch64/hpeldsp_neon.o
> -NEON-OBJS-$(CONFIG_IMDCT15) += aarch64/imdct15_neon.o
>  NEON-OBJS-$(CONFIG_MDCT)+= aarch64/mdct_neon.o
>  NEON-OBJS-$(CONFIG_MPEGAUDIODSP)+= aarch64/mpegaudiodsp_neon.o
>
> diff --git a/libavcodec/aarch64/imdct15_init.c
> b/libavcodec/aarch64/imdct15_init.c
> deleted file mode 100644
> index 58af9f00c0..00
> --- a/libavcodec/aarch64/imdct15_init.c
> +++ /dev/null
> @@ -1,46 +0,0 @@
> -/*
> - * This file is part of FFmpeg.
> - *
> - * FFmpeg is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU Lesser General Public
> - * License as published by the Free Software Foundation; either
> - * version 2.1 of the License, or (at your option) any later version.
> - *
> - * FFmpeg is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> - * Lesser General Public License for more details.
> - *
> - * You should have received a copy of the GNU Lesser General Public
> - * License along with FFmpeg; if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> - */
> -
> -#include 
> -
> -#include "libavutil/cpu.h"
> -#include "libavutil/aarch64/cpu.h"
> -#include "libavutil/internal.h"
> -
> -#include "libavcodec/imdct15.h"
> -
> -#include "asm-offsets.h"
> -
> -AV_CHECK_OFFSET(IMDCT15Context, exptab, CELT_EXPTAB);
> -AV_CHECK_OFFSET(IMDCT15Context, fft_n,  CELT_FFT_N);
> -AV_CHECK_OFFSET(IMDCT15Context, len2,   CELT_LEN2);
> -AV_CHECK_OFFSET(IMDCT15Context, len4,   CELT_LEN4);
> -AV_CHECK_OFFSET(IMDCT15Context, tmp,CELT_TMP);
> -AV_CHECK_OFFSET(IMDCT15Context, twiddle_exptab, CELT_TWIDDLE);
> -
> -void ff_celt_imdct_half_neon(IMDCT15Context *s, float *dst, const float
> *src,
> - ptrdiff_t stride, float scale);
> -
> -void ff_imdct15_init_aarch64(IMDCT15Context *s)
> -{
> -int cpu_flags = av_get_cpu_flags();
> -
> -if (have_neon(cpu_flags)) {
> -s->imdct_half = ff_celt_imdct_half_neon;
> -}
> -}
> diff --git a/libavcodec/aarch64/imdct15_neon.S
> b/libavcodec/aarch64/imdct15_neon.S
> deleted file mode 100644
> index 97e1442ccc..00
> --- a/libavcodec/aarch64/imdct15_neon.S
> +++ /dev/null
> @@ -1,647 +0,0 @@
> -/*
> - * Copyright (c) 2014 Janne Grunau 
> - *
> - * 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
> - * MERCHANTAB

Re: [FFmpeg-devel] [PATCH] avformat/test/fifo_muxer: add check for FailingMuxerPacketData alloc

2017-01-05 Thread Steven Liu
2017-01-06 2:02 GMT+08:00 Michael Niedermayer :

> On Thu, Jan 05, 2017 at 10:45:23AM +0800, Steven Liu wrote:
> > CID: 1396257
> > Signed-off-by: Steven Liu 
> > ---
> >  libavformat/tests/fifo_muxer.c | 3 +++
> >  1 file changed, 3 insertions(+)
>
> LGTM
>
applied


Thanks!

>
> thx
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Those who are best at talking, realize last or never when they are wrong.
>
> ___
> 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] avformat/hlsenc: fix Explicit null dereferenced

2017-01-05 Thread Steven Liu
2017-01-06 2:00 GMT+08:00 Michael Niedermayer :

> On Thu, Jan 05, 2017 at 08:40:56AM +0800, Steven Liu wrote:
> > CID: 1323076
> > Passing null pointer loc to avformat_new_stream, which dereferences it
>
> >  fix: because the vtt_oc maybe have not value, so fix it.
>
> hmm
>
> i think:
> this is wrong:
> hls->vtt_oformat = av_guess_format("webvtt", NULL, NULL);
> if (!hls->oformat) {
> above checks the wrong value
>
> then vtt_oformat should be non null
>
Ok, ignore this patch please :-D

>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Breaking DRM is a little like attempting to break through a door even
> though the window is wide open and the only thing in the house is a bunch
> of things you dont want and which you would get tomorrow for free anyway
>
> ___
> 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 1/4] dxva2: make ff_dxva2_get_surface() static and rename it

2017-01-05 Thread Hendrik Leppkes
On Fri, Jan 6, 2017 at 9:15 AM, Michael Niedermayer
 wrote:
> On Wed, Jan 04, 2017 at 02:36:41PM +0100, Steve Lhomme wrote:
>> ---
>>  libavcodec/dxva2.c  | 8 
>>  libavcodec/dxva2_internal.h | 2 --
>>  2 files changed, 4 insertions(+), 6 deletions(-)
>
> applied
>
> PS: it seems this was posted over a month ago with no reviewes or
> comments, is some co-maintainer needed for this ?
>
> thx
>

This set was being reviewed on the libav mailing list, it makes no
sense to review it twice.

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


Re: [FFmpeg-devel] [PATCH] configure: disable the new optimizer in Visual Studio 2015 Update 3

2017-01-05 Thread Kacper Michajlow
2016-07-04 3:53 GMT+02:00 Kacper Michajlow :
> 2016-07-03 23:39 GMT+02:00 Hendrik Leppkes :
>> On Tue, Jun 28, 2016 at 12:01 PM, Hendrik Leppkes  
>> wrote:
>>> On Tue, Jun 28, 2016 at 11:48 AM, Hendrik Leppkes  
>>> wrote:
 Visual Studio 2015 Update 3 introduced a new SSA optimizer, however
 it unfortunately causes miscompilations. Until it is fixed, the new
 optimizations are disabled and should be re-checked on subsequent
 compiler releases.

 Fixes recent FATE failure of fate-lavf-pam on VS2015.
>>>
>>> On that note, i'm not exactly sure which code actually miscompiles.
>>> I though its pamenc, but the generated files are identical, then I
>>> though its the crc computing code (crcenc/adler32), but those seem
>>> fine as well and would likely screw up in more then one case if they
>>> would miscompile.
>>>
>>> So that leaves pnmdec, I suppose, but I didn't make much headway to
>>> poke around in that. If anyone has any handy hints how to find the
>>> code in question that might be helpful.
>>> Maybe the code is actually not-quite-right and might enjoy some 
>>> straigtening.
>>>
>>
>> Applied the patch to disable the new optimizations in MSVC as I did
>> not spot anything obviously "bad" in pamdec - which does not mean
>> there isn't anything there, of course.
>>
>
> This is pretty bad miscompilation in new SSA optimizer. It assumes
> that variable declared in loop doesn't change the value even if there
> is assignment. I minimized testcese and reported the bug
> https://connect.microsoft.com/VisualStudio/feedback/details/2890170
>
> - Kacper

Sorry for bumping such old thread, but I just got information that the
bug has been fixed in MSVC.

It is fixed in hotfix for VS2015 - KB3207317
https://support.microsoft.com/en-us/kb/3207317 and of course in
upcoming VS2017.

I've confirmed that this hotfix fixes fate-lavf-pam test. The
following change will enable SSA Optimizer on newer compiler versions.

---
 configure | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 398e843..cf82b3b 100755
--- a/configure
+++ b/configure
@@ -6317,9 +6317,9 @@ EOF
 check_func strtoll || add_cflags -Dstrtoll=_strtoi64
 check_func strtoull || add_cflags -Dstrtoull=_strtoui64
 # the new SSA optimzer in VS2015 U3 is mis-optimizing some parts
of the code
-# this flag should be re-checked on newer compiler releases and put under a
-# version check once its fixed
-check_cflags -d2SSAOptimizer-
+# Issue has been fixed in MSVC v19.00.24218.
+check_cpp_condition windows.h "_MSC_FULL_VER >= 190024218" ||
+check_cflags -d2SSAOptimizer-
 fi

 for pfx in "" host_; do
-- 
2.10.0.windows.1.325.ge6089c1

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


Re: [FFmpeg-devel] [PATCH 1/4] dxva2: make ff_dxva2_get_surface() static and rename it

2017-01-05 Thread Michael Niedermayer
On Fri, Jan 06, 2017 at 09:52:48AM +1100, Hendrik Leppkes wrote:
> On Fri, Jan 6, 2017 at 9:15 AM, Michael Niedermayer
>  wrote:
> > On Wed, Jan 04, 2017 at 02:36:41PM +0100, Steve Lhomme wrote:
> >> ---
> >>  libavcodec/dxva2.c  | 8 
> >>  libavcodec/dxva2_internal.h | 2 --
> >>  2 files changed, 4 insertions(+), 6 deletions(-)
> >
> > applied
> >
> > PS: it seems this was posted over a month ago with no reviewes or
> > comments, is some co-maintainer needed for this ?
> >
> > thx
> >
> 
> This set was being reviewed on the libav mailing list, it makes no
> sense to review it twice.

It makes sense to approve or reject patches. Otherwise noone knows
and also patchwork has the status wrong then.

Furthermore without approval, patches wont neccessarily get applied
and without rejection patches may get applied that someone would have
arguments against.

So i think the maintainer should reply to patches here with either
a review, an approval or a rejection or something along these lines.
And in that light, was my question about a co-maintainer ...

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates


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


[FFmpeg-devel] [PATCH] avcodec/atrac3: use AVCodec.init_static_data() to initialize static data

2017-01-05 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/atrac3.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index 256990b..208762d 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -771,7 +771,7 @@ static int atrac3_decode_frame(AVCodecContext *avctx, void 
*data,
 return avctx->block_align;
 }
 
-static av_cold void atrac3_init_static_data(void)
+static av_cold void atrac3_decode_init_static_data(AVCodec *codec)
 {
 int i;
 
@@ -791,7 +791,6 @@ static av_cold void atrac3_init_static_data(void)
 
 static av_cold int atrac3_decode_init(AVCodecContext *avctx)
 {
-static int static_init_done;
 int i, ret;
 int version, delay, samples_per_frame, frame_factor;
 const uint8_t *edata_ptr = avctx->extradata;
@@ -802,10 +801,6 @@ static av_cold int atrac3_decode_init(AVCodecContext 
*avctx)
 return AVERROR(EINVAL);
 }
 
-if (!static_init_done)
-atrac3_init_static_data();
-static_init_done = 1;
-
 /* Take care of the codec-specific extradata. */
 if (avctx->extradata_size == 14) {
 /* Parse the extradata, WAV format */
@@ -932,6 +927,7 @@ AVCodec ff_atrac3_decoder = {
 .id   = AV_CODEC_ID_ATRAC3,
 .priv_data_size   = sizeof(ATRAC3Context),
 .init = atrac3_decode_init,
+.init_static_data = atrac3_decode_init_static_data,
 .close= atrac3_decode_close,
 .decode   = atrac3_decode_frame,
 .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DR1,
-- 
2.10.2

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


Re: [FFmpeg-devel] [PATCH 1/4] dxva2: make ff_dxva2_get_surface() static and rename it

2017-01-05 Thread Hendrik Leppkes
On Fri, Jan 6, 2017 at 11:11 AM, Michael Niedermayer
 wrote:
> On Fri, Jan 06, 2017 at 09:52:48AM +1100, Hendrik Leppkes wrote:
>> On Fri, Jan 6, 2017 at 9:15 AM, Michael Niedermayer
>>  wrote:
>> > On Wed, Jan 04, 2017 at 02:36:41PM +0100, Steve Lhomme wrote:
>> >> ---
>> >>  libavcodec/dxva2.c  | 8 
>> >>  libavcodec/dxva2_internal.h | 2 --
>> >>  2 files changed, 4 insertions(+), 6 deletions(-)
>> >
>> > applied
>> >
>> > PS: it seems this was posted over a month ago with no reviewes or
>> > comments, is some co-maintainer needed for this ?
>> >
>> > thx
>> >
>>
>> This set was being reviewed on the libav mailing list, it makes no
>> sense to review it twice.
>
> It makes sense to approve or reject patches. Otherwise noone knows
> and also patchwork has the status wrong then.
>
> Furthermore without approval, patches wont neccessarily get applied
> and without rejection patches may get applied that someone would have
> arguments against.
>
> So i think the maintainer should reply to patches here with either
> a review, an approval or a rejection or something along these lines.
> And in that light, was my question about a co-maintainer ...

While review is still on-going, there is no such status to apply.

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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/matroskaenc: Regression fix for invalid MKV headers

2017-01-05 Thread James Almer
On 1/5/2017 3:07 PM, Soft Works wrote:
> The following three commits created a regression by writing initially
> invalid mkv headers:
> 
> 650e17d88b63b5aca6e0a43483e89e64b0f7d2dd avformat/matroskaenc: write a
> CRC32 element on Tags
> 3bcadf822711720ff0f8d14db71ae47cdf97e652 avformat/matroskaenc: write a
> CRC32 element on Info
> ee888cfbe777cd2916a3548c750e433ab8f8e6a5 avformat/matroskaenc: postpone
> writing the Tracks master
> 
> Symptoms:
> 
> - You can no longer playback a file that is still processed by ffmpeg,
> e.g. VLC fails playback
> - You can no longer stream a file to a client while if is still being
> processed
> - Various diagnosing tools show header errors or incomplete headers
> (e.g. ffprobe, mediainfo, mkvalidator)
> 
> Note: The symptoms do not apply to completed files or ffmpeg runs that
> were interrupted with 'q'
> 
> Cause:
> 
> The mentioned commits made changes in a way that some header elements
> are only partially written in
> mkv_write_header, leaving the header in an invalid state. Only in
> mkv_write_trailer, these elements
> are finished correctly, but that does only occur at the end of the
> process.
> 
> Regression:
> 
> Before these commits were applied, mkv headers have always been valid,
> even before completion of ffmpeg.
> This has worked reliably over many versions of ffmpeg, to it was an
> obvious regression.
> 
> Bugtracker:
> 
> This issue has been recorded as #5977 which is resolved by this patch
> 
> Patch:
> 
> The patch adds a new function 'end_ebml_master_crc32_preliminary' that
> preliminarily finishes the ebl
> element without destroying the buffer. The buffer can be used to update
> the ebml element later during
> mkv_write_trailer. But most important: mkv_write_header finishes with a
> valid mkv header again.
> ---
>  libavformat/matroskaenc.c | 28 +---
>  1 file changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index 827d755..27d83a6 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -367,6 +367,28 @@ static void end_ebml_master_crc32(AVIOContext *pb, 
> AVIOContext **dyn_cp, Matrosk
>  *dyn_cp = NULL;
>  }
>  
> +/**
> +* Complete ebml master whithout destroying the buffer, allowing for later 
> updates
> +*/
> +static void end_ebml_master_crc32_preliminary(AVIOContext *pb, AVIOContext 
> **dyn_cp, MatroskaMuxContext *mkv,
> +ebml_master master)
> +{
> +uint8_t *buf, crc[4];
> +int size, skip = 0;
> +
> +if (pb->seekable) {
> +
> +size = avio_get_dyn_buf(*dyn_cp, &buf);
> +if (mkv->write_crc && mkv->mode != MODE_WEBM) {
> +skip = 6; /* Skip reserved 6-byte long void element from the 
> dynamic buffer. */
> +AV_WL32(crc, av_crc(av_crc_get_table(AV_CRC_32_IEEE_LE), 
> UINT32_MAX, buf + skip, size - skip) ^ UINT32_MAX);
> +put_ebml_binary(pb, EBML_ID_CRC32, crc, sizeof(crc));
> +}

IMO, no point calculating and writing a CRC element for this temporary state.
You can rename and simplify this function into something like

static void end_ebml_master_preliminary(AVIOContext *pb, AVIOContext **dyn_cp,
ebml_master master)
{
uint8_t *buf;
int size = avio_get_dyn_buf(*dyn_cp, &buf);

avio_write(pb, buf, size);
end_ebml_master(pb, master);
}

> +avio_write(pb, buf + skip, size - skip);
> +end_ebml_master(pb, master);
> +}
> +}
> +
>  static void put_xiph_size(AVIOContext *pb, int size)
>  {
>  ffio_fill(pb, 255, size / 255);
> @@ -1309,7 +1331,7 @@ static int mkv_write_tracks(AVFormatContext *s)
>  }
>  
>  if (pb->seekable && !mkv->is_live)
> -put_ebml_void(pb, avio_tell(mkv->tracks_bc));
> +end_ebml_master_crc32_preliminary(pb, &mkv->tracks_bc, mkv, 
> mkv->tracks_master);
>  else
>  end_ebml_master_crc32(pb, &mkv->tracks_bc, mkv, mkv->tracks_master);
>  
> @@ -1554,7 +1576,7 @@ static int mkv_write_tags(AVFormatContext *s)
>  
>  if (mkv->tags.pos) {
>  if (s->pb->seekable && !mkv->is_live)
> -put_ebml_void(s->pb, avio_tell(mkv->tags_bc));
> +end_ebml_master_crc32_preliminary(s->pb, &mkv->tags_bc, mkv, 
> mkv->tags);
>  else
>  end_ebml_master_crc32(s->pb, &mkv->tags_bc, mkv, mkv->tags);
>  }
> @@ -1811,7 +1833,7 @@ static int mkv_write_header(AVFormatContext *s)
>  }
>  }
>  if (s->pb->seekable && !mkv->is_live)
> -put_ebml_void(s->pb, avio_tell(pb));
> +end_ebml_master_crc32_preliminary(s->pb, &mkv->info_bc, mkv, 
> mkv->info);
>  else
>  end_ebml_master_crc32(s->pb, &mkv->info_bc, mkv, mkv->info);
>  pb = s->pb;

FATE passes so LGTM.

I'll leave the avio changes review to someone else.

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


Re: [FFmpeg-devel] [PATCH] lavc/cuvid: fail early if GPU can't handle given video resolution

2017-01-05 Thread Ruta Gadkari
On Jan 3, 2017 03:38 AM, "Pavel Koshevoy"  wrote:

>> I don't recall seeing it mentioned that they do not support 422 and
>> 444 in nvidia docs

> It decodes "fine", except for one green line along the bottom edge of the 
> frame.
> The other file I have that decodes with severe artifacts with mpeg2_cuvid is

Thank you for bringing this to notice. We are working on this and will update 
the thread again once the fixes are in place.

Thanks
Ruta 






---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] mov: support for multiple edits and cenc decryption

2017-01-05 Thread Sasi Inguva
I agree . #4 makes the most sense.

On Thu, Jan 5, 2017 at 12:38 PM, Eran Kornblau 
wrote:

> Hi all,
>
> We found today that this change:
> https://github.com/FFmpeg/FFmpeg/commit/ca6cae73db207f17a0d5507609de12
> 842d8f0ca3
> can break the decryption of MP4s encrypted with common encryption.
>
> I would like to submit a patch for that, but wanted to consult first about
> the best approach.
>
> The problem is that following this change the frames may not be traversed
> sequentially from the beginning.
> The issue we are currently experiencing is that the first audio frame gets
> removed by mov_fix_index,
> but the same issue will occur if there are frames that are duplicated or
> dropped in the middle of the stream.
>
> The reason this breaks the decryption is that sc->cenc.auxiliary_info_pos
> should be pointing to the auxiliary
> info (=the encryption iv, in case of audio) of the next frame to be read.
> It is initialized to the first frame in
> mov_read_senc, incremented on every frame in cenc_filter, and updated in
> mov_seek_auxiliary_info in case
> of seek.
> What happens here is that auxiliary_info_pos remains pointing to the first
> frame in the track, but due to the
> edit list, that is not the same frame as st->index_entries[0]. So the
> frames get decrypted with wrong IVs,
> and we get invalid data.
>
> I'm considering a few options for solving this:
>
> 1.   The specific case we're currently experiencing (frames removed
> from the beginning of the track)
> can be easily solved by updating auxiliary_info_pos as part of
> mov_fix_index. However, this solution
> won't work for more complex edit lists (e.g. gaps in the middle).
>
> 2.   Build a new auxiliary info buffer that will match the order of
> the frames following the edit list.
> For example, if some frames were removed from the beginning of the stream,
> this new buffer
> will be a suffix of the original buffer. If some frames were duplicated,
> this new buffer will have
> their auxiliary info duplicated as well.
>
> 3.   Add a field to AVIndexEntry that will retain the original index
> of the frame in the MP4 file.
> So, for example, if a frame was removed from the beginning,
> st->index_entries[0].index will
> be 1 instead of 0. With this info, it will be possible to detect a frame
> index discontinuity in
> cenc_filter and recalculate the auxiliary info position accordingly.
>
> 4.   Add a new array to MOVStreamContext that will retain the ranges
> of frame indexes following
> the edit list, e.g. if the edit list takes frames 30..60 and then
> 100..150, the array will have 2 records
> (30,60), (100, 150). This array will be built in mov_fix_index, and will
> be used by cenc_filter.
>
> The pros/cons as I see it -
>
> 1.   Pros: simple, cons: no support for complex edit lists
>
> 2.   Cons: seems more complicated, and less efficient than the other
> solutions
>
> 3.   Pros: simple, cons: makes AVIndexEntry larger (and it seems care
> has been taken to keep this
> struct to the minimum...)
>
> 4.   Pros: very low memory footprint, cons: slightly more complex than
> #3
>
> Personally, I'm leaning toward #4, but any comments are welcome
>
> Thank you
>
> Eran
>
> ___
> 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] libavutil/hwcontext_qsv: Command line using hwaccel 'QSV' doesn't work

2017-01-05 Thread Huang, Zhengxu

Hi

According to the suggestion update the patch.

thanks.


在 2017/1/3 21:14, Mark Thompson 写道:

On 03/01/17 07:13, Huang, Zhengxu wrote:

 From 687ce9c804b2618f021100235c46a33b48fa522c Mon Sep 17 00:00:00 2001
From: Zhengxu 
Date: Wed, 14 Dec 2016 11:55:31 +0800
Subject: [PATCH] libavutil/hwcontext_qsv: Command line using hwaccel 'QSV'
  doesn't work.

Command: ffmpeg -hwaccel qsv -c:v h264_qsv -i test.264 -c:v h264_qsv out.264

Reason: hwcontext_qsv will create a child hwcontext_vaapi. VAAPI will
  open X11 display ":0.0" defaultly. However, MSDK doesn't support X11 so
  far. This results in the failure of this command.

Fix: When using VAAPI, let VAAPI try to create DRM display handle by scanning
  device nodes under '/dev/dri/'.

We already default to attempting to open the first render node inside 
hwcontext_vaapi (if opening via X11 fails):

http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavutil/hwcontext_vaapi.c;h=6176bdc880c81dec7cac0b214a8d55f3b1160abc;hb=HEAD#l936

I think if you want this behaviour it would be better to add code there rather 
than in hwcontext_qsv (which doesn't really care about this aspect at all, it 
just wants a usable subdevice for the platform).

Can you explain your case which hits this?  Do you have some other external 
graphics card(s) along with the on-chip Intel graphics?  For that case, I don't 
like the idea of scanning for a device node because it is perfectly possible to 
get a valid VADisplay handle for a non-QSV device (an AMD or Nvidia card with 
mesa, most obviously) which will then fail opaquely later when libmfx tries to 
use it because the Intel proprietary driver is required.  This may even fail 
randomly, because device nodes associated with independent drivers are not 
ordered.


Signed-off-by: ChaoX A Liu 
Signed-off-by: Huang, Zhengxu 
Signed-off-by: Andrew, Zhang 
---
  libavutil/hwcontext_qsv.c | 44 +++-
  1 file changed, 31 insertions(+), 13 deletions(-)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 2dc9aca..2701b5a 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -707,12 +707,41 @@ static mfxIMPL choose_implementation(const char *device)
  return impl;
  }
  
+static int create_proper_child_device(AVBufferRef **ctx, const char *device, int flags)

+{
+enum AVHWDeviceType child_device_type;
+char adapter[256];
+int  adapter_num;
+
+if (CONFIG_VAAPI)
+child_device_type = AV_HWDEVICE_TYPE_VAAPI;
+else if (CONFIG_DXVA2)
+child_device_type = AV_HWDEVICE_TYPE_DXVA2;
+else
+return AVERROR(ENOSYS);
+
+if (device || CONFIG_DXVA2)
+return av_hwdevice_ctx_create(ctx, child_device_type, device, NULL, 
flags);
+
+for (adapter_num = 0; adapter_num < 6; adapter_num++) {
+if (adapter_num < 3)
+snprintf(adapter,sizeof(adapter),
+"/dev/dri/renderD%d", adapter_num+128);
+else
+snprintf(adapter,sizeof(adapter),
+"/dev/dri/card%d", adapter_num-3);

I would prefer not to open the DRM master device (/dev/dri/card*) by default - 
until very recent kernels it was exclusive-access-only, so nothing else can use 
the graphics at the same time (most obviously another ffmpeg instance).


+if (av_hwdevice_ctx_create(ctx, child_device_type, adapter, NULL, 
flags) == 0)
+return 0;
+}
+
+return AVERROR(ENOSYS);
+}
+
  static int qsv_device_create(AVHWDeviceContext *ctx, const char *device,
   AVDictionary *opts, int flags)
  {
  AVQSVDeviceContext *hwctx = ctx->hwctx;
  QSVDevicePriv *priv;
-enum AVHWDeviceType child_device_type;
  AVDictionaryEntry *e;
  
  mfxVersionver = { { 3, 1 } };

@@ -730,18 +759,7 @@ static int qsv_device_create(AVHWDeviceContext *ctx, const 
char *device,
  ctx->free= qsv_device_free;
  
  e = av_dict_get(opts, "child_device", NULL, 0);

-
-if (CONFIG_VAAPI)
-child_device_type = AV_HWDEVICE_TYPE_VAAPI;
-else if (CONFIG_DXVA2)
-child_device_type = AV_HWDEVICE_TYPE_DXVA2;
-else {
-av_log(ctx, AV_LOG_ERROR, "No supported child device type is 
enabled\n");
-return AVERROR(ENOSYS);
-}
-
-ret = av_hwdevice_ctx_create(&priv->child_device_ctx, child_device_type,
- e ? e->value : NULL, NULL, 0);
+ret = create_proper_child_device(&priv->child_device_ctx, e ? e->value : 
NULL, 0);
  if (ret < 0)
  return ret;
  
--

1.8.3.1


For your specific case in the ffmpeg utility it might be best to add a new command-line 
option (-qsv_device?) and then pass it as the "child_device" in the options 
dictionary?  I admit this isn't necessarily helpful for other users, but it would fix 
your command above without running into the other problems above.

Thanks,

- Mark

___
ffmpeg-devel mailing list
ffmpeg-devel