[FFmpeg-devel] [PATCH] webp: avoid trying to decode trailing junk in bitstreams

2019-09-03 Thread Pascal Massimino
Hi,

this patch break the decoding loop when invalid webp chunk is encountered.
We can still have a valid frame ready to be returned (*got_frame = 1).

fixes trac #8107 (/#7612)

skal/


0001-webp-fix-decoding-for-trailing-junk.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/2 v2] avformat/matroskadec: use av_fast_realloc to reallocate ebml list arrays

2019-09-03 Thread James Almer
On 9/4/2019 1:21 AM, Carl Eugen Hoyos wrote:
> 
> 
> Von meinem iPhone gesendet
> 
>> Am 04.09.2019 um 01:03 schrieb James Almer :
>>
>> Speeds up the process considerably.
>>
>> Fixes ticket #8109.
>>
>> Suggested-by: nevcairiel
>> Suggested-by: cehoyos
>> Signed-off-by: James Almer 
>> ---
>> libavformat/matroskadec.c | 12 ++--
>> 1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
>> index 439ee462a5..0f227eb33d 100644
>> --- a/libavformat/matroskadec.c
>> +++ b/libavformat/matroskadec.c
>> @@ -110,6 +110,7 @@ typedef const struct EbmlSyntax {
>>
>> typedef struct EbmlList {
>> int nb_elem;
>> +unsigned int alloc_elem_size;
>> void *elem;
>> } EbmlList;
>>
>> @@ -1236,8 +1237,14 @@ static int ebml_parse(MatroskaDemuxContext *matroska,
>> data = (char *) data + syntax->data_offset;
>> if (syntax->list_elem_size) {
>> EbmlList *list = data;
>> -void *newelem = av_realloc_array(list->elem, list->nb_elem + 1,
>> -   syntax->list_elem_size);
>> +void *newelem;
> 
>> +if ((unsigned)list->nb_elem + 1 >= UINT_MAX / 
>> syntax->list_elem_size)
>> +return AVERROR(ENOMEM);
> 
> I would have naively expected this to use INT_MAX.

The size parameter in av_fast_realloc() is unsigned int.
av_add_index_entry() does the exact same check.

> 
> And please reconsider backporting random fixes for issues that are not 
> regressions.

Despite not being a regression, the speed up from this fix on real world
files is considerable, so it's worth backporting to at least release/4.2.

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

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

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

Re: [FFmpeg-devel] [PATCH 2/2 v2] avformat/matroskadec: use av_fast_realloc to reallocate ebml list arrays

2019-09-03 Thread Carl Eugen Hoyos


Von meinem iPhone gesendet

> Am 04.09.2019 um 01:03 schrieb James Almer :
> 
> Speeds up the process considerably.
> 
> Fixes ticket #8109.
> 
> Suggested-by: nevcairiel
> Suggested-by: cehoyos
> Signed-off-by: James Almer 
> ---
> libavformat/matroskadec.c | 12 ++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 439ee462a5..0f227eb33d 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -110,6 +110,7 @@ typedef const struct EbmlSyntax {
> 
> typedef struct EbmlList {
> int nb_elem;
> +unsigned int alloc_elem_size;
> void *elem;
> } EbmlList;
> 
> @@ -1236,8 +1237,14 @@ static int ebml_parse(MatroskaDemuxContext *matroska,
> data = (char *) data + syntax->data_offset;
> if (syntax->list_elem_size) {
> EbmlList *list = data;
> -void *newelem = av_realloc_array(list->elem, list->nb_elem + 1,
> -   syntax->list_elem_size);
> +void *newelem;

> +if ((unsigned)list->nb_elem + 1 >= UINT_MAX / 
> syntax->list_elem_size)
> +return AVERROR(ENOMEM);

I would have naively expected this to use INT_MAX.

And please reconsider backporting random fixes for issues that are not 
regressions.

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

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

[FFmpeg-devel] blended telecine... possible?

2019-09-03 Thread Mark Filipak
No one has responded. What does that indicate? Lack of interest? Lack of 
knowledge? Lack of time? Shunning of anyone who's not a current developer?


Given:
i30-telecast =
[A][a][B][b][C][c][D][d][E][e]

And given:
p24 =
[A/a][B/b][C/c][D/d]
i30-telecine =
[A][a][B][b][B][c][C][d][D][d]
p30-telecine =
[A/a][B/b][B/c][C/d][D/d]

Can ffmpeg do the following?

p30-telecine-blend
[A/a][AB/b][BC/bc][C/cd][D/d]

If so, what lib & what args/parms?

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

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

Re: [FFmpeg-devel] [PATCH 2/2 v2] avformat/matroskadec: use av_fast_realloc to reallocate ebml list arrays

2019-09-03 Thread James Almer
On 9/3/2019 8:36 PM, Andreas Rheinhardt wrote:
> James Almer:
>> Speeds up the process considerably.
>>
>> Fixes ticket #8109.
>>
>> Suggested-by: nevcairiel
>> Suggested-by: cehoyos
>> Signed-off-by: James Almer 
>> ---
>>  libavformat/matroskadec.c | 12 ++--
>>  1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
>> index 439ee462a5..0f227eb33d 100644
>> --- a/libavformat/matroskadec.c
>> +++ b/libavformat/matroskadec.c
>> @@ -110,6 +110,7 @@ typedef const struct EbmlSyntax {
>>  
>>  typedef struct EbmlList {
>>  int nb_elem;
>> +unsigned int alloc_elem_size;
>>  void *elem;
>>  } EbmlList;
>>  
>> @@ -1236,8 +1237,14 @@ static int ebml_parse(MatroskaDemuxContext *matroska,
>>  data = (char *) data + syntax->data_offset;
>>  if (syntax->list_elem_size) {
>>  EbmlList *list = data;
>> -void *newelem = av_realloc_array(list->elem, list->nb_elem + 1,
>> -   syntax->list_elem_size);
>> +void *newelem;
>> +
>> +if ((unsigned)list->nb_elem + 1 >= UINT_MAX / 
>> syntax->list_elem_size)
>> +return AVERROR(ENOMEM);
>> +
>> +newelem = av_fast_realloc(list->elem,
>> +  >alloc_elem_size,
>> +  (list->nb_elem + 1) * 
>> syntax->list_elem_size);
> If this fails, list->alloc_elem_size will be zero, yet list->elem and
> list->nb_elem might be non NULL/zero. I actually think that this will
> probably work, but it is nevertheless ugly.

It should work.

I'll push this tomorrow if no one objects, then backport to supported
branches.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] avcodec/videotoolboxenc: fix encoding frame crash on iOS 11

2019-09-03 Thread Aman Gupta
On Mon, Aug 12, 2019 at 11:50 PM sharpbai  wrote:

> On iOS 11, encoding a frame may return error with log
> "Error encoding frame 0", which means vtenc_output_callback
> is called with status=0 and sample_buffer=NULL. Then the
> encoding session will be crashed on next callback wether or not
> closing the codec context.
>
> Let us look through the link below introducing VTCompressionOutputCallback,
>
>
> https://developer.apple.com/documentation/videotoolbox/vtcompressionoutputcallback?language=objc
>
> "status=0" (noErr) means compression was successful.
> "sampleBuffer=NULL" means the frame was dropped when compression
> was successful (status=0) or compression was not successful (status!=0).
>
> So we should not set AVERROR_EXTERNAL on "status=0" and
> "sample_buffer=NULL"
> as it is not a error.
>
> The fix is that we only set AVERROR_EXTERNAL with status value non zero.
> When sample_buffer is NULL and status value is zero, we simply return
> with no other operation.
>
> This crash often occurs on iOS 11 for example encoding 720p@25fps.
>

Is it fixed in iOS 12, or untested there?


>
> Signed-off-by: sharpbai 
> ---
>  libavcodec/videotoolboxenc.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index d76bb7f646..8afdd125d2 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -569,12 +569,16 @@ static void vtenc_output_callback(
>  return;
>  }
>
> -if (status || !sample_buffer) {
> +if (status) {
>  av_log(avctx, AV_LOG_ERROR, "Error encoding frame: %d\n",
> (int)status);
>  set_async_error(vtctx, AVERROR_EXTERNAL);
>  return;
>  }
>
> +if (!sample_buffer) {
> +return;
> +}
> +
>  if (!avctx->extradata && (avctx->flags &
> AV_CODEC_FLAG_GLOBAL_HEADER)) {
>  int set_status = set_extradata(avctx, sample_buffer);
>  if (set_status) {
> --
> 2.21.0
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/2 v2] avformat/matroskadec: use av_fast_realloc to reallocate ebml list arrays

2019-09-03 Thread Andreas Rheinhardt
James Almer:
> Speeds up the process considerably.
> 
> Fixes ticket #8109.
> 
> Suggested-by: nevcairiel
> Suggested-by: cehoyos
> Signed-off-by: James Almer 
> ---
>  libavformat/matroskadec.c | 12 ++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 439ee462a5..0f227eb33d 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -110,6 +110,7 @@ typedef const struct EbmlSyntax {
>  
>  typedef struct EbmlList {
>  int nb_elem;
> +unsigned int alloc_elem_size;
>  void *elem;
>  } EbmlList;
>  
> @@ -1236,8 +1237,14 @@ static int ebml_parse(MatroskaDemuxContext *matroska,
>  data = (char *) data + syntax->data_offset;
>  if (syntax->list_elem_size) {
>  EbmlList *list = data;
> -void *newelem = av_realloc_array(list->elem, list->nb_elem + 1,
> -   syntax->list_elem_size);
> +void *newelem;
> +
> +if ((unsigned)list->nb_elem + 1 >= UINT_MAX / 
> syntax->list_elem_size)
> +return AVERROR(ENOMEM);
> +
> +newelem = av_fast_realloc(list->elem,
> +  >alloc_elem_size,
> +  (list->nb_elem + 1) * 
> syntax->list_elem_size);
If this fails, list->alloc_elem_size will be zero, yet list->elem and
list->nb_elem might be non NULL/zero. I actually think that this will
probably work, but it is nevertheless ugly.

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

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

[FFmpeg-devel] [PATCH 2/2 v2] avformat/matroskadec: use av_fast_realloc to reallocate ebml list arrays

2019-09-03 Thread James Almer
Speeds up the process considerably.

Fixes ticket #8109.

Suggested-by: nevcairiel
Suggested-by: cehoyos
Signed-off-by: James Almer 
---
 libavformat/matroskadec.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 439ee462a5..0f227eb33d 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -110,6 +110,7 @@ typedef const struct EbmlSyntax {
 
 typedef struct EbmlList {
 int nb_elem;
+unsigned int alloc_elem_size;
 void *elem;
 } EbmlList;
 
@@ -1236,8 +1237,14 @@ static int ebml_parse(MatroskaDemuxContext *matroska,
 data = (char *) data + syntax->data_offset;
 if (syntax->list_elem_size) {
 EbmlList *list = data;
-void *newelem = av_realloc_array(list->elem, list->nb_elem + 1,
-   syntax->list_elem_size);
+void *newelem;
+
+if ((unsigned)list->nb_elem + 1 >= UINT_MAX / 
syntax->list_elem_size)
+return AVERROR(ENOMEM);
+
+newelem = av_fast_realloc(list->elem,
+  >alloc_elem_size,
+  (list->nb_elem + 1) * 
syntax->list_elem_size);
 if (!newelem)
 return AVERROR(ENOMEM);
 list->elem = newelem;
@@ -1490,6 +1497,7 @@ static void ebml_free(EbmlSyntax *syntax, void *data)
 ebml_free(syntax[i].def.n, ptr);
 av_freep(>elem);
 list->nb_elem = 0;
+list->alloc_elem_size = 0;
 } else
 ebml_free(syntax[i].def.n, data_off);
 default:
-- 
2.22.0

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

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

Re: [FFmpeg-devel] [PATCH 2/2] avformat/matroskadec: use av_fast_realloc to reallocate ebml list arrays

2019-09-03 Thread Carl Eugen Hoyos



> Am 03.09.2019 um 23:56 schrieb James Almer :
> 
> Speeds up the process considerably.
> 
> Fixes ticket #8109.
> 
> Suggested-by: nevcairiel
> Suggested-by: cehoyos
> Signed-off-by: James Almer 
> ---
> libavformat/matroskadec.c | 6 --
> 1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 439ee462a5..fe45c4fd7f 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -110,6 +110,7 @@ typedef const struct EbmlSyntax {
> 
> typedef struct EbmlList {
> int nb_elem;
> +unsigned int alloc_elem_size;
> void *elem;
> } EbmlList;
> 
> @@ -1236,8 +1237,9 @@ static int ebml_parse(MatroskaDemuxContext *matroska,
> data = (char *) data + syntax->data_offset;
> if (syntax->list_elem_size) {
> EbmlList *list = data;
> -void *newelem = av_realloc_array(list->elem, list->nb_elem + 1,
> -   syntax->list_elem_size);
> +void *newelem = av_fast_realloc(list->elem,
> +>alloc_elem_size,
> +(list->nb_elem + 1) * 
> syntax->list_elem_size);

Is it not necessary to check for an overflow of size * elem?

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

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

Re: [FFmpeg-devel] [PATCH v1 1/2] avfilter/vf_scale: split the scale_frame function from filter_frame for activate function support

2019-09-03 Thread Michael Niedermayer
On Sat, Jul 27, 2019 at 08:18:16PM +0800, lance.lmw...@gmail.com wrote:
> From: Limin Wang 
> 
> Signed-off-by: Limin Wang 
> ---
>  libavfilter/vf_scale.c | 29 +
>  1 file changed, 25 insertions(+), 4 deletions(-)

LGTM

thx

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

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


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

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

[FFmpeg-devel] [PATCH 2/2] avformat/matroskadec: use av_fast_realloc to reallocate ebml list arrays

2019-09-03 Thread James Almer
Speeds up the process considerably.

Fixes ticket #8109.

Suggested-by: nevcairiel
Suggested-by: cehoyos
Signed-off-by: James Almer 
---
 libavformat/matroskadec.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 439ee462a5..fe45c4fd7f 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -110,6 +110,7 @@ typedef const struct EbmlSyntax {
 
 typedef struct EbmlList {
 int nb_elem;
+unsigned int alloc_elem_size;
 void *elem;
 } EbmlList;
 
@@ -1236,8 +1237,9 @@ static int ebml_parse(MatroskaDemuxContext *matroska,
 data = (char *) data + syntax->data_offset;
 if (syntax->list_elem_size) {
 EbmlList *list = data;
-void *newelem = av_realloc_array(list->elem, list->nb_elem + 1,
-   syntax->list_elem_size);
+void *newelem = av_fast_realloc(list->elem,
+>alloc_elem_size,
+(list->nb_elem + 1) * 
syntax->list_elem_size);
 if (!newelem)
 return AVERROR(ENOMEM);
 list->elem = newelem;
-- 
2.22.0

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

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

[FFmpeg-devel] [PATCH 1/2] avformat/matroskadec: use proper types for some EbmlSyntax fields

2019-09-03 Thread James Almer
Signed-off-by: James Almer 
---
 libavformat/matroskadec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 1ea9b807e6..439ee462a5 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -97,8 +97,8 @@ typedef enum {
 typedef const struct EbmlSyntax {
 uint32_t id;
 EbmlType type;
-int list_elem_size;
-int data_offset;
+size_t list_elem_size;
+size_t data_offset;
 union {
 int64_t i;
 uint64_tu;
-- 
2.22.0

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

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

Re: [FFmpeg-devel] [PATCH] DVB EPG decoder

2019-09-03 Thread Marton Balint

Hi,

I am not sure if you are interested getting only patch 1, 2 and 3
merged, but if you are, then here are my comments for patch 3.


From 025ec8e8d607d02f2e5b4021783ab8f3b42d0bc1 Mon Sep 17 00:00:00 2001
From: Anthony Delannoy 
Date: Wed, 21 Aug 2019 11:46:56 +0200
Subject: [PATCH 03/10] lavf/mpegts: EPG extraction from mpegts

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

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 47d8d5f877..03c1753ac7 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2489,13 +2489,57 @@ static void pat_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 }
 }

+static void eit_cb(MpegTSFilter *filter, const uint8_t *section, int 
section_len)
+{
+MpegTSContext *ts = filter->u.section_filter.opaque;
+MpegTSSectionFilter *tssf = >u.section_filter;
+const uint8_t *p, *p_end;
+SectionHeader h1, *h = 
+int idx;
+AVProgram *prg;


Maybe you can check if AVStream->discard == DISCARD_ALL for the EIT stream and
skip the packet if the stream is discarded.


+
+p_end = section + section_len - 4;
+p = section;
+
+if (parse_section_header(h, , p_end) < 0)
+return;
+if (h->tid < EIT_TID || h->tid > OEITS_END_TID)
+return;



+if (ts->skip_changes)
+return;
+if (skip_identical(h, tssf))
+return;


I don't think these last two checks (skip changes and skip identical) makes
much sense here, just remove them.


+
+idx = ff_find_stream_index(ts->stream, filter->pid);
+if (idx < 0)
+return;


Instead of finding the stream each time, you should simply add an AVStream
*epg_stream to MpegTsContext, set it where you create the stream, and use that
always.


+
+/**
+ * In case we receive an EPG packet before mpegts context is fully
+ * initialized.
+ */
+if (!ts->pkt)
+return;
+
+new_data_packet(section, section_len, ts->pkt);
+ts->pkt->stream_index = idx;



+prg = av_find_program_from_stream(ts->stream, NULL, idx);
+if (prg && prg->pcr_pid != -1 && prg->discard != AVDISCARD_ALL) {
+MpegTSFilter *f = ts->pids[prg->pcr_pid];
+if (f && f->last_pcr != -1)
+ts->pkt->pts = ts->pkt->dts = f->last_pcr/300;
+}


This program based logic is no longer needed since EIT is not added to programs.


+ts->stop_parse = 1;
+}
+
 static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int 
section_len)
 {
 MpegTSContext *ts = filter->u.section_filter.opaque;
 MpegTSSectionFilter *tssf = >u.section_filter;
 SectionHeader h1, *h = 
 const uint8_t *p, *p_end, *desc_list_end, *desc_end;
-int onid, val, sid, desc_list_len, desc_tag, desc_len, service_type;
+int onid, val, sid, desc_list_len, desc_tag, desc_len, service_type,
+eit_sched, eit_pres_following;
 char *name, *provider_name;

 av_log(ts->stream, AV_LOG_TRACE, "SDT:\n");
@@ -2525,6 +2569,24 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 val = get8(, p_end);
 if (val < 0)
 break;
+eit_sched = (val >> 1) & 0x1;
+eit_pres_following = val & 0x1;
+
+if (eit_sched | eit_pres_following) {
+int idx = ff_find_stream_index(ts->stream, EIT_PID);
+AVStream *st = (idx >= 0) ? ts->stream->streams[EIT_PID] : NULL;


I guess ts->stream->streams[EIT_PID] wanted to be ts->stream->streams[idx] but
it does not matter because you should rework this if you add epg_stream to
MpegTsContext.


+
+if (!st) {
+st = avformat_new_stream(ts->stream, NULL);
+if (!st)
+return;
+st->id = EIT_PID;
+st->program_num = sid;
+st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+st->codecpar->codec_id = AV_CODEC_ID_EPG;
+}
+}
+
 desc_list_len = get16(, p_end);
 if (desc_list_len < 0)
 break;
@@ -2975,8 +3037,8 @@ static int mpegts_read_header(AVFormatContext *s)
 seek_back(s, pb, pos);

 mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1);
-
 mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);
+mpegts_open_section_filter(ts, EIT_PID, eit_cb, ts, 1);

 handle_packets(ts, probesize / ts->raw_packet_size);
 /* if could not find service, enable auto_guess */
@@ -3233,6 +3295,7 @@ MpegTSContext *avpriv_mpegts_parse_open(AVFormatContext 
*s)
 ts->auto_guess = 1;
 mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1);
 mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);
+mpegts_open_section_filter(ts, EIT_PID, eit_cb, ts, 1);

 return ts;
 }
--
2.23.0


Regards,
Marton
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

[FFmpeg-devel] blended telecine... possible? (revised)

2019-09-03 Thread Mark Filipak

Opps... Missed p30

Given:
i30-telecast =
[A][a][B][b][C][c][D][d][E][e]

And given:
p24 =
[A/a][B/b][C/c][D/d]
i30-telecine =
[A][a][B][b][B][c][C][d][D][d]
p30-telecine =
[A/a][B/b][B/c][C/d][D/d]

Can ffmpeg do this:
[A/a][AB/b][BC/bc][C/cd][D/d]
?

If so, what lib & what args/parms?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] blended telecine... possible?

2019-09-03 Thread Mark Filipak

Given:
i30-telecast =
[A][a][B][b][C][c][D][d][E][e]

And given:
p24 =
[A/a][B/b][C/c][D/d]
i30-telecine =
[A][a][B][b][B][c][C][d][D][d]

Can ffmpeg do this:
[A/a][AB/b][BC/bc][C/cd][D/d]
?

If so, what lib & what args/parms?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] libavcodec: add editpts bitstream filter [v4]

2019-09-03 Thread Marton Balint



On Tue, 3 Sep 2019, Andreas Håkon wrote:


Hi Marton,


‐‐‐ Original Message ‐‐‐
On Tuesday, 3 de September de 2019 9:57, Marton Balint  wrote:


On Tue, 3 Sep 2019, Andreas Håkon wrote:

> Hi,
> Ping, ping! (another time).
> Please take note of these three points:
>
> 1.  Lip-Syncing is a relevant topic in the AV editing area. Almost all 
professional video editors have
> the functionality to realign audio with video. And at time the ffmpeg 
project lacks for a lipsync
> bitstream filter. For this reason, this new filter is relevant. Although 
it can also be used for other purposes.
>
> 2.  This is the fourth iteration of the patch, and it incorporates all 
suggested requests. So it's ready
> for review and acceptance.
>
> 3.  Although the current implementation can be improved (using, for example, 
values expressed in
> nano-seconds), it's preferable to first add it and then improve it.
>

Some things can't be improved later, because they become part of the
public interface so we can no longer just remove them, we'd have to
deprecate them first.

Also ffmpeg tries to be consistent with other parts of the code, use names
based on the same logic, or use similar concepts throughout the libraries.

Avoiding duplicated functionality is also a strong requirement for us, if
something can be implemented in a more generic way (even if that takes a
little more work), we should aim for that.

That is why I suggest you implement a more generic approach, a setpts like
filter (setts) with evaluation. As others pointed out, you typically need
to modify both PTS and DTS, so the expression should affect both.
Additional parameters can be introduced if somebody wants different
expressions for PTS and DTS.


After looking at the "libavfilter/setpts.c" and the documentation I don't see 
what you want to copy from it.
The "expression" functionality can be useful, but the number of constants 
compatible with a bitstream filter
are very limited. From my point of view only some of them have sense: PTS and T 
in fact.


- PTS
- DTS
- STARTDTS
- TB - stream time base
- TS - when a single expression is used, TS is pts when pts is evaluated, 
TS is dts when dts is evaluated.




Any suggestion?
Perhaps you should describe the functionality of the "setpts_bsf" filter.


name is "setts".

options:
ts=
dts=
pts=

 is an expression to be evaluated. Either the ts expression or 
both pts and dts expressions are defined.


If only ts expression is defined then it is evaluated for both PTS and 
DTS.


If pts and dts expressions are defined, they are used instead of the 
common expression.


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

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

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/h264: fix draw_horiz_band with slice threads

2019-09-03 Thread Michael Niedermayer
On Mon, Sep 02, 2019 at 04:28:53PM +0200, James Darnley wrote:
> From: Kieran Kunhya 
> 
> ---
>  libavcodec/h264_slice.c | 29 +++--
>  1 file changed, 23 insertions(+), 6 deletions(-)

with this:
./ffmpeg -i Deep%20Blue.ts -t 1 -vsync 1 -bitexact -an -f framecrc -

output is different on each run
was the same before this patch

https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket697/Deep%2520Blue-short.ts

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

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


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

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

Re: [FFmpeg-devel] [PATCH] avformat/mpegts: check end of init before treating SCTE data

2019-09-03 Thread Marton Balint



On Tue, 3 Sep 2019, Anthony Delannoy wrote:


Hi

On some DVB stream ffprobe segfaulted, it was because of SCTE-35 data
packet reception
before the end of MpegTSContext initialization.

On this patch I check for `ts->pkt` availability before trying to
generate a new SCTE data
packet.



Thanks, applied.

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

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

Re: [FFmpeg-devel] [PATCH 3/5] avcodec: add max_samples

2019-09-03 Thread Nicolas George
James Almer (12019-09-03):
> I prefer a separate field. If the existing field was called in a more
> ambiguous way I'd be ok with reusing it, but not like this.

Same for me.

Regards,

-- 
  Nicolas George


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

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

Re: [FFmpeg-devel] [PATCH 3/5] avcodec: add max_samples

2019-09-03 Thread James Almer
On 9/3/2019 7:57 AM, Michael Niedermayer wrote:
> On Tue, Sep 03, 2019 at 09:20:52AM +0200, Paul B Mahol wrote:
>> NAK, you can use max_pixels for the same cause.
> 
> yes, we can, its poor design though audio samples are not
> pixels.
> 
> Anyone else has an opinion on this ?
> 
> Thanks

I prefer a separate field. If the existing field was called in a more
ambiguous way I'd be ok with reusing it, but not like this.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 5/5] avcodec/apedec: Check max_samples

2019-09-03 Thread James Almer
On 9/3/2019 8:13 AM, Michael Niedermayer wrote:
> On Mon, Sep 02, 2019 at 09:40:47PM -0300, James Almer wrote:
>> On 9/2/2019 9:14 PM, Michael Niedermayer wrote:
>>> Fixes: OOM
>>> Fixes: 
>>> 16627/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5638059583864832
>>>
>>> Found-by: continuous fuzzing process 
>>> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>>> Signed-off-by: Michael Niedermayer 
>>> ---
>>>  libavcodec/apedec.c | 3 +++
>>>  1 file changed, 3 insertions(+)
>>>
>>> diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
>>> index e218f7c043..774ce18531 100644
>>> --- a/libavcodec/apedec.c
>>> +++ b/libavcodec/apedec.c
>>> @@ -1475,6 +1475,9 @@ static int ape_decode_frame(AVCodecContext *avctx, 
>>> void *data,
>>>  return AVERROR_INVALIDDATA;
>>>  }
>>>  
>>> +if (nblocks * (int64_t)avctx->channels > avctx->max_samples)
>>> +return AVERROR(EINVAL);
>>> +
>>
>> Shouldn't this be checked in ff_get_buffer()? Same as max_pixels, but
>> checking "frame->nb_samples > avctx->max_samples" instead or
>> width/height. Otherwise it will barely be used.
> 
> you are correct, it should be checked in *get_buffer somewhere too.
> But the offending allocation occurs before any *get_buffer calls so
> this check here is what is neccessary and sufficient for this specific
> bug

If the allocation you're talking about is
https://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavcodec/apedec.c;h=490b11b94e0b1666f18248b2b247c874fed6e0bc;hb=HEAD#l1500
then you could just move it (and the five lines that follow it) right
below the ff_get_buffer() call.

But it should be ok either way.

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

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

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

Re: [FFmpeg-devel] [PATCH/RFC] libavcodec/cinepak: Separate decoding from parsing

2019-09-03 Thread Tomas Härdin
tis 2019-09-03 klockan 13:53 +0200 skrev Michael Niedermayer:
> On Sun, Sep 01, 2019 at 10:58:27PM +0200, Tomas Härdin wrote:
> >  libavcodec/cinepak.c|  337 ---
> > -
> >  tests/ref/fate/cvid-palette |1 
> >  tests/ref/fate/cvid-partial |1 
> >  3 files changed, 215 insertions(+), 124 deletions(-)
> > 197f986bfb297c54ee0f208449d4053fcb948645  0001-libavcodec-cinepak-
> > Separate-decoding-from-parsing.patch
> > From d4bda2edbecb93fa5c5910b8b91a866210368a95 Mon Sep 17 00:00:00
> > 2001
> > From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
> > Date: Sun, 1 Sep 2019 15:37:13 +0200
> > Subject: [PATCH] libavcodec/cinepak: Separate decoding from parsing
> > 
> > This is rather strict and replaces the previous hacks with checks
> > that should hopefully placate the fuzzers for the forseeable future
> > ---
> >  libavcodec/cinepak.c| 337 +++-
> > 
> >  tests/ref/fate/cvid-palette |   1 -
> >  tests/ref/fate/cvid-partial |   1 -
> >  3 files changed, 215 insertions(+), 124 deletions(-)
> 
> this does not seem to apply automatically here

Oops, forgot to squash WIP commits into a single patch. Squashed,
rebased and tested patch attached. Moved some functions around and used
format-patch --patience to make the diff smaller. And again, it's still
preliminary as I want feedback before going any further

/Tomas
From bfc4fb532b340d62eb4cd1db5d4b93a273f95b6c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
Date: Sun, 18 Aug 2019 17:42:27 +0200
Subject: [PATCH] libavcodec/cinepak: Separate decoding from parsing

This is rather strict and replaces the previous hacks with checks that should hopefully placate the fuzzers for the forseeable future
---
 libavcodec/cinepak.c| 268 +---
 tests/ref/fate/cvid-palette |   1 -
 tests/ref/fate/cvid-partial |   1 -
 3 files changed, 191 insertions(+), 79 deletions(-)

diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c
index aeb15de0ed..03cbb1777a 100644
--- a/libavcodec/cinepak.c
+++ b/libavcodec/cinepak.c
@@ -46,6 +46,8 @@
 typedef uint8_t cvid_codebook[12];
 
 #define MAX_STRIPS  32
+#define MAX_HEIGHT  UINT16_MAX
+#define MB_AREA 16
 
 typedef struct cvid_strip {
 uint16_t  id;
@@ -53,6 +55,8 @@ typedef struct cvid_strip {
 uint16_t  x2, y2;
 cvid_codebook v4_codebook[256];
 cvid_codebook v1_codebook[256];
+const uint8_t *data;// points to strip data, excluding header
+int   size;
 } cvid_strip;
 
 typedef struct CinepakContext {
@@ -60,9 +64,6 @@ typedef struct CinepakContext {
 AVCodecContext *avctx;
 AVFrame *frame;
 
-const unsigned char *data;
-int size;
-
 int width, height;
 
 int palette_video;
@@ -71,6 +72,10 @@ typedef struct CinepakContext {
 int sega_film_skip_bytes;
 
 uint32_t pal[256];
+
+int frame_flags;
+int num_strips;
+uint8_t strip_cover[MAX_HEIGHT];
 } CinepakContext;
 
 static void cinepak_decode_codebook (cvid_codebook *codebook,
@@ -269,12 +274,6 @@ static int cinepak_decode_strip (CinepakContext *s,
 const uint8_t *eod = (data + size);
 int  chunk_id, chunk_size;
 
-/* coordinate sanity checks */
-if (strip->x2 > s->width   ||
-strip->y2 > s->height  ||
-strip->x1 >= strip->x2 || strip->y1 >= strip->y2)
-return AVERROR_INVALIDDATA;
-
 while ((data + 4) <= eod) {
 chunk_id   = data[0];
 chunk_size = AV_RB24 ([1]) - 4;
@@ -315,16 +314,20 @@ static int cinepak_decode_strip (CinepakContext *s,
 return AVERROR_INVALIDDATA;
 }
 
-static int cinepak_predecode_check (CinepakContext *s)
+static int cinepak_parse_header(AVCodecContext *avctx, const AVPacket *avpkt)
 {
-int   num_strips;
-int   encoded_buf_size;
-
-num_strips  = AV_RB16 (>data[8]);
-encoded_buf_size = AV_RB24(>data[1]);
+CinepakContext *s = avctx->priv_data;
+int w, h, encoded_buf_size;
 
-if (s->size < encoded_buf_size * (int64_t)(100 - s->avctx->discard_damaged_percentage) / 100)
+if (avpkt->size < 10) {
 return AVERROR_INVALIDDATA;
+}
+
+s->frame_flags   = avpkt->data[0];
+encoded_buf_size = AV_RB24(>data[1]);
+w= AV_RB16(>data[4]);
+h= AV_RB16(>data[6]);
+s->num_strips= AV_RB16(>data[8]);
 
 /* if this is the first frame, check for deviant Sega FILM data */
 if (s->sega_film_skip_bytes == -1) {
@@ -332,20 +335,20 @@ static int cinepak_predecode_check (CinepakContext *s)
 avpriv_request_sample(s->avctx, "encoded_buf_size 0");
 return AVERROR_PATCHWELCOME;
 }
-if (encoded_buf_size != s->size && (s->size % encoded_buf_size) != 0) {
+if (encoded_buf_size != avpkt->size && (avpkt->size % encoded_buf_size) != 0) {
 /* If the encoded frame size differs from the frame size as indicated
   

Re: [FFmpeg-devel] [PATCH 3/5] avcodec: add max_samples

2019-09-03 Thread Tomas Härdin
tis 2019-09-03 klockan 13:10 +0200 skrev Michael Niedermayer:
> On Tue, Sep 03, 2019 at 12:21:26PM +0200, Tomas Härdin wrote:
> > tis 2019-09-03 klockan 09:20 +0200 skrev Paul B Mahol:
> > > On 9/3/19, Michael Niedermayer  wrote:
> > > > TODO: APIChanges, bump version
> > > > 
> > > > Signed-off-by: Michael Niedermayer 
> > > > ---
> > > >  libavcodec/avcodec.h | 8 
> > > >  libavcodec/options_table.h   | 1 +
> > > >  tests/ref/fate/api-mjpeg-codec-param | 2 ++
> > > >  tests/ref/fate/api-png-codec-param   | 2 ++
> > > >  4 files changed, 13 insertions(+)
> > > > 
> > > > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > > > index de4feb6a65..4b771a6ae6 100644
> > > > --- a/libavcodec/avcodec.h
> > > > +++ b/libavcodec/avcodec.h
> > > > @@ -3371,6 +3371,14 @@ typedef struct AVCodecContext {
> > > >   * - encoding: unused
> > > >   */
> > > >  int discard_damaged_percentage;
> > > > +
> > > > +/**
> > > > + * The number of samples per frame to maximally accept.
> > > > + *
> > > > + * - decoding: set by user
> > > > + * - encoding: set by user
> > > > + */
> > > > +int64_t max_samples;
> > > >  } AVCodecContext;
> > > 
> > > NAK, you can use max_pixels for the same cause.
> > 
> > Or the other way around. Has max_pixels made it to an official release
> > yet? 
> 
> max_pixels is in AVCodecContext since 3.3
> 
> but even if it wasnt. while no question max_samples would be a much
> better name for a unified field than max_pixels.
> 
> We do not unify other related fields like
> width & height with for example nb_samples and channels
> 
> There is also a semantic difference between max_pixels and max_samples
> 
> the max_pixels are the samples at one instance of time
> while max_samples cover a period of time depending on the duration of a packet

This is a good point. max_pixels as applied to audio would then mean
maximum number of channels.

I still think putting audio and video stuff in the same struct is a bit
of a mistake, for just this reason

/Tomas

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

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

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/apedec: Fix 32bit int overflow in do_apply_filter()

2019-09-03 Thread Tomas Härdin
tis 2019-09-03 klockan 13:25 +0200 skrev Michael Niedermayer:
> On Tue, Sep 03, 2019 at 12:16:47PM +0200, Tomas Härdin wrote:
> > tis 2019-09-03 klockan 02:14 +0200 skrev Michael Niedermayer:
> > > Fixes: signed integer overflow: 2147480546 + 4096 cannot be represented 
> > > in type 'int'
> > > Fixes: 
> > > 16280/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5123442566758400
> > > 
> > > Found-by: continuous fuzzing process 
> > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > > Signed-off-by: Michael Niedermayer 
> > > ---
> > >  libavcodec/apedec.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
> > > index 490b11b94e..ed22f0f019 100644
> > > --- a/libavcodec/apedec.c
> > > +++ b/libavcodec/apedec.c
> > > @@ -1266,7 +1266,7 @@ static void do_apply_filter(APEContext *ctx, int 
> > > version, APEFilter *f,
> > >   f->delay - order,
> > >   f->adaptcoeffs - 
> > > order,
> > >   order, 
> > > APESIGN(*data));
> > > -res = (res + (1 << (fracbits - 1))) >> fracbits;
> > > +res = (int)(res + (1U << (fracbits - 1))) >> fracbits;
> > 
> > Does this mean the old code was decoding incorrectly, or is this just
> > an UB fix? (fixing UBs is good of course)
> 
> it is just a UB fix.
> If iam not misreading the reference source then it has the same UB in it
> so there is no correct way in case this ever triggers on a real file.
> 
> The specific patch here was done so that the result should hopefully
> match what a common machine with 32bit int (most platforms) would
> likely produce.

Right, and the cast back to int is required for proper sign extension
in the >> fracbits. Looks OK to me then. Kind of a weird codec feature
IMO

/Tomas

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

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

[FFmpeg-devel] [PATCH] avformat/mpegts: check end of init before treating SCTE data

2019-09-03 Thread Anthony Delannoy
Hi

On some DVB stream ffprobe segfaulted, it was because of SCTE-35 data
packet reception
before the end of MpegTSContext initialization.

On this patch I check for `ts->pkt` availability before trying to
generate a new SCTE data
packet.

Anthony Delannoy
From 6dd92519ce5f7c85ca35c7227d35ff49fa6de3ef Mon Sep 17 00:00:00 2001
From: Anthony Delannoy 
Date: Tue, 3 Sep 2019 17:54:24 +0200
Subject: [PATCH] avformat/mpegts: Check if ready on SCTE reception

On some DVB stream SCTE-35 data packet are available before the end of
MpegTSContext initialization. We have to check if it is the case to
avoid a SEGFAULT.
---
 libavformat/mpegts.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 58902527c5..0415ceea02 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -1725,6 +1725,13 @@ static void scte_data_cb(MpegTSFilter *filter, const uint8_t *section,
 if (idx < 0)
 return;
 
+/**
+ * In case we receive an SCTE-35 packet before mpegts context is fully
+ * initialized.
+ */
+if (!ts->pkt)
+return;
+
 new_data_packet(section, section_len, ts->pkt);
 ts->pkt->stream_index = idx;
 prg = av_find_program_from_stream(ts->stream, NULL, idx);
-- 
2.23.0

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

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

Re: [FFmpeg-devel] [PATCH v2 2/2] avformat/hlsenc: avformat/hlsenc: reopen new http session for http_persistent

2019-09-03 Thread Steven Liu


> 在 2019年9月3日,22:30,Ian Klassen  写道:
> 
> On Thu, Aug 29, 2019 at 6:15 PM Steven Liu  wrote:
> 
>> fix ticket: 7975
>> 
>> Signed-off-by: Steven Liu 
>> ---
>> libavformat/hlsenc.c | 66
>> +++-
>> 1 file changed, 55 insertions(+), 11 deletions(-)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index c6bd664b92..d9b48f0e7c 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -118,6 +118,7 @@ typedef struct VariantStream {
>> AVIOContext *out;
>> int packets_written;
>> int init_range_length;
>> +uint8_t *temp_buffer;
>> 
>> AVFormatContext *avf;
>> AVFormatContext *vtt_avf;
>> @@ -262,11 +263,12 @@ static int hlsenc_io_open(AVFormatContext *s,
>> AVIOContext **pb, char *filename,
>> return err;
>> }
>> 
>> -static void hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char
>> *filename) {
>> +static int hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char
>> *filename) {
>> HLSContext *hls = s->priv_data;
>> int http_base_proto = filename ? ff_is_http_proto(filename) : 0;
>> +int ret = 0;
>> if (!*pb)
>> -return;
>> +return ret;
>> if (!http_base_proto || !hls->http_persistent || hls->key_info_file
>> || hls->encrypt) {
>> ff_format_io_close(s, pb);
>> #if CONFIG_HTTP_PROTOCOL
>> @@ -275,8 +277,10 @@ static void hlsenc_io_close(AVFormatContext *s,
>> AVIOContext **pb, char *filename
>> av_assert0(http_url_context);
>> avio_flush(*pb);
>> ffurl_shutdown(http_url_context, AVIO_FLAG_WRITE);
>> +ret = ff_http_get_shutdown_status(http_url_context);
>> #endif
>> }
>> +return ret;
>> }
>> 
>> static void set_http_options(AVFormatContext *s, AVDictionary **options,
>> HLSContext *c)
>> @@ -447,7 +451,6 @@ static void write_styp(AVIOContext *pb)
>> static int flush_dynbuf(VariantStream *vs, int *range_length)
>> {
>> AVFormatContext *ctx = vs->avf;
>> -uint8_t *buffer;
>> 
>> if (!ctx->pb) {
>> return AVERROR(EINVAL);
>> @@ -458,15 +461,20 @@ static int flush_dynbuf(VariantStream *vs, int
>> *range_length)
>> avio_flush(ctx->pb);
>> 
>> // write out to file
>> -*range_length = avio_close_dyn_buf(ctx->pb, );
>> +*range_length = avio_close_dyn_buf(ctx->pb, >temp_buffer);
>> ctx->pb = NULL;
>> -avio_write(vs->out, buffer, *range_length);
>> -av_free(buffer);
>> +avio_write(vs->out, vs->temp_buffer, *range_length);
>> 
>> // re-open buffer
>> return avio_open_dyn_buf(>pb);
>> }
>> 
>> +static void reflush_dynbuf(VariantStream *vs, int *range_length)
>> +{
>> +// re-open buffer
>> +avio_write(vs->out, vs->temp_buffer, *range_length);;
>> +}
>> +
>> static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
>>VariantStream *vs) {
>> 
>> @@ -1544,7 +1552,10 @@ static int hls_window(AVFormatContext *s, int last,
>> VariantStream *vs)
>> 
>> fail:
>> av_dict_free();
>> -hlsenc_io_close(s, (byterange_mode || hls->segment_type ==
>> SEGMENT_TYPE_FMP4) ? >m3u8_out : >out, temp_filename);
>> +ret = hlsenc_io_close(s, (byterange_mode || hls->segment_type ==
>> SEGMENT_TYPE_FMP4) ? >m3u8_out : >out, temp_filename);
>> +if (ret < 0) {
>> +return ret;
>> +}
>> hlsenc_io_close(s, >sub_m3u8_out, vs->vtt_m3u8_name);
>> if (use_temp_file) {
>> ff_rename(temp_filename, vs->m3u8_name, s);
>> @@ -2399,7 +2410,16 @@ static int hls_write_packet(AVFormatContext *s,
>> AVPacket *pkt)
>> if (ret < 0) {
>> return ret;
>> }
>> -hlsenc_io_close(s, >out, filename);
>> +ret = hlsenc_io_close(s, >out, filename);
>> +if (ret < 0) {
>> +av_log(s, AV_LOG_WARNING, "upload segment failed,"
>> +   "and will retry upload by a new http
>> session.\n");
>> +ff_format_io_close(s, >out);
>> +ret = hlsenc_io_open(s, >out, filename, );
>> +reflush_dynbuf(vs, _length);
>> +ret = hlsenc_io_close(s, >out, filename);
>> +}
>> +av_free(vs->temp_buffer);
>> av_free(filename);
>> }
>> }
>> @@ -2426,8 +2446,13 @@ static int hls_write_packet(AVFormatContext *s,
>> AVPacket *pkt)
>> // if we're building a VOD playlist, skip writing the manifest
>> multiple times, and just wait until the end
>> if (hls->pl_type != PLAYLIST_TYPE_VOD) {
>> if ((ret = hls_window(s, 0, vs)) < 0) {
>> -av_free(old_filename);
>> -return ret;
>> +av_log(s, AV_LOG_WARNING, "update playlist failed, will
>> retry once time\n");
>> +ff_format_io_close(s, >out);
>> +vs->out = NULL;
>> +if ((ret = hls_window(s, 0, vs)) < 0) {
>> 

Re: [FFmpeg-devel] [PATCH 3/4] avformat/hashenc: add option to create hash per stream

2019-09-03 Thread Paul B Mahol
I think better thing to do is to add streamhash muxer instead of doing
it in hash muxer.

On 8/11/19, Moritz Barsnick  wrote:
> Non-frame based muxers only, the frame based ones are already per
> stream.
>
> Signed-off-by: Moritz Barsnick 
> ---
>  doc/muxers.texi   |  5 +
>  libavformat/hashenc.c | 41 +
>  2 files changed, 34 insertions(+), 12 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index bc38cf6029..34ca7f07cb 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -511,6 +511,11 @@ Supported values include @code{MD5}, @code{murmur3},
> @code{RIPEMD128},
>  @code{SHA224}, @code{SHA256} (default), @code{SHA512/224},
> @code{SHA512/256},
>  @code{SHA384}, @code{SHA512}, @code{CRC32} and @code{adler32}.
>
> +@item per_stream @var{bool}
> +Whether to calculate a hash per stream, instead of combined over all
> +packets' payload. Each stream's hash is prefixed with its stream index.
> +Default is @code{false}.
> +
>  @end table
>
>  @subsection Examples
> diff --git a/libavformat/hashenc.c b/libavformat/hashenc.c
> index 96e00f580c..394b8a0fce 100644
> --- a/libavformat/hashenc.c
> +++ b/libavformat/hashenc.c
> @@ -31,6 +31,7 @@ struct HashContext {
>  const AVClass *avclass;
>  struct AVHashContext **hashes;
>  char *hash_name;
> +int per_stream;
>  int format_version;
>  };
>
> @@ -40,10 +41,13 @@ struct HashContext {
>  { "hash", "set hash to use", OFFSET(hash_name), AV_OPT_TYPE_STRING,
> {.str = defaulttype}, 0, 0, ENC }
>  #define FORMAT_VERSION_OPT \
>  { "format_version", "file format version", OFFSET(format_version),
> AV_OPT_TYPE_INT, {.i64 = 2}, 1, 2, ENC }
> +#define PER_STREAM_OPT \
> +{ "per_stream", "whether to calculate a hash per stream",
> OFFSET(per_stream), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, ENC }
>
>  #if CONFIG_HASH_MUXER
>  static const AVOption hash_options[] = {
>  HASH_OPT("sha256"),
> +PER_STREAM_OPT,
>  { NULL },
>  };
>  #endif
> @@ -59,6 +63,7 @@ static const AVOption framehash_options[] = {
>  #if CONFIG_MD5_MUXER
>  static const AVOption md5_options[] = {
>  HASH_OPT("md5"),
> +PER_STREAM_OPT,
>  { NULL },
>  };
>  #endif
> @@ -74,39 +79,51 @@ static const AVOption framemd5_options[] = {
>  #if CONFIG_HASH_MUXER || CONFIG_MD5_MUXER
>  static int hash_write_header(struct AVFormatContext *s)
>  {
> -int res;
> +int i, res;
>  struct HashContext *c = s->priv_data;
> -c->hashes = av_malloc_array(1, sizeof(c->hashes));
> +int num_hashes = c->per_stream ? s->nb_streams : 1;
> +c->hashes = av_malloc_array(num_hashes, sizeof(c->hashes));
>  if (!c->hashes)
>  return AVERROR(ENOMEM);
> -res = av_hash_alloc(>hashes[0], c->hash_name);
> -if (res < 0) {
> -av_freep(>hashes);
> -return res;
> +for (i = 0; i < num_hashes; i++) {
> +res = av_hash_alloc(>hashes[i], c->hash_name);
> +if (res < 0)
> +goto err;
> +av_hash_init(c->hashes[i]);
>  }
> -av_hash_init(c->hashes[0]);
>  return 0;
> +err:
> +for (int j = 0; j < i; j++)
> +av_hash_freep(>hashes[j]);
> +av_freep(>hashes);
> +return res;
>  }
>
>  static int hash_write_packet(struct AVFormatContext *s, AVPacket *pkt)
>  {
>  struct HashContext *c = s->priv_data;
> -av_hash_update(c->hashes[0], pkt->data, pkt->size);
> +av_hash_update(c->hashes[c->per_stream ? pkt->stream_index : 0],
> pkt->data, pkt->size);
>  return 0;
>  }
>
>  static int hash_write_trailer(struct AVFormatContext *s)
>  {
>  struct HashContext *c = s->priv_data;
> +int num_hashes = c->per_stream ? s->nb_streams : 1;
> +for (int i = 0; i < num_hashes; i++) {
>  char buf[AV_HASH_MAX_SIZE*2+128];
> -snprintf(buf, sizeof(buf) - 200, "%s=",
> av_hash_get_name(c->hashes[0]));
> -
> -av_hash_final_hex(c->hashes[0], buf + strlen(buf), sizeof(buf) -
> strlen(buf));
> +if (c->per_stream) {
> +snprintf(buf, sizeof(buf) - 200, "%d,%s=", i,
> av_hash_get_name(c->hashes[i]));
> +} else {
> +snprintf(buf, sizeof(buf) - 200, "%s=",
> av_hash_get_name(c->hashes[i]));
> +}
> +av_hash_final_hex(c->hashes[i], buf + strlen(buf), sizeof(buf) -
> strlen(buf));
>  av_strlcatf(buf, sizeof(buf), "\n");
>  avio_write(s->pb, buf, strlen(buf));
>  avio_flush(s->pb);
>
> -av_hash_freep(>hashes[0]);
> +av_hash_freep(>hashes[i]);
> +}
>  av_freep(>hashes);
>  return 0;
>  }
> --
> 2.20.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email

Re: [FFmpeg-devel] [PATCH v2 2/2] avformat/hlsenc: avformat/hlsenc: reopen new http session for http_persistent

2019-09-03 Thread Ian Klassen
On Thu, Aug 29, 2019 at 6:15 PM Steven Liu  wrote:

> fix ticket: 7975
>
> Signed-off-by: Steven Liu 
> ---
>  libavformat/hlsenc.c | 66
> +++-
>  1 file changed, 55 insertions(+), 11 deletions(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index c6bd664b92..d9b48f0e7c 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -118,6 +118,7 @@ typedef struct VariantStream {
>  AVIOContext *out;
>  int packets_written;
>  int init_range_length;
> +uint8_t *temp_buffer;
>
>  AVFormatContext *avf;
>  AVFormatContext *vtt_avf;
> @@ -262,11 +263,12 @@ static int hlsenc_io_open(AVFormatContext *s,
> AVIOContext **pb, char *filename,
>  return err;
>  }
>
> -static void hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char
> *filename) {
> +static int hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char
> *filename) {
>  HLSContext *hls = s->priv_data;
>  int http_base_proto = filename ? ff_is_http_proto(filename) : 0;
> +int ret = 0;
>  if (!*pb)
> -return;
> +return ret;
>  if (!http_base_proto || !hls->http_persistent || hls->key_info_file
> || hls->encrypt) {
>  ff_format_io_close(s, pb);
>  #if CONFIG_HTTP_PROTOCOL
> @@ -275,8 +277,10 @@ static void hlsenc_io_close(AVFormatContext *s,
> AVIOContext **pb, char *filename
>  av_assert0(http_url_context);
>  avio_flush(*pb);
>  ffurl_shutdown(http_url_context, AVIO_FLAG_WRITE);
> +ret = ff_http_get_shutdown_status(http_url_context);
>  #endif
>  }
> +return ret;
>  }
>
>  static void set_http_options(AVFormatContext *s, AVDictionary **options,
> HLSContext *c)
> @@ -447,7 +451,6 @@ static void write_styp(AVIOContext *pb)
>  static int flush_dynbuf(VariantStream *vs, int *range_length)
>  {
>  AVFormatContext *ctx = vs->avf;
> -uint8_t *buffer;
>
>  if (!ctx->pb) {
>  return AVERROR(EINVAL);
> @@ -458,15 +461,20 @@ static int flush_dynbuf(VariantStream *vs, int
> *range_length)
>  avio_flush(ctx->pb);
>
>  // write out to file
> -*range_length = avio_close_dyn_buf(ctx->pb, );
> +*range_length = avio_close_dyn_buf(ctx->pb, >temp_buffer);
>  ctx->pb = NULL;
> -avio_write(vs->out, buffer, *range_length);
> -av_free(buffer);
> +avio_write(vs->out, vs->temp_buffer, *range_length);
>
>  // re-open buffer
>  return avio_open_dyn_buf(>pb);
>  }
>
> +static void reflush_dynbuf(VariantStream *vs, int *range_length)
> +{
> +// re-open buffer
> +avio_write(vs->out, vs->temp_buffer, *range_length);;
> +}
> +
>  static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
> VariantStream *vs) {
>
> @@ -1544,7 +1552,10 @@ static int hls_window(AVFormatContext *s, int last,
> VariantStream *vs)
>
>  fail:
>  av_dict_free();
> -hlsenc_io_close(s, (byterange_mode || hls->segment_type ==
> SEGMENT_TYPE_FMP4) ? >m3u8_out : >out, temp_filename);
> +ret = hlsenc_io_close(s, (byterange_mode || hls->segment_type ==
> SEGMENT_TYPE_FMP4) ? >m3u8_out : >out, temp_filename);
> +if (ret < 0) {
> +return ret;
> +}
>  hlsenc_io_close(s, >sub_m3u8_out, vs->vtt_m3u8_name);
>  if (use_temp_file) {
>  ff_rename(temp_filename, vs->m3u8_name, s);
> @@ -2399,7 +2410,16 @@ static int hls_write_packet(AVFormatContext *s,
> AVPacket *pkt)
>  if (ret < 0) {
>  return ret;
>  }
> -hlsenc_io_close(s, >out, filename);
> +ret = hlsenc_io_close(s, >out, filename);
> +if (ret < 0) {
> +av_log(s, AV_LOG_WARNING, "upload segment failed,"
> +   "and will retry upload by a new http
> session.\n");
> +ff_format_io_close(s, >out);
> +ret = hlsenc_io_open(s, >out, filename, );
> +reflush_dynbuf(vs, _length);
> +ret = hlsenc_io_close(s, >out, filename);
> +}
> +av_free(vs->temp_buffer);
>  av_free(filename);
>  }
>  }
> @@ -2426,8 +2446,13 @@ static int hls_write_packet(AVFormatContext *s,
> AVPacket *pkt)
>  // if we're building a VOD playlist, skip writing the manifest
> multiple times, and just wait until the end
>  if (hls->pl_type != PLAYLIST_TYPE_VOD) {
>  if ((ret = hls_window(s, 0, vs)) < 0) {
> -av_free(old_filename);
> -return ret;
> +av_log(s, AV_LOG_WARNING, "update playlist failed, will
> retry once time\n");
> +ff_format_io_close(s, >out);
> +vs->out = NULL;
> +if ((ret = hls_window(s, 0, vs)) < 0) {
> +av_free(old_filename);
> +return ret;
> +}
>  }
>  }
>
> @@ 

Re: [FFmpeg-devel] [PATCH] tools/target_dec_fuzzer: add support to fuzz bitstream filters

2019-09-03 Thread James Almer
On 8/30/2019 1:39 PM, James Almer wrote:
> Signed-off-by: James Almer 
> ---
> Untested. I'm also not sure how to add the FFMPEG_BSF define to 
> tools/Makefile,
> and have it coexist with FFMPEG_DECODER. Assuming it's needed.
> 
>  tools/target_dec_fuzzer.c | 43 +++
>  1 file changed, 43 insertions(+)
> 
> diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
> index 0d10503cfb..b8fe1f2aa1 100644
> --- a/tools/target_dec_fuzzer.c
> +++ b/tools/target_dec_fuzzer.c
> @@ -65,6 +65,8 @@ static void error(const char *err)
>  }
>  
>  static AVCodec *c = NULL;
> +static AVBitStreamFilter *f = NULL;
> +
>  static AVCodec *AVCodecInitialize(enum AVCodecID codec_id)
>  {
>  AVCodec *res;
> @@ -102,6 +104,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
> size) {
>int *got_picture_ptr,
>const AVPacket *avpkt) = NULL;
>  AVCodecParserContext *parser = NULL;
> +AVBSFContext *bsf = NULL;
>  
>  
>  if (!c) {
> @@ -120,6 +123,27 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
> size) {
>  av_log_set_level(AV_LOG_PANIC);
>  }
>  
> +if (!f) {
> +#ifdef FFMPEG_BSF
> +#define BSF_SYMBOL0(BSF) ff_##BSF##_bsf
> +#define BSF_SYMBOL(BSF) BSF_SYMBOL0(BSF)
> +extern AVBitStreamFilter BSF_SYMBOL(FFMPEG_BSF);
> +f = _SYMBOL(FFMPEG_BSF);
> +
> +if (f->codec_ids) {
> +const enum AVCodecID *ids;
> +for (ids = f->codec_ids; *ids != AV_CODEC_ID_NONE; ids++)
> +if (*ids == c->id)
> +break;
> +if (ids == AV_CODEC_ID_NONE)
> +error("Invalid bsf");
> +}
> +#else
> +extern AVBitStreamFilter ff_null_bsf;
> +f = _null_bsf;
> +#endif
> +}
> +
>  switch (c->type) {
>  case AVMEDIA_TYPE_AUDIO   : decode_handler = avcodec_decode_audio4; 
> break;
>  case AVMEDIA_TYPE_VIDEO   : decode_handler = avcodec_decode_video2; 
> break;
> @@ -181,6 +205,18 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
> size) {
>  }
>  parser_avctx->codec_id = ctx->codec_id;
>  
> +res = av_bsf_alloc(f, );
> +if (res < 0)
> +error("Failed memory allocation");
> +
> +res = avcodec_parameters_from_context(bsf->par_in, ctx);
> +if (res < 0)
> +error("Failed memory allocation");
> +
> +res = av_bsf_init(bsf);
> +if (res < 0)
> +return 0; // Failure of av_bsf_init() does not imply that a issue 
> was found
> +
>  int got_frame;
>  AVFrame *frame = av_frame_alloc();
>  if (!frame)
> @@ -237,6 +273,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
> size) {
>  }
>  
>// Iterate through all data
> +  res = av_bsf_send_packet(bsf, );
> +  while (res >= 0) {
> +res = av_bsf_receive_packet(bsf, );
> +if (res < 0)
> +break;
>while (avpkt.size > 0 && it++ < maxiteration) {
>  av_frame_unref(frame);
>  int ret = decode_handler(ctx, frame, _frame, );
> @@ -255,6 +296,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
> size) {
>  avpkt.size -= ret;
>}
>av_packet_unref();
> +  }
>  }
>  av_packet_unref();
>  }
> @@ -270,6 +312,7 @@ maximums_reached:
>  
>  fprintf(stderr, "pixels decoded: %"PRId64", iterations: %d\n", 
> ec_pixels, it);
>  
> +av_bsf_free();
>  av_frame_free();
>  avcodec_free_context();
>  avcodec_free_context(_avctx);

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

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

Re: [FFmpeg-devel] [PATCH] avcodec/decode: add a flags parameter to ff_reget_buffer()

2019-09-03 Thread James Almer
On 8/31/2019 12:22 PM, James Almer wrote:
> Some decoders may not need a writable buffer in some specific cases, but only
> a reference to the existing buffer with updated frame properties instead, for
> the purpose of returning duplicate frames. For this, the
> FF_REGET_BUFFER_FLAG_READONLY flag is added, which will prevent potential
> allocations and buffer copies when they are not needed.
> 
> Signed-off-by: James Almer 
> ---
> Decided to keep the default behavior untouched (meaning a writable buffer is
> returned), and turned the new parameter into a flags one.
> It's cleaner overall, as almost every ff_reget_buffer calls will use a 0 as
> argument for it.

Will push this soon.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] Hello

2019-09-03 Thread Mark Filipak
Hello, I'm new to this list. I have a specific development goal: To 
implement a non-judder 2-3 pull-down of my design if it doesn't alreay 
exist.


Is that goal permitted here?

Warm Regards,
Mark.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] libavcodec: add editpts bitstream filter [v4]

2019-09-03 Thread Andreas Håkon
Hi Marton,


‐‐‐ Original Message ‐‐‐
On Tuesday, 3 de September de 2019 9:57, Marton Balint  wrote:

> On Tue, 3 Sep 2019, Andreas Håkon wrote:
>
> > Hi,
> > Ping, ping! (another time).
> > Please take note of these three points:
> >
> > 1.  Lip-Syncing is a relevant topic in the AV editing area. Almost all 
> > professional video editors have
> > the functionality to realign audio with video. And at time the ffmpeg 
> > project lacks for a lipsync
> > bitstream filter. For this reason, this new filter is relevant. 
> > Although it can also be used for other purposes.
> >
> > 2.  This is the fourth iteration of the patch, and it incorporates all 
> > suggested requests. So it's ready
> > for review and acceptance.
> >
> > 3.  Although the current implementation can be improved (using, for 
> > example, values expressed in
> > nano-seconds), it's preferable to first add it and then improve it.
> >
>
> Some things can't be improved later, because they become part of the
> public interface so we can no longer just remove them, we'd have to
> deprecate them first.
>
> Also ffmpeg tries to be consistent with other parts of the code, use names
> based on the same logic, or use similar concepts throughout the libraries.
>
> Avoiding duplicated functionality is also a strong requirement for us, if
> something can be implemented in a more generic way (even if that takes a
> little more work), we should aim for that.
>
> That is why I suggest you implement a more generic approach, a setpts like
> filter (setts) with evaluation. As others pointed out, you typically need
> to modify both PTS and DTS, so the expression should affect both.
> Additional parameters can be introduced if somebody wants different
> expressions for PTS and DTS.

After looking at the "libavfilter/setpts.c" and the documentation I don't see 
what you want to copy from it.
The "expression" functionality can be useful, but the number of constants 
compatible with a bitstream filter
are very limited. From my point of view only some of them have sense: PTS and T 
in fact.

Any suggestion?
Perhaps you should describe the functionality of the "setpts_bsf" filter.

Regards.
A.H.

---

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

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

[FFmpeg-devel] [PATCH 2/2] avfilter/vf_v360: stop using floats in interpolation

2019-09-03 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/vf_v360.c | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index 2fee0016b9..dd41bb293c 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -118,7 +118,7 @@ typedef struct V360Context {
 int nb_planes;
 
 uint16_t *u[4], *v[4];
-float *ker[4];
+int16_t *ker[4];
 
 int (*remap_slice)(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs);
 } V360Context;
@@ -330,12 +330,12 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext 
*ctx, void *arg, int jo
 uint##bits##_t *d = dst + y * out_linesize;
\
 const uint16_t *u = s->u[plane] + y * width * ws * ws; 
\
 const uint16_t *v = s->v[plane] + y * width * ws * ws; 
\
-const float *ker = s->ker[plane] + y * width * ws * ws;
\
+const int16_t *ker = s->ker[plane] + y * width * ws * ws;  
\
 for (x = 0; x < width; x++) {  
\
 const uint16_t *uu = u + x * ws * ws;  
\
 const uint16_t *vv = v + x * ws * ws;  
\
-const float *kker = ker + x * ws * ws; 
\
-float tmp = 0.f;   
\
+const int16_t *kker = ker + x * ws * ws;   
\
+int tmp = 0;   
\

\
 for (i = 0; i < ws; i++) { 
\
 for (j = 0; j < ws; j++) { 
\
@@ -343,7 +343,7 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext 
*ctx, void *arg, int jo
 }  
\
 }  
\

\
-*d++ = av_clip_uint##bits(roundf(tmp));
\
+*d++ = av_clip_uint##bits(tmp >> (15 - ws));   
\
 }  
\
 }  
\
 }  
\
@@ -367,7 +367,7 @@ DEFINE_REMAP(4, 16, 2)
  * @param ker ker remap data
  */
 static void nearest_kernel(float du, float dv, const XYRemap *r_tmp,
-   uint16_t *u, uint16_t *v, float *ker)
+   uint16_t *u, uint16_t *v, int16_t *ker)
 {
 const int i = roundf(dv) + 1;
 const int j = roundf(du) + 1;
@@ -387,7 +387,7 @@ static void nearest_kernel(float du, float dv, const 
XYRemap *r_tmp,
  * @param ker ker remap data
  */
 static void bilinear_kernel(float du, float dv, const XYRemap *r_tmp,
-uint16_t *u, uint16_t *v, float *ker)
+uint16_t *u, uint16_t *v, int16_t *ker)
 {
 int i, j;
 
@@ -398,10 +398,10 @@ static void bilinear_kernel(float du, float dv, const 
XYRemap *r_tmp,
 }
 }
 
-ker[0] = (1.f - du) * (1.f - dv);
-ker[1] =du  * (1.f - dv);
-ker[2] = (1.f - du) *dv;
-ker[3] =du  *dv;
+ker[0] = (1.f - du) * (1.f - dv) * 8192;
+ker[1] =du  * (1.f - dv) * 8192;
+ker[2] = (1.f - du) *dv  * 8192;
+ker[3] =du  *dv  * 8192;
 }
 
 /**
@@ -432,7 +432,7 @@ static inline void calculate_bicubic_coeffs(float t, float 
*coeffs)
  * @param ker ker remap data
  */
 static void bicubic_kernel(float du, float dv, const XYRemap *r_tmp,
-   uint16_t *u, uint16_t *v, float *ker)
+   uint16_t *u, uint16_t *v, int16_t *ker)
 {
 int i, j;
 float du_coeffs[4];
@@ -445,7 +445,7 @@ static void bicubic_kernel(float du, float dv, const 
XYRemap *r_tmp,
 for (j = 0; j < 4; j++) {
 u[i * 4 + j] = 

[FFmpeg-devel] [PATCH 1/2] avfilter/vf_v360: rewrite storing of remap positions and interpolations

2019-09-03 Thread Paul B Mahol
In preparation of SIMD assembly.

Signed-off-by: Paul B Mahol 
---
 libavfilter/vf_v360.c | 168 ++
 1 file changed, 89 insertions(+), 79 deletions(-)

diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index 627caedc01..2fee0016b9 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -117,7 +117,8 @@ typedef struct V360Context {
 int inplanewidth[4], inplaneheight[4];
 int nb_planes;
 
-void *remap[4];
+uint16_t *u[4], *v[4];
+float *ker[4];
 
 int (*remap_slice)(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs);
 } V360Context;
@@ -249,11 +250,6 @@ static int query_formats(AVFilterContext *ctx)
 return ff_set_common_formats(ctx, fmts_list);
 }
 
-typedef struct XYRemap1 {
-uint16_t u;
-uint16_t v;
-} XYRemap1;
-
 /**
  * Generate no-interpolation remapping function with a given pixel depth.
  *
@@ -275,7 +271,6 @@ static int remap1_##bits##bit_slice(AVFilterContext *ctx, 
void *arg, int jobnr,
 const int out_linesize = out->linesize[plane] / div;   
  \
 const uint##bits##_t *src = (const uint##bits##_t *)in->data[plane];   
  \
 uint##bits##_t *dst = (uint##bits##_t *)out->data[plane];  
  \
-const XYRemap1 *remap = s->remap[plane];   
  \
 const int width = s->planewidth[plane];
  \
 const int height = s->planeheight[plane];  
  \

  \
@@ -283,12 +278,11 @@ static int remap1_##bits##bit_slice(AVFilterContext *ctx, 
void *arg, int jobnr,
 const int slice_end   = (height * (jobnr + 1)) / nb_jobs;  
  \

  \
 for (y = slice_start; y < slice_end; y++) {
  \
+const uint16_t *u = s->u[plane] + y * width;   
  \
+const uint16_t *v = s->v[plane] + y * width;   
  \
 uint##bits##_t *d = dst + y * out_linesize;
  \
-for (x = 0; x < width; x++) {  
  \
-const XYRemap1 *r = [y * width + x]; 
  \
-   
  \
-*d++ = src[r->v * in_linesize + r->u]; 
  \
-}  
  \
+for (x = 0; x < width; x++)
  \
+*d++ = src[v[x] * in_linesize + u[x]]; 
  \
 }  
  \
 }  
  \

  \
@@ -298,27 +292,21 @@ static int remap1_##bits##bit_slice(AVFilterContext *ctx, 
void *arg, int jobnr,
 DEFINE_REMAP1( 8, 1)
 DEFINE_REMAP1(16, 2)
 
-typedef struct XYRemap2 {
-uint16_t u[2][2];
-uint16_t v[2][2];
-float ker[2][2];
-} XYRemap2;
-
-typedef struct XYRemap4 {
+typedef struct XYRemap {
 uint16_t u[4][4];
 uint16_t v[4][4];
 float ker[4][4];
-} XYRemap4;
+} XYRemap;
 
 /**
  * Generate remapping function with a given window size and pixel depth.
  *
- * @param window_size size of interpolation window
+ * @param ws size of interpolation window
  * @param bits number of bits per pixel
  * @param div number of bytes per pixel
  */
-#define DEFINE_REMAP(window_size, bits, div)   
\
-static int remap##window_size##_##bits##bit_slice(AVFilterContext *ctx, void 
*arg, int jobnr, int nb_jobs) \
+#define DEFINE_REMAP(ws, bits, div)
\
+static int remap##ws##_##bits##bit_slice(AVFilterContext *ctx, void *arg, int 
jobnr, int nb_jobs)  \
 {  
\
 ThreadData *td = (ThreadData*)arg; 
\
 const V360Context *s = ctx->priv;  
\
@@ -332,7 +320,6 @@ static int 
remap##window_size##_##bits##bit_slice(AVFilterContext *ctx, void *ar
 const int out_linesize = out->linesize[plane] / div;   
   

[FFmpeg-devel] [PATCH v2] avfilter/vf_delogo: avfilter/vf_delogo: add auto set the area inside of the frame

2019-09-03 Thread Steven Liu
when the area outside of the frame, then use expr should
give user warning message and auto set to the area inside of the frame.

Signed-off-by: Steven Liu 
---
 libavfilter/vf_delogo.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
index 814575a36c..2d058021fb 100644
--- a/libavfilter/vf_delogo.c
+++ b/libavfilter/vf_delogo.c
@@ -327,6 +327,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 s->w = av_expr_eval(s->w_pexpr, s->var_values, s);
 s->h = av_expr_eval(s->h_pexpr, s->var_values, s);
 
+if (s->x + (s->band - 1) <= 0 || s->x + s->w - (s->band*2 - 2) > inlink->w 
||
+s->y + (s->band - 1) <= 0 || s->y + s->h - (s->band*2 - 2) > 
inlink->h) {
+av_log(s, AV_LOG_WARNING, "Logo area is outside of the frame,"
+   "auto set the area inside of the frame\n");
+}
+
+if (s->x + (s->band - 1) <= 0)
+s->x = 1 + s->band;
+if (s->y + (s->band - 1) <= 0)
+s->y = 1 + s->band;
+if (s->x + s->w - (s->band*2 - 2) > inlink->w)
+s->w = inlink->w - s->x - (s->band*2 - 2);
+if (s->y + s->h - (s->band*2 - 2) > inlink->h)
+s->h = inlink->h - s->y - (s->band*2 - 2);
+
 ret = config_input(inlink);
 if (ret < 0) {
 av_frame_free();
-- 
2.17.2 (Apple Git-113)



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

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

Re: [FFmpeg-devel] [PATCH/RFC] libavcodec/cinepak: Separate decoding from parsing

2019-09-03 Thread Michael Niedermayer
On Sun, Sep 01, 2019 at 10:58:27PM +0200, Tomas Härdin wrote:
>  libavcodec/cinepak.c|  337 
> 
>  tests/ref/fate/cvid-palette |1 
>  tests/ref/fate/cvid-partial |1 
>  3 files changed, 215 insertions(+), 124 deletions(-)
> 197f986bfb297c54ee0f208449d4053fcb948645  
> 0001-libavcodec-cinepak-Separate-decoding-from-parsing.patch
> From d4bda2edbecb93fa5c5910b8b91a866210368a95 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
> Date: Sun, 1 Sep 2019 15:37:13 +0200
> Subject: [PATCH] libavcodec/cinepak: Separate decoding from parsing
> 
> This is rather strict and replaces the previous hacks with checks that should 
> hopefully placate the fuzzers for the forseeable future
> ---
>  libavcodec/cinepak.c| 337 +++-
>  tests/ref/fate/cvid-palette |   1 -
>  tests/ref/fate/cvid-partial |   1 -
>  3 files changed, 215 insertions(+), 124 deletions(-)

this does not seem to apply automatically here

Applying: libavcodec/cinepak: Separate decoding from parsing
error: sha1 information is lacking or useless (libavcodec/cinepak.c).
error: could not build fake ancestor
Patch failed at 0001 libavcodec/cinepak: Separate decoding from parsing


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus


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

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

Re: [FFmpeg-devel] [PATCH 1/2] avformat/avformat: Introduced `AVInputFormat.read_timestamp2` to fix keyframe seeking for formats that rely on `read_timestamp` for seeking

2019-09-03 Thread Michael Niedermayer
On Mon, Sep 02, 2019 at 01:01:50PM -0700, Darren Mo wrote:
> That’s true. However, I think your approach would produce incorrect results 
> when `AVSEEK_FLAG_BACKWARD` is used.
> 
> The bisection would find the frame just before the target time and then we 
> would search for the next keyframe, which would be after the target time. 
> Instead, we want to return the keyframe just before the target time.
> 
> Any ideas on how to do that more efficiently?

stepwise searching for the keyframe in forward direction while taking steps
backward
..k.K.v-start
 A--->
B--->
C>k-K-->

there is code somewhere in git to do something similar already
this should be faster than always searching for keyframes during bisection as
long as the initial step is reasonable in relation to the keyframe distance

also as both approaches are quite similar one could even choose which
way to do it depending on the expected cost of seeks and bandwidth and
if some statistics on the keyframe distance are known and or the
search direction

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

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


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

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

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/apedec: Fix 32bit int overflow in do_apply_filter()

2019-09-03 Thread Michael Niedermayer
On Tue, Sep 03, 2019 at 12:16:47PM +0200, Tomas Härdin wrote:
> tis 2019-09-03 klockan 02:14 +0200 skrev Michael Niedermayer:
> > Fixes: signed integer overflow: 2147480546 + 4096 cannot be represented in 
> > type 'int'
> > Fixes: 
> > 16280/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5123442566758400
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/apedec.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
> > index 490b11b94e..ed22f0f019 100644
> > --- a/libavcodec/apedec.c
> > +++ b/libavcodec/apedec.c
> > @@ -1266,7 +1266,7 @@ static void do_apply_filter(APEContext *ctx, int 
> > version, APEFilter *f,
> >   f->delay - order,
> >   f->adaptcoeffs - 
> > order,
> >   order, 
> > APESIGN(*data));
> > -res = (res + (1 << (fracbits - 1))) >> fracbits;
> > +res = (int)(res + (1U << (fracbits - 1))) >> fracbits;
> 
> Does this mean the old code was decoding incorrectly, or is this just
> an UB fix? (fixing UBs is good of course)

it is just a UB fix.
If iam not misreading the reference source then it has the same UB in it
so there is no correct way in case this ever triggers on a real file.

The specific patch here was done so that the result should hopefully
match what a common machine with 32bit int (most platforms) would
likely produce.

thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.


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

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

Re: [FFmpeg-devel] [PATCH 5/5] avcodec/apedec: Check max_samples

2019-09-03 Thread Michael Niedermayer
On Mon, Sep 02, 2019 at 09:40:47PM -0300, James Almer wrote:
> On 9/2/2019 9:14 PM, Michael Niedermayer wrote:
> > Fixes: OOM
> > Fixes: 
> > 16627/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5638059583864832
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/apedec.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
> > index e218f7c043..774ce18531 100644
> > --- a/libavcodec/apedec.c
> > +++ b/libavcodec/apedec.c
> > @@ -1475,6 +1475,9 @@ static int ape_decode_frame(AVCodecContext *avctx, 
> > void *data,
> >  return AVERROR_INVALIDDATA;
> >  }
> >  
> > +if (nblocks * (int64_t)avctx->channels > avctx->max_samples)
> > +return AVERROR(EINVAL);
> > +
> 
> Shouldn't this be checked in ff_get_buffer()? Same as max_pixels, but
> checking "frame->nb_samples > avctx->max_samples" instead or
> width/height. Otherwise it will barely be used.

you are correct, it should be checked in *get_buffer somewhere too.
But the offending allocation occurs before any *get_buffer calls so
this check here is what is neccessary and sufficient for this specific
bug

Thanks

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

It is what and why we do it that matters, not just one of them.


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

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

Re: [FFmpeg-devel] [PATCH] avfilter/vf_delogo: add auto set the area inside of the frame

2019-09-03 Thread Liu Steven


> 在 2019年9月3日,下午3:24,Paul B Mahol  写道:
> 
> On 9/2/19, Steven Liu  wrote:
>> when the area outside of the frame, then use expr should
>> give user warning message and auto set to the area inside of the frame.
>> 
>> Signed-off-by: Steven Liu 
>> ---
>> libavfilter/vf_delogo.c | 14 ++
>> 1 file changed, 14 insertions(+)
>> 
>> diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
>> index 814575a36c..5521a29214 100644
>> --- a/libavfilter/vf_delogo.c
>> +++ b/libavfilter/vf_delogo.c
>> @@ -327,6 +327,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
>> *in)
>> s->w = av_expr_eval(s->w_pexpr, s->var_values, s);
>> s->h = av_expr_eval(s->h_pexpr, s->var_values, s);
>> 
>> +if (s->x + (s->band - 1) < 0 || s->x + s->w - (s->band*2 - 2) >
>> inlink->w ||
>> +s->y + (s->band - 1) < 0 || s->y + s->h - (s->band*2 - 2) >
>> inlink->h) {
>> +av_log(s, AV_LOG_WARNING, "Logo area is outside of the frame,"
>> +   "auto set the area inside of the frame\n");
>> +}
>> +if (s->x + (s->band - 1) < 0)
>> +s->x = s->band;
>> +if (s->y + (s->band - 1) < 0)
>> +s->y = s->band;
>> +if (s->x + s->w - (s->band*2 - 2) > inlink->w)
>> +s->x = inlink->w - s->w + (s->band*2 - 2);
>> +if (s->y + s->h - (s->band*2 - 2) > inlink->h)
>> +s->y = inlink->h - s->h + (s->band*2 - 2);
>> +
> 
> What about s->h and s->w being too big?

I got your mean.
> 
> 
>> ret = config_input(inlink);
>> if (ret < 0) {
>> av_frame_free();
>> --
>> 2.15.1
>> 
>> 
>> 
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".



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

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

Re: [FFmpeg-devel] [PATCH 3/5] avcodec: add max_samples

2019-09-03 Thread Michael Niedermayer
On Tue, Sep 03, 2019 at 12:21:26PM +0200, Tomas Härdin wrote:
> tis 2019-09-03 klockan 09:20 +0200 skrev Paul B Mahol:
> > 
> > On 9/3/19, Michael Niedermayer  wrote:
> > > TODO: APIChanges, bump version
> > > 
> > > Signed-off-by: Michael Niedermayer 
> > > ---
> > >  libavcodec/avcodec.h | 8 
> > >  libavcodec/options_table.h   | 1 +
> > >  tests/ref/fate/api-mjpeg-codec-param | 2 ++
> > >  tests/ref/fate/api-png-codec-param   | 2 ++
> > >  4 files changed, 13 insertions(+)
> > > 
> > > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > > index de4feb6a65..4b771a6ae6 100644
> > > --- a/libavcodec/avcodec.h
> > > +++ b/libavcodec/avcodec.h
> > > @@ -3371,6 +3371,14 @@ typedef struct AVCodecContext {
> > >   * - encoding: unused
> > >   */
> > >  int discard_damaged_percentage;
> > > +
> > > +/**
> > > + * The number of samples per frame to maximally accept.
> > > + *
> > > + * - decoding: set by user
> > > + * - encoding: set by user
> > > + */
> > > +int64_t max_samples;
> > >  } AVCodecContext;
> > 
> > NAK, you can use max_pixels for the same cause.
> 
> Or the other way around. Has max_pixels made it to an official release
> yet? 

max_pixels is in AVCodecContext since 3.3

but even if it wasnt. while no question max_samples would be a much
better name for a unified field than max_pixels.

We do not unify other related fields like
width & height with for example nb_samples and channels

There is also a semantic difference between max_pixels and max_samples

the max_pixels are the samples at one instance of time
while max_samples cover a period of time depending on the duration of a packet

if ever a video codec had packets covering a period of time the same way
audio does (like maybe 0.5 seconds or 15 frames) we would not apply
max_pixels to the whole but to the 15 frames individually

So IMHO its possible to use the same field for both but it feels a
bit like bending 2 slightly different things onto each other.

But sure if people prefer it ill change the patches.


> Using it for samples is obviously confusing

yes

thanks


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle


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

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

Re: [FFmpeg-devel] [PATCH] lavc/qsvdec: fix the regression on linux for init_hw_device

2019-09-03 Thread Fu, Linjie
> -Original Message-
> From: Li, Zhong
> Sent: Tuesday, September 3, 2019 18:18
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Cc: Fu, Linjie 
> Subject: RE: [FFmpeg-devel] [PATCH] lavc/qsvdec: fix the regression on linux
> for init_hw_device
> 
> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index
> eef4fe7..319b549
> > 100644
> > --- a/libavcodec/qsvdec.c
> > +++ b/libavcodec/qsvdec.c
> > @@ -46,6 +46,7 @@ const AVCodecHWConfigInternal
> *ff_qsv_hw_configs[] = {
> >  .public = {
> >  .pix_fmt = AV_PIX_FMT_QSV,
> >  .methods =
> AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
> > +   AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
> 
> AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX means we can
> support AV_PIX_FMT_QSV by AVCodecContext.hw_device_ctx
> This is not supported for qsv now.
> And even if it is supported, there is no business of system memory frame,
> just means output AV_PIX_FMT_QSV format frame created by
> hw_device_ctx.

Thanks for the explanation of this flag.

> 
> > AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
> >  .device_type = AV_HWDEVICE_TYPE_QSV,
> >  },
> > --
> > 2.7.4
> 
> Probably we need to add MFXVideoCORE_SetHandle() function for system
> memory output path, which is removed by
> 1f26a231bb065276cd80ce02957c759f3197edfa.

Yes, that's another possibility to fix this issue.
This patch aims at matching the behavior before the regression happened since
currently qsv is working on different session_init path compared with previous
version.

If ff_qsv_init_session_device() should not be called, it's good to set handle in
ff_qsv_init_internal_session (), since MSDK won't do such implementation on 
Linux
internally:
https://github.com/Intel-Media-SDK/MediaSDK/issues/1611#issuecomment-527359911

> I will try to give a patch to fix it ASAP.

Thanks,

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

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

Re: [FFmpeg-devel] [PATCH] avfilter/vf_delogo: add auto set the area inside of the frame

2019-09-03 Thread Liu Steven


> 在 2019年9月3日,下午3:24,Paul B Mahol  写道:
> 
> On 9/2/19, Steven Liu  wrote:
>> when the area outside of the frame, then use expr should
>> give user warning message and auto set to the area inside of the frame.
>> 
>> Signed-off-by: Steven Liu 
>> ---
>> libavfilter/vf_delogo.c | 14 ++
>> 1 file changed, 14 insertions(+)
>> 
>> diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
>> index 814575a36c..5521a29214 100644
>> --- a/libavfilter/vf_delogo.c
>> +++ b/libavfilter/vf_delogo.c
>> @@ -327,6 +327,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
>> *in)
>> s->w = av_expr_eval(s->w_pexpr, s->var_values, s);
>> s->h = av_expr_eval(s->h_pexpr, s->var_values, s);
>> 
>> +if (s->x + (s->band - 1) < 0 || s->x + s->w - (s->band*2 - 2) >
>> inlink->w ||
>> +s->y + (s->band - 1) < 0 || s->y + s->h - (s->band*2 - 2) >
>> inlink->h) {
>> +av_log(s, AV_LOG_WARNING, "Logo area is outside of the frame,"
>> +   "auto set the area inside of the frame\n");
>> +}
>> +if (s->x + (s->band - 1) < 0)
>> +s->x = s->band;
>> +if (s->y + (s->band - 1) < 0)
>> +s->y = s->band;
>> +if (s->x + s->w - (s->band*2 - 2) > inlink->w)
>> +s->x = inlink->w - s->w + (s->band*2 - 2);
>> +if (s->y + s->h - (s->band*2 - 2) > inlink->h)
>> +s->y = inlink->h - s->h + (s->band*2 - 2);
>> +
> 
> What about s->h and s->w being too big?
dou you mean this test case?


 localhost:dash StevenLiu$ ./ffmpeg -f lavfi -i testsrc2=s=1280x720 
-filter_complex "delogo=x=(20*t):y=(20*t):w=(2000*t):h=(3*t)" -y 
output.mp4
ffmpeg version N-94769-g4ae6031b20 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
  configuration: --enable-libass --enable-opengl --enable-libx264 
--enable-libmp3lame --enable-gpl --enable-nonfree --prefix=/usr/local 
--enable-libtesseract --enable-libspeex --enable-libfreetype 
--enable-libfontconfig --enable-libfdk-aac --enable-videotoolbox 
--enable-libxml2 --enable-librsvg --enable-libvmaf --enable-version3 
--disable-stripping --disable-optimizations --enable-libvmaf
  libavutil  56. 34.100 / 56. 34.100
  libavcodec 58. 56.101 / 58. 56.101
  libavformat58. 32.104 / 58. 32.104
  libavdevice58.  9.100 / 58.  9.100
  libavfilter 7. 58.102 /  7. 58.102
  libswscale  5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc55.  6.100 / 55.  6.100
Input #0, lavfi, from 'testsrc2=s=1280x720':
  Duration: N/A, start: 0.00, bitrate: N/A
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720 [SAR 
1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 (rawvideo) -> delogo
  delogo -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[delogo @ 0x7fd078d48340] Logo area is outside of the frame.
[Parsed_delogo_0 @ 0x7fd078d47a40] Failed to configure input pad on 
Parsed_delogo_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!
localhost:dash StevenLiu$



> 
> 
>> ret = config_input(inlink);
>> if (ret < 0) {
>> av_frame_free();
>> --
>> 2.15.1
>> 
>> 
>> 
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".



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

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

Re: [FFmpeg-devel] [PATCH 3/5] avcodec: add max_samples

2019-09-03 Thread Michael Niedermayer
On Tue, Sep 03, 2019 at 09:20:52AM +0200, Paul B Mahol wrote:
> NAK, you can use max_pixels for the same cause.

yes, we can, its poor design though audio samples are not
pixels.

Anyone else has an opinion on this ?

Thanks

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

Modern terrorism, a quick summary: Need oil, start war with country that
has oil, kill hundread thousand in war. Let country fall into chaos,
be surprised about raise of fundamantalists. Drop more bombs, kill more
people, be surprised about them taking revenge and drop even more bombs
and strip your own citizens of their rights and freedoms. to be continued


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

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

Re: [FFmpeg-devel] [PATCH 3/5] avcodec: add max_samples

2019-09-03 Thread Tomas Härdin
tis 2019-09-03 klockan 09:20 +0200 skrev Paul B Mahol:
> 
> On 9/3/19, Michael Niedermayer  wrote:
> > TODO: APIChanges, bump version
> > 
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/avcodec.h | 8 
> >  libavcodec/options_table.h   | 1 +
> >  tests/ref/fate/api-mjpeg-codec-param | 2 ++
> >  tests/ref/fate/api-png-codec-param   | 2 ++
> >  4 files changed, 13 insertions(+)
> > 
> > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > index de4feb6a65..4b771a6ae6 100644
> > --- a/libavcodec/avcodec.h
> > +++ b/libavcodec/avcodec.h
> > @@ -3371,6 +3371,14 @@ typedef struct AVCodecContext {
> >   * - encoding: unused
> >   */
> >  int discard_damaged_percentage;
> > +
> > +/**
> > + * The number of samples per frame to maximally accept.
> > + *
> > + * - decoding: set by user
> > + * - encoding: set by user
> > + */
> > +int64_t max_samples;
> >  } AVCodecContext;
> 
> NAK, you can use max_pixels for the same cause.

Or the other way around. Has max_pixels made it to an official release
yet? Using it for samples is obviously confusing

Hot take: AVCodec is way overdue for a split into ACodec and VCodec
(and SCodec and so on), with AVCodec being a typed union

/Tomas

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

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

Re: [FFmpeg-devel] [PATCH] lavc/qsvdec: fix the regression on linux for init_hw_device

2019-09-03 Thread Li, Zhong
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index eef4fe7..319b549
> 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -46,6 +46,7 @@ const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
>  .public = {
>  .pix_fmt = AV_PIX_FMT_QSV,
>  .methods = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
> +   AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |

AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX means we can support AV_PIX_FMT_QSV by 
AVCodecContext.hw_device_ctx
This is not supported for qsv now. 
And even if it is supported, there is no business of system memory frame, just 
means output AV_PIX_FMT_QSV format frame created by hw_device_ctx.

> AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
>  .device_type = AV_HWDEVICE_TYPE_QSV,
>  },
> --
> 2.7.4

Probably we need to add MFXVideoCORE_SetHandle() function for system memory 
output path, which is removed by 1f26a231bb065276cd80ce02957c759f3197edfa.
I will try to give a patch to fix it ASAP. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/apedec: Fix 32bit int overflow in do_apply_filter()

2019-09-03 Thread Tomas Härdin
tis 2019-09-03 klockan 02:14 +0200 skrev Michael Niedermayer:
> Fixes: signed integer overflow: 2147480546 + 4096 cannot be represented in 
> type 'int'
> Fixes: 
> 16280/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5123442566758400
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/apedec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
> index 490b11b94e..ed22f0f019 100644
> --- a/libavcodec/apedec.c
> +++ b/libavcodec/apedec.c
> @@ -1266,7 +1266,7 @@ static void do_apply_filter(APEContext *ctx, int 
> version, APEFilter *f,
>   f->delay - order,
>   f->adaptcoeffs - order,
>   order, APESIGN(*data));
> -res = (res + (1 << (fracbits - 1))) >> fracbits;
> +res = (int)(res + (1U << (fracbits - 1))) >> fracbits;

Does this mean the old code was decoding incorrectly, or is this just
an UB fix? (fixing UBs is good of course)

/Tomas

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

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

Re: [FFmpeg-devel] [PATCH] libavcodec: add editpts bitstream filter [v4]

2019-09-03 Thread Paul B Mahol
On 9/3/19, Marton Balint  wrote:
>
>
> On Tue, 3 Sep 2019, Andreas Håkon wrote:
>
>> Hi,
>>
>> Ping, ping! (another time).
>>
>> Please take note of these three points:
>>
>> 1. Lip-Syncing is a relevant topic in the AV editing area. Almost all
>> professional video editors have
>> the functionality to realign audio with video. And at time the ffmpeg
>> project lacks for a lipsync
>> bitstream filter. For this reason, this new filter is relevant. Although
>> it can also be used for other purposes.
>>
>> 2. This is the fourth iteration of the patch, and it incorporates all
>> suggested requests. So it's ready
>> for review and acceptance.
>>
>> 3. Although the current implementation can be improved (using, for
>> example, values expressed in
>> nano-seconds), it's preferable to first add it and then improve it.
>
> Some things can't be improved later, because they become part of the
> public interface so we can no longer just remove them, we'd have to
> deprecate them first.
>
> Also ffmpeg tries to be consistent with other parts of the code, use names
> based on the same logic, or use similar concepts throughout the libraries.
>
> Avoiding duplicated functionality is also a strong requirement for us, if
> something can be implemented in a more generic way (even if that takes a
> little more work), we should aim for that.
>
> That is why I suggest you implement a more generic approach, a setpts like
> filter (setts) with evaluation. As others pointed out, you typically need
> to modify both PTS and DTS, so the expression should affect both.
> Additional parameters can be introduced if somebody wants different
> expressions for PTS and DTS.

Agree with Marton here, looking at source code of bitstream filter it
is very limited in functionality.

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

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

Re: [FFmpeg-devel] [PATCH 1/2] lavu/hwcontext_vaapi: cope with race map for YUV420P

2019-09-03 Thread Fu, Linjie
> -Original Message-
> From: Fu, Linjie
> Sent: Thursday, August 15, 2019 12:33
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [PATCH 1/2] lavu/hwcontext_vaapi: cope with race map for
> YUV420P
> 
> There is a race condition for AV_PIX_FMT_YUV420P when mapping from
> pix_fmt
> to fourcc, both VA_FOURCC_I420 and VA_FOURCC_YV12 could be found by
> pix_fmt.
> 
> Currently, vaapi_get_image_format will go through the query results of
> pix_fmt and returned the first matched result according to the declared
> order in driver.This may leads to a wrong image_format.
> 
> Modify to find image_format via fourcc.
> 
> Fix vaapi CSC to I420:
> ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -f rawvideo
> -pix_fmt nv12 -s:v 1280x720 -i NV12.yuv -vf
> 'format=nv12,hwupload,scale_vaapi=format=yuv420p,hwdownload,format=
> yuv420p'
> -f rawvideo -vsync passthrough -vframes 10 -y aa.yuv
> 
> Reviewed-by: Zhong Li 
> Signed-off-by: Linjie Fu 
> ---
>  libavutil/hwcontext_vaapi.c | 14 +++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> index cf11764..64f14de 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -63,6 +63,7 @@ typedef struct VAAPIDevicePriv {
>  typedef struct VAAPISurfaceFormat {
>  enum AVPixelFormat pix_fmt;
>  VAImageFormat image_format;
> +unsigned int fourcc;
>  } VAAPISurfaceFormat;
> 
>  typedef struct VAAPIDeviceContext {
> @@ -171,15 +172,21 @@ static int
> vaapi_get_image_format(AVHWDeviceContext *hwdev,
>VAImageFormat **image_format)
>  {
>  VAAPIDeviceContext *ctx = hwdev->internal->priv;
> +VAAPIFormatDescriptor *desc;
>  int i;
> 
> +desc = vaapi_format_from_pix_fmt(pix_fmt);
> +if (!desc || !image_format)
> +goto fail;
> +
>  for (i = 0; i < ctx->nb_formats; i++) {
> -if (ctx->formats[i].pix_fmt == pix_fmt) {
> -if (image_format)
> -*image_format = >formats[i].image_format;
> +if (ctx->formats[i].fourcc == desc->fourcc) {
> +*image_format = >formats[i].image_format;
>  return 0;
>  }
>  }
> +
> +fail:
>  return AVERROR(EINVAL);
>  }
> 
> @@ -368,6 +375,7 @@ static int vaapi_device_init(AVHWDeviceContext
> *hwdev)
>  av_log(hwdev, AV_LOG_DEBUG, "Format %#x -> %s.\n",
> fourcc, av_get_pix_fmt_name(pix_fmt));
>  ctx->formats[ctx->nb_formats].pix_fmt  = pix_fmt;
> +ctx->formats[ctx->nb_formats].fourcc   = fourcc;
>  ctx->formats[ctx->nb_formats].image_format = image_list[i];
>  ++ctx->nb_formats;
>  }
> --
> 2.7.4

Ping?
Apart from the CSC issue, this also enables directly hwmap for yuv420p
in ffmpeg vaapi and is able to improve the performance by eliminating
redundant memory copy.

Tested on local KBL environment, from 45 fps to 70 fps
hwdownload  hwmap=mode=direct
YUV420P 45 fps  70 fps (1.5x)


Cmdline:
ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -v verbose 
-hwaccel_output_format vaapi -i Nature.h264 -vf 
scale_vaapi=format=yuv420p,hwmap=mode=direct,format=yuv420p -f null -
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] libavcodec: add editpts bitstream filter [v4]

2019-09-03 Thread Marton Balint



On Tue, 3 Sep 2019, Andreas Håkon wrote:


Hi,

Ping, ping! (another time).

Please take note of these three points:

1. Lip-Syncing is a relevant topic in the AV editing area. Almost all 
professional video editors have
the functionality to realign audio with video. And at time the ffmpeg project 
lacks for a lipsync
bitstream filter. For this reason, this new filter is relevant. Although it can 
also be used for other purposes.

2. This is the fourth iteration of the patch, and it incorporates all suggested 
requests. So it's ready
for review and acceptance.

3. Although the current implementation can be improved (using, for example, 
values expressed in
nano-seconds), it's preferable to first add it and then improve it.


Some things can't be improved later, because they become part of the 
public interface so we can no longer just remove them, we'd have to 
deprecate them first.


Also ffmpeg tries to be consistent with other parts of the code, use names 
based on the same logic, or use similar concepts throughout the libraries.


Avoiding duplicated functionality is also a strong requirement for us, if 
something can be implemented in a more generic way (even if that takes a 
little more work), we should aim for that.


That is why I suggest you implement a more generic approach, a setpts like 
filter (setts) with evaluation. As others pointed out, you typically need 
to modify both PTS and DTS, so the expression should affect both. 
Additional parameters can be introduced if somebody wants different 
expressions for PTS and DTS.


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

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

Re: [FFmpeg-devel] [PATCH] avfilter/vf_delogo: add auto set the area inside of the frame

2019-09-03 Thread Paul B Mahol
On 9/2/19, Steven Liu  wrote:
> when the area outside of the frame, then use expr should
> give user warning message and auto set to the area inside of the frame.
>
> Signed-off-by: Steven Liu 
> ---
>  libavfilter/vf_delogo.c | 14 ++
>  1 file changed, 14 insertions(+)
>
> diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c
> index 814575a36c..5521a29214 100644
> --- a/libavfilter/vf_delogo.c
> +++ b/libavfilter/vf_delogo.c
> @@ -327,6 +327,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *in)
>  s->w = av_expr_eval(s->w_pexpr, s->var_values, s);
>  s->h = av_expr_eval(s->h_pexpr, s->var_values, s);
>
> +if (s->x + (s->band - 1) < 0 || s->x + s->w - (s->band*2 - 2) >
> inlink->w ||
> +s->y + (s->band - 1) < 0 || s->y + s->h - (s->band*2 - 2) >
> inlink->h) {
> +av_log(s, AV_LOG_WARNING, "Logo area is outside of the frame,"
> +   "auto set the area inside of the frame\n");
> +}
> +if (s->x + (s->band - 1) < 0)
> +s->x = s->band;
> +if (s->y + (s->band - 1) < 0)
> +s->y = s->band;
> +if (s->x + s->w - (s->band*2 - 2) > inlink->w)
> +s->x = inlink->w - s->w + (s->band*2 - 2);
> +if (s->y + s->h - (s->band*2 - 2) > inlink->h)
> +s->y = inlink->h - s->h + (s->band*2 - 2);
> +

What about s->h and s->w being too big?


>  ret = config_input(inlink);
>  if (ret < 0) {
>  av_frame_free();
> --
> 2.15.1
>
>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 3/5] avcodec: add max_samples

2019-09-03 Thread Paul B Mahol
NAK, you can use max_pixels for the same cause.

On 9/3/19, Michael Niedermayer  wrote:
> TODO: APIChanges, bump version
>
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/avcodec.h | 8 
>  libavcodec/options_table.h   | 1 +
>  tests/ref/fate/api-mjpeg-codec-param | 2 ++
>  tests/ref/fate/api-png-codec-param   | 2 ++
>  4 files changed, 13 insertions(+)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index de4feb6a65..4b771a6ae6 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -3371,6 +3371,14 @@ typedef struct AVCodecContext {
>   * - encoding: unused
>   */
>  int discard_damaged_percentage;
> +
> +/**
> + * The number of samples per frame to maximally accept.
> + *
> + * - decoding: set by user
> + * - encoding: set by user
> + */
> +int64_t max_samples;
>  } AVCodecContext;
>
>  #if FF_API_CODEC_GET_SET
> diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
> index c3a500a629..b56e653bf6 100644
> --- a/libavcodec/options_table.h
> +++ b/libavcodec/options_table.h
> @@ -476,6 +476,7 @@ static const AVOption avcodec_options[] = {
>  {"pixel_format", "set pixel format", OFFSET(pix_fmt),
> AV_OPT_TYPE_PIXEL_FMT, {.i64=AV_PIX_FMT_NONE}, -1, INT_MAX, 0 },
>  {"video_size", "set video size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE,
> {.str=NULL}, 0, INT_MAX, 0 },
>  {"max_pixels", "Maximum number of pixels", OFFSET(max_pixels),
> AV_OPT_TYPE_INT64, {.i64 = INT_MAX }, 0, INT_MAX, A|V|S|D|E },
> +{"max_samples", "Maximum number of samples", OFFSET(max_samples),
> AV_OPT_TYPE_INT64, {.i64 = INT_MAX }, 0, INT_MAX, A|D|E },
>  {"hwaccel_flags", NULL, OFFSET(hwaccel_flags), AV_OPT_TYPE_FLAGS, {.i64 =
> AV_HWACCEL_FLAG_IGNORE_LEVEL }, 0, UINT_MAX, V|D, "hwaccel_flags"},
>  {"ignore_level", "ignore level even if the codec level used is unknown or
> higher than the maximum supported level reported by the hardware driver", 0,
> AV_OPT_TYPE_CONST, { .i64 = AV_HWACCEL_FLAG_IGNORE_LEVEL }, INT_MIN,
> INT_MAX, V | D, "hwaccel_flags" },
>  {"allow_high_depth", "allow to output YUV pixel formats with a different
> chroma sampling than 4:2:0 and/or other than 8 bits per component", 0,
> AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH }, INT_MIN,
> INT_MAX, V | D, "hwaccel_flags"},
> diff --git a/tests/ref/fate/api-mjpeg-codec-param
> b/tests/ref/fate/api-mjpeg-codec-param
> index 0815919d7d..e55cef0eb9 100644
> --- a/tests/ref/fate/api-mjpeg-codec-param
> +++ b/tests/ref/fate/api-mjpeg-codec-param
> @@ -136,6 +136,7 @@ stream=0, decode=0
>  pixel_format=yuvj422p
>  video_size=400x225
>  max_pixels=2147483647
> +max_samples=2147483647
>  hwaccel_flags=0x0001
>  extra_hw_frames=-1
>  discard_damaged_percentage=95
> @@ -277,6 +278,7 @@ stream=0, decode=1
>  pixel_format=yuvj422p
>  video_size=400x225
>  max_pixels=2147483647
> +max_samples=2147483647
>  hwaccel_flags=0x0001
>  extra_hw_frames=-1
>  discard_damaged_percentage=95
> diff --git a/tests/ref/fate/api-png-codec-param
> b/tests/ref/fate/api-png-codec-param
> index a47d0963da..c04c8cc7c1 100644
> --- a/tests/ref/fate/api-png-codec-param
> +++ b/tests/ref/fate/api-png-codec-param
> @@ -136,6 +136,7 @@ stream=0, decode=0
>  pixel_format=rgba
>  video_size=128x128
>  max_pixels=2147483647
> +max_samples=2147483647
>  hwaccel_flags=0x0001
>  extra_hw_frames=-1
>  discard_damaged_percentage=95
> @@ -277,6 +278,7 @@ stream=0, decode=1
>  pixel_format=rgba
>  video_size=128x128
>  max_pixels=2147483647
> +max_samples=2147483647
>  hwaccel_flags=0x0001
>  extra_hw_frames=-1
>  discard_damaged_percentage=95
> --
> 2.23.0
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] libavcodec: add editpts bitstream filter [v4]

2019-09-03 Thread Andreas Håkon
Hi,

Ping, ping! (another time).

Please take note of these three points:

1. Lip-Syncing is a relevant topic in the AV editing area. Almost all 
professional video editors have
the functionality to realign audio with video. And at time the ffmpeg project 
lacks for a lipsync
bitstream filter. For this reason, this new filter is relevant. Although it can 
also be used for other purposes.

2. This is the fourth iteration of the patch, and it incorporates all suggested 
requests. So it's ready
for review and acceptance.

3. Although the current implementation can be improved (using, for example, 
values expressed in
nano-seconds), it's preferable to first add it and then improve it.

‐‐‐ Original Message ‐‐‐
On Tuesday, 27 de August de 2019 11:02, Andreas Håkon 
 wrote:

> Hi,
>
> Ping!
>
> ‐‐‐ Original Message ‐‐‐
>
>> On Friday, 16 de August de 2019 12:19, Andreas Håkon 
>>  wrote:
>>
>>> Hi,
>>>
>>> The latest version ready to merge of the bitstream filter "editpts".
>>> Implements all requests.
>>>
>>> This supersedes:
>>>
>>> https://patchwork.ffmpeg.org/patch/14302/
>>>
>>> https://patchwork.ffmpeg.org/patch/14195/
>>>
>>> https://patchwork.ffmpeg.org/patch/13743/
>>>
>>> https://patchwork.ffmpeg.org/patch/13699/
>>
>> And I explain the reason for this filter:
>> - When there is a slight misalignment in some stream, for example a lipsync 
>> failure,
>> it's possible to compensate such misalignment without having to recompress 
>> any stream.
>> Just by applying this filter you can do all the work.

I hope it will be reviewed and accepted soon.
Regards.
A.H.

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

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

[FFmpeg-devel] [PATCH] lavc/qsvdec: fix the regression on linux for init_hw_device

2019-09-03 Thread Linjie Fu
Fixed the regression mentioned in #7030 since commit:
b0cd14fb1dab4b044f7fe6b53ac635409849de77
which breaks the decode pipeline with " -init_hw_device qsv:hw"
on Linux.

hw_device_match_by_codec(ist->dec) can't get the valid dev for QSV
thus can't call ff_qsv_init_session_device.
(called ff_qsv_init_internal_session instead)

As a contrast, the previous version found the dev and called
ff_qsv_init_session_device successfully.

Application shall call SetHandle on Linux, however currently in
Linux pipeline ff_qsv_set_display_handle was removed in
ff_qsv_init_internal_session since commit:
1f26a231bb065276cd80ce02957c759f3197edfa
so the Handle was not set on ffmpeg level.

The regression could not be detected on windows is because of the
difference between windows and linux in MSDK:

"on the past we intentionally didn't implement initialization of
vaDisplay inside MSDK library on Linux."

Details in ticket #7030 and issue in MSDK:
https://github.com/Intel-Media-SDK/MediaSDK/issues/1611

Signed-off-by: Linjie Fu 
---
 libavcodec/qsvdec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index eef4fe7..319b549 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -46,6 +46,7 @@ const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
 .public = {
 .pix_fmt = AV_PIX_FMT_QSV,
 .methods = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
+   AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
 .device_type = AV_HWDEVICE_TYPE_QSV,
 },
-- 
2.7.4

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

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