Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Nicolas George
Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
> So it is. So unless you tell what exactly you mean I can not help you.

My bad.

> testsrc(2) are useless for lipsync testing, when one needs to know
> exact time something is played in wrong time.

Yes, testsrc alone is not enough. But you did not read carefully enough:
I mentioned testsrc2+sine. The sine source can optionally generate a
periodic beep, just like your proposal. I grant you, the duration and
period of the beep cannot be configured, but that would be easy to add.
And sine is bit-exact and faster.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Paul B Mahol
On 8/19/17, Nicolas George  wrote:
> Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
>> So it is. So unless you tell what exactly you mean I can not help you.
>
> My bad.
>
>> testsrc(2) are useless for lipsync testing, when one needs to know
>> exact time something is played in wrong time.
>
> Yes, testsrc alone is not enough. But you did not read carefully enough:
> I mentioned testsrc2+sine. The sine source can optionally generate a
> periodic beep, just like your proposal. I grant you, the duration and
> period of the beep cannot be configured, but that would be easy to add.
> And sine is bit-exact and faster.

And how would you show delay introduced with video source filter?
testsrc(2) does not show anything resembling that.

Look at those youtube videos:
https://www.youtube.com/results?search_query=video+sync
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/mov: initial support for reading HEIF images

2017-08-19 Thread Carl Eugen Hoyos
2017-08-19 9:24 GMT+02:00 Rodger Combs :

>  AVInputFormat ff_mov_demuxer = {
> -.name   = "mov,mp4,m4a,3gp,3g2,mj2",
> +.name   = "mov,mp4,m4a,3gp,3g2,mj2,heif,heic",

Since it isn't necessary for the new feature:
Please don't change this line.

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


Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Paul B Mahol
On 8/19/17, Nicolas George  wrote:
> Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
>> Try harder to explain what you think.
>
> This "filter" has no input. All similar "filters" are called sources and
> implemented in files named accordingly.

So it is. So unless you tell what exactly you mean I can not help you.

>
>> If you actually tried you would know.
>
> I am sorry, but I do not accept that as an answer. Please explain why
> all this extra code is useful compared to what already exists.

testsrc(2) are useless for lipsync testing, when one needs to know
exact time something is played in wrong time.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Nicolas George
Le nonidi 29 thermidor, an CCXXV, Paul B Mahol a écrit :
> Hi,
> 
> patch attached.

> From 8d3876499b93e61ec1aec39adfc3c3be8d622464 Mon Sep 17 00:00:00 2001
> From: Paul B Mahol 
> Date: Fri, 28 Apr 2017 20:18:38 +0200
> Subject: [PATCH] avfilter: add Audio Video Sync Test filter
> 
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/Makefile |   1 +
>  libavfilter/allfilters.c |   1 +
>  libavfilter/src_avsynctest.c | 314 
> +++
>  3 files changed, 316 insertions(+)
>  create mode 100644 libavfilter/src_avsynctest.c

Documentation missing.

> 
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 545b871cd7..aaf7375303 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -373,6 +373,7 @@ OBJS-$(CONFIG_SHOWWAVESPIC_FILTER)   += 
> avf_showwaves.o
>  OBJS-$(CONFIG_SPECTRUMSYNTH_FILTER)  += vaf_spectrumsynth.o 
> window_func.o
>  
>  # multimedia sources

> +OBJS-$(CONFIG_AVSYNCTEST_FILTER) += src_avsynctest.o

It is a source, not a filter.

>  OBJS-$(CONFIG_AMOVIE_FILTER) += src_movie.o
>  OBJS-$(CONFIG_MOVIE_FILTER)  += src_movie.o
>  
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index f1dacaffa8..32f4049b30 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -384,6 +384,7 @@ static void register_all(void)
>  REGISTER_FILTER(SPECTRUMSYNTH,  spectrumsynth,  vaf);
>  
>  /* multimedia sources */
> +REGISTER_FILTER(AVSYNCTEST, avsynctest, avsrc);
>  REGISTER_FILTER(AMOVIE, amovie, avsrc);
>  REGISTER_FILTER(MOVIE,  movie,  avsrc);
>  
> diff --git a/libavfilter/src_avsynctest.c b/libavfilter/src_avsynctest.c
> new file mode 100644
> index 00..2f95976cbb
> --- /dev/null
> +++ b/libavfilter/src_avsynctest.c
> @@ -0,0 +1,314 @@
> +/*
> + * Copyright (c) 2017 Paul B Mahol
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include "libavutil/avassert.h"
> +#include "libavutil/common.h"
> +#include "libavutil/ffmath.h"
> +#include "libavutil/opt.h"
> +#include "libavutil/imgutils.h"
> +#include "libavutil/intreadwrite.h"
> +#include "libavutil/parseutils.h"
> +#include "libavutil/timestamp.h"
> +#include "libavutil/xga_font_data.h"
> +#include "avfilter.h"
> +#include "drawutils.h"
> +#include "formats.h"
> +#include "internal.h"
> +#include "audio.h"
> +#include "video.h"
> +
> +typedef struct AVSyncTestContext {
> +const AVClass *class;
> +
> +int w, h;
> +AVRational frame_rate;
> +int sample_rate;
> +int64_t apts, vpts, prev_vpts;
> +float amplitude;
> +int period;
> +int delay;
> +int cycle;
> +
> +int previ;
> +int beep;
> +int beep_duration;
> +int flash;
> +int dir;
> +float vdelay, delay_max, delay_min;
> +float delay_range;
> +
> +FFDrawContext draw;
> +FFDrawColor white;
> +FFDrawColor black;
> +FFDrawColor gray;
> +} AVSyncTestContext;
> +
> +#define OFFSET(x) offsetof(AVSyncTestContext, x)
> +#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
> +#define V AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
> +
> +static const AVOption avsynctest_options[] = {
> +{"size",   "set frame size",  OFFSET(w),   
> AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"},   0,   0, V },
> +{"s",  "set frame size",  OFFSET(w),   
> AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"},   0,   0, V },
> +{"framerate",  "set frame rate",  OFFSET(frame_rate),  
> AV_OPT_TYPE_VIDEO_RATE, {.str="30"},   0,INT_MAX, V },
> +{"fr", "set frame rate",  OFFSET(frame_rate),  
> AV_OPT_TYPE_VIDEO_RATE, {.str="30"},   0,INT_MAX, V },
> +{"samplerate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT,  
>   {.i64=44100},8000,192000, A },
> +{"sr", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT,  
>   {.i64=44100},8000,192000, A },
> +{"amplitude",  "set amplitude",   OFFSET(amplitude),   
> AV_OPT_TYPE_FLOAT,  {.dbl=.5},   0.,  1., A },
> +{"a",  "set amplitude",   OFFSET(amplitude),   
> 

Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Nicolas George
Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
> And how would you show delay introduced with video source filter?
> testsrc(2) does not show anything resembling that.

I do not understand what you mean. The output of "ffmpeg -lavfi
'testsrc2;sine'" looks functionally identical to the video you point.
Please be more specific, with more than two short lines of answer.

Regards,

-- 
  Nicolas George


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


[FFmpeg-devel] [PATCH] lavf/mov: initial support for reading HEIF images

2017-08-19 Thread Rodger Combs
There's a decent chance this doesn't work on [pretty much anything other than
the samples I tested it with], but I haven't found very many samples, and don't
want to implement the rest of the features blind with nothing but a spec, and
most of it's pretty over-the-top anyway.

For some reason my phone running iOS 11 doesn't actually export HEIFs; it just
gives me JPEGs with a .HEIC extension.

HEIF is basically just an overengineered new mechanism for attaching still
pictures to MP4 files. Its atoms can exist along with a moov, or without one.

This can probably seek-thrash pretty badly in some cases, so if it becomes
common to use this to attach pictures to audio or video files, it'd probably
be worth adding an "ignore_attached_pics" option, a la "ignore_chapters". It'd
be possible to optimize some of the seeks out by adding some more internal
state (this is a naive implementation of a very implementer-unfriendly format),
but some are inherent to the design, like with "chap" chapters.

Short rant: this whole format is crazy. There are a bunch of variable-size
fields ("in case you ever need more than 2^16 pictures in a file!", and also
"in case you want to save space by using 3 bytes for the size instead of 4!"),
and everything has extra cruft at every opportunity in the name of future
extensibility. If somebody wants to explain why an 8-byte atom containing a
width and a height needs another 4 bytes for version and flags fields, I'm
all ears. There are also some count fields that serve no purpose within their
parent atom.

For some reason the format supports splitting a picture into multiple byte
ranges, which can be in separate mdats, or separate positions in the same
mdat, and there are 3 different ways to address them (I've only implemented
the one used in the samples I had). If anyone knows why anyone would ever
want to do that, please inform me.

This will definitely completely fall apart if any of the metadata atoms come
after the iloc. Hopefully that never happens, because it would be a pain to
work around.

TL;DR this format is bad, but at least we're finally moving past JPEG.
---
 libavformat/isom.h |   2 +
 libavformat/mov.c  | 331 +++--
 2 files changed, 326 insertions(+), 7 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index ff009b0896..a3ba10bf76 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -223,7 +223,9 @@ typedef struct MOVContext {
 int found_moov;   ///< 'moov' atom has been found
 int found_mdat;   ///< 'mdat' atom has been found
 int found_hdlr_mdta;  ///< 'hdlr' atom with type 'mdta' has been found
+int found_iloc;   ///< 'iloc' atom has been found
 int trak_index;   ///< Index of the current 'trak'
+int cur_stream_index; ///< Stream currently being populated
 char **meta_keys;
 unsigned meta_keys_count;
 DVDemuxContext *dv_demux;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 522ce60c2d..87dbc83d6f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1678,9 +1678,9 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 AVStream *st;
 int ret;
 
-if (c->fc->nb_streams < 1)
+if (c->cur_stream_index < 0)
 return 0;
-st = c->fc->streams[c->fc->nb_streams-1];
+st = c->fc->streams[c->cur_stream_index];
 
 if ((uint64_t)atom.size > (1<<30))
 return AVERROR_INVALIDDATA;
@@ -3742,6 +3742,8 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 sc = av_mallocz(sizeof(MOVStreamContext));
 if (!sc) return AVERROR(ENOMEM);
 
+c->cur_stream_index = st->index;
+
 st->priv_data = sc;
 st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
 sc->ffindex = st->index;
@@ -3976,6 +3978,10 @@ static int mov_read_custom(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 
 static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
+// Skip version and flags
+avio_skip(pb, 4);
+atom.size -= 4;
+
 while (atom.size > 8) {
 uint32_t tag = avio_rl32(pb);
 atom.size -= 4;
@@ -5470,6 +5476,310 @@ static int mov_read_dops(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 return 0;
 }
 
+static uint64_t read_length(AVIOContext *pb, unsigned len)
+{
+uint64_t ret = 0, i = 0;
+for (i = 0; i < len; i++)
+ret = (ret << 8) | avio_r8(pb);
+return ret;
+}
+
+enum HEIFOffsetType {
+HEIF_OFFSET_FILE = 0,
+HEIF_OFFSET_MDAT = 1,
+HEIF_OFFSET_ITEM = 2
+};
+
+static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+int version = avio_r8(pb);
+avio_rb24(pb); // flags
+int ret = 0;
+
+unsigned item_count, i, j;
+
+int offset_size = avio_r8(pb);
+int length_size = offset_size & 0xf;
+int base_offset_size = avio_r8(pb);
+int index_size = base_offset_size & 0xf;
+offset_size >>= 4;
+base_offset_size >>= 4;
+
+if (version > 2) {
+

Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Nicolas George
Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
> Try harder to explain what you think.

This "filter" has no input. All similar "filters" are called sources and
implemented in files named accordingly.

> If you actually tried you would know.

I am sorry, but I do not accept that as an answer. Please explain why
all this extra code is useful compared to what already exists.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Nicolas George
Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
> How do you know when beep and blink should happen in your example?
> 
> What is blink for testsrc2? Where in testsrc2 you can see delay in numeric 
> form?

Have you tried? You have a numeric timestamp and frame counter in the
upper left corner and a beating cross, both in sync with the beeps.
Please tell me what you are missing here. With more than two lines
please.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Paul B Mahol
On 8/19/17, Nicolas George  wrote:
> Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
>> And how would you show delay introduced with video source filter?
>> testsrc(2) does not show anything resembling that.
>
> I do not understand what you mean. The output of "ffmpeg -lavfi
> 'testsrc2;sine'" looks functionally identical to the video you point.
> Please be more specific, with more than two short lines of answer.

How do you know when beep and blink should happen in your example?

What is blink for testsrc2? Where in testsrc2 you can see delay in numeric form?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Paul B Mahol
On 8/19/17, Nicolas George  wrote:
> Le nonidi 29 thermidor, an CCXXV, Paul B Mahol a écrit :
>> Hi,
>>
>> patch attached.
>
>> From 8d3876499b93e61ec1aec39adfc3c3be8d622464 Mon Sep 17 00:00:00 2001
>> From: Paul B Mahol 
>> Date: Fri, 28 Apr 2017 20:18:38 +0200
>> Subject: [PATCH] avfilter: add Audio Video Sync Test filter
>>
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavfilter/Makefile |   1 +
>>  libavfilter/allfilters.c |   1 +
>>  libavfilter/src_avsynctest.c | 314
>> +++
>>  3 files changed, 316 insertions(+)
>>  create mode 100644 libavfilter/src_avsynctest.c
>
> Documentation missing.
>
>>
>> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
>> index 545b871cd7..aaf7375303 100644
>> --- a/libavfilter/Makefile
>> +++ b/libavfilter/Makefile
>> @@ -373,6 +373,7 @@ OBJS-$(CONFIG_SHOWWAVESPIC_FILTER)   +=
>> avf_showwaves.o
>>  OBJS-$(CONFIG_SPECTRUMSYNTH_FILTER)  += vaf_spectrumsynth.o
>> window_func.o
>>
>>  # multimedia sources
>
>> +OBJS-$(CONFIG_AVSYNCTEST_FILTER) += src_avsynctest.o
>
> It is a source, not a filter.

Try harder to explain what you think.

>
>>  OBJS-$(CONFIG_AMOVIE_FILTER) += src_movie.o
>>  OBJS-$(CONFIG_MOVIE_FILTER)  += src_movie.o
>>
>> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
>> index f1dacaffa8..32f4049b30 100644
>> --- a/libavfilter/allfilters.c
>> +++ b/libavfilter/allfilters.c
>> @@ -384,6 +384,7 @@ static void register_all(void)
>>  REGISTER_FILTER(SPECTRUMSYNTH,  spectrumsynth,  vaf);
>>
>>  /* multimedia sources */
>> +REGISTER_FILTER(AVSYNCTEST, avsynctest, avsrc);
>>  REGISTER_FILTER(AMOVIE, amovie, avsrc);
>>  REGISTER_FILTER(MOVIE,  movie,  avsrc);
>>
>> diff --git a/libavfilter/src_avsynctest.c b/libavfilter/src_avsynctest.c
>> new file mode 100644
>> index 00..2f95976cbb
>> --- /dev/null
>> +++ b/libavfilter/src_avsynctest.c
>> @@ -0,0 +1,314 @@
>> +/*
>> + * Copyright (c) 2017 Paul B Mahol
>> + *
>> + * This file is part of FFmpeg.
>> + *
>> + * FFmpeg is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU Lesser General Public
>> + * License as published by the Free Software Foundation; either
>> + * version 2.1 of the License, or (at your option) any later version.
>> + *
>> + * FFmpeg is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with FFmpeg; if not, write to the Free Software
>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
>> 02110-1301 USA
>> + */
>> +
>> +#include "libavutil/avassert.h"
>> +#include "libavutil/common.h"
>> +#include "libavutil/ffmath.h"
>> +#include "libavutil/opt.h"
>> +#include "libavutil/imgutils.h"
>> +#include "libavutil/intreadwrite.h"
>> +#include "libavutil/parseutils.h"
>> +#include "libavutil/timestamp.h"
>> +#include "libavutil/xga_font_data.h"
>> +#include "avfilter.h"
>> +#include "drawutils.h"
>> +#include "formats.h"
>> +#include "internal.h"
>> +#include "audio.h"
>> +#include "video.h"
>> +
>> +typedef struct AVSyncTestContext {
>> +const AVClass *class;
>> +
>> +int w, h;
>> +AVRational frame_rate;
>> +int sample_rate;
>> +int64_t apts, vpts, prev_vpts;
>> +float amplitude;
>> +int period;
>> +int delay;
>> +int cycle;
>> +
>> +int previ;
>> +int beep;
>> +int beep_duration;
>> +int flash;
>> +int dir;
>> +float vdelay, delay_max, delay_min;
>> +float delay_range;
>> +
>> +FFDrawContext draw;
>> +FFDrawColor white;
>> +FFDrawColor black;
>> +FFDrawColor gray;
>> +} AVSyncTestContext;
>> +
>> +#define OFFSET(x) offsetof(AVSyncTestContext, x)
>> +#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
>> +#define V AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
>> +
>> +static const AVOption avsynctest_options[] = {
>> +{"size",   "set frame size",  OFFSET(w),
>> AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"},   0,   0, V },
>> +{"s",  "set frame size",  OFFSET(w),
>> AV_OPT_TYPE_IMAGE_SIZE, {.str="hd720"},   0,   0, V },
>> +{"framerate",  "set frame rate",  OFFSET(frame_rate),
>> AV_OPT_TYPE_VIDEO_RATE, {.str="30"},   0,INT_MAX, V },
>> +{"fr", "set frame rate",  OFFSET(frame_rate),
>> AV_OPT_TYPE_VIDEO_RATE, {.str="30"},   0,INT_MAX, V },
>> +{"samplerate", "set sample rate", OFFSET(sample_rate),
>> AV_OPT_TYPE_INT,{.i64=44100},8000,192000, A },
>> +{"sr", "set sample rate", OFFSET(sample_rate),
>> AV_OPT_TYPE_INT,{.i64=44100},8000,192000, A },
>> +

Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Nicolas George
Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
> That is not delay between blink and beep. But video timestamps.

Since the beeps happen every second, the delay is the fractional part,
or the remainder of the frame count divided by the frame rate. But if
you think this arithmetic is too complex for our users, feel free to
propose an option to add it on testsrc2.

> For lipsync one would need to alter so blinks happens at exact same
> time as beeps.

They do.

> Say delay is 10 frames, you modify filter to produce delayed blinks.

I think it should be a job for setpts, but if you consider that too
complex, again, I am not against a time delay option to testsrc2.

> > The beep is when the cross is fully contracted.
> That is far for being user friendly and obvious.

It looks as obvious as the bumping dot on the videos you showed, in my
opinion.

Anyway, I am not against you wasting your time adding yet another test
pattern, but not as proposed in this patch: use the framework of all the
test patterns and make it bit-exact.

Regards,

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


Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Paul B Mahol
On 8/19/17, Nicolas George  wrote:
> Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
>> That is not delay between blink and beep. But video timestamps.
>
> Since the beeps happen every second, the delay is the fractional part,
> or the remainder of the frame count divided by the frame rate. But if
> you think this arithmetic is too complex for our users, feel free to
> propose an option to add it on testsrc2.
>
>> For lipsync one would need to alter so blinks happens at exact same
>> time as beeps.
>
> They do.
>
>> Say delay is 10 frames, you modify filter to produce delayed blinks.
>
> I think it should be a job for setpts, but if you consider that too
> complex, again, I am not against a time delay option to testsrc2.
>
>> > The beep is when the cross is fully contracted.
>> That is far for being user friendly and obvious.
>
> It looks as obvious as the bumping dot on the videos you showed, in my
> opinion.
>
> Anyway, I am not against you wasting your time adding yet another test
> pattern, but not as proposed in this patch: use the framework of all the
> test patterns and make it bit-exact.

I like idea of having single A/V filter to do this job, not combinations where
users might become confused.
Also this filter displays audio parameters in video output, which would become
pain to do in combination of filters.

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


Re: [FFmpeg-devel] [PATCH] opus_pvq_search: Restore the proper use of conditional define and simplify the function name suffix handling

2017-08-19 Thread Rostislav Pehlivanov
On 19 August 2017 at 16:10, Ivan Kalvachev  wrote:

> Using named define properly documents the code paths.
> It also avoids passing additional numbered arguments through
> multiple levels of macro templates.
>
> The suffix handling is done by concatenation, like in
> other asm functions and avoid having two separate
> "cglobal" defines.
>
> ---
> I have to point few things out.
>
> commit f386dd70acdc81d42d6bcb885d2889634cdf45b7
> "opus_pvq_search: only use rsqrtps approximation on CPUs with avx"
> was rushed hack job:
>

Well, your original patch was unpolished, so there's that.


>
> 3. The changes were numerous and intrusive, obfuscating code,
> while the same result could have been achieved
> with a single new line.
>
>
I disagree. Its completely clear and unobfuscated.


> I did request revert of this commit on irc and in ffmpeg-cvs-log mail,
> I did request a patch to be sent to ffmpeg-dev-eng, to discuss the
> best way to make the change.
>
> I did oppose the follow up commit 3c99523a2864af729a8576c3fffe81
> fb884fa0d5,
> that tried to fix the compilation, by redoing the intrusive changes once
> again,
> and making new changes that affect the C code too. (Thus making revert
> a lot more messy.)
>
> I find it extremely offensive that I as author of the code and FFmpeg
> developer
> was totally ignored, without providing any technical reasons and with
> something that sums up to "I like my code more".
>
> This breaks good faith, COC and the written rules.
>
>
As the maintainer of the encoder I have the last word on what goes on. I
could have instead amended your original patch but that would probably have
been even more offensive, hence I chose to have separate patches to fix the
problems.

On the other hand, the patch you've included is nothing more than a case of
"I like my code more". All you do is you add back a macro which doesn't
(and did not in the first place) even follow the code standard. It has
indentation, and it shouldn't.

The only way I'm going to accept this patch is if you send a V2 of the
patch which correctly removes the ident on the macro. And does away with
your pointless protests.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/pixlet: Fixes: undefined shift in av_mod_uintp2()

2017-08-19 Thread Paul B Mahol
On 8/19/17, Michael Niedermayer  wrote:
> On Fri, Aug 18, 2017 at 06:21:56PM +0200, Paul B Mahol wrote:
>> On 8/18/17, Michael Niedermayer  wrote:
>> > Fixes: runtime error: shift exponent 4294967289 is too large for 32-bit
>> > type
>> > 'int'
>> > Fixes: 3030/clusterfuzz-testcase-minimized-4649809254285312
>> >
>> > Found-by: continuous fuzzing process
>> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>> > Signed-off-by: Michael Niedermayer 
>> > ---
>> >  libavcodec/pixlet.c | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/libavcodec/pixlet.c b/libavcodec/pixlet.c
>> > index 088226bdda..a9cfe085c9 100644
>> > --- a/libavcodec/pixlet.c
>> > +++ b/libavcodec/pixlet.c
>> > @@ -262,7 +262,7 @@ static int read_high_coeffs(AVCodecContext *avctx,
>> > uint8_t *src, int16_t *dst, i
>> >
>> >  flag = 0;
>> >
>> > -if (state * 4ULL > 0xFF || i >= size)
>> > +if ((uint64_t)state > 0xFF / 4 || i >= size)
>>
>> This is not exact same behaviour.
>
> no, it differs for a small number of cases that have one of the 2
> most significant bits (of the 64 bits) set in state.
> I think this was a bug i introduced in a previous commit.
>
> If above change is not the correct thing to do, please elaborate.
> state is passed into ff_clz() later which has no deterministic
> behavior when these MSBs are set as ff_clz() uses unsigned and state
> is int64_t and unsigned can be 32 or 64bit.

Only 32 bits matters for ff_clz() anyway.

> So this really just change cases that do not work equally
> across platforms
>
> looking at this now, i suspect independant of this patch
> the 32 and 24 in
> pfx = ((state + 8) >> 5) + (state ? ff_clz(state): 32) - 24;
> should be CHAR_BIT * sizeof(unsiged) or something similar
> or something else should be changed
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Take away the freedom of one citizen and you will be jailed, take away
> the freedom of all citizens and you will be congratulated by your peers
> in Parliament.
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Paul B Mahol
On 8/19/17, Nicolas George  wrote:
> Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
>> Exact delay in number of frames and that converted to milliseconds.
>
> Already present. I asked you if you tested, obviously you did not.

Sorry but where is that present? I nowhere can determine exact delay
in number of frames versus sine beep.

>
>> Also one can not set custom delay between beep and blink.
>
> I already mentioned that. You can propose a patch to sine to add that
> option.

It is not sine but testsrc2 one that would need modification.

>
>> Also beating cross is far from being easily noticed like blink.
>
> I do not agree.

Why you do not agree? When is actual beep when beating cross appears?

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


[FFmpeg-devel] [PATCH] opus_pvq_search: Restore the proper use of conditional define and simplify the function name suffix handling

2017-08-19 Thread Ivan Kalvachev
Using named define properly documents the code paths.
It also avoids passing additional numbered arguments through
multiple levels of macro templates.

The suffix handling is done by concatenation, like in
other asm functions and avoid having two separate
"cglobal" defines.

---
I have to point few things out.

commit f386dd70acdc81d42d6bcb885d2889634cdf45b7
"opus_pvq_search: only use rsqrtps approximation on CPUs with avx"
was rushed hack job:

1. It broke compilation with yasm.
2. Its subject says the opposite of what the patch does.
3. The changes were numerous and intrusive, obfuscating code,
while the same result could have been achieved
with a single new line.

I did request revert of this commit on irc and in ffmpeg-cvs-log mail,
I did request a patch to be sent to ffmpeg-dev-eng, to discuss the
best way to make the change.

I did oppose the follow up commit 3c99523a2864af729a8576c3fffe81fb884fa0d5,
that tried to fix the compilation, by redoing the intrusive changes once again,
and making new changes that affect the C code too. (Thus making revert
a lot more messy.)

I find it extremely offensive that I as author of the code and FFmpeg developer
was totally ignored, without providing any technical reasons and with
something that sums up to "I like my code more".

This breaks good faith, COC and the written rules.

I'm not going to request punishment, reverts, public lynching...
I don't want drama.

I'm sending this patch to make the code as
I think it should have been done from the start and
I do ask you to push it without further bikeshedding.

That would be enough of an apology.
From 18324e5535dd0c928a3ec2e8f25babc583b031d5 Mon Sep 17 00:00:00 2001
From: Ivan Kalvachev 
Date: Sat, 19 Aug 2017 14:29:40 +0300
Subject: [PATCH] opus_pvq_search: Restore the proper use of conditional define
 and simplify the function name suffix handling.

Using named define properly documents the code paths.
It also avoids passing additional numbered arguments through
multiple levels of macro templates.

The suffix handling is done by concatenation, like in
other asm functions and avoid having two separate
"cglobal" defines.

Signed-off-by: Ivan Kalvachev 
---
 libavcodec/x86/opus_pvq_search.asm | 37 ++---
 1 file changed, 18 insertions(+), 19 deletions(-)

diff --git a/libavcodec/x86/opus_pvq_search.asm b/libavcodec/x86/opus_pvq_search.asm
index 8cf040465d..5c1e6d6174 100644
--- a/libavcodec/x86/opus_pvq_search.asm
+++ b/libavcodec/x86/opus_pvq_search.asm
@@ -82,7 +82,7 @@ SECTION .text
 %endif
 %endmacro
 
-%macro PULSES_SEARCH 2 ; %1 - add or sub, %2 - use approximation
+%macro PULSES_SEARCH 1
 ; m6 Syy_norm
 ; m7 Sxy_norm
 addps  m6, mm_const_float_0_5   ; Syy_norm += 1.0/2
@@ -96,17 +96,17 @@ align 16
 movaps m4, [tmpY + r4]  ; y[i]
 movaps m5, [tmpX + r4]  ; X[i]
 
-%if %2
+  %if USE_APPROXIMATION == 1
 xorps  m0, m0
 cmpps  m0, m0, m5, 4; m0 = (X[i] != 0.0)
-%endif
+  %endif
 
 addps  m4, m6   ; m4 = Syy_new = y[i] + Syy_norm
 addps  m5, m7   ; m5 = Sxy_new = X[i] + Sxy_norm
 
-%if %2
+  %if USE_APPROXIMATION == 1
 andps  m5, m0   ; if(X[i] == 0) Sxy_new = 0; Prevent aproximation error from setting pulses in array padding.
-%endif
+  %endif
 
 %else
 movaps m5, [tmpY + r4]  ; m5 = y[i]
@@ -119,7 +119,7 @@ align 16
 andps  m5, m0   ; (0 0
 %%add_pulses_loop:
 
-PULSES_SEARCH add, %1   ; m6 Syy_norm ; m7 Sxy_norm
+PULSES_SEARCH add   ; m6 Syy_norm ; m7 Sxy_norm
 
 subKd, 1
 jnz  %%add_pulses_loop
@@ -325,7 +320,7 @@ align 16; K - pulses > 0
 align 16
 %%remove_pulses_loop:
 
-PULSES_SEARCH sub, %1   ; m6 Syy_norm ; m7 Sxy_norm
+PULSES_SEARCH sub   ; m6 Syy_norm ; m7 Sxy_norm
 
 addKd, 1
 jnz  

Re: [FFmpeg-devel] [PATCH 2/2] avcodec/pixlet: Fixes: undefined shift in av_mod_uintp2()

2017-08-19 Thread Michael Niedermayer
On Fri, Aug 18, 2017 at 06:21:56PM +0200, Paul B Mahol wrote:
> On 8/18/17, Michael Niedermayer  wrote:
> > Fixes: runtime error: shift exponent 4294967289 is too large for 32-bit type
> > 'int'
> > Fixes: 3030/clusterfuzz-testcase-minimized-4649809254285312
> >
> > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/pixlet.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/pixlet.c b/libavcodec/pixlet.c
> > index 088226bdda..a9cfe085c9 100644
> > --- a/libavcodec/pixlet.c
> > +++ b/libavcodec/pixlet.c
> > @@ -262,7 +262,7 @@ static int read_high_coeffs(AVCodecContext *avctx,
> > uint8_t *src, int16_t *dst, i
> >
> >  flag = 0;
> >
> > -if (state * 4ULL > 0xFF || i >= size)
> > +if ((uint64_t)state > 0xFF / 4 || i >= size)
> 
> This is not exact same behaviour.

no, it differs for a small number of cases that have one of the 2
most significant bits (of the 64 bits) set in state.
I think this was a bug i introduced in a previous commit.

If above change is not the correct thing to do, please elaborate.
state is passed into ff_clz() later which has no deterministic
behavior when these MSBs are set as ff_clz() uses unsigned and state
is int64_t and unsigned can be 32 or 64bit.
So this really just change cases that do not work equally
across platforms

looking at this now, i suspect independant of this patch
the 32 and 24 in
pfx = ((state + 8) >> 5) + (state ? ff_clz(state): 32) - 24;
should be CHAR_BIT * sizeof(unsiged) or something similar
or something else should be changed

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

Take away the freedom of one citizen and you will be jailed, take away
the freedom of all citizens and you will be congratulated by your peers
in Parliament.


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


Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Nicolas George
Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
> Exact delay in number of frames and that converted to milliseconds.

Already present. I asked you if you tested, obviously you did not.

> Also one can not set custom delay between beep and blink.

I already mentioned that. You can propose a patch to sine to add that
option.

> Also beating cross is far from being easily noticed like blink.

I do not agree.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Paul B Mahol
On 8/19/17, Nicolas George  wrote:
> Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
>> Sorry but where is that present? I nowhere can determine exact delay
>> in number of frames versus sine beep.
>
> In the upper-left corner, you have a microsecond timestamp and a frame
> counter.

That is not delay between blink and beep. But video timestamps.

>
>> It is not sine but testsrc2 one that would need modification.
>
> Care to explain? The beep is produced by sine. Why would you want to
> modify testsrc2?

For lipsync one would need to alter so blinks happens at exact same
time as beeps.
Say delay is 10 frames, you modify filter to produce delayed blinks.

>
>> Why you do not agree? When is actual beep when beating cross appears?
>
> The beep is when the cross is fully contracted.

That is far for being user friendly and obvious.

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


Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Nicolas George
Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
> I like idea of having single A/V filter to do this job, not combinations where
> users might become confused.

I do not agree. Adding yet another filter causes confusion in itself.
Not counting the extra boilerplate code (I suggest you permanently
disable the copy-paste feature of your development editor ;-).
Documenting the combination would have the same result.

Furthermore, having this in a single filter would possibly cause the
misapprehension that something special happens there, while in truth it
is no different from two individual filters.

Also, two individual filters would be able to run in separate threads
when filter-level threading will be implemented.

Regards,

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


Re: [FFmpeg-devel] [PATCH] [PATCH] avdevice/avfoundation: add scaleFactor attribute for avfoundation

2017-08-19 Thread Thilo Borgmann
Hi,

Am 18.08.17 um 15:44 schrieb sharp bai:
> Thank you for your patient. I will follow your direction.
> 
> Question 1: Your patch misses to cover the scale factor in case of a
> device name string given by the user.
> 
> The problem in mac os the screen to be catpured in avfoundation not
> have a real name. Only video device in avfoundation has a name. The
> screen name "Capture screen [n]" you have seen through "-list_devices"
> is given by ffmpeg developer for convinent. So there is a possibility
> that someone may build a capture device which name is the same as
> "Capture screen 0" which may result in capturing wrong device. 

this is obviously why unique indices are there.

> So
> using "-list_devices" to find out the screen index then assign it
> should be the only right way.

This is the only unique and failsafe way. However, we support both ways and if 
you add functionality it has to continue to work with both existing ways. This 
is why I want you to add your scale factor handling also to the case of device 
names used.


> Question 2: Although Apple's reference says it works for scale_factor
>> 1.0, it should be documented (at least in the code) that it seems
> not to actually do anything for scale_factor > 1.0.
> 
> This is a tough problem. I spent 5 days to prepare an available test
> environment which is almost done yesterday. My test environment covers
> the following operating systems:
> 
> - Mac OS X 10.7.5
> - Mac OS X 10.8.5
> - Mac OS X 10.8.5
> - Mac OS X 10.10.5
> - Mac OS X 10.11.5
> - mac OS 10.12.6
> 
> I have confirmed that on 10.7 and 10.8 the value of scale_factor can
> be larger than 1.0(scale_factor = 10.0 works. scale_factor = 20.0, the
> ffmpeg using 2.4GB memory and freezing), the maximum value is unknown
> but i think is infinate :)

Please add this to the documentation and limit the scale_factor range to 0.0 to 
1.0.
Add a small note to the documents and a complete short explanation directly in 
the code.


> I have compared the images which scale_factor range from 1.0 to 4.0
> captured in 10.8, the images which scale_factor greater than 1.0 are
> not clearer than 1.0. They are simply scaled larger.
>
> From 10.9 and later, the value of scale_factor is limited to maximum
> 1.0. I think Apple had recognized that the value larger than 1.0 is
> not useful.

Just for completeness, this has nothing to do with superresolution or similar 
so the output is never expected to be "more sharp" after upscaling.
Values > 1.0f seem to be a perfectly valid desire like they are for the scale 
filter...

You still don't answer to my question about scale_factor == 0.0f.
If this technically works correctly, you should add a warning whenever the 
output image becomes smaller than 1x1 pixels.
If this does not technically work correctly, you have to catch that case and do 
proper error handling.

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


Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Paul B Mahol
On 8/19/17, Nicolas George  wrote:
> Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
>> How do you know when beep and blink should happen in your example?
>>
>> What is blink for testsrc2? Where in testsrc2 you can see delay in numeric
>> form?
>
> Have you tried? You have a numeric timestamp and frame counter in the
> upper left corner and a beating cross, both in sync with the beeps.
> Please tell me what you are missing here. With more than two lines
> please.

Exact delay in number of frames and that converted to milliseconds.
Also one can not set custom delay between beep and blink.
Also beating cross is far from being easily noticed like blink.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Nicolas George
Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
> Sorry but where is that present? I nowhere can determine exact delay
> in number of frames versus sine beep.

In the upper-left corner, you have a microsecond timestamp and a frame
counter.

> It is not sine but testsrc2 one that would need modification.

Care to explain? The beep is produced by sine. Why would you want to
modify testsrc2?

> Why you do not agree? When is actual beep when beating cross appears?

The beep is when the cross is fully contracted.

Regards,

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


Re: [FFmpeg-devel] [PATCH] vp9: set color range to MPEG for intraonly profile 0

2017-08-19 Thread Ronald S. Bultje
Hi,

On Fri, Aug 18, 2017 at 11:31 PM, James Zern  wrote:

> this is undocumented in the vp9 bitstream and decoding specification
> doc, but matches libvpx
>
> Signed-off-by: James Zern 
> ---
>  libavcodec/vp9.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
> index 7d8aced8c8..94430db9a3 100644
> --- a/libavcodec/vp9.c
> +++ b/libavcodec/vp9.c
> @@ -459,7 +459,7 @@ static int decode_frame_header(AVCodecContext *avctx,
>  s->bytesperpixel = 1;
>  s->pix_fmt = AV_PIX_FMT_YUV420P;
>  avctx->colorspace = AVCOL_SPC_BT470BG;
> -avctx->color_range = AVCOL_RANGE_JPEG;
> +avctx->color_range = AVCOL_RANGE_MPEG;
>

OK.

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


Re: [FFmpeg-devel] [PATCH] opus_pvq_search: Restore the proper use of conditional define and simplify the function name suffix handling

2017-08-19 Thread Hendrik Leppkes
On Sat, Aug 19, 2017 at 5:40 PM, Rostislav Pehlivanov
 wrote:
> On 19 August 2017 at 16:10, Ivan Kalvachev  wrote:
>
>> Using named define properly documents the code paths.
>> It also avoids passing additional numbered arguments through
>> multiple levels of macro templates.
>>
>> The suffix handling is done by concatenation, like in
>> other asm functions and avoid having two separate
>> "cglobal" defines.
>>
>> ---
>> I have to point few things out.
>>
>> commit f386dd70acdc81d42d6bcb885d2889634cdf45b7
>> "opus_pvq_search: only use rsqrtps approximation on CPUs with avx"
>> was rushed hack job:
>>
>
> Well, your original patch was unpolished, so there's that.
>
>

You reviewed it, approved it, and pushed it. You only have yourself to
blame in that case.

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


[FFmpeg-devel] HLS + SAMPLE-AES

2017-08-19 Thread Krystof Vasa
Hello everyone,

I hope this is not out of the code of conduct, but I was hoping to motivate if 
someone would look into implementing this ticket:

https://trac.ffmpeg.org/ticket/5375 

I've found a project that relies on FFmpeg and does this, is under MIT license 
(https://github.com/selsta/hlsdl/blob/master/src/hls.c#L292). And was wondering 
if this could be used in the FFmpeg project.

I don't unfortunately have the skills - or rather A/V knowledge - to implement 
this myself, but was wondering if I could donate some cash to the project, or a 
particular individual who'd be willing to implement this?

Thanks in advance!

Sincerely yours,

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


Re: [FFmpeg-devel] [PATCH] avfilter: add Audio Video Sync Test filter

2017-08-19 Thread Paul B Mahol
On 8/19/17, Nicolas George  wrote:
> Le duodi 2 fructidor, an CCXXV, Paul B Mahol a écrit :
>> I like idea of having single A/V filter to do this job, not combinations
>> where
>> users might become confused.
>
> I do not agree. Adding yet another filter causes confusion in itself.
> Not counting the extra boilerplate code (I suggest you permanently
> disable the copy-paste feature of your development editor ;-).
> Documenting the combination would have the same result.

You completely ignored and removed other aspects of my reply.

>
> Furthermore, having this in a single filter would possibly cause the
> misapprehension that something special happens there, while in truth it
> is no different from two individual filters.

Something special, like one can control both audio and video aspect at
once and provide same info to output.

>
> Also, two individual filters would be able to run in separate threads
> when filter-level threading will be implemented.

*when*

Also that matter less.

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


[FFmpeg-devel] [PATCH] avcodec/me_cmp: Fix crashes on ARM due to misalignment

2017-08-19 Thread Michael Niedermayer
Adds a diff_pixels_unaligned()

Fixes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=872503

Signed-off-by: Michael Niedermayer 
---
 libavcodec/me_cmp.c   | 10 +-
 libavcodec/pixblockdsp.c  |  1 +
 libavcodec/pixblockdsp.h  |  5 +
 libavcodec/x86/pixblockdsp_init.c |  2 ++
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c
index 6639b919ff..5e34a11593 100644
--- a/libavcodec/me_cmp.c
+++ b/libavcodec/me_cmp.c
@@ -628,7 +628,7 @@ static int dct_sad8x8_c(MpegEncContext *s, uint8_t *src1,
 
 av_assert2(h == 8);
 
-s->pdsp.diff_pixels(temp, src1, src2, stride);
+s->pdsp.diff_pixels_unaligned(temp, src1, src2, stride);
 s->fdsp.fdct(temp);
 return s->mecc.sum_abs_dctelem(temp);
 }
@@ -668,7 +668,7 @@ static int dct264_sad8x8_c(MpegEncContext *s, uint8_t *src1,
 int16_t dct[8][8];
 int i, sum = 0;
 
-s->pdsp.diff_pixels(dct[0], src1, src2, stride);
+s->pdsp.diff_pixels_unaligned(dct[0], src1, src2, stride);
 
 #define SRC(x) dct[i][x]
 #define DST(x, v) dct[i][x] = v
@@ -695,7 +695,7 @@ static int dct_max8x8_c(MpegEncContext *s, uint8_t *src1,
 
 av_assert2(h == 8);
 
-s->pdsp.diff_pixels(temp, src1, src2, stride);
+s->pdsp.diff_pixels_unaligned(temp, src1, src2, stride);
 s->fdsp.fdct(temp);
 
 for (i = 0; i < 64; i++)
@@ -714,7 +714,7 @@ static int quant_psnr8x8_c(MpegEncContext *s, uint8_t *src1,
 av_assert2(h == 8);
 s->mb_intra = 0;
 
-s->pdsp.diff_pixels(temp, src1, src2, stride);
+s->pdsp.diff_pixels_unaligned(temp, src1, src2, stride);
 
 memcpy(bak, temp, 64 * sizeof(int16_t));
 
@@ -817,7 +817,7 @@ static int bit8x8_c(MpegEncContext *s, uint8_t *src1, 
uint8_t *src2,
 
 av_assert2(h == 8);
 
-s->pdsp.diff_pixels(temp, src1, src2, stride);
+s->pdsp.diff_pixels_unaligned(temp, src1, src2, stride);
 
 s->block_last_index[0 /* FIXME */] =
 last   =
diff --git a/libavcodec/pixblockdsp.c b/libavcodec/pixblockdsp.c
index 417c944e00..50e1d1d735 100644
--- a/libavcodec/pixblockdsp.c
+++ b/libavcodec/pixblockdsp.c
@@ -82,6 +82,7 @@ av_cold void ff_pixblockdsp_init(PixblockDSPContext *c, 
AVCodecContext *avctx)
 {
 const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8;
 
+c->diff_pixels_unaligned =
 c->diff_pixels = diff_pixels_c;
 
 switch (avctx->bits_per_raw_sample) {
diff --git a/libavcodec/pixblockdsp.h b/libavcodec/pixblockdsp.h
index 3ba1596a88..e036700ff0 100644
--- a/libavcodec/pixblockdsp.h
+++ b/libavcodec/pixblockdsp.h
@@ -33,6 +33,11 @@ typedef struct PixblockDSPContext {
 const uint8_t *s1 /* align 8 */,
 const uint8_t *s2 /* align 8 */,
 ptrdiff_t stride);
+void (*diff_pixels_unaligned)(int16_t *av_restrict block /* align 16 */,
+const uint8_t *s1,
+const uint8_t *s2,
+ptrdiff_t stride);
+
 } PixblockDSPContext;
 
 void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx);
diff --git a/libavcodec/x86/pixblockdsp_init.c 
b/libavcodec/x86/pixblockdsp_init.c
index fa9578a2d3..ade55e01a3 100644
--- a/libavcodec/x86/pixblockdsp_init.c
+++ b/libavcodec/x86/pixblockdsp_init.c
@@ -39,12 +39,14 @@ av_cold void ff_pixblockdsp_init_x86(PixblockDSPContext *c,
 if (EXTERNAL_MMX(cpu_flags)) {
 if (!high_bit_depth)
 c->get_pixels = ff_get_pixels_mmx;
+c->diff_pixels_unaligned =
 c->diff_pixels = ff_diff_pixels_mmx;
 }
 
 if (EXTERNAL_SSE2(cpu_flags)) {
 if (!high_bit_depth)
 c->get_pixels = ff_get_pixels_sse2;
+c->diff_pixels_unaligned =
 c->diff_pixels = ff_diff_pixels_sse2;
 }
 }
-- 
2.14.1

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/pixlet: Fixes: undefined shift in av_mod_uintp2()

2017-08-19 Thread Michael Niedermayer
On Sat, Aug 19, 2017 at 04:00:18PM +0200, Paul B Mahol wrote:
> On 8/19/17, Michael Niedermayer  wrote:
> > On Fri, Aug 18, 2017 at 06:21:56PM +0200, Paul B Mahol wrote:
> >> On 8/18/17, Michael Niedermayer  wrote:
> >> > Fixes: runtime error: shift exponent 4294967289 is too large for 32-bit
> >> > type
> >> > 'int'
> >> > Fixes: 3030/clusterfuzz-testcase-minimized-4649809254285312
> >> >
> >> > Found-by: continuous fuzzing process
> >> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> >> > Signed-off-by: Michael Niedermayer 
> >> > ---
> >> >  libavcodec/pixlet.c | 2 +-
> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >> >
> >> > diff --git a/libavcodec/pixlet.c b/libavcodec/pixlet.c
> >> > index 088226bdda..a9cfe085c9 100644
> >> > --- a/libavcodec/pixlet.c
> >> > +++ b/libavcodec/pixlet.c
> >> > @@ -262,7 +262,7 @@ static int read_high_coeffs(AVCodecContext *avctx,
> >> > uint8_t *src, int16_t *dst, i
> >> >
> >> >  flag = 0;
> >> >
> >> > -if (state * 4ULL > 0xFF || i >= size)
> >> > +if ((uint64_t)state > 0xFF / 4 || i >= size)
> >>
> >> This is not exact same behaviour.
> >
> > no, it differs for a small number of cases that have one of the 2
> > most significant bits (of the 64 bits) set in state.
> > I think this was a bug i introduced in a previous commit.
> >
> > If above change is not the correct thing to do, please elaborate.
> > state is passed into ff_clz() later which has no deterministic
> > behavior when these MSBs are set as ff_clz() uses unsigned and state
> > is int64_t and unsigned can be 32 or 64bit.
> 
> Only 32 bits matters for ff_clz() anyway.

your reply is a bit terse.
Does that mean you have no objections to the patch ?

about ff_clz(), with 64bit unsigned a ff_clz(1) should return 63, the
code looks like it expects 31

[...]
-- 
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: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/3] avcodec/fic: Fixes signed integer overflow

2017-08-19 Thread Michael Niedermayer
On Fri, Aug 18, 2017 at 12:17:33AM +0200, Michael Niedermayer wrote:
> Fixes: runtime error: signed integer overflow: 1037142357 + 1227025305 cannot 
> be represented in type 'int'
> Fixes: 3024/clusterfuzz-testcase-minimized-5885660323905536
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/fic.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)

patchset applied

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

The real ebay dictionary, page 1
"Used only once"- "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."


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


Re: [FFmpeg-devel] [PATCH v3] libavformat/mov: fix multiple stsd handling of files with edit list, fix #6584

2017-08-19 Thread Michael Niedermayer
On Sat, Aug 19, 2017 at 08:32:18AM +0800, Jiejun Zhang wrote:
> On Fri, Aug 18, 2017 at 8:16 AM, Michael Niedermayer
>  wrote:
> >
> > seeking still fails with this and the sample from #6584 is that
> > intended or a seperate issue ?
> 
> I didn't see any failure using "./ffmpeg -ss 00:00:10" (and also other
> time from 0s to 20s). How to reproduce a seeking failure?

i tested using ffplay and seeking with cursor keys and mouse
there where some green frames flashing IIRC

tell me if you can reproduce or not. If not ill try to come up with
some deterministic testcase



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

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


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


Re: [FFmpeg-devel] [PATCH] libavfilter/af_ambisonic.c Added File for Ambisonic Filter

2017-08-19 Thread Sanchit Sinha
On Fri, Aug 18, 2017 at 2:57 PM, Mailtrack Reminder 
wrote:

> ⚠️ Your email to ffmpeg-devel@ffmpeg.org has not been opened yet. Be
> reminded in 24H
> 
>  or 48H
> 
>  (disable
> )
>
>



-- 
Sanchit Sinha
B.Tech- CSE
IIIT-Delhi
Roll-2015083
https://sinhaaftersanchit.com/
From 93d709a6c04af3749cd12ed98791bceb05f3f626 Mon Sep 17 00:00:00 2001
From: Sanchit Sinha 
Date: Sun, 20 Aug 2017 03:02:00 +0530
Subject: [PATCH] libavfilter/af_ambisonic.c:Added File for Ambisonic Decoding

Signed-off-by: Sanchit Sinha 
---
 Changelog  |   1 +
 libavfilter/Makefile   |   1 +
 libavfilter/af_ambisonic.c | 736 +
 libavfilter/allfilters.c   |   1 +
 4 files changed, 739 insertions(+)
 create mode 100644 libavfilter/af_ambisonic.c

diff --git a/Changelog b/Changelog
index 7a6987a..f4fb9df 100644
--- a/Changelog
+++ b/Changelog
@@ -33,6 +33,7 @@ version :
 - tlut2 video filter
 - floodfill video filter
 - pseudocolor video filter
+- Ambisonic Decoder
 
 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 1d92dc1..32bf378 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -45,6 +45,7 @@ OBJS-$(CONFIG_AINTERLEAVE_FILTER)+= f_interleave.o
 OBJS-$(CONFIG_ALIMITER_FILTER)   += af_alimiter.o
 OBJS-$(CONFIG_ALLPASS_FILTER)+= af_biquads.o
 OBJS-$(CONFIG_ALOOP_FILTER)  += f_loop.o
+OBJS-$(CONFIG_AMBISONIC_FILTER)  += af_ambisonic.o
 OBJS-$(CONFIG_AMERGE_FILTER) += af_amerge.o
 OBJS-$(CONFIG_AMETADATA_FILTER)  += f_metadata.o
 OBJS-$(CONFIG_AMIX_FILTER)   += af_amix.o
diff --git a/libavfilter/af_ambisonic.c b/libavfilter/af_ambisonic.c
new file mode 100644
index 000..d18e7e2
--- /dev/null
+++ b/libavfilter/af_ambisonic.c
@@ -0,0 +1,736 @@
+/*
+ * Copyright (c) 2017 Sanchit Sinha
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/avstring.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/opt.h"
+#include "libavutil/avassert.h"
+#include "audio.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include 
+#include 
+#define SQRT_3 1.732051
+
+enum FilterType {
+shelf,
+nearfield
+};
+
+enum InputFormat {
+  N3D,
+  SN3D   ,
+  FURMUL
+};
+
+enum Rotate {
+TILT  ,
+TUMBLE,
+YAW
+};
+
+enum Layouts {
+MONO,
+STEREO  ,
+TRIANGLE,
+SQUARE  ,
+PENTAGON,
+HEXAGON ,
+HEPTAGON,
+OCTAGON ,
+TETRAHEDRON ,
+OCTAHEDRON  ,
+CUBE,
+DODECAHEDRON,
+ICOSAHEDRON
+};
+
+typedef struct Cache {
+double i1, i2;
+double o1, o2;
+} Cache;
+
+/*Decoding matrix for 1st order files. Similar can be done for 2nd, 3rd etc*/
+static const struct {
+  int speakers;
+float matrix[22][15];
+} ambisonic_matrix[]= {
+[MONO]={
+  .speakers=1,
+.matrix={
+{0.22156, 0, 0, 0},
+},
+},
+[TRIANGLE]={
+  .speakers=3,
+.matrix={
+{0.17836, 0.32555, 0.18795, 0},
+{0.17836, 0  ,-0.37591, 0},
+{0.17836,-0.32555, 0.18795, 0},
+},
+},
+[SQUARE]={
+  .speakers=4,
+.matrix={
+{0.39388, 0.18690, 0.18690, 0},
+{0.39388,-0.18690, 0.18690, 0},
+{0.39388,-0.18690,-0.18690, 0},
+{0.39388, 0.18690,-0.18690, 0},
+},
+},
+[PENTAGON]={
+  .speakers=5,
+.matrix={
+{0.20195, 0  , 0.33420, 0},
+{0.11356, 0.2901 , 0.04186, 0},
+

Re: [FFmpeg-devel] [mov] Fix trampling of ctts during seeks when sidx support is enabled.

2017-08-19 Thread Michael Niedermayer
On Fri, Aug 18, 2017 at 03:57:45PM -0700, Dale Curtis wrote:
> Anything else here? It'd be nice to get this landed soon if no one has any
> other comments.

it appears to not apply cleanly anymore


> 
> - dale
> 
> On Thu, Aug 10, 2017 at 1:02 PM, Dale Curtis 
> wrote:
> 
> > On Tue, Aug 8, 2017 at 6:48 PM, Michael Niedermayer <
> > mich...@niedermayer.cc> wrote:
> >
> >>
> >> the fate test seems to fail:
> >>
> >> did i do something silly ?
> >>
> >
> > Ah no, I did when I remuxed the test file. Updated expectations and test
> > clip at http://storage.googleapis.com/dalecurtis/buck480p30_na.mp4
> >
> > - dale
> >
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

-- 
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: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [mov] Fix trampling of ctts during seeks when sidx support is enabled.

2017-08-19 Thread Michael Niedermayer
On Sun, Aug 20, 2017 at 12:48:30AM +0200, Michael Niedermayer wrote:
> On Fri, Aug 18, 2017 at 03:57:45PM -0700, Dale Curtis wrote:
> > Anything else here? It'd be nice to get this landed soon if no one has any
> > other comments.
> 
> it appears to not apply cleanly anymore

seems caused by f4544163b27615ecfff1b42d6acdb3672ac92399.

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides


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


Re: [FFmpeg-devel] [PATCH] lavf/bink: fix latest header and add all existing revisions

2017-08-19 Thread Michael Niedermayer
On Fri, Aug 18, 2017 at 07:45:16PM +0200, bananaman...@gmail.com wrote:
> From: bnnm 
> 
> KB2 'i' found in Life is Strange (Xbox 360), rest verified against 
> binkconv.exe
> 
> Signed-off-by: bnnm 
> ---
>  libavformat/bink.c | 17 +
>  1 file changed, 13 insertions(+), 4 deletions(-)

will apply

thanks

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

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin


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


Re: [FFmpeg-devel] [PATCH] Fix signed integer overflows

2017-08-19 Thread Michael Niedermayer
On Thu, Aug 17, 2017 at 11:14:47PM -0700, Vitaly Buka wrote:
> Signed integer overflow is undefined behavior.
> Detected with clang and -fsanitize=signed-integer-overflow
> 
> Signed-off-by: Vitaly Buka 
> ---
>  libavcodec/utils.c| 2 +-
>  libavformat/aviobuf.c | 4 +++-
>  libavformat/mov.c | 2 +-
>  3 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 1336e921c9..024dc1f3e2 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -971,7 +971,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>  }
>  
>  if (!avctx->rc_initial_buffer_occupancy)
> -avctx->rc_initial_buffer_occupancy = avctx->rc_buffer_size * 3 / 
> 4;
> +avctx->rc_initial_buffer_occupancy = avctx->rc_buffer_size * 3ll 
> / 4;
>  
>  if (avctx->ticks_per_frame && avctx->time_base.num &&
>  avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) {
> diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> index 7f4e740a33..319a402faf 100644
> --- a/libavformat/aviobuf.c
> +++ b/libavformat/aviobuf.c
> @@ -259,7 +259,9 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int 
> whence)
>  offset1 = pos + (s->buf_ptr - s->buffer);
>  if (offset == 0)
>  return offset1;
> -offset += offset1;
> +// Use unsigned type to avoid undefined behavior of singed overflow.
> +// Code below will report error on overflow anyway.
> +offset += (uint64_t)offset1;

instead of 2 lines of comments why not add a if() that checks for
the specififc case and error out instead of the cast?

The code from the patch depends on the input being limited range
and being followed by a check. If either changes then the cast to
uin64_t would silently give something wrong


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data


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


[FFmpeg-devel] [PATCH] Fix signed integer overflows

2017-08-19 Thread Vitaly Buka
Signed integer overflow is undefined behavior.
Detected with clang and -fsanitize=signed-integer-overflow

Signed-off-by: Vitaly Buka 
---
 libavcodec/utils.c| 2 +-
 libavformat/aviobuf.c | 3 +++
 libavformat/mov.c | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 1336e921c9..024dc1f3e2 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -971,7 +971,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 
 if (!avctx->rc_initial_buffer_occupancy)
-avctx->rc_initial_buffer_occupancy = avctx->rc_buffer_size * 3 / 4;
+avctx->rc_initial_buffer_occupancy = avctx->rc_buffer_size * 3ll / 
4;
 
 if (avctx->ticks_per_frame && avctx->time_base.num &&
 avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) {
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 7f4e740a33..b708f18d43 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -259,7 +259,10 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int 
whence)
 offset1 = pos + (s->buf_ptr - s->buffer);
 if (offset == 0)
 return offset1;
+if (offset > INT64_MAX - offset1)
+return AVERROR(EINVAL);
 offset += offset1;
+   
 }
 if (offset < 0)
 return AVERROR(EINVAL);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 522ce60c2d..a14c9f182b 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5572,7 +5572,7 @@ static int mov_read_default(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 
 if (atom.size < 0)
 atom.size = INT64_MAX;
-while (total_size + 8 <= atom.size && !avio_feof(pb)) {
+while (total_size <= atom.size - 8 && !avio_feof(pb)) {
 int (*parse)(MOVContext*, AVIOContext*, MOVAtom) = NULL;
 a.size = atom.size;
 a.type=0;
-- 
2.14.1.480.gb18f417b89-goog

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


Re: [FFmpeg-devel] [PATCH] opus_pvq_search: Restore the proper use of conditional define and simplify the function name suffix handling

2017-08-19 Thread Ivan Kalvachev
The issue has been resolved.
The patch has been pushed.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2]v7 Opus Pyramid Vector Quantization Search in x86 SIMD asm

2017-08-19 Thread Rostislav Pehlivanov
On 6 August 2017 at 19:52, Ivan Kalvachev  wrote:

> This patch requires "Add macros used in opus_pvq_search to x86util.asm"
> as 4 of the macros are moved there.
>
> 1. Cosmetics is completely redone.
>
> 2. I've left the align code as it is.
> I found a really old nasm-2.07 version (from 19 Jan 2010) and made a test
> build.
> I got nasm-2.09.04 (from Jan 11 2011) too, just to be sure.
> They all passed without issues.
>
> The x264 x86inc.asm also uses smartalign without
> checking version number.
>
> Also I had to do a bit more extensive benchmarks,
> because it's hard to tell which version is better
> (with or without align).
> So far it looks like the align might be faster
> with 2-6 cycles at best.
>
> So until somebody finds some concrete issue
> I'd like to keep the code as it is.
>
> (maybe try avx2 without align:)
>
>
> I hope I haven't forgotten to do something.
> And I do hope I haven't messed up something new.
>
> Best Regards.
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
Pushed, thanks
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/bink: fix latest header and add all existing revisions

2017-08-19 Thread Michael Niedermayer
On Sun, Aug 20, 2017 at 01:51:07AM +0200, Michael Niedermayer wrote:
> On Fri, Aug 18, 2017 at 07:45:16PM +0200, bananaman...@gmail.com wrote:
> > From: bnnm 
> > 
> > KB2 'i' found in Life is Strange (Xbox 360), rest verified against 
> > binkconv.exe
> > 
> > Signed-off-by: bnnm 
> > ---
> >  libavformat/bink.c | 17 +
> >  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> will apply

before pushing, just to confirm

"bnnm" is the intended Author ? (it cannot be changed later)

[...]


-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes


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


[FFmpeg-devel] [PATCH] Fix signed integer overflows

2017-08-19 Thread Vitaly Buka
Signed integer overflow is undefined behavior.
Detected with clang and -fsanitize=signed-integer-overflow

Signed-off-by: Vitaly Buka 
---
 libavcodec/utils.c| 2 +-
 libavformat/aviobuf.c | 2 ++
 libavformat/mov.c | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 1336e921c9..024dc1f3e2 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -971,7 +971,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 
 if (!avctx->rc_initial_buffer_occupancy)
-avctx->rc_initial_buffer_occupancy = avctx->rc_buffer_size * 3 / 4;
+avctx->rc_initial_buffer_occupancy = avctx->rc_buffer_size * 3ll / 
4;
 
 if (avctx->ticks_per_frame && avctx->time_base.num &&
 avctx->ticks_per_frame > INT_MAX / avctx->time_base.num) {
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 7f4e740a33..ec21fc7d38 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -259,6 +259,8 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int 
whence)
 offset1 = pos + (s->buf_ptr - s->buffer);
 if (offset == 0)
 return offset1;
+if (offset > INT64_MAX - offset1)
+return AVERROR(EINVAL);
 offset += offset1;
 }
 if (offset < 0)
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 522ce60c2d..a14c9f182b 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5572,7 +5572,7 @@ static int mov_read_default(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 
 if (atom.size < 0)
 atom.size = INT64_MAX;
-while (total_size + 8 <= atom.size && !avio_feof(pb)) {
+while (total_size <= atom.size - 8 && !avio_feof(pb)) {
 int (*parse)(MOVContext*, AVIOContext*, MOVAtom) = NULL;
 a.size = atom.size;
 a.type=0;
-- 
2.14.1.480.gb18f417b89-goog

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


[FFmpeg-devel] [PATCH] Add FITS Decoder

2017-08-19 Thread Paras Chadha
Signed-off-by: Paras Chadha 
---
Add FATE coverage

 Changelog  |   1 +
 doc/general.texi   |   2 +
 libavcodec/Makefile|   2 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/avcodec.h   |   1 +
 libavcodec/codec_desc.c|   7 +
 libavcodec/fits.c  | 203 ++
 libavcodec/fits.h  |  79 ++
 libavcodec/fitsdec.c   | 318 +
 libavcodec/version.h   |   2 +-
 tests/Makefile |   1 +
 tests/fate/fits.mak|  14 ++
 tests/ref/fate/fitsdec-gbrap16 |   6 +
 tests/ref/fate/fitsdec-gbrp|   6 +
 tests/ref/fate/fitsdec-gbrp16  |   6 +
 tests/ref/fate/fitsdec-gray|   6 +
 tests/ref/fate/fitsdec-gray16  |   6 +
 tests/ref/fate/fitsdec-multi   |  10 ++
 18 files changed, 670 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/fits.c
 create mode 100644 libavcodec/fits.h
 create mode 100644 libavcodec/fitsdec.c
 create mode 100644 tests/fate/fits.mak
 create mode 100644 tests/ref/fate/fitsdec-gbrap16
 create mode 100644 tests/ref/fate/fitsdec-gbrp
 create mode 100644 tests/ref/fate/fitsdec-gbrp16
 create mode 100644 tests/ref/fate/fitsdec-gray
 create mode 100644 tests/ref/fate/fitsdec-gray16
 create mode 100644 tests/ref/fate/fitsdec-multi

diff --git a/Changelog b/Changelog
index 7a6987a..9c7a533 100644
--- a/Changelog
+++ b/Changelog
@@ -33,6 +33,7 @@ version :
 - tlut2 video filter
 - floodfill video filter
 - pseudocolor video filter
+- FITS demuxer and decoder

 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/doc/general.texi b/doc/general.texi
index 036c8c2..01402cb 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -592,6 +592,8 @@ following image formats are supported:
 @tab Digital Picture Exchange
 @item EXR  @tab   @tab X
 @tab OpenEXR
+@item FITS @tab   @tab X
+@tab Flexible Image Transport System
 @item JPEG @tab X @tab X
 @tab Progressive JPEG is not supported.
 @item JPEG 2000@tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b0c39ac..42eec07 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -291,6 +291,7 @@ OBJS-$(CONFIG_FFV1_DECODER)+= ffv1dec.o ffv1.o
 OBJS-$(CONFIG_FFV1_ENCODER)+= ffv1enc.o ffv1.o
 OBJS-$(CONFIG_FFWAVESYNTH_DECODER) += ffwavesynth.o
 OBJS-$(CONFIG_FIC_DECODER) += fic.o
+OBJS-$(CONFIG_FITS_DECODER)+= fitsdec.o fits.o
 OBJS-$(CONFIG_FLAC_DECODER)+= flacdec.o flacdata.o flac.o
 OBJS-$(CONFIG_FLAC_ENCODER)+= flacenc.o flacdata.o flac.o 
vorbis_data.o
 OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o
@@ -846,6 +847,7 @@ OBJS-$(CONFIG_ISO_MEDIA)   += mpeg4audio.o 
mpegaudiodata.o
 OBJS-$(CONFIG_ADTS_MUXER)  += mpeg4audio.o
 OBJS-$(CONFIG_CAF_DEMUXER) += ac3tab.o
 OBJS-$(CONFIG_DNXHD_DEMUXER)   += dnxhddata.o
+OBJS-$(CONFIG_FITS_DEMUXER)+= fits.o
 OBJS-$(CONFIG_FLV_DEMUXER) += mpeg4audio.o
 OBJS-$(CONFIG_LATM_MUXER)  += mpeg4audio.o
 OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER)+= mpeg4audio.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 4712592..8678ac2 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -192,6 +192,7 @@ static void register_all(void)
 REGISTER_ENCDEC (FFV1,  ffv1);
 REGISTER_ENCDEC (FFVHUFF,   ffvhuff);
 REGISTER_DECODER(FIC,   fic);
+REGISTER_DECODER(FITS,  fits);
 REGISTER_ENCDEC (FLASHSV,   flashsv);
 REGISTER_ENCDEC (FLASHSV2,  flashsv2);
 REGISTER_DECODER(FLIC,  flic);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index c594993..b28002f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -447,6 +447,7 @@ enum AVCodecID {
 AV_CODEC_ID_SRGC,
 AV_CODEC_ID_SVG,
 AV_CODEC_ID_GDV,
+AV_CODEC_ID_FITS,

 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 6f43b68..2fea680 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1464,6 +1464,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
  AV_CODEC_PROP_LOSSLESS,
 },
 {
+.id= AV_CODEC_ID_FITS,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "fits",
+.long_name = NULL_IF_CONFIG_SMALL("FITS image"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
+{
 .id= AV_CODEC_ID_GIF,
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "gif",
diff --git a/libavcodec/fits.c b/libavcodec/fits.c
new file mode 100644
index 000..fc6fd03
--- /dev/null
+++ b/libavcodec/fits.c
@@ 

[FFmpeg-devel] [PATCH] Add FITS Muxer

2017-08-19 Thread Paras Chadha
Signed-off-by: Paras Chadha 
---
Add FATE coverage

 libavformat/Makefile |   1 +
 libavformat/allformats.c |   2 +-
 libavformat/fitsenc.c| 183 +++
 libavformat/img2enc.c|   2 +
 tests/fate/avformat.mak  |   1 +
 tests/lavf-regression.sh |   9 +++
 tests/ref/lavf/fits  |  18 +
 7 files changed, 215 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/fitsenc.c
 create mode 100644 tests/ref/lavf/fits

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 266b77a..faca4a0 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -165,6 +165,7 @@ OBJS-$(CONFIG_FIFO_MUXER)+= fifo.o
 OBJS-$(CONFIG_FILMSTRIP_DEMUXER) += filmstripdec.o
 OBJS-$(CONFIG_FILMSTRIP_MUXER)   += filmstripenc.o
 OBJS-$(CONFIG_FITS_DEMUXER)  += fitsdec.o
+OBJS-$(CONFIG_FITS_MUXER)+= fitsenc.o
 OBJS-$(CONFIG_FLAC_DEMUXER)  += flacdec.o rawdec.o \
 flac_picture.o   \
 oggparsevorbis.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 3c12760..f3b2edb 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -121,7 +121,7 @@ static void register_all(void)
 REGISTER_MUXDEMUX(FFMETADATA,   ffmetadata);
 REGISTER_MUXER   (FIFO, fifo);
 REGISTER_MUXDEMUX(FILMSTRIP,filmstrip);
-REGISTER_DEMUXER (FITS, fits);
+REGISTER_MUXDEMUX(FITS, fits);
 REGISTER_MUXDEMUX(FLAC, flac);
 REGISTER_DEMUXER (FLIC, flic);
 REGISTER_MUXDEMUX(FLV,  flv);
diff --git a/libavformat/fitsenc.c b/libavformat/fitsenc.c
new file mode 100644
index 000..0dcdcdf
--- /dev/null
+++ b/libavformat/fitsenc.c
@@ -0,0 +1,183 @@
+/*
+ * FITS muxer
+ * Copyright (c) 2017 Paras Chadha
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * FITS muxer.
+ */
+
+#include "internal.h"
+
+typedef struct FITSContext {
+int first_image;
+} FITSContext;
+
+static int fits_write_header(AVFormatContext *s)
+{
+FITSContext *fitsctx = s->priv_data;
+fitsctx->first_image = 1;
+return 0;
+}
+
+/**
+ * Write one header line comprising of keyword and value(int)
+ * @param s AVFormat Context
+ * @param keyword pointer to the char array in which keyword is stored
+ * @param value the value corresponding to the keyword
+ * @param lines_written to keep track of lines written so far
+ * @return 0
+ */
+static int write_keyword_value(AVFormatContext *s, const char *keyword, int 
value, int *lines_written)
+{
+int len, ret;
+uint8_t header[80];
+
+len = strlen(keyword);
+memset(header, ' ', sizeof(header));
+memcpy(header, keyword, len);
+
+header[8] = '=';
+header[9] = ' ';
+
+ret = snprintf(header + 10, 70, "%d", value);
+header[ret + 10] = ' ';
+
+avio_write(s->pb, header, sizeof(header));
+*lines_written += 1;
+return 0;
+}
+
+static int write_image_header(AVFormatContext *s)
+{
+AVStream *st = s->streams[0];
+AVCodecParameters *encctx = st->codecpar;
+FITSContext *fitsctx = s->priv_data;
+uint8_t buffer[80];
+int bitpix, naxis, naxis3 = 1, bzero = 0, rgb = 0, lines_written = 0, 
lines_left;
+
+switch (encctx->format) {
+case AV_PIX_FMT_GRAY8:
+bitpix = 8;
+naxis = 2;
+break;
+case AV_PIX_FMT_GRAY16BE:
+bitpix = 16;
+naxis = 2;
+bzero = 32768;
+break;
+case AV_PIX_FMT_GBRP:
+case AV_PIX_FMT_GBRAP:
+bitpix = 8;
+naxis = 3;
+rgb = 1;
+if (encctx->format == AV_PIX_FMT_GBRP) {
+naxis3 = 3;
+} else {
+naxis3 = 4;
+}
+break;
+case AV_PIX_FMT_GBRP16BE:
+case AV_PIX_FMT_GBRAP16BE:
+bitpix = 16;
+naxis = 3;
+rgb = 1;
+if (encctx->format == AV_PIX_FMT_GBRP16BE) {
+naxis3 = 3;
+} else {
+naxis3 = 4;
+}
+bzero = 32768;
+   

[FFmpeg-devel] [PATCH] Add FITS Demuxer

2017-08-19 Thread Paras Chadha
Signed-off-by: Paras Chadha 
---
Add FATE coverage

 libavformat/Makefile  |   1 +
 libavformat/allformats.c  |   1 +
 libavformat/fitsdec.c | 231 ++
 libavformat/version.h |   2 +-
 tests/fate/demux.mak  |   3 +
 tests/ref/fate/fits-demux |  10 ++
 6 files changed, 247 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/fitsdec.c
 create mode 100644 tests/ref/fate/fits-demux

diff --git a/libavformat/Makefile b/libavformat/Makefile
index b0ef82c..266b77a 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -164,6 +164,7 @@ OBJS-$(CONFIG_FFMETADATA_MUXER)  += ffmetaenc.o
 OBJS-$(CONFIG_FIFO_MUXER)+= fifo.o
 OBJS-$(CONFIG_FILMSTRIP_DEMUXER) += filmstripdec.o
 OBJS-$(CONFIG_FILMSTRIP_MUXER)   += filmstripenc.o
+OBJS-$(CONFIG_FITS_DEMUXER)  += fitsdec.o
 OBJS-$(CONFIG_FLAC_DEMUXER)  += flacdec.o rawdec.o \
 flac_picture.o   \
 oggparsevorbis.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 1ebc142..3c12760 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -121,6 +121,7 @@ static void register_all(void)
 REGISTER_MUXDEMUX(FFMETADATA,   ffmetadata);
 REGISTER_MUXER   (FIFO, fifo);
 REGISTER_MUXDEMUX(FILMSTRIP,filmstrip);
+REGISTER_DEMUXER (FITS, fits);
 REGISTER_MUXDEMUX(FLAC, flac);
 REGISTER_DEMUXER (FLIC, flic);
 REGISTER_MUXDEMUX(FLV,  flv);
diff --git a/libavformat/fitsdec.c b/libavformat/fitsdec.c
new file mode 100644
index 000..4b288b3
--- /dev/null
+++ b/libavformat/fitsdec.c
@@ -0,0 +1,231 @@
+/*
+ * FITS demuxer
+ * Copyright (c) 2017 Paras Chadha
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * FITS demuxer.
+ */
+
+#include "libavutil/intreadwrite.h"
+#include "internal.h"
+#include "libavutil/opt.h"
+#include "libavcodec/fits.h"
+#include "libavutil/bprint.h"
+
+#define FITS_BLOCK_SIZE 2880
+
+typedef struct FITSContext {
+const AVClass *class;
+AVRational framerate;
+int first_image;
+int64_t pts;
+} FITSContext;
+
+static int fits_probe(AVProbeData *p)
+{
+const uint8_t *b = p->buf;
+if (!memcmp(b, "SIMPLE  =T", 30))
+return AVPROBE_SCORE_MAX - 1;
+return 0;
+}
+
+static int fits_read_header(AVFormatContext *s)
+{
+AVStream *st;
+FITSContext * fits = s->priv_data;
+
+st = avformat_new_stream(s, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+
+st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+st->codecpar->codec_id = AV_CODEC_ID_FITS;
+
+avpriv_set_pts_info(st, 64, fits->framerate.den, fits->framerate.num);
+fits->pts = 0;
+fits->first_image = 1;
+return 0;
+}
+
+/**
+ * Parses header and checks that the current HDU contains image or not
+ * It also stores the header in the avbuf and stores the size of data part in 
data_size
+ * @param s pointer to AVFormat Context
+ * @param fits pointer to FITSContext
+ * @param header pointer to FITSHeader
+ * @param avbuf pointer to AVBPrint to store the header
+ * @param data_size to store the size of data part
+ * @return 1 if image found, 0 if any other extension and AVERROR_INVALIDDATA 
otherwise
+ */
+static int64_t is_image(AVFormatContext *s, FITSContext *fits, FITSHeader 
*header,
+ AVBPrint *avbuf, uint64_t *data_size)
+{
+int i, ret, image = 0;
+char buf[FITS_BLOCK_SIZE] = { 0 };
+int64_t buf_size = 0, size = 0, t;
+
+do {
+ret = avio_read(s->pb, buf, FITS_BLOCK_SIZE);
+if (ret < 0) {
+return ret;
+} else if (ret < FITS_BLOCK_SIZE) {
+return AVERROR_INVALIDDATA;
+}
+
+av_bprint_append_data(avbuf, buf, FITS_BLOCK_SIZE);
+ret = 0;
+buf_size = 0;
+while(!ret && buf_size < FITS_BLOCK_SIZE) {
+ret = avpriv_fits_header_parse_line(s, header, buf + buf_size, 
NULL);
+buf_size += 80;
+}
+} while (!ret);
+if (ret < 0)
+return ret;
+
+image = 

[FFmpeg-devel] [PATCH] Add FITS Encoder

2017-08-19 Thread Paras Chadha
Signed-off-by: Paras Chadha 
---
Add FATE coverage

 Changelog|   1 +
 doc/general.texi |   2 +-
 libavcodec/Makefile  |   1 +
 libavcodec/allcodecs.c   |   2 +-
 libavcodec/fitsenc.c | 130 +++
 tests/fate/fits.mak  |  11 
 tests/ref/fate/fitsenc-gbrap |  10 +++
 tests/ref/fate/fitsenc-gbrap16be |  10 +++
 tests/ref/fate/fitsenc-gbrp  |  10 +++
 tests/ref/fate/fitsenc-gbrp16be  |  10 +++
 tests/ref/fate/fitsenc-gray  |  10 +++
 tests/ref/fate/fitsenc-gray16be  |  10 +++
 12 files changed, 205 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/fitsenc.c
 create mode 100644 tests/ref/fate/fitsenc-gbrap
 create mode 100644 tests/ref/fate/fitsenc-gbrap16be
 create mode 100644 tests/ref/fate/fitsenc-gbrp
 create mode 100644 tests/ref/fate/fitsenc-gbrp16be
 create mode 100644 tests/ref/fate/fitsenc-gray
 create mode 100644 tests/ref/fate/fitsenc-gray16be

diff --git a/Changelog b/Changelog
index 9c7a533..8977ee6 100644
--- a/Changelog
+++ b/Changelog
@@ -34,6 +34,7 @@ version :
 - floodfill video filter
 - pseudocolor video filter
 - FITS demuxer and decoder
+- FITS muxer and encoder

 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/doc/general.texi b/doc/general.texi
index 01402cb..1ea7984 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -592,7 +592,7 @@ following image formats are supported:
 @tab Digital Picture Exchange
 @item EXR  @tab   @tab X
 @tab OpenEXR
-@item FITS @tab   @tab X
+@item FITS @tab X @tab X
 @tab Flexible Image Transport System
 @item JPEG @tab X @tab X
 @tab Progressive JPEG is not supported.
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 42eec07..590410c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -292,6 +292,7 @@ OBJS-$(CONFIG_FFV1_ENCODER)+= ffv1enc.o ffv1.o
 OBJS-$(CONFIG_FFWAVESYNTH_DECODER) += ffwavesynth.o
 OBJS-$(CONFIG_FIC_DECODER) += fic.o
 OBJS-$(CONFIG_FITS_DECODER)+= fitsdec.o fits.o
+OBJS-$(CONFIG_FITS_ENCODER)+= fitsenc.o
 OBJS-$(CONFIG_FLAC_DECODER)+= flacdec.o flacdata.o flac.o
 OBJS-$(CONFIG_FLAC_ENCODER)+= flacenc.o flacdata.o flac.o 
vorbis_data.o
 OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 8678ac2..7fe66f4 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -192,7 +192,7 @@ static void register_all(void)
 REGISTER_ENCDEC (FFV1,  ffv1);
 REGISTER_ENCDEC (FFVHUFF,   ffvhuff);
 REGISTER_DECODER(FIC,   fic);
-REGISTER_DECODER(FITS,  fits);
+REGISTER_ENCDEC (FITS,  fits);
 REGISTER_ENCDEC (FLASHSV,   flashsv);
 REGISTER_ENCDEC (FLASHSV2,  flashsv2);
 REGISTER_DECODER(FLIC,  flic);
diff --git a/libavcodec/fitsenc.c b/libavcodec/fitsenc.c
new file mode 100644
index 000..f67f3ad
--- /dev/null
+++ b/libavcodec/fitsenc.c
@@ -0,0 +1,130 @@
+/*
+ * FITS image encoder
+ * Copyright (c) 2017 Paras Chadha
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * FITS image encoder
+ *
+ * Specification: https://fits.gsfc.nasa.gov/fits_standard.html Version 3.0
+ *
+ * RGBA images are encoded as planes in RGBA order. So, NAXIS3 is 3 or 4 for 
them.
+ * Also CTYPE3 = 'RGB ' is added to the header to distinguish them from 3d 
images.
+ */
+
+#include "libavutil/intreadwrite.h"
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+const AVFrame *pict, int *got_packet)
+{
+AVFrame * const p = (AVFrame *)pict;
+uint8_t *bytestream, *bytestream_start, *ptr;
+const uint16_t flip = (1 << 15);
+uint64_t data_size = 0, padded_data_size = 0;
+int ret, bitpix, naxis3 = 1, i, j, k, bytes_left;
+int map[] = {2, 0, 1, 3}; // mapping from GBRA -> RGBA as RGBA is to be 
stored in FITS file..
+
+switch (avctx->pix_fmt) {
+case AV_PIX_FMT_GRAY8:
+case