Re: [FFmpeg-devel] [PATCH] ffmpeg: remove premature rescaling of forced_keyframe times

2020-01-03 Thread Gyan



On 02-01-2020 09:21 pm, Gyan Doshi wrote:

The user-set forced KF times are parsed *after* this deleted
loop and rescaled right after parsing.
---
  fftools/ffmpeg.c | 4 
  1 file changed, 4 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 9af2bc2fb5..2c5fcc0532 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3367,10 +3367,6 @@ static int init_output_stream_encode(OutputStream *ost)
  av_log(oc, AV_LOG_WARNING, "Frame rate very high for a muxer not 
efficiently supporting it.\n"
 "Please consider specifying a lower 
framerate, a different muxer or -vsync 2\n");
  }
-for (j = 0; j < ost->forced_kf_count; j++)
-ost->forced_kf_pts[j] = av_rescale_q(ost->forced_kf_pts[j],
- AV_TIME_BASE_Q,
- enc_ctx->time_base);
  
  enc_ctx->width  = av_buffersink_get_w(ost->filter->filter);

  enc_ctx->height = av_buffersink_get_h(ost->filter->filter);


Will push tonight.

Gyan
___
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] ffmpeg: don't force source-tracked keyframes for duplicates

2020-01-03 Thread Gyan



On 03-01-2020 04:05 pm, Gyan wrote:



On 03-01-2020 03:30 pm, Michael Niedermayer wrote:

On Fri, Jan 03, 2020 at 12:35:22PM +0530, Gyan Doshi wrote:

Prevents a run of consecutive duplicate frames from all being encoded
as keyframes, when force_key_frames is set to source.
---
  fftools/ffmpeg.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
maybe ok (i wonder if this would be expected behavior with intra only 
input)


If user wants intra-only output, they can use an intra-coded encoder 
or -g 1.


If they want to preserve same seek points as source, then the 
non-duplicated frame has the closest pts sync to the source timestamp.


Will push tonight.

Gyan
___
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 v3] avfilter/formats: optimize ff_all_formats

2020-01-03 Thread quinkblack
From: Zhao Zhili 

This is a micro-optimization. Saving almost 200 reallocations makes it
worth a try.
---
v3: fix an obvious infinite loop and pass fate-filter test

 libavfilter/formats.c | 41 ++---
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 33c64668a0..f29cddc250 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -348,21 +348,48 @@ int ff_add_channel_layout(AVFilterChannelLayouts **l, 
uint64_t channel_layout)
 
 AVFilterFormats *ff_all_formats(enum AVMediaType type)
 {
-AVFilterFormats *ret = NULL;
+int count, i;
+AVFilterFormats *ret = av_mallocz(sizeof(*ret));
+
+if (!ret)
+return NULL;
 
 if (type == AVMEDIA_TYPE_VIDEO) {
 const AVPixFmtDescriptor *desc = NULL;
-while ((desc = av_pix_fmt_desc_next(desc))) {
-if (ff_add_format(, av_pix_fmt_desc_get_id(desc)) < 0)
-return NULL;
+
+count = 0;
+while ((desc = av_pix_fmt_desc_next(desc)))
+count++;
+
+ret->formats = av_malloc_array(count, sizeof(*ret->formats));
+if (!ret->formats) {
+av_free(ret);
+return NULL;
+}
+ret->nb_formats = count;
+
+for (i = 0, desc = NULL; i < count; i++) {
+desc = av_pix_fmt_desc_next(desc);
+ret->formats[i] = av_pix_fmt_desc_get_id(desc);
 }
 } else if (type == AVMEDIA_TYPE_AUDIO) {
 enum AVSampleFormat fmt = 0;
-while (av_get_sample_fmt_name(fmt)) {
-if (ff_add_format(, fmt) < 0)
-return NULL;
+
+while (av_get_sample_fmt_name(fmt))
 fmt++;
+
+count = fmt;
+ret->formats = av_malloc_array(count, sizeof(*ret->formats));
+if (!ret->formats) {
+av_free(ret);
+return NULL;
 }
+ret->nb_formats = count;
+
+for (fmt = 0; fmt < count; fmt++)
+ret->formats[fmt] = fmt;
+} else {
+av_freep();
 }
 
 return ret;
-- 
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] avcodec/libvpxenc, cosmetics: prefer sizeof(var)

2020-01-03 Thread James Almer
On 1/3/2020 10:16 PM, James Zern wrote:
> Signed-off-by: James Zern 
> ---
>  libavcodec/libvpxenc.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index 3f659b4b67..0b8a070304 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -1041,8 +1041,7 @@ static int queue_frames(AVCodecContext *avctx, AVPacket 
> *pkt_out)
>  if (size < 0)
>  return size;
>  } else {
> -struct FrameListData *cx_frame =
> -av_malloc(sizeof(struct FrameListData));
> +struct FrameListData *cx_frame = 
> av_malloc(sizeof(*cx_frame));
>  
>  if (!cx_frame) {
>  av_log(avctx, AV_LOG_ERROR,

LGTM
___
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] avcodec/libvpxenc, cosmetics: prefer sizeof(var)

2020-01-03 Thread James Zern
Signed-off-by: James Zern 
---
 libavcodec/libvpxenc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 3f659b4b67..0b8a070304 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -1041,8 +1041,7 @@ static int queue_frames(AVCodecContext *avctx, AVPacket 
*pkt_out)
 if (size < 0)
 return size;
 } else {
-struct FrameListData *cx_frame =
-av_malloc(sizeof(struct FrameListData));
+struct FrameListData *cx_frame = av_malloc(sizeof(*cx_frame));
 
 if (!cx_frame) {
 av_log(avctx, AV_LOG_ERROR,
-- 
2.24.1.735.g03f4e72817-goog

___
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] avcodec/iff: Over-allocate ham_palbuf for HAM6 IFF-PBM

2020-01-03 Thread Michael Niedermayer
IFF-PBM-HAM6 can read out of array without this overallocation
Fixes: Out of array read
Fixes: 
19752/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5675331403120640

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/iff.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index f82141d2e7..cee0c2261a 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -332,13 +332,17 @@ static int extract_header(AVCodecContext *const avctx,
 int i, count = FFMIN(palette_size / 3, 1 << s->ham);
 int ham_count;
 const uint8_t *const palette = avctx->extradata + 
AV_RB16(avctx->extradata);
+int extra_space = 1;
+
+if (avctx->codec_tag == MKTAG('P', 'B', 'M', ' ') && s->ham == 4)
+extra_space = 4;
 
 s->ham_buf = av_malloc((s->planesize * 8) + 
AV_INPUT_BUFFER_PADDING_SIZE);
 if (!s->ham_buf)
 return AVERROR(ENOMEM);
 
 ham_count = 8 * (1 << s->ham);
-s->ham_palbuf = av_malloc((ham_count << !!(s->masking == 
MASK_HAS_MASK)) * sizeof (uint32_t) + AV_INPUT_BUFFER_PADDING_SIZE);
+s->ham_palbuf = av_malloc(extra_space * (ham_count << 
!!(s->masking == MASK_HAS_MASK)) * sizeof (uint32_t) + 
AV_INPUT_BUFFER_PADDING_SIZE);
 if (!s->ham_palbuf) {
 av_freep(>ham_buf);
 return AVERROR(ENOMEM);
-- 
2.24.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 V1 04/12] lavc/libvpxenc: fix memory leak after av_dict_parse_string fail

2020-01-03 Thread James Zern
Hi,

On Tue, Dec 31, 2019 at 9:21 PM Jun Zhao  wrote:
>
> From: Jun Zhao 
>
> In case of failure, all the successfully set entries are stored in
> *pm. We need to manually free the created dictionary to avoid
> memory leak.
>
> Signed-off-by: Jun Zhao 
> ---
>  libavcodec/libvpxenc.c |3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
>

I think this is unnecessary after:
9ac1066dc6 avcodec/libvpxenc: use AV_OPT_TYPE_DICT for ts-parameters
___
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] Workaround to build ffmpeg on MacOs 10.15

2020-01-03 Thread Henrik Gramner
On Fri, Jan 3, 2020 at 7:37 PM Moritz Barsnick  wrote:
> On Fri, Jan 03, 2020 at 11:05:25 +0100, Timo Rothenpieler wrote:
> > I think this was discussed on this list in the past.
> > Not sure what the conclusion was, but I think an unconditional flag like
> > this being added wasn't all that well received.
>
> Yes, discussed in this thread in November:
> http://ffmpeg.org/pipermail/ffmpeg-devel/2019-November/253193.html

Lmao "security feature". Just disable that flag and call it a day, it
adds nothing of value (unless you consider crashing to be a "security
feature"?).
___
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/ffv1: Properly check that the 4th and 5th quant tables are zeroes

2020-01-03 Thread Jerome Martinez

On 03/01/2020 22:59, Derek Buitenhuis wrote:

On 02/01/2020 23:09, Michael Niedermayer wrote:

I think if entry 128 is 0 then the whole table must be 0.
If that is the case, checking the entry 128 of table 4 and 5 would be enough
and caching the entry comparission is maybe not needed.

Is this guaranteed somehow? It isn't mentioned in the spec.


Checking better the spec about how the quant table is stored in 
bitstream, we may have missed in our past discussion that it is actually 
not stored as 256 independent values, "QuantizationTable(i, j, scale)" 
permits only increasing numbers from index 0 to 127 (so 128, as index 
128 is the negative of index 127), so it seems that by design of how the 
quant table is stored it is impossible to have 0 at index 128 without 
having 0 at indexes 0-127 (one value of "len - 1", 127, seems to be the 
only way to have 0 at index 128).


The need to check the 5th quant table is still valid.

Jérôme

___
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] Workaround to build ffmpeg on MacOs 10.15

2020-01-03 Thread Thierry Foucu
On Fri, Jan 3, 2020 at 1:56 PM Nicolas George  wrote:

> Thierry Foucu (12020-01-03):
> > So, right now, we cannot build ffmpeg with optimization on Mac Os 10.15.
>
> Can't you pass the option as extra-cflags to configure? It should work,
> until a proper fix is proposed.
>

Yes i can, but why should we have all the Mac user to do it until a fix is
proposed?
Is there any documentation on how to build ffmpeg on Mac where we can make
sure users know about passing this option as extra-cflags to configure?

if not, i think it will be best to have this option in configure so ffmpeg
users do not have to use some search engine to find out how to build ffmpeg
for Mac Os 10.15.


>
> Regards,
>
> --
>   Nicolas George
> ___
> 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".



-- 
---
Thierry Foucu
___
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/ffv1: Properly check that the 4th and 5th quant tables are zeroes

2020-01-03 Thread Derek Buitenhuis
On 02/01/2020 23:09, Michael Niedermayer wrote:
> I think if entry 128 is 0 then the whole table must be 0.
> If that is the case, checking the entry 128 of table 4 and 5 would be enough
> and caching the entry comparission is maybe not needed.

Is this guaranteed somehow? It isn't mentioned in the spec.

- Derek
___
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] Workaround to build ffmpeg on MacOs 10.15

2020-01-03 Thread Nicolas George
Thierry Foucu (12020-01-03):
> So, right now, we cannot build ffmpeg with optimization on Mac Os 10.15.

Can't you pass the option as extra-cflags to configure? It should work,
until a proper fix is proposed.

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] Workaround to build ffmpeg on MacOs 10.15

2020-01-03 Thread Thierry Foucu
On Fri, Jan 3, 2020 at 10:37 AM Moritz Barsnick  wrote:

> On Fri, Jan 03, 2020 at 11:05:25 +0100, Timo Rothenpieler wrote:
> > I think this was discussed on this list in the past.
> > Not sure what the conclusion was, but I think an unconditional flag like
> > this being added wasn't all that well received.
>
> Yes, discussed in this thread in November:
> http://ffmpeg.org/pipermail/ffmpeg-devel/2019-November/253193.html
>
>
Thanks Moritz.
So, right now, we cannot build ffmpeg with optimization on Mac Os 10.15.
note that VLC added such option in
https://git.videolan.org/?p=vlc.git;a=commit;h=856ddd8d1af955712c7effb1876ca9544b688cab

to build libav libraries...


> Moritz
> ___
> 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".



-- 
---
Thierry Foucu
___
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/3] avformat: remove more unneeded avio_flush() calls

2020-01-03 Thread Martin Storsjö

On Fri, 3 Jan 2020, Marton Balint wrote:


On Fri, 3 Jan 2020, Martin Storsjö wrote:


On Fri, 3 Jan 2020, Marton Balint wrote:

Throughout libavformat there are lots of avio_flush() calls which are 

unneeded:
- Instances found at the end of write_header, write_packet and 

write_trailer

 callbacks. These are handled by the generic code in libavformat/mux.c.


They are only handled by the generic code, if the flush_packets flag is 
set. If it isn't, and the flush was there for a reason (I'm sure not all 
of them are, but I'm also quite sure a few of them are there for very 
specific reasons), things will now break.


For write_packet, you are right, it removes the explicit flush and fall 
backs to the default behaviour of the flush_packets flag, which is to 
flush if the output is streamed, and not flush otherwise. Can you a think 
of a case which breaks when the output is not streamed?


Hmm, not really

For write_header there is an explicit flush in avio_write_marker if the 
marker type is AVIO_DATA_MARKER_HEADER and if the type is different to the 
existing marker, so it should not make a difference.


Ah, I overlooked that - then it might be fine.



One such case that you're removing comes from 
8ad5124b7ecf7f727724e270a7b4bb8c7bcbf6a4 which was added for a specific 
reason.


I guess this predates your avio_write_marker addition.


Yeah, I guess so.





- Instances in the middle of write_header and write_trailer which are
 redundant or are present becuase avio_flush() used to be required before
 doing a seekback. That is no longer the case, aviobuf code does the flush
 automatically on seek.


It's not necessarily about flushing before doing seekback, it's also about 
ensuring that seekback can be done within the current buffer.


For streaming output (where we can't seek back once data has been 
flushed), it's cruicial to flush _before_ a point you want to seek to. 
Consider if we have a 32k avio buffer, and it's filled up to 30k at the 
moment. We're going to write a 8k structure which requires seeks back and 
forth. If we remove the pre-write-flush, we'll write 2k of data, flush it 
out, and later seeks to the beginning of this block will fail.


If we explicitly flush before starting to write one block where we know 
we'll need to seek to, we maximize the chances of it working. (If we need 
to seek across a larger area than the avio buffer, then it still won't 
work of course.)


I didn't check yet all of the ones you are removing, but I'd say at least 
that movenc.c has cases of intentional flushing in this style.


Ok, this can be a problem indeed. A proper solution would be to use a 
dynbuf in these cases if streaming is of importance because it is wrong to 
assume any particular output buffer size in a muxer and rely on this 
behaviour.


Yes, that would be better indeed. For the case with movenc, I think I 
think I might have taken this route in order to reduce the amount of 
needed refactoring as this method felt good enough for the cases at hand 
at the time.


So this patch removes those cases. Removing explicit avio_flush() calls 

helps
us to buffer more data and avoid flushing the IO context too often which 

causes

reduced IO throughput for non-streamed file output.


So if you're arguing that some can be removed because the generic code in 
mux.c does the same (although it only does so if a nondefault flag is 
set?), this benefit can only be attributed to the other ones, that are 
removed from the middle of functions.


Yes. I will rework the patchset, sepearte the cases better and maybe keep 
the ones in the middle write_header/write_trailer for now.


Awesome, that'd make me more comfortable with it!

// Martin
___
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/3] avformat: remove more unneeded avio_flush() calls

2020-01-03 Thread Marton Balint

On Fri, 3 Jan 2020, Martin Storsjö wrote:


On Fri, 3 Jan 2020, Marton Balint wrote:

Throughout libavformat there are lots of avio_flush() calls which are 

unneeded:
- Instances found at the end of write_header, write_packet and 

write_trailer

 callbacks. These are handled by the generic code in libavformat/mux.c.


They are only handled by the generic code, if the flush_packets flag is 
set. If it isn't, and the flush was there for a reason (I'm sure not all 
of them are, but I'm also quite sure a few of them are there for very 
specific reasons), things will now break.


For write_packet, you are right, it removes the explicit flush and fall 
backs to the default behaviour of the flush_packets flag, which is to 
flush if the output is streamed, and not flush otherwise. Can you a think 
of a case which breaks when the output is not streamed?


For write_header there is an explicit flush in avio_write_marker if the 
marker type is AVIO_DATA_MARKER_HEADER and if the type is different to the 
existing marker, so it should not make a difference.




One such case that you're removing comes from 
8ad5124b7ecf7f727724e270a7b4bb8c7bcbf6a4 which was added for a specific 
reason.


I guess this predates your avio_write_marker addition.




- Instances in the middle of write_header and write_trailer which are
 redundant or are present becuase avio_flush() used to be required before
 doing a seekback. That is no longer the case, aviobuf code does the flush
 automatically on seek.


It's not necessarily about flushing before doing seekback, it's also about 
ensuring that seekback can be done within the current buffer.


For streaming output (where we can't seek back once data has been 
flushed), it's cruicial to flush _before_ a point you want to seek to. 
Consider if we have a 32k avio buffer, and it's filled up to 30k at the 
moment. We're going to write a 8k structure which requires seeks back and 
forth. If we remove the pre-write-flush, we'll write 2k of data, flush it 
out, and later seeks to the beginning of this block will fail.


If we explicitly flush before starting to write one block where we know 
we'll need to seek to, we maximize the chances of it working. (If we need 
to seek across a larger area than the avio buffer, then it still won't 
work of course.)


I didn't check yet all of the ones you are removing, but I'd say at least 
that movenc.c has cases of intentional flushing in this style.


Ok, this can be a problem indeed. A proper solution would be to use a 
dynbuf in these cases if streaming is of importance because it is wrong to 
assume any particular output buffer size in a muxer and rely on this 
behaviour.


So this patch removes those cases. Removing explicit avio_flush() calls 

helps
us to buffer more data and avoid flushing the IO context too often which 

causes

reduced IO throughput for non-streamed file output.


So if you're arguing that some can be removed because the generic code in 
mux.c does the same (although it only does so if a nondefault flag is 
set?), this benefit can only be attributed to the other ones, that are 
removed from the middle of functions.


Yes. I will rework the patchset, sepearte the cases better and maybe keep 
the ones in the middle write_header/write_trailer for now.


Thanks,
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/3] avformat: remove more unneeded avio_flush() calls

2020-01-03 Thread Martin Storsjö

On Fri, 3 Jan 2020, Marton Balint wrote:


Throughout libavformat there are lots of avio_flush() calls which are unneeded:
- Instances found at the end of write_header, write_packet and write_trailer
 callbacks. These are handled by the generic code in libavformat/mux.c.


They are only handled by the generic code, if the flush_packets flag is 
set. If it isn't, and the flush was there for a reason (I'm sure not all 
of them are, but I'm also quite sure a few of them are there for very 
specific reasons), things will now break.


One such case that you're removing comes from 
8ad5124b7ecf7f727724e270a7b4bb8c7bcbf6a4 which was added for a specific 
reason.



- Instances in the middle of write_header and write_trailer which are
 redundant or are present becuase avio_flush() used to be required before
 doing a seekback. That is no longer the case, aviobuf code does the flush
 automatically on seek.


It's not necessarily about flushing before doing seekback, it's also about 
ensuring that seekback can be done within the current buffer.


For streaming output (where we can't seek back once data has been 
flushed), it's cruicial to flush _before_ a point you want to seek to. 
Consider if we have a 32k avio buffer, and it's filled up to 30k at the 
moment. We're going to write a 8k structure which requires seeks back and 
forth. If we remove the pre-write-flush, we'll write 2k of data, flush it 
out, and later seeks to the beginning of this block will fail.


If we explicitly flush before starting to write one block where we know 
we'll need to seek to, we maximize the chances of it working. (If we need 
to seek across a larger area than the avio buffer, then it still won't 
work of course.)


I didn't check yet all of the ones you are removing, but I'd say at least 
that movenc.c has cases of intentional flushing in this style.



So this patch removes those cases. Removing explicit avio_flush() calls helps
us to buffer more data and avoid flushing the IO context too often which causes
reduced IO throughput for non-streamed file output.


So if you're arguing that some can be removed because the generic code in 
mux.c does the same (although it only does so if a nondefault flag is 
set?), this benefit can only be attributed to the other ones, that are 
removed from the middle of functions.


// Martin

___
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/3] avformat: remove more unneeded avio_flush() calls

2020-01-03 Thread Marton Balint
Throughout libavformat there are lots of avio_flush() calls which are unneeded:
- Instances found at the end of write_header, write_packet and write_trailer
  callbacks. These are handled by the generic code in libavformat/mux.c.
- Instances in the middle of write_header and write_trailer which are
  redundant or are present becuase avio_flush() used to be required before
  doing a seekback. That is no longer the case, aviobuf code does the flush
  automatically on seek.

So this patch removes those cases. Removing explicit avio_flush() calls helps
us to buffer more data and avoid flushing the IO context too often which causes
reduced IO throughput for non-streamed file output.

The user can still control flushing behaviour using the -flush_packets option,
the default typically means to flush unless a non-streamed file output is used.

Signed-off-by: Marton Balint 
---
 libavformat/aiffenc.c |  5 -
 libavformat/amr.c |  1 -
 libavformat/asfenc.c  |  3 ---
 libavformat/assenc.c  |  1 -
 libavformat/astenc.c  |  3 ---
 libavformat/au.c  |  2 --
 libavformat/avienc.c  |  3 ---
 libavformat/cafenc.c  |  2 --
 libavformat/ffmetaenc.c   |  1 -
 libavformat/flacenc.c |  1 -
 libavformat/framehash.c   |  1 -
 libavformat/gxfenc.c  |  3 ---
 libavformat/hashenc.c |  2 --
 libavformat/icoenc.c  |  2 --
 libavformat/idroqenc.c|  1 -
 libavformat/ilbc.c|  1 -
 libavformat/img2enc.c |  1 -
 libavformat/jacosubenc.c  |  1 -
 libavformat/matroskaenc.c |  2 --
 libavformat/microdvdenc.c |  1 -
 libavformat/mmf.c |  4 
 libavformat/movenc.c  |  3 ---
 libavformat/mpegenc.c |  1 -
 libavformat/mpjpeg.c  |  1 -
 libavformat/mxfenc.c  |  3 ---
 libavformat/nutenc.c  |  2 --
 libavformat/rmenc.c   |  1 -
 libavformat/rsoenc.c  |  2 --
 libavformat/segafilmenc.c |  2 --
 libavformat/smjpegenc.c   |  1 -
 libavformat/soxenc.c  |  4 
 libavformat/swfenc.c  |  1 -
 libavformat/ttaenc.c  |  1 -
 libavformat/vc1testenc.c  |  1 -
 libavformat/wavenc.c  | 11 ---
 libavformat/webvttenc.c   |  1 -
 libavformat/wtvenc.c  |  2 --
 tests/ref/fate/movenc | 24 
 38 files changed, 8 insertions(+), 94 deletions(-)

diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index e25794d185..0145596bec 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -199,9 +199,6 @@ static int aiff_write_header(AVFormatContext *s)
 avpriv_set_pts_info(s->streams[aiff->audio_stream_idx], 64, 1,
 
s->streams[aiff->audio_stream_idx]->codecpar->sample_rate);
 
-/* Data is starting here */
-avio_flush(pb);
-
 return 0;
 }
 
@@ -266,8 +263,6 @@ static int aiff_write_trailer(AVFormatContext *s)
 file_size = avio_tell(pb);
 avio_seek(pb, aiff->form, SEEK_SET);
 avio_wb32(pb, file_size - aiff->form - 4);
-
-avio_flush(pb);
 }
 
 return ret;
diff --git a/libavformat/amr.c b/libavformat/amr.c
index 42840a50a3..650b565b1b 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -60,7 +60,6 @@ static int amr_write_header(AVFormatContext *s)
 } else {
 return -1;
 }
-avio_flush(pb);
 return 0;
 }
 
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 44e11fc763..8eaa9d40ce 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -801,8 +801,6 @@ static int asf_write_header(AVFormatContext *s)
 return -1;
 }
 
-avio_flush(s->pb);
-
 asf->packet_nb_payloads = 0;
 asf->packet_timestamp_start = -1;
 asf->packet_timestamp_end   = -1;
@@ -1132,7 +1130,6 @@ static int asf_write_trailer(AVFormatContext *s)
 return ret;
 asf_write_index(s, asf->index_ptr, asf->maximum_packet, 
asf->next_start_sec);
 }
-avio_flush(s->pb);
 
 if (asf->is_streamed || !(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
 put_chunk(s, 0x4524, 0, 0); /* end of stream */
diff --git a/libavformat/assenc.c b/libavformat/assenc.c
index 12aadca171..68c3396e5a 100644
--- a/libavformat/assenc.c
+++ b/libavformat/assenc.c
@@ -77,7 +77,6 @@ static int write_header(AVFormatContext *s)
 avio_printf(s->pb, "[Events]\r\nFormat: %s, Start, End, Style, 
Name, MarginL, MarginR, MarginV, Effect, Text\r\n",
 ass->ssa_mode ? "Marked" : "Layer");
 }
-avio_flush(s->pb);
 
 return 0;
 }
diff --git a/libavformat/astenc.c b/libavformat/astenc.c
index 578e658891..e0b94b8b63 100644
--- a/libavformat/astenc.c
+++ b/libavformat/astenc.c
@@ -101,8 +101,6 @@ static int ast_write_header(AVFormatContext *s)
 avio_wb64(pb, 0);
 avio_wb32(pb, 0);
 
-avio_flush(pb);
-
 return 0;
 }
 
@@ -180,7 +178,6 @@ static int ast_write_trailer(AVFormatContext *s)
 }
 
 avio_seek(pb, file_size, SEEK_SET);
-avio_flush(pb);
 }
 return 0;
 }
diff --git a/libavformat/au.c 

[FFmpeg-devel] [PATCH 1/3] avformat: remove unneded avio_flush() calls before calling avio_close_dyn_buf()

2020-01-03 Thread Marton Balint
avio_close_dyn_buf() also does avio_flush().

Signed-off-by: Marton Balint 
---
 libavformat/hlsenc.c | 2 --
 libavformat/oggenc.c | 1 -
 libavformat/rtpdec.c | 2 --
 3 files changed, 5 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 561e3ff736..d130f03ea6 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -459,7 +459,6 @@ static int flush_dynbuf(VariantStream *vs, int 
*range_length)
 
 // flush
 av_write_frame(ctx, NULL);
-avio_flush(ctx->pb);
 
 // write out to file
 *range_length = avio_close_dyn_buf(ctx->pb, >temp_buffer);
@@ -2548,7 +2547,6 @@ static int hls_write_trailer(struct AVFormatContext *s)
 if (!vs->init_range_length) {
 uint8_t *buffer = NULL;
 av_write_frame(oc, NULL); /* Flush any buffered data */
-avio_flush(oc->pb);
 
 range_length = avio_close_dyn_buf(oc->pb, );
 avio_write(vs->out, buffer, range_length);
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index d3ae07351d..04f7813083 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -133,7 +133,6 @@ static int ogg_write_page(AVFormatContext *s, OGGPage 
*page, int extra_flags)
 avio_write(pb, page->data, page->size);
 
 ogg_update_checksum(s, pb, crc_offset);
-avio_flush(pb);
 
 size = avio_close_dyn_buf(pb, );
 if (size < 0)
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index e75a34cb93..3d5b200099 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -415,7 +415,6 @@ void ff_rtp_send_punch_packets(URLContext *rtp_handle)
 avio_wb32(pb, 0); /* Timestamp */
 avio_wb32(pb, 0); /* SSRC */
 
-avio_flush(pb);
 len = avio_close_dyn_buf(pb, );
 if ((len > 0) && buf)
 ffurl_write(rtp_handle, buf, len);
@@ -430,7 +429,6 @@ void ff_rtp_send_punch_packets(URLContext *rtp_handle)
 avio_wb16(pb, 1); /* length in words - 1 */
 avio_wb32(pb, 0); /* our own SSRC */
 
-avio_flush(pb);
 len = avio_close_dyn_buf(pb, );
 if ((len > 0) && buf)
 ffurl_write(rtp_handle, buf, len);
-- 
2.16.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".

Re: [FFmpeg-devel] [PATCH] avfilter: add freezeframes video filter

2020-01-03 Thread Moritz Barsnick
> +This filter freeze video frames using frame from 2nd input.
   ^
Grammar nit: freezes

Moritz
___
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] avfilter/formats: optimize ff_all_formats

2020-01-03 Thread Andreas Rheinhardt
quinkbl...@foxmail.com:
> From: Zhao Zhili 
> 
> This is a micro-optimization. Saving almost 200 reallocations makes it
> worth a try.
> ---
>  libavfilter/formats.c | 43 +++
>  1 file changed, 35 insertions(+), 8 deletions(-)
> 
> diff --git a/libavfilter/formats.c b/libavfilter/formats.c
> index 33c64668a0..c04253d898 100644
> --- a/libavfilter/formats.c
> +++ b/libavfilter/formats.c
> @@ -348,21 +348,48 @@ int ff_add_channel_layout(AVFilterChannelLayouts **l, 
> uint64_t channel_layout)
>  
>  AVFilterFormats *ff_all_formats(enum AVMediaType type)
>  {
> -AVFilterFormats *ret = NULL;
> +int count, i;
> +AVFilterFormats *ret = av_mallocz(sizeof(*ret));
> +
> +if (!ret)
> +return NULL;
>  
>  if (type == AVMEDIA_TYPE_VIDEO) {
>  const AVPixFmtDescriptor *desc = NULL;
> -while ((desc = av_pix_fmt_desc_next(desc))) {
> -if (ff_add_format(, av_pix_fmt_desc_get_id(desc)) < 0)
> -return NULL;
> +
> +count = 0;
> +while ((desc = av_pix_fmt_desc_next(desc)))
> +count++;
> +
> +ret->formats = av_malloc_array(count, sizeof(*ret->formats));
> +if (!ret->formats) {
> +av_free(ret);
> +return NULL;
> +}
> +ret->nb_formats = count;
> +
> +for (i = 0, desc = NULL; i < count; i++) {
> +desc = av_pix_fmt_desc_next(desc);
> +ret->formats[i] = av_pix_fmt_desc_get_id(desc);
>  }
>  } else if (type == AVMEDIA_TYPE_AUDIO) {
>  enum AVSampleFormat fmt = 0;
> -while (av_get_sample_fmt_name(fmt)) {
> -if (ff_add_format(, fmt) < 0)
> -return NULL;
> -fmt++;
> +
> +count = 0;
> +while (av_get_sample_fmt_name(fmt))
> +count++;

This looks like an infinite loop. (The code you removed incremented
fmt in the loop.)

- Andreas

> +
> +ret->formats = av_malloc_array(count, sizeof(*ret->formats));
> +if (!ret->formats) {
> +av_free(ret);
> +return NULL;
>  }
> +ret->nb_formats = count;
> +
> +for (fmt = 0; fmt < count; fmt++)
> +ret->formats[fmt] = fmt;
> +} else {
> +av_freep();
>  }
>  
>  return ret;
> 

___
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] avfilter/formats: optimize ff_all_formats

2020-01-03 Thread Andriy Gelman
On Fri, 03. Jan 22:25, quinkbl...@foxmail.com wrote:
> From: Zhao Zhili 
> 
> This is a micro-optimization. Saving almost 200 reallocations makes it
> worth a try.
> ---
>  libavfilter/formats.c | 43 +++
>  1 file changed, 35 insertions(+), 8 deletions(-)
> 
> diff --git a/libavfilter/formats.c b/libavfilter/formats.c
> index 33c64668a0..c04253d898 100644
> --- a/libavfilter/formats.c
> +++ b/libavfilter/formats.c
> @@ -348,21 +348,48 @@ int ff_add_channel_layout(AVFilterChannelLayouts **l, 
> uint64_t channel_layout)
>  
>  AVFilterFormats *ff_all_formats(enum AVMediaType type)
>  {
> -AVFilterFormats *ret = NULL;
> +int count, i;
> +AVFilterFormats *ret = av_mallocz(sizeof(*ret));
> +
> +if (!ret)
> +return NULL;
>  
>  if (type == AVMEDIA_TYPE_VIDEO) {
>  const AVPixFmtDescriptor *desc = NULL;
> -while ((desc = av_pix_fmt_desc_next(desc))) {
> -if (ff_add_format(, av_pix_fmt_desc_get_id(desc)) < 0)
> -return NULL;
> +
> +count = 0;
> +while ((desc = av_pix_fmt_desc_next(desc)))
> +count++;
> +
> +ret->formats = av_malloc_array(count, sizeof(*ret->formats));
> +if (!ret->formats) {
> +av_free(ret);
> +return NULL;
> +}
> +ret->nb_formats = count;
> +
> +for (i = 0, desc = NULL; i < count; i++) {
> +desc = av_pix_fmt_desc_next(desc);
> +ret->formats[i] = av_pix_fmt_desc_get_id(desc);
>  }
>  } else if (type == AVMEDIA_TYPE_AUDIO) {
>  enum AVSampleFormat fmt = 0;
> -while (av_get_sample_fmt_name(fmt)) {
> -if (ff_add_format(, fmt) < 0)
> -return NULL;
> -fmt++;
> +
> +count = 0;
> +while (av_get_sample_fmt_name(fmt))
> +count++;
> +
> +ret->formats = av_malloc_array(count, sizeof(*ret->formats));
> +if (!ret->formats) {
> +av_free(ret);
> +return NULL;
>  }
> +ret->nb_formats = count;
> +
> +for (fmt = 0; fmt < count; fmt++)
> +ret->formats[fmt] = fmt;
> +} else {
> +av_freep();
>  }
>  
>  return ret;
> -- 
> 2.22.0
> 

There is somekind of infinite loop here. 
Gets stuck in fate during:

TESTlavf-mxf

-- 
Andriy
___
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/3] avdevice/decklink_dec: remove the @mode syntax

2020-01-03 Thread Marton Balint



On Fri, 27 Dec 2019, Marton Balint wrote:


Deprecated since March 28, 2017.


Applied the series.

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 1/8] doc/muxers: fix order of options and examples for image2 muxer

2020-01-03 Thread Marton Balint



On Fri, 27 Dec 2019, Lou Logan wrote:


On Fri, Dec 27, 2019, at 12:14 PM, Marton Balint wrote:

Signed-off-by: Marton Balint 
---
 doc/muxers.texi | 52 ++--
 1 file changed, 26 insertions(+), 26 deletions(-)


LGTM


Thanks, applied, as well as patches 1-7 in the series. The last one is 
still pending discussion.


Thanks,
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] [PATCH 5/9] avformat/wavdec: s337m support

2020-01-03 Thread Nicolas Gaullier
Add s337m probing/reading similarly to spdif.
Add a new AVOption 'dolbyeprobe' to enable it.
---
 libavformat/wavdec.c | 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 575c667452..2796905e1f 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -41,6 +41,7 @@
 #include "riff.h"
 #include "w64.h"
 #include "spdif.h"
+#include "s337m.h"
 
 typedef struct WAVDemuxContext {
 const AVClass *class;
@@ -55,15 +56,18 @@ typedef struct WAVDemuxContext {
 int audio_eof;
 int ignore_length;
 int spdif;
+int s337m;
+int s337m_probe;
 int smv_cur_pt;
 int smv_given_first;
 int unaligned; // e.g. if an odd number of bytes ID3 tag was prepended
 int rifx; // RIFX: integer byte order for parameters is big endian
 } WAVDemuxContext;
 
-static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav)
+static void set_spdif_s337m(AVFormatContext *s, WAVDemuxContext *wav)
 {
-if (CONFIG_SPDIF_DEMUXER && s->streams[0]->codecpar->codec_tag == 1) {
+AVCodecParameters *par = s->streams[0]->codecpar;
+if ((CONFIG_SPDIF_DEMUXER || CONFIG_S337M_DEMUXER) && par->codec_tag == 1) 
{
 enum AVCodecID codec;
 int len = 1<<16;
 int ret = ffio_ensure_seekback(s->pb, len);
@@ -80,6 +84,12 @@ static void set_spdif(AVFormatContext *s, WAVDemuxContext 
*wav)
 if (ret > AVPROBE_SCORE_EXTENSION) {
 s->streams[0]->codecpar->codec_id = codec;
 wav->spdif = 1;
+} else if (wav->s337m_probe && (par->codec_id == 
AV_CODEC_ID_PCM_S16LE || par->codec_id == AV_CODEC_ID_PCM_S24LE) && 
par->channels == 2) {
+ret = ff_s337m_probe(buf, len, , s, 
par->bits_per_coded_sample);
+if (ret > AVPROBE_SCORE_EXTENSION) {
+s->streams[0]->codecpar->codec_id = codec;
+wav->s337m = 1;
+}
 }
 }
 avio_seek(s->pb, pos, SEEK_SET);
@@ -596,7 +606,7 @@ break_loop:
 ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
 ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv);
 
-set_spdif(s, wav);
+set_spdif_s337m(s, wav);
 
 return 0;
 }
@@ -633,6 +643,8 @@ static int wav_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1)
 return ff_spdif_read_packet(s, pkt);
+if (CONFIG_S337M_DEMUXER && wav->s337m == 1)
+return ff_s337m_read_packet(s, pkt);
 
 if (wav->smv_data_ofs > 0) {
 int64_t audio_dts, video_dts;
@@ -753,6 +765,9 @@ static int wav_read_seek(AVFormatContext *s,
 #define DEC AV_OPT_FLAG_DECODING_PARAM
 static const AVOption demux_options[] = {
 { "ignore_length", "Ignore length", OFFSET(ignore_length), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, DEC },
+#if CONFIG_S337M_DEMUXER
+{"dolbyeprobe", "Probe Dolby E in pcm/stereo streams", 
OFFSET(s337m_probe), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, DEC },
+#endif
 { NULL },
 };
 
@@ -895,7 +910,7 @@ static int w64_read_header(AVFormatContext *s)
 
 avio_seek(pb, data_ofs, SEEK_SET);
 
-set_spdif(s, wav);
+set_spdif_s337m(s, wav);
 
 return 0;
 }
-- 
2.14.1.windows.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] [PATCH 4/9] avformat/s337m: New ff_s337m_probe()

2020-01-03 Thread Nicolas Gaullier
Similar to ff_spdif_probe() with two additionnal parameters:
- an AVClass for logging
- the bit resolution of the container as it may be 16 or 24 for s337m
---
 libavformat/s337m.c | 35 +++
 libavformat/s337m.h | 19 +++
 2 files changed, 54 insertions(+)

diff --git a/libavformat/s337m.c b/libavformat/s337m.c
index 5c8ab2649c..dc62d6ab98 100644
--- a/libavformat/s337m.c
+++ b/libavformat/s337m.c
@@ -133,6 +133,41 @@ static int s337m_probe(const AVProbeData *p)
 return 0;
 }
 
+int ff_s337m_probe(const uint8_t *buf, int size, enum AVCodecID *codec, void 
*avc, int container_word_bits)
+{
+int pos = 0;
+int consecutive_codes = 0;
+
+if ( size < S337M_MIN_OFFSET)
+return 0;
+size = FFMIN(2 * S337M_MAX_OFFSET, size);
+
+do {
+uint64_t state;
+int data_type, data_size, offset;
+while (pos < size - 12 && !buf[pos]) {
+pos++;
+}
+if (pos >= size - 12 || pos < S337M_PROBE_GUARDBAND_MIN_BYTES)
+return 0;
+state = container_word_bits == 16 ? AV_RB32(buf + pos) : AV_RB48(buf + 
pos);
+if (!IS_LE_MARKER(state))
+return 0;
+data_type = container_word_bits == 16 ? AV_RL16(buf + pos + 4) : 
AV_RL24(buf + pos + 6);
+data_size = container_word_bits == 16 ? AV_RL16(buf + pos + 6) : 
AV_RL24(buf + pos + 9);
+if (s337m_get_offset_and_codec(avc, state, data_type, data_size, 
container_word_bits, , codec))
+return 0;
+if (avc) {
+double s337m_phase = pos * 4. / container_word_bits / 48000;
+av_log(avc, AV_LOG_INFO, "s337m sample %d detected with phase = 
%.6fs\n", consecutive_codes, s337m_phase);
+if (*codec == AV_CODEC_ID_DOLBY_E && (s337m_phase < 
DOLBY_E_PHASE_MIN || s337m_phase > DOLBY_E_PHASE_MAX))
+av_log(avc, AV_LOG_WARNING, "Dolby E phase is out of valid 
range (%.6fs-%.6fs)\n", DOLBY_E_PHASE_MIN, DOLBY_E_PHASE_MAX);
+}
+} while (++consecutive_codes < 2);
+
+return AVPROBE_SCORE_MAX;
+}
+
 static int s337m_read_header(AVFormatContext *s)
 {
 s->ctx_flags |= AVFMTCTX_NOHEADER;
diff --git a/libavformat/s337m.h b/libavformat/s337m.h
index d78ee8c501..707f982c9f 100644
--- a/libavformat/s337m.h
+++ b/libavformat/s337m.h
@@ -21,6 +21,25 @@
 #ifndef AVFORMAT_S337M_H
 #define AVFORMAT_S337M_H
 
+#define S337M_MIN_OFFSET 1601*4
+#define S337M_MAX_OFFSET 2002*6
+
+#define S337M_PROBE_GUARDBAND_MIN_BYTES 0
+#define DOLBY_E_PHASE_MIN   0.000610
+#define DOLBY_E_PHASE_MAX   0.001050
+
+/**
+ * Detect s337m packets in a PCM_S16LE/S24LE stereo stream
+ * Requires two samples with enough (S337M_PROBE_GUARDBAND_MIN_BYTES) and 
clean (set to zero) guard band
+ * @param p_buf Buffer
+ * @param size Buffer size
+ * @param codec Returns AV_CODEC_ID_DOLBY_E upon successful probing
+ * @param avc For av_log
+ * @param container_word_bits 16 or 24
+ * @return = AVPROBE_SCORE
+ */
+int ff_s337m_probe(const uint8_t *p_buf, int size, enum AVCodecID *codec, void 
*avc, int container_word_bits);
+
 /**
  * Read s337m packets in a PCM_S16LE/S24LE stereo stream
  * Returns the first inner packet found
-- 
2.14.1.windows.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] [PATCH 7/9] avformat/wavdec: Fix s337m last packet parsing

2020-01-03 Thread Nicolas Gaullier
Fix reading beyond data_end.
---
 libavformat/wavdec.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index ccb9576b84..039ec1658e 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -643,8 +643,6 @@ static int wav_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1)
 return ff_spdif_read_packet(s, pkt);
-if (CONFIG_S337M_DEMUXER && wav->s337m == 1)
-return ff_s337m_read_packet(s, pkt);
 
 if (wav->smv_data_ofs > 0) {
 int64_t audio_dts, video_dts;
@@ -712,6 +710,10 @@ smv_out:
 wav->data_end = avio_tell(s->pb) + left;
 }
 
+if (CONFIG_S337M_DEMUXER && wav->s337m == 1) {
+size = FFMIN(S337M_MAX_OFFSET, left);
+ret  = ff_s337m_get_packet(s->pb, pkt, size, NULL, s, 
st->codecpar->bits_per_coded_sample);
+} else {
 size = MAX_SIZE;
 if (st->codecpar->block_align > 1) {
 if (size < st->codecpar->block_align)
@@ -720,6 +722,8 @@ smv_out:
 }
 size = FFMIN(size, left);
 ret  = av_get_packet(s->pb, pkt, size);
+}
+
 if (ret < 0)
 return ret;
 pkt->stream_index = 0;
-- 
2.14.1.windows.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] [PATCH 9/9] avformat/wavdec: Test s337m

2020-01-03 Thread Nicolas Gaullier
Test the new 'dolbyeprobe' AVOption.
Test dolby_e decoding for 24 bits with program config '5.1+2'
---
 tests/Makefile   | 1 +
 tests/fate-run.sh| 4 
 tests/fate/audio.mak | 5 +
 3 files changed, 10 insertions(+)

diff --git a/tests/Makefile b/tests/Makefile
index e5f41008d4..65cccac312 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -75,6 +75,7 @@ ENCDEC2 = $(call ALLYES, $(firstword $(1))_ENCODER $(lastword 
$(1))_DECODER  \
  $(firstword $(3))_MUXER   $(lastword $(3))_DEMUXER)
 
 DEMDEC  = $(call ALLYES, $(1)_DEMUXER $(2:%=%_DECODER))
+DEMDEMDEC  = $(call ALLYES, $(1)_DEMUXER $(2)_DEMUXER $(3:%=%_DECODER))
 ENCMUX  = $(call ALLYES, $(1:%=%_ENCODER) $(2)_MUXER)
 
 DEMMUX  = $(call ALLYES, $(1)_DEMUXER $(2)_MUXER)
diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index 83cad8cabe..f06b2fd029 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -162,6 +162,10 @@ pcm(){
 ffmpeg "$@" -vn -f s16le -
 }
 
+dolbye2pcm16(){
+ffmpeg -dolbyeprobe 1 "$@" -vn -f s16le -
+}
+
 fmtstdout(){
 fmt=$1
 shift 1
diff --git a/tests/fate/audio.mak b/tests/fate/audio.mak
index c41958ea2d..0e56d401ea 100644
--- a/tests/fate/audio.mak
+++ b/tests/fate/audio.mak
@@ -24,6 +24,11 @@ fate-dolby-e: CMD = pcm -i $(TARGET_SAMPLES)/dolby_e/16-11
 fate-dolby-e: CMP = oneoff
 fate-dolby-e: REF = $(SAMPLES)/dolby_e/16-11.pcm
 
+FATE_SAMPLES_AUDIO-$(call DEMDEMDEC, WAV, S337M, DOLBY_E) += fate-dolby-e-wav
+fate-dolby-e-wav: CMD = dolbye2pcm16 -i $(TARGET_SAMPLES)/dolby_e/512.wav
+fate-dolby-e-wav: CMP = oneoff
+fate-dolby-e-wav: REF = $(SAMPLES)/dolby_e/512.wav.pcm
+
 FATE_SAMPLES_AUDIO-$(call DEMDEC, DSS, DSS_SP) += fate-dss-lp fate-dss-sp
 fate-dss-lp: CMD = framecrc -i $(TARGET_SAMPLES)/dss/lp.dss -frames 30
 fate-dss-sp: CMD = framecrc -i $(TARGET_SAMPLES)/dss/sp.dss -frames 30
-- 
2.14.1.windows.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] [PATCH 8/9] avformat/wavdec: Reindent after last commit

2020-01-03 Thread Nicolas Gaullier
---
 libavformat/wavdec.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 039ec1658e..0980d85189 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -714,14 +714,14 @@ smv_out:
 size = FFMIN(S337M_MAX_OFFSET, left);
 ret  = ff_s337m_get_packet(s->pb, pkt, size, NULL, s, 
st->codecpar->bits_per_coded_sample);
 } else {
-size = MAX_SIZE;
-if (st->codecpar->block_align > 1) {
-if (size < st->codecpar->block_align)
-size = st->codecpar->block_align;
-size = (size / st->codecpar->block_align) * st->codecpar->block_align;
-}
-size = FFMIN(size, left);
-ret  = av_get_packet(s->pb, pkt, size);
+size = MAX_SIZE;
+if (st->codecpar->block_align > 1) {
+if (size < st->codecpar->block_align)
+size = st->codecpar->block_align;
+size = (size / st->codecpar->block_align) * 
st->codecpar->block_align;
+}
+size = FFMIN(size, left);
+ret  = av_get_packet(s->pb, pkt, size);
 }
 
 if (ret < 0)
-- 
2.14.1.windows.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] [PATCH 6/9] avformat/wavdec: fix s337m/spdif probing beyond data_end

2020-01-03 Thread Nicolas Gaullier
---
 libavformat/wavdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 2796905e1f..ccb9576b84 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -78,7 +78,7 @@ static void set_spdif_s337m(AVFormatContext *s, 
WAVDemuxContext *wav)
 ret = AVERROR(ENOMEM);
 } else {
 int64_t pos = avio_tell(s->pb);
-len = ret = avio_read(s->pb, buf, len);
+len = ret = avio_read(s->pb, buf, FFMIN(len, wav->data_end - 
pos));
 if (len >= 0) {
 ret = ff_spdif_probe(buf, len, );
 if (ret > AVPROBE_SCORE_EXTENSION) {
-- 
2.14.1.windows.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] [PATCH 2/9] avformat/s337m: Split read_packet/get_packet

2020-01-03 Thread Nicolas Gaullier
Prepare use of s337m_get_packet from outside.
---
 libavformat/s337m.c | 28 +---
 libavformat/s337m.h | 38 ++
 2 files changed, 59 insertions(+), 7 deletions(-)
 create mode 100644 libavformat/s337m.h

diff --git a/libavformat/s337m.c b/libavformat/s337m.c
index 8956afb23f..eb26952834 100644
--- a/libavformat/s337m.c
+++ b/libavformat/s337m.c
@@ -21,6 +21,7 @@
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "spdif.h"
+#include "s337m.h"
 
 #define MARKER_16LE 0x72F81F4E
 #define MARKER_20LE 0x20876FF0E154
@@ -141,18 +142,20 @@ static void bswap_buf24(uint8_t *data, int size)
 FFSWAP(uint8_t, data[0], data[2]);
 }
 
-static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
+int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum 
AVCodecID *codec, void *avc)
 {
-AVIOContext *pb = s->pb;
 uint64_t state = 0;
 int ret, data_type, data_size, offset;
-enum AVCodecID codec;
-int64_t pos;
+int64_t pos, orig_pos = avio_tell(pb);
 
 while (!IS_LE_MARKER(state)) {
 state = (state << 8) | avio_r8(pb);
 if (avio_feof(pb))
 return AVERROR_EOF;
+if (avio_tell(pb) - orig_pos + 6 >= size) {
+av_log(avc, AV_LOG_ERROR, "s337m : sync bytes not found at packet 
pos=0x%"PRIx64" size=%d\n", orig_pos, size);
+return AVERROR_INVALIDDATA;
+}
 }
 
 if (IS_16LE_MARKER(state)) {
@@ -165,10 +168,10 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 pos = avio_tell(pb);
 
-if ((ret = s337m_get_offset_and_codec(s, state, data_type, data_size, 
, )) < 0)
+if ((ret = s337m_get_offset_and_codec(avc, state, data_type, data_size, 
, codec)) < 0)
 return ret;
 
-if ((ret = av_new_packet(pkt, offset)) < 0)
+if (ret = av_new_packet(pkt, FFMIN(offset, size - (pos - orig_pos))) < 0)
 return ret;
 
 pkt->pos = pos;
@@ -183,6 +186,17 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 else
 bswap_buf24(pkt->data, pkt->size);
 
+return 0;
+}
+
+int ff_s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+enum AVCodecID codec;
+int ret;
+
+if ((ret = ff_s337m_get_packet(s->pb, pkt, avio_size(s->pb), , s)) < 
0)
+return ret;
+
 if (!s->nb_streams) {
 AVStream *st = avformat_new_stream(s, NULL);
 if (!st) {
@@ -201,6 +215,6 @@ AVInputFormat ff_s337m_demuxer = {
 .long_name  = NULL_IF_CONFIG_SMALL("SMPTE 337M"),
 .read_probe = s337m_probe,
 .read_header= s337m_read_header,
-.read_packet= s337m_read_packet,
+.read_packet= ff_s337m_read_packet,
 .flags  = AVFMT_GENERIC_INDEX,
 };
diff --git a/libavformat/s337m.h b/libavformat/s337m.h
new file mode 100644
index 00..86d2da6f57
--- /dev/null
+++ b/libavformat/s337m.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2017 foo86
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVFORMAT_S337M_H
+#define AVFORMAT_S337M_H
+
+/**
+ * Read s337m packets in a PCM_S16LE/S24LE stereo stream
+ * Returns the first inner packet found
+ * Note that it does not require a clean guard band
+ * @param pb Associated IO context
+ * @param pkt On success, returns a DOLBY E packet
+ * @param size Maximum IO read size available for reading at current position
+ * @param codec Returns AV_CODEC_ID_DOLBY_E
+ * @param avc For av_log
+ * @return = 0 on success (an error is raised if no s337m was found)
+ */
+int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum 
AVCodecID *codec, void *avc);
+
+int ff_s337m_read_packet(AVFormatContext *s, AVPacket *pkt);
+#endif /* AVFORMAT_S337M_H */
-- 
2.14.1.windows.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] [PATCH 3/9] avformat/s337m: Consider container bit resolution

2020-01-03 Thread Nicolas Gaullier
Prepare the support of s337m in muxers other than raw (ex: wav).
For example, this forbids reading 16 bits DolbyE stream from a 24 bit wav file.
---
 libavformat/s337m.c | 20 ++--
 libavformat/s337m.h |  3 ++-
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/libavformat/s337m.c b/libavformat/s337m.c
index eb26952834..5c8ab2649c 100644
--- a/libavformat/s337m.c
+++ b/libavformat/s337m.c
@@ -34,7 +34,7 @@
 
 static int s337m_get_offset_and_codec(void *avc,
   uint64_t state,
-  int data_type, int data_size,
+  int data_type, int data_size, int 
container_word_bits,
   int *offset, enum AVCodecID *codec)
 {
 int word_bits;
@@ -55,6 +55,11 @@ static int s337m_get_offset_and_codec(void *avc,
 avpriv_report_missing_feature(avc, "Data type %#x in SMPTE 337M", 
data_type & 0x1F);
 return AVERROR_PATCHWELCOME;
 }
+if (container_word_bits && (container_word_bits+7)/8 != (word_bits+7)/8) {
+if (avc)
+av_log(avc, AV_LOG_ERROR, "s337m: Container is %d bits vs. stream 
is %d bits\n", container_word_bits, word_bits);
+return AVERROR_INVALIDDATA;
+}
 
 if (codec)
 *codec = AV_CODEC_ID_DOLBY_E;
@@ -104,7 +109,7 @@ static int s337m_probe(const AVProbeData *p)
 data_size = AV_RL24(buf + 3);
 }
 
-if (s337m_get_offset_and_codec(NULL, state, data_type, data_size, 
, NULL))
+if (s337m_get_offset_and_codec(NULL, state, data_type, data_size, 0, 
, NULL))
 continue;
 
 i = IS_16LE_MARKER(state) ? 0 : IS_20LE_MARKER(state) ? 1 : 2;
@@ -142,13 +147,16 @@ static void bswap_buf24(uint8_t *data, int size)
 FFSWAP(uint8_t, data[0], data[2]);
 }
 
-int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum 
AVCodecID *codec, void *avc)
+int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum 
AVCodecID *codec, void *avc, int container_word_bits)
 {
 uint64_t state = 0;
 int ret, data_type, data_size, offset;
 int64_t pos, orig_pos = avio_tell(pb);
 
-while (!IS_LE_MARKER(state)) {
+if (container_word_bits && container_word_bits != 16 && 
container_word_bits != 24)
+return AVERROR_INVALIDDATA;
+while ((container_word_bits == 24 || !IS_16LE_MARKER(state))
+&& (container_word_bits == 16 || !IS_20LE_MARKER(state) && 
!IS_24LE_MARKER(state))) {
 state = (state << 8) | avio_r8(pb);
 if (avio_feof(pb))
 return AVERROR_EOF;
@@ -168,7 +176,7 @@ int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int 
size, enum AVCodecID
 
 pos = avio_tell(pb);
 
-if ((ret = s337m_get_offset_and_codec(avc, state, data_type, data_size, 
, codec)) < 0)
+if ((ret = s337m_get_offset_and_codec(avc, state, data_type, data_size, 
container_word_bits, , codec)) < 0)
 return ret;
 
 if (ret = av_new_packet(pkt, FFMIN(offset, size - (pos - orig_pos))) < 0)
@@ -194,7 +202,7 @@ int ff_s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
 enum AVCodecID codec;
 int ret;
 
-if ((ret = ff_s337m_get_packet(s->pb, pkt, avio_size(s->pb), , s)) < 
0)
+if ((ret = ff_s337m_get_packet(s->pb, pkt, avio_size(s->pb), , s, 
0)) < 0)
 return ret;
 
 if (!s->nb_streams) {
diff --git a/libavformat/s337m.h b/libavformat/s337m.h
index 86d2da6f57..d78ee8c501 100644
--- a/libavformat/s337m.h
+++ b/libavformat/s337m.h
@@ -30,9 +30,10 @@
  * @param size Maximum IO read size available for reading at current position
  * @param codec Returns AV_CODEC_ID_DOLBY_E
  * @param avc For av_log
+ * @param container_word_bits 16,24, or 0 for autodetect
  * @return = 0 on success (an error is raised if no s337m was found)
  */
-int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum 
AVCodecID *codec, void *avc);
+int ff_s337m_get_packet(AVIOContext *pb, AVPacket *pkt, int size, enum 
AVCodecID *codec, void *avc, int container_word_bits);
 
 int ff_s337m_read_packet(AVFormatContext *s, AVPacket *pkt);
 #endif /* AVFORMAT_S337M_H */
-- 
2.14.1.windows.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] [PATCH 1/9] avformat/s337m: Use base AVClass for av_log usage

2020-01-03 Thread Nicolas Gaullier
s337m_get_offset_and_codec does not make use of
AVFormatContext: AVClass is enough for logging.
Will facilitate further use from outside
---
 libavformat/s337m.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavformat/s337m.c b/libavformat/s337m.c
index 48ab66a6da..8956afb23f 100644
--- a/libavformat/s337m.c
+++ b/libavformat/s337m.c
@@ -31,7 +31,7 @@
 #define IS_24LE_MARKER(state)   ((state & 0x) == MARKER_24LE)
 #define IS_LE_MARKER(state) (IS_16LE_MARKER(state) || 
IS_20LE_MARKER(state) || IS_24LE_MARKER(state))
 
-static int s337m_get_offset_and_codec(AVFormatContext *s,
+static int s337m_get_offset_and_codec(void *avc,
   uint64_t state,
   int data_type, int data_size,
   int *offset, enum AVCodecID *codec)
@@ -50,8 +50,8 @@ static int s337m_get_offset_and_codec(AVFormatContext *s,
 }
 
 if ((data_type & 0x1F) != 0x1C) {
-if (s)
-avpriv_report_missing_feature(s, "Data type %#x in SMPTE 337M", 
data_type & 0x1F);
+if (avc)
+avpriv_report_missing_feature(avc, "Data type %#x in SMPTE 337M", 
data_type & 0x1F);
 return AVERROR_PATCHWELCOME;
 }
 
@@ -72,8 +72,8 @@ static int s337m_get_offset_and_codec(AVFormatContext *s,
 *offset = 1601;
 break;
 default:
-if (s)
-avpriv_report_missing_feature(s, "Dolby E data size %d in SMPTE 
337M", data_size);
+if (avc)
+avpriv_report_missing_feature(avc, "Dolby E data size %d in SMPTE 
337M", data_size);
 return AVERROR_PATCHWELCOME;
 }
 
-- 
2.14.1.windows.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] [PATCH 0/9] avformat: Use s337m subdemux inside wav

2020-01-03 Thread Nicolas Gaullier
This is a new version of my previous patchset reviewed by Tomas.
http://ffmpeg.org/pipermail/ffmpeg-devel/2019-August/247677.html

It takes into account the last feedback from Carl Eugen,
I mean that the integration of s337m in wav is now similar to the existing one 
for spdif,
main differences remains that :
- s337m is not enabled by default (activated by the 'dolbyeprobe' AVOption)
- container bit resolution is checked (DolbyE stream bit resolution = WAV PCM 
bit resolution)
- takes data_end into account (see my latest patch here below: 'Fix s337m last 
packet parsing'),
but this one could also be 'forwarded' to spdif
- verbose detection and phase (I think it is a broadcast requirement)

Fate samples can be found here:
- 512.wav : http://0x0.st/zdW-.wav
- 512.mxf.pcm : http://0x0.st/zdWo.pcm

Thank you for this new review...

Nicolas Gaullier (9):
  avformat/s337m: Use base AVClass for av_log usage
  avformat/s337m: Split read_packet/get_packet
  avformat/s337m: Consider container bit resolution
  avformat/s337m: New ff_s337m_probe()
  avformat/wavdec: s337m support
  avformat/wavdec: fix s337m/spdif probing beyond data_end
  avformat/wavdec: Fix s337m last packet parsing
  avformat/wavdec: Reindent after last commit
  avformat/wavdec: Test s337m

 libavformat/s337m.c  | 87 +++-
 libavformat/s337m.h  | 58 +++
 libavformat/wavdec.c | 43 ++
 tests/Makefile   |  1 +
 tests/fate-run.sh|  4 +++
 tests/fate/audio.mak |  5 +++
 6 files changed, 171 insertions(+), 27 deletions(-)
 create mode 100644 libavformat/s337m.h

-- 
2.14.1.windows.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] [PATCH v2] avfilter/formats: optimize ff_all_formats

2020-01-03 Thread quinkblack
From: Zhao Zhili 

This is a micro-optimization. Saving almost 200 reallocations makes it
worth a try.
---
 libavfilter/formats.c | 43 +++
 1 file changed, 35 insertions(+), 8 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 33c64668a0..c04253d898 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -348,21 +348,48 @@ int ff_add_channel_layout(AVFilterChannelLayouts **l, 
uint64_t channel_layout)
 
 AVFilterFormats *ff_all_formats(enum AVMediaType type)
 {
-AVFilterFormats *ret = NULL;
+int count, i;
+AVFilterFormats *ret = av_mallocz(sizeof(*ret));
+
+if (!ret)
+return NULL;
 
 if (type == AVMEDIA_TYPE_VIDEO) {
 const AVPixFmtDescriptor *desc = NULL;
-while ((desc = av_pix_fmt_desc_next(desc))) {
-if (ff_add_format(, av_pix_fmt_desc_get_id(desc)) < 0)
-return NULL;
+
+count = 0;
+while ((desc = av_pix_fmt_desc_next(desc)))
+count++;
+
+ret->formats = av_malloc_array(count, sizeof(*ret->formats));
+if (!ret->formats) {
+av_free(ret);
+return NULL;
+}
+ret->nb_formats = count;
+
+for (i = 0, desc = NULL; i < count; i++) {
+desc = av_pix_fmt_desc_next(desc);
+ret->formats[i] = av_pix_fmt_desc_get_id(desc);
 }
 } else if (type == AVMEDIA_TYPE_AUDIO) {
 enum AVSampleFormat fmt = 0;
-while (av_get_sample_fmt_name(fmt)) {
-if (ff_add_format(, fmt) < 0)
-return NULL;
-fmt++;
+
+count = 0;
+while (av_get_sample_fmt_name(fmt))
+count++;
+
+ret->formats = av_malloc_array(count, sizeof(*ret->formats));
+if (!ret->formats) {
+av_free(ret);
+return NULL;
 }
+ret->nb_formats = count;
+
+for (fmt = 0; fmt < count; fmt++)
+ret->formats[fmt] = fmt;
+} else {
+av_freep();
 }
 
 return ret;
-- 
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 V2 5/5] tools/aviocat: fix memory leak after av_dict_parse_string fail

2020-01-03 Thread myp...@gmail.com
On Fri, Jan 3, 2020 at 7:39 AM Michael Niedermayer
 wrote:
>
> On Thu, Jan 02, 2020 at 07:55:05PM +0800, Jun Zhao wrote:
> > From: Jun Zhao 
> >
> > In case of failure, all the successfully set entries are stored in
> > *pm. We need to manually free the created dictionary to avoid
> > memory leak.
> >
> > Signed-off-by: Jun Zhao 
> > ---
> >  tools/aviocat.c |2 ++
> >  1 files changed, 2 insertions(+), 0 deletions(-)
> >
> > diff --git a/tools/aviocat.c b/tools/aviocat.c
> > index 816ab70..0fdf39b 100644
> > --- a/tools/aviocat.c
> > +++ b/tools/aviocat.c
> > @@ -53,6 +53,7 @@ int main(int argc, char **argv)
> >  i++;
> >  } else if (!strcmp(argv[i], "-oi") && i + 1 < argc) {
> >  if (av_dict_parse_string(_opts, argv[i + 1], "=", ":", 0) < 
> > 0) {
> > +av_dict_free(_opts);
> >  fprintf(stderr, "Cannot parse option string %s\n",
> >  argv[i + 1]);
> >  return usage(argv[0], 1);
> > @@ -60,6 +61,7 @@ int main(int argc, char **argv)
> >  i++;
> >  } else if (!strcmp(argv[i], "-oo") && i + 1 < argc) {
> >  if (av_dict_parse_string(_opts, argv[i + 1], "=", ":", 0) 
> > < 0) {
> > +av_dict_free(_opts);
> >  fprintf(stderr, "Cannot parse option string %s\n",
> >  argv[i + 1]);
> >  return usage(argv[0], 1);
>
> I think these are not sufficient to fix the memleaks
>
> thanks
>

Will double-check this part, thx
___
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] ffmpeg: don't force source-tracked keyframes for duplicates

2020-01-03 Thread Gyan



On 03-01-2020 03:30 pm, Michael Niedermayer wrote:

On Fri, Jan 03, 2020 at 12:35:22PM +0530, Gyan Doshi wrote:

Prevents a run of consecutive duplicate frames from all being encoded
as keyframes, when force_key_frames is set to source.
---
  fftools/ffmpeg.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

maybe ok (i wonder if this would be expected behavior with intra only input)


If user wants intra-only output, they can use an intra-coded encoder or 
-g 1.


If they want to preserve same seek points as source, then the 
non-duplicated frame has the closest pts sync to the source timestamp.



Gyan
___
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] avcodec/aacenc: Compatibility with Bluetooth A2DP headsets

2020-01-03 Thread Hendrik Leppkes
On Fri, Jan 3, 2020 at 9:24 AM Andrey Semashev
 wrote:
>
> On 2020-01-03 09:14, Kieran Kunhya wrote:
> >>
> >>> Thanks.
> >>
> >> Ping?
> >>
> >
> > Have you tried using our LATM mux?
>
> No, I'm trying to avoid libavformat dependency. I'm sure my LATM code is
> fine because it works with libfdk-aac.

No harm in testing to confirm.

- Hendrik
___
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] Workaround to build ffmpeg on MacOs 10.15

2020-01-03 Thread Timo Rothenpieler

I think this was discussed on this list in the past.
Not sure what the conclusion was, but I think an unconditional flag like 
this being added wasn't all that well received.

___
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] ffmpeg: don't force source-tracked keyframes for duplicates

2020-01-03 Thread Michael Niedermayer
On Fri, Jan 03, 2020 at 12:35:22PM +0530, Gyan Doshi wrote:
> Prevents a run of consecutive duplicate frames from all being encoded
> as keyframes, when force_key_frames is set to source.
> ---
>  fftools/ffmpeg.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

maybe ok (i wonder if this would be expected behavior with intra only input)

thx

[...]

-- 
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 V4 1/2] libswscale/x86/yuv2rgb: Change inline assembly into nasm code

2020-01-03 Thread Michael Niedermayer
On Fri, Jan 03, 2020 at 06:59:28AM +, Fu, Ting wrote:
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Michael Niedermayer
> > Sent: Friday, December 27, 2019 07:38 PM
> > To: FFmpeg development discussions and patches 
> > Subject: Re: [FFmpeg-devel] [PATCH V4 1/2] libswscale/x86/yuv2rgb: Change
> > inline assembly into nasm code
> > 
> > On Thu, Dec 19, 2019 at 11:35:51AM +0800, Ting Fu wrote:
> > > Tested using this command:
> > > ./ffmpeg -pix_fmt yuv420p -s 1920*1080 -i ArashRawYuv420.yuv \ -vcodec
> > > rawvideo -s 1920*1080 -pix_fmt rgb24 -f null /dev/null
> > >
> > 
> > > The fps increase from 151 to 389 on my local machine.
> > 
> > Thats nice but why is there such a difference from changing the way the 
> > code is
> > assembled ?
> > This should definitly be explained more detailedly in the commit message
> > 
> Hi, Michael
> 
> The fps increasing means mmx compared to C code, not inline compared nasm 
> one. I will remove it from the commit message next patch version.

please test apples against apples, a benchmark of the inline vs NASM code
certainly cannot hurt. Testing unoptimized vs new optimized code is not
interresting. Testing old optimized vs new optimized code is interresting


> 
> > 
> > >
> > > Signed-off-by: Ting Fu 
> > > ---
> > >  libswscale/x86/Makefile   |   1 +
> > >  libswscale/x86/swscale.c  |  16 +-
> > >  libswscale/x86/yuv2rgb.c  |  81 +++---
> > >  libswscale/x86/yuv2rgb_template.c | 441 ++
> > >  libswscale/x86/yuv_2_rgb.asm  | 270 ++
> > >  5 files changed, 395 insertions(+), 414 deletions(-)  create mode
> > > 100644 libswscale/x86/yuv_2_rgb.asm
> > >
> > > diff --git a/libswscale/x86/Makefile b/libswscale/x86/Makefile index
> > > f317d5dd9b..831d5359aa 100644
> > > --- a/libswscale/x86/Makefile
> > > +++ b/libswscale/x86/Makefile
> > > @@ -12,3 +12,4 @@ X86ASM-OBJS += x86/input.o  
> > > \
> > > x86/output.o \
> > > x86/scale.o  \
> > > x86/rgb_2_rgb.o  \
> > > +   x86/yuv_2_rgb.o  \
> > > diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c index
> > > 0eed4f18d5..e9d474a1e8 100644
> > > --- a/libswscale/x86/swscale.c
> > > +++ b/libswscale/x86/swscale.c
> > > @@ -29,6 +29,14 @@
> > >  #include "libavutil/cpu.h"
> > >  #include "libavutil/pixdesc.h"
> > >
> > > +const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
> > > +0x0103010301030103LL,
> > > +0x0200020002000200LL,};
> > > +
> > > +const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
> > > +0x0602060206020602LL,
> > > +0x0004000400040004LL,};
> > > +
> > >  #if HAVE_INLINE_ASM
> > >
> > >  #define DITHER1XBPP
> > > @@ -38,14 +46,6 @@ DECLARE_ASM_CONST(8, uint64_t, bFC)=
> > 0xFCFCFCFCFCFCFCFCLL;
> > >  DECLARE_ASM_CONST(8, uint64_t, w10)=   0x0010001000100010LL;
> > >  DECLARE_ASM_CONST(8, uint64_t, w02)=   0x0002000200020002LL;
> > >
> > > -const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
> > > -0x0103010301030103LL,
> > > -0x0200020002000200LL,};
> > > -
> > > -const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
> > > -0x0602060206020602LL,
> > > -0x0004000400040004LL,};
> > > -
> > >  DECLARE_ASM_CONST(8, uint64_t, b16Mask)=   0x001F001F001F001FLL;
> > >  DECLARE_ASM_CONST(8, uint64_t, g16Mask)=   0x07E007E007E007E0LL;
> > >  DECLARE_ASM_CONST(8, uint64_t, r16Mask)=   0xF800F800F800F800LL;
> > > diff --git a/libswscale/x86/yuv2rgb.c b/libswscale/x86/yuv2rgb.c index
> > > 5e2f77c20f..ed9b613cab 100644
> > > --- a/libswscale/x86/yuv2rgb.c
> > > +++ b/libswscale/x86/yuv2rgb.c
> > > @@ -37,7 +37,7 @@
> > >  #include "libavutil/x86/cpu.h"
> > >  #include "libavutil/cpu.h"
> > >
> > > -#if HAVE_INLINE_ASM
> > > +#if HAVE_X86ASM
> > >
> > >  #define DITHER1XBPP // only for MMX
> > >
> > > @@ -50,70 +50,51 @@ DECLARE_ASM_CONST(8, uint64_t, pb_03) =
> > > 0x0303030303030303ULL;  DECLARE_ASM_CONST(8, uint64_t, pb_07) =
> > > 0x0707070707070707ULL;
> > >
> > >  //MMX versions
> > > -#if HAVE_MMX_INLINE && HAVE_6REGS
> > > -#undef RENAME
> > > +#if HAVE_MMX
> > >  #undef COMPILE_TEMPLATE_MMXEXT
> > >  #define COMPILE_TEMPLATE_MMXEXT 0
> > > -#define RENAME(a) a ## _mmx
> > > -#include "yuv2rgb_template.c"
> > > -#endif /* HAVE_MMX_INLINE && HAVE_6REGS */
> > > +#endif /* HAVE_MMX */
> > >
> > >  // MMXEXT versions
> > > -#if HAVE_MMXEXT_INLINE && HAVE_6REGS
> > > -#undef RENAME
> > > +#if HAVE_MMXEXT
> > >  #undef COMPILE_TEMPLATE_MMXEXT
> > >  #define COMPILE_TEMPLATE_MMXEXT 1
> > > -#define RENAME(a) a ## _mmxext
> > > -#include "yuv2rgb_template.c"
> > > -#endif /* HAVE_MMXEXT_INLINE && HAVE_6REGS */
> > > +#endif /* HAVE_MMXEXT */
> > >
> > > -#endif /* HAVE_INLINE_ASM */
> > > 

Re: [FFmpeg-devel] avcodec/aacenc: Compatibility with Bluetooth A2DP headsets

2020-01-03 Thread Andrey Semashev

On 2020-01-03 09:14, Kieran Kunhya wrote:



Thanks.


Ping?



Have you tried using our LATM mux?


No, I'm trying to avoid libavformat dependency. I'm sure my LATM code is 
fine because it works with libfdk-aac.

___
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".