Re: [FFmpeg-devel] [PATCH 4/4] libavcodec/dev: v4l2: add support for v4l2 mem2mem codecs

2017-07-27 Thread Jorge Ramirez

On 07/26/2017 04:04 PM, Michael Niedermayer wrote:

On Mon, Jul 24, 2017 at 09:08:49PM +0200, Jorge Ramirez-Ortiz wrote:

From: Alexis Ballier 

This patchset enhances Alexis Ballier's original patch and validates
it using Qualcomm's Venus hardware (driver recently landed upstream
[1]).

This has been tested on Qualcomm's DragonBoard 410c and 820c

ffplay tested video decoders:
- h264,
- vp8
- mpeg4

Some of the changes introduced:
- v4l2: some cleanup of the code.
- v4l2: some cleaup before upstreaming.
- v4l2: follow the new decode api.
- v4l2: fix display size for NV12 output pool.
- v4l2: handle EOS.
- v4l2: fix vp8 and mpeg4 decoding.
- v4l2: generate EOF on dequeue errors.
- v4l2: h264_mp4toannexb filtering.

[1] https://lwn.net/Articles/697956/

this with the other patches breaks build


Hi Michael,

Could you provide some details of your build environment and kernel please?
What is the oldest kernel that you have to build on?

The identifiers that the compiler is moaning about were added to the API 
a few years back (2 and 4) to v4l2-controls.h and videodev2.h)


1) For instance the kernel added support for 
V4L2_CID_MPEG_VIDEO_VPX_MIN_QP in 2013 with commit:


commit 4773ab99aa8bda57de22bf54ddbaa1a941b25fb0
Author: Arun Kumar K 
Date:   Fri Nov 15 02:29:22 2013 -0300

[media] s5p-mfc: Add QP setting support for vp8 encoder

Adds v4l2 controls to set MIN, MAX QP values and
I, P frame QP for vp8 encoder.

Signed-off-by: Kiran AVND 
Signed-off-by: Arun Kumar K 
Signed-off-by: Kamil Debski 
Signed-off-by: Mauro Carvalho Chehab 


2) Similarly V4L2_BUF_FLAG_LAST was introduced a couple of years ago with

Author: Philipp Zabel 
Date:   Mon May 4 07:51:04 2015 -0300

[media] DocBook media: document codec draining flow

Document the interaction between VIDIOC_DECODER_CMD 
V4L2_DEC_CMD_STOP and
VIDIOC_ENCODER_CMD V4L2_ENC_CMD_STOP to start the draining, the 
V4L2_EVENT_EOS
event signalling all capture buffers are finished and ready to be 
dequeud,
the new V4L2_BUF_FLAG_LAST buffer flag indicating the last buffer 
being dequeued
from the capture queue, and the poll and VIDIOC_DQBUF ioctl return 
values once

the queue is drained.

Signed-off-by: Philipp Zabel 
Acked-by: Hans Verkuil 
Signed-off-by: Kamil Debski 
Signed-off-by: Mauro Carvalho Chehab 


For users, those identifiers are defined in 
/usr/include/linux/videodev2.h and /usr/include/linux/v4l2-controls.h. 
so they should have been there along with the others; however and since 
this is not the case for you, it must be caused by the build environment 
being not too recent (I have been testing on Ubuntu 16.04)


(btw I have fixed the av log warning on v2)


CC  libavcodec/v4l2-buffers.o
CC  libavcodec/v4l2_m2m_enc.o
libavcodec/v4l2_m2m_enc.c: In function ‘v4lm2m_encode_init’:
libavcodec/v4l2_m2m_enc.c:150:103: error: ‘V4L2_CID_MPEG_VIDEO_VPX_MIN_QP’ 
undeclared (first use in this function)
  SET_V4L_EXT_CTRL(value, V4L2_CID_MPEG_VIDEO_VPX_MIN_QP, avctx->qmin, 
V4L2_CTRL_CLASS_MPEG, "minimum video quantizer scale");

^
libavcodec/v4l2_m2m_enc.c:150:103: note: each undeclared identifier is reported 
only once for each function it appears in
libavcodec/v4l2_m2m_enc.c:151:103: error: ‘V4L2_CID_MPEG_VIDEO_VPX_MAX_QP’ 
undeclared (first use in this function)
  SET_V4L_EXT_CTRL(value, V4L2_CID_MPEG_VIDEO_VPX_MAX_QP, avctx->qmax, 
V4L2_CTRL_CLASS_MPEG, "maximum video quantizer scale");

^
make: *** [libavcodec/v4l2_m2m_enc.o] Error 1
libavcodec/v4l2-buffers.c: In function ‘avpriv_init_v4lbufpool’:
libavcodec/v4l2-buffers.c:276:9: warning: unknown conversion type character ‘y’ 
in format [-Wformat=]
  av_log(bufs->log_ctx, AV_LOG_ERROR, "%type %i not supported\n", 
bufs->type);
  ^
libavcodec/v4l2-buffers.c: In function ‘avpkt_to_v4lbuf’:
libavcodec/v4l2-buffers.c:414:22: error: ‘V4L2_BUF_FLAG_LAST’ undeclared (first 
use in this function)
  out->flags = V4L2_BUF_FLAG_LAST;
   ^
libavcodec/v4l2-buffers.c:414:22: note: each undeclared identifier is reported 
only once for each function it appears in
libavcodec/v4l2-buffers.c: In function ‘v4lbuf_to_avpkt’:
libavcodec/v4l2-buffers.c:464:5: warning: ‘av_free_packet’ is deprecated 
(declared at libavcodec/avcodec.h:4621) [-Wdeprecated-declarations]
  av_free_packet(pkt);
  ^
make: *** [libavcodec/v4l2-buffers.o] Error 1
make: Target `all' not remade because of errors.

[...]



Re: [FFmpeg-devel] [PATCH] fate: update pixfmt_best test to check for endianness

2017-07-27 Thread Tobias Rapp

On 26.07.2017 17:05, Michael Niedermayer wrote:

On Wed, Jul 26, 2017 at 03:58:54PM +0200, Tobias Rapp wrote:

Signed-off-by: Tobias Rapp 
---
 libavutil/tests/pixfmt_best.c | 14 ++
 tests/ref/fate/pixfmt_best|  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)


LGTM

thx


Applied.


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


Re: [FFmpeg-devel] [PATCH] doc/libav-merge: remove the hls merge TODO

2017-07-27 Thread Steven Liu
2017-07-27 13:55 GMT+08:00 Clément Bœsch :
> On Thu, Jul 27, 2017 at 11:45:32AM +0800, Steven Liu wrote:
>> 2017-07-25 11:42 GMT+08:00 Steven Liu :
>> > From: Steven Liu 
>> >
>> > because the commit id 3c7fa8cbb93dba96acb12aef6e00d929c1da1ae8
>> > have been done for OPENSSL at hlsenc.
>> >
>
> I don't understand what you mean here: we need in FFmpeg an equivalent to
> the options added in edc43c571d: do we have them? If so, you should
> reference them.
All the Encrypt HLS have been done, you could check it.
I think the doc should update, so modify it.

>
> [...]
>
> --
> Clément B.
>
> ___
> 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]v6 Opus Pyramid Vector Quantization Search in x86 SIMD asm

2017-07-27 Thread Rostislav Pehlivanov
On 27 July 2017 at 09:38, Ivan Kalvachev  wrote:

> On 7/27/17, Rostislav Pehlivanov  wrote:
> > On 26 July 2017 at 15:56, Ivan Kalvachev  wrote:
> >
> >> +if (ARCH_X86 && CONFIG_OPUS_ENCODER)
> >> +ff_opus_dsp_init_x86(s);
> >>
> >
> > Just change it to
> > +if (ARCH_X86)
> >
> > The init function is named opus_dsp, so it'll get used to other opus
> > things, not just the encoder.
>
> But at the moment it does not.
> I do prefer to leave that task for the one that
> adds opus decoder functions.
>
> Also this change alone would break compilation, since
> it also requires changing the libavcodec/x86/Makefile
> and adding the guard inside the opus_dsp_init.c
>
> Another option is to have "opus_enc_dsp_init.c" and call
> the function "ff_opus_enc_dsp_init_x86()".
>
> Do tell me which option do you prefer
> and do you insist on v7 just for that.
>
> > The assembly code looks fine to me, but other people will have to take a
> > look at it in case I'm missing something.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

The former, but that can be changed later after pushing
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2017-07-27 Thread Ivan Kalvachev
On 7/27/17, Rostislav Pehlivanov  wrote:
> On 26 July 2017 at 15:56, Ivan Kalvachev  wrote:
>
>> +if (ARCH_X86 && CONFIG_OPUS_ENCODER)
>> +ff_opus_dsp_init_x86(s);
>>
>
> Just change it to
> +if (ARCH_X86)
>
> The init function is named opus_dsp, so it'll get used to other opus
> things, not just the encoder.

But at the moment it does not.
I do prefer to leave that task for the one that
adds opus decoder functions.

Also this change alone would break compilation, since
it also requires changing the libavcodec/x86/Makefile
and adding the guard inside the opus_dsp_init.c

Another option is to have "opus_enc_dsp_init.c" and call
the function "ff_opus_enc_dsp_init_x86()".

Do tell me which option do you prefer
and do you insist on v7 just for that.

> The assembly code looks fine to me, but other people will have to take a
> look at it in case I'm missing something.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/pixlet: Simplify nbits computation

2017-07-27 Thread Paul B Mahol
On 7/27/17, Michael Niedermayer  wrote:
> Fixes multiple integer overflows
> Fixes: runtime error: signed integer overflow: 1 + 2147483647 cannot be
> represented in type 'int'
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/pixlet.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

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


[FFmpeg-devel] [PATCH v2] doc/libav-merge: remove the hls merge TODO

2017-07-27 Thread Steven Liu
This TODO is done.
See 5caaa3a49e76b084ff8a9840d541bad64d96d7f7

Signed-off-by: Steven Liu 
---
 doc/libav-merge.txt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/doc/libav-merge.txt b/doc/libav-merge.txt
index 690c4ef97f..96b008b71b 100644
--- a/doc/libav-merge.txt
+++ b/doc/libav-merge.txt
@@ -105,7 +105,6 @@ Collateral damage that needs work locally:
 - Merge proresdec2.c and proresdec_lgpl.c
 - Merge proresenc_anatoliy.c and proresenc_kostya.c
 - Fix MIPS AC3 downmix
-- hlsenc encryption support may need some adjustment (see edc43c571d)
 
 Extra changes needed to be aligned with Libav:
 --
-- 
2.11.0 (Apple Git-81)



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


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

2017-07-27 Thread Ivan Kalvachev
On 7/27/17, Rostislav Pehlivanov  wrote:
> On 27 July 2017 at 09:38, Ivan Kalvachev  wrote:
>
>> On 7/27/17, Rostislav Pehlivanov  wrote:
>> > On 26 July 2017 at 15:56, Ivan Kalvachev  wrote:
>> >
>> >> +if (ARCH_X86 && CONFIG_OPUS_ENCODER)
>> >> +ff_opus_dsp_init_x86(s);
>> >>
>> >
>> > Just change it to
>> > +if (ARCH_X86)
>> >
>> > The init function is named opus_dsp, so it'll get used to other opus
>> > things, not just the encoder.
>>
>> But at the moment it does not.
>> I do prefer to leave that task for the one that
>> adds opus decoder functions.
>>
>> Also this change alone would break compilation, since
>> it also requires changing the libavcodec/x86/Makefile
>> and adding the guard inside the opus_dsp_init.c
>>
>> Another option is to have "opus_enc_dsp_init.c" and call
>> the function "ff_opus_enc_dsp_init_x86()".
>>
>> Do tell me which option do you prefer
>> and do you insist on v7 just for that.
>>
>> > The assembly code looks fine to me, but other people will have to take a
>> > look at it in case I'm missing something.
>
> The former, but that can be changed later after pushing

Here is the patch.
I'll merge it in v7, if there is one.

Please note that makefile needs to use two separate
config_opus_decoder/encoder, since there is no config_opus_codec . All
other dsp seem to use separate files for encoder and decoder dsp.

Best Regards.
From 1a6ee9b2880c67db25737a6317f09cbbac441c83 Mon Sep 17 00:00:00 2001
From: Ivan Kalvachev 
Date: Thu, 27 Jul 2017 14:21:33 +0300
Subject: [PATCH 2/6] Build opus dsp for encoder and decoder.

---
 libavcodec/opus_pvq.c  | 2 +-
 libavcodec/x86/Makefile| 1 +
 libavcodec/x86/opus_dsp_init.c | 2 ++
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/opus_pvq.c b/libavcodec/opus_pvq.c
index 3aa502929c..2fb276099b 100644
--- a/libavcodec/opus_pvq.c
+++ b/libavcodec/opus_pvq.c
@@ -947,7 +947,7 @@ int av_cold ff_celt_pvq_init(CeltPVQ **pvq)
 s->encode_band= pvq_encode_band;
 s->band_cost  = pvq_band_cost;
 
-if (ARCH_X86 && CONFIG_OPUS_ENCODER)
+if (ARCH_X86)
 ff_opus_dsp_init_x86(s);
 
 *pvq = s;
diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile
index 9875f48797..e36644c72a 100644
--- a/libavcodec/x86/Makefile
+++ b/libavcodec/x86/Makefile
@@ -52,6 +52,7 @@ OBJS-$(CONFIG_APNG_DECODER)+= x86/pngdsp_init.o
 OBJS-$(CONFIG_CAVS_DECODER)+= x86/cavsdsp.o
 OBJS-$(CONFIG_DCA_DECODER) += x86/dcadsp_init.o x86/synth_filter_init.o
 OBJS-$(CONFIG_DNXHD_ENCODER)   += x86/dnxhdenc_init.o
+OBJS-$(CONFIG_OPUS_DECODER)+= x86/opus_dsp_init.o
 OBJS-$(CONFIG_OPUS_ENCODER)+= x86/opus_dsp_init.o
 OBJS-$(CONFIG_HEVC_DECODER)+= x86/hevcdsp_init.o
 OBJS-$(CONFIG_JPEG2000_DECODER)+= x86/jpeg2000dsp_init.o
diff --git a/libavcodec/x86/opus_dsp_init.c b/libavcodec/x86/opus_dsp_init.c
index f4c25822db..c51f786ee8 100644
--- a/libavcodec/x86/opus_dsp_init.c
+++ b/libavcodec/x86/opus_dsp_init.c
@@ -32,6 +32,7 @@ av_cold void ff_opus_dsp_init_x86(CeltPVQ *s)
 {
 int cpu_flags = av_get_cpu_flags();
 
+#if CONFIG_OPUS_ENCODER
 if (EXTERNAL_SSE2(cpu_flags))
 s->pvq_search = ff_pvq_search_sse2;
 
@@ -40,4 +41,5 @@ av_cold void ff_opus_dsp_init_x86(CeltPVQ *s)
 
 if (EXTERNAL_AVX(cpu_flags))
 s->pvq_search = ff_pvq_search_avx;
+#endif
 }
-- 
2.13.2

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


Re: [FFmpeg-devel] [PATCH 01/10] lavfi/vf_threshold: move to activate design.

2017-07-27 Thread Paul B Mahol
On 7/17/17, Nicolas George  wrote:
> Also fix missing dependency.
>
> Signed-off-by: Nicolas George 
> ---
>  libavfilter/Makefile   |  2 +-
>  libavfilter/vf_threshold.c | 34 --
>  2 files changed, 13 insertions(+), 23 deletions(-)
>
>
> For all this series: the filter builds, FATE passes, but no further tests
> have been done.
>
> These are all the filters that use framesync directly except streamselect
> that will require a more careful look. TODO: dualinput.
>
>

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


Re: [FFmpeg-devel] [PATCH] libavformat/mov: Fix inserting frames before current_frame

2017-07-27 Thread Moritz Barsnick
On Wed, Jul 26, 2017 at 15:37:16 -0700, Jacob Trimble wrote:
>  av_log(c->fc, AV_LOG_ERROR, "Failed to add index entry\n");
> +} else if (err <= sc->current_sample && err + 1 !=
> st->nb_index_entries &&
> +st->nb_index_entries != old_nb_index_entries) {

Your mailer inserted line breaks into the patch. Please either attach
it, or even better, send it with git send-email.

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


Re: [FFmpeg-devel] [PATCH] Fix static linking openssl library

2017-07-27 Thread Alexandr Topilski
That's all what puppies can do, good work, please close issue! I will patch
build by hands for raspberry.

On Thu, Jul 6, 2017 at 3:25 PM, Alexandr Topilski 
wrote:

> Ping
>
> On Fri, Jun 23, 2017 at 10:26 AM, Alexandr Topilski 
> wrote:
>
>> Hi, thank you for reply but output of pkg-config --static --libs openssl
>> is next:
>> $ -L/usr/local/lib -lssl -ldl -lcrypto -ldl
>>
>> Also i built openssl without any flags, simple execute: ./config && make && 
>> make install
>>
>>
>> On Thu, Jun 22, 2017 at 11:07 AM, Moritz Barsnick 
>> wrote:
>>
>>> (This really belongs to ffmpeg-user.)
>>>
>>> On Thu, Jun 22, 2017 at 08:14:56 +0300, Alexandr Topilski wrote:
>>>
>>> > use_pkg_config openssl openssl/ssl.h SSL_library_init
>>> > check_pkg_config openssl openssl/ssl.h SSL_library_init
>>> > pkg-config --exists --print-errors openssl
>>> > check_func_headers openssl/ssl.h SSL_library_init -I/usr/local/include
>>> -L/usr/local/lib -lssl -lcrypto
>>> > check_ld cc -I/usr/local/include -L/usr/local/lib -lssl -lcrypto
>>> > check_cc -I/usr/local/include -L/usr/local/lib
>>> > BEGIN /tmp/ffconf.QjUh7os0.c
>>> > 1   #include 
>>> > 2   #include 
>>> > 3   long check_SSL_library_init(void) { return (long)
>>> SSL_library_init; }
>>> > 4   int main(void) { int ret = 0;
>>> > 5ret |= ((intptr_t)check_SSL_library_init) & 0x;
>>> > 6   return ret; }
>>> > END /tmp/ffconf.QjUh7os0.c
>>> > gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
>>> -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -march=armv6 -std=c11
>>> > +-fomit-frame-pointer -marm -pthread -isystem/opt/vc/include/
>>> -isystem/opt/vc/include/interface/vmcs_host/linux
>>> > +-isystem/opt/vc/include/interface/vcos/pthreads -fgnu89-inline
>>> -isystem/opt/vc/include/IL -I/usr/local/include -L/usr/local/lib -c -o
>>> > +/tmp/ffconf.YcV8E8C1.o /tmp/ffconf.QjUh7os0.c
>>> > gcc -march=armv6 -Wl,--as-needed -Wl,-z,noexecstack
>>> -I/usr/local/include -L/usr/local/lib -o /tmp/ffconf.iIiIBDDZ
>>> /tmp/ffconf.YcV8E8C1.o
>>> > +-lssl -lcrypto -L/opt/vc/lib/ -lmmal_core -lmmal_util
>>> -lmmal_vc_client -lbcm_host -lm -lbz2 -lz -pthread
>>> > /usr/local/lib/libcrypto.a(dso_dlfcn.o): In function
>>> `dlfcn_globallookup':
>>> > dso_dlfcn.c:(.text+0x10): undefined reference to `dlopen'
>>> > dso_dlfcn.c:(.text+0x20): undefined reference to `dlsym'
>>> > dso_dlfcn.c:(.text+0x2c): undefined reference to `dlclose'
>>> > /usr/local/lib/libcrypto.a(dso_dlfcn.o): In function
>>> `dlfcn_bind_func':
>>> > dso_dlfcn.c:(.text+0x318): undefined reference to `dlsym'
>>> > dso_dlfcn.c:(.text+0x3bc): undefined reference to `dlerror'
>>>
>>> If the static libcrypto.a requires "-dl", its pkg-config file should
>>> say so, i.e.
>>> $ pkg-config --static --libs openssl
>>> should include "-dl". If not, I believe it's wrong (for your particular
>>> library).
>>>
>>> Moritz
>>> ___
>>> 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] libavformat/mov: Fix inserting frames before current_frame.

2017-07-27 Thread Jacob Trimble
When using streaming input, it may be possible to see frames that appear
before the current_frame.  When these frames are inserted into the
index, the current_frame needs to be updated so it is still pointing
at the same frame.

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

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 63f84be782..d039f27063 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4259,7 +4259,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 int64_t dts;
 int data_offset = 0;
 unsigned entries, first_sample_flags = frag->flags;
-int flags, distance, i, err;
+int flags, distance, i, err, old_nb_index_entries;
 
 for (i = 0; i < c->fc->nb_streams; i++) {
 if (c->fc->streams[i]->id == frag->track_id) {
@@ -4352,13 +4352,19 @@ static int mov_read_trun(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
   MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES));
 if (keyframe)
 distance = 0;
+old_nb_index_entries = st->nb_index_entries;
 err = av_add_index_entry(st, offset, dts, sample_size, distance,
  keyframe ? AVINDEX_KEYFRAME : 0);
 if (err < 0) {
 av_log(c->fc, AV_LOG_ERROR, "Failed to add index entry\n");
+} else if (err <= sc->current_sample && err + 1 != 
st->nb_index_entries &&
+st->nb_index_entries != old_nb_index_entries) {
+// if we inserted a new item before the current sample, move the
+// counter ahead so it is still pointing to the same sample.
+sc->current_sample++;
 }
-av_log(c->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %u, offset 
%"PRIx64", dts %"PRId64", "
-"size %u, distance %d, keyframe %d\n", st->index, 
sc->sample_count+i,
+av_log(c->fc, AV_LOG_TRACE, "AVIndex stream %d, sample %d, offset 
%"PRIx64", dts %"PRId64", "
+"size %u, distance %d, keyframe %d\n", st->index, err,
 offset, dts, sample_size, distance, keyframe);
 distance++;
 dts += sample_duration;
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] avcodec/dirac_vlc: Fix invalid shift

2017-07-27 Thread Michael Niedermayer
Fixes: runtime error: shift exponent 65 is too large for 64-bit type 'residual' 
(aka 'unsigned long')
Fixes: 2737/clusterfuzz-testcase-minimized-4968639147016192

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

diff --git a/libavcodec/dirac_vlc.c b/libavcodec/dirac_vlc.c
index 773f720858..f9a6017ec0 100644
--- a/libavcodec/dirac_vlc.c
+++ b/libavcodec/dirac_vlc.c
@@ -96,6 +96,9 @@ int ff_dirac_golomb_read_16bit(DiracGolombLUT *lut_ctx, const 
uint8_t *buf,
 if ((c_idx + 1) > coeffs)
 return c_idx;
 
+if (res_bits >= RSIZE_BITS)
+return 0;
+
 if (res_bits && l->sign) {
 int32_t coeff = 1;
 APPEND_RESIDUE(res, l->preamble);
-- 
2.13.0

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


[FFmpeg-devel] [PATCH 2/2] avcodec/dirac_dwt: Fix multiple integer overflows in COMPOSE_DD97iH0()

2017-07-27 Thread Michael Niedermayer
Fixes: runtime error: signed integer overflow: 9 * 335544320 cannot be 
represented in type 'int'
Fixes: 2739/clusterfuzz-testcase-minimized-6737297955356672

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/dirac_dwt.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/dirac_dwt.h b/libavcodec/dirac_dwt.h
index 4d338651fa..62f8472b41 100644
--- a/libavcodec/dirac_dwt.h
+++ b/libavcodec/dirac_dwt.h
@@ -99,7 +99,7 @@ void ff_spatial_idwt_slice2(DWTContext *d, int y);
 (b1 + ((b0 + b2 + 1) >> 1))
 
 #define COMPOSE_DD97iH0(b0, b1, b2, b3, b4)\
-(b2 + ((-b0 + 9*b1 + 9*b3 - b4 + 8) >> 4))
+(b2 + ((int)(-b0 + 9U*b1 + 9U*b3 - b4 + 8) >> 4))
 
 #define COMPOSE_DD137iL0(b0, b1, b2, b3, b4)\
 (b2 - ((-b0 + 9*b1 + 9*b3 - b4 + 16) >> 5))
-- 
2.13.0

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


Re: [FFmpeg-devel] [PATCH] avcodec/diracdec: Fix integer overflow in signed multiplication in UNPACK_ARITH()

2017-07-27 Thread Michael Niedermayer
On Wed, Jul 26, 2017 at 09:49:30PM +0200, Michael Niedermayer wrote:
> Fixes: runtime error: signed integer overflow: 1073741823 * 4 cannot be 
> represented in type 'int'
> Fixes: 2729/clusterfuzz-testcase-minimized-5902915464069120
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/diracdec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

applied

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

What does censorship reveal? It reveals fear. -- Julian Assange


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


Re: [FFmpeg-devel] [PATCH] Add FITS Encoder

2017-07-27 Thread Paras Chadha
On Mon, Jul 24, 2017 at 3:42 AM, Carl Eugen Hoyos 
wrote:

> 2017-07-21 20:16 GMT+02:00 Reimar Döffinger :
> > On 21.07.2017, at 16:26, Paras Chadha  wrote:
> >
> >> On Fri, Jul 21, 2017 at 3:27 AM, Carl Eugen Hoyos 
> >> wrote:
> >>
> >>> 2017-07-20 21:46 GMT+02:00 Paras Chadha :
> >>>
>  +case AV_PIX_FMT_RGB24:
>  +case AV_PIX_FMT_RGBA:
>  +for (k = 0; k < naxis3; k++) {
>  +for (i = 0; i < avctx->height; i++) {
>  +ptr = p->data[0] + (avctx->height - i - 1) *
> >>> p->linesize[0] + k;
>  +for (j = 0; j < avctx->width; j++) {
>  +bytestream_put_byte(,
> ptr[0]);
>  +ptr += naxis3;
> >>>
> >>> (Sorry if this is nonsense:)
> >>> Shouldn't you be using PIX_FMT_GBRP and PIX_FMT_GBRAP?
> >>>
> >>
> >> No, the current pixel formats are working fine. I have tested using GIMP
> >> too. It is showing all the RGB images (and others too) correctly.
> >
> > I think that's not what he meant.
> > You are explicitly requesting a packed format that has the data in
> > RGBRGBRGB... order, and you then need these loops to split it into
> > ... ... ...
> > He's suggesting you should simply request the format storing the data
> like that
>
> Yes, this makes above code both simpler and (on typical hardware)
> always faster (it will never be slower, no matter the hardware).
>

Yes, done. It has made the code a lot simple, thanks.


>
> > then all you need to do is the unsigned -> signed conversion
>
> Which is not necessary for the above case.
>
> Carl Eugen
> ___
> 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] Add FITS Encoder

2017-07-27 Thread Paras Chadha
On Fri, Jul 21, 2017 at 7:59 PM, Nicolas George  wrote:

> Le tridi 3 thermidor, an CCXXV, Paras Chadha a écrit :
> > > >  AVOutputFormat ff_image2pipe_muxer = {
> > > >  .name   = "image2pipe",
> > > >  .long_name  = NULL_IF_CONFIG_SMALL("piped image2 sequence"),
> > > > +.extensions = "fits",
> > > This is probably wrong. Did you intend to add this extension to
> > > ff_image2_muxer instead?
> > No, if there are multiple images, i want them to be appended one after
> > other. I think image2pipe is the correct muxer to use.
>
> But it is not the way image2pipe handles extensions, otherwise you would
> see tga, tiff, sun, etc., already there.
>

Okay, I will create a separate muxer for FITS.


>
> 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] Add FITS Demuxer

2017-07-27 Thread Paras Chadha
Signed-off-by: Paras Chadha 
---

Made all the changes suggested.

 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/fitsdec.c| 236 +++
 libavformat/version.h|   2 +-
 4 files changed, 239 insertions(+), 1 deletion(-)
 create mode 100644 libavformat/fitsdec.c

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..a8e9396
--- /dev/null
+++ b/libavformat/fitsdec.c
@@ -0,0 +1,236 @@
+/*
+ * 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;
+int image;
+int64_t pts;
+} FITSContext;
+
+static int fits_probe(AVProbeData *p)
+{
+const uint8_t *b = p->buf;
+
+if (AV_RB64(b) == 0x53494d504c452020 &&
+AV_RB64(b + 8) == 0x3D20202020202020 &&
+AV_RB64(b + 16) == 0x2020202020202020 &&
+AV_RB48(b + 24) == 0x202020202054)
+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;
+}
+
+static int64_t find_size(AVFormatContext *s, FITSContext *fits, FITSHeader 
*header, AVBPrint *avbuf)
+{
+int i, ret;
+char buf[FITS_BLOCK_SIZE] = { 0 };
+int64_t buf_size = 0, data_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_EOF;
+}
+
+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;
+
+fits->image = fits->first_image || header->image_extension;
+
+if (header->groups) {
+fits->image = 0;
+if (header->naxis > 1)
+data_size = 1;
+for (i = 1; i < header->naxis; i++) {
+if(data_size && header->naxisn[i] > LLONG_MAX / data_size)
+return AVERROR_INVALIDDATA;
+data_size *= header->naxisn[i];
+}
+} else if (header->naxis) {
+data_size = 1;
+for (i = 0; i < header->naxis; i++) {
+

[FFmpeg-devel] [PATCH] Add FITS Decoder

2017-07-27 Thread Paras Chadha
Signed-off-by: Paras Chadha 
---
 Changelog   |   1 +
 doc/general.texi|   2 +
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/avcodec.h|   1 +
 libavcodec/codec_desc.c |   7 +
 libavcodec/fits.h   |  79 +++
 libavcodec/fitsdec.c| 550 
 libavcodec/version.h|   2 +-
 9 files changed, 643 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/fits.h
 create mode 100644 libavcodec/fitsdec.c

diff --git a/Changelog b/Changelog
index 187ae79..d9af2b9 100644
--- a/Changelog
+++ b/Changelog
@@ -29,6 +29,7 @@ version :
 - limiter video filter
 - libvmaf video filter
 - Dolby E decoder and SMPTE 337M demuxer
+- 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 357fa1a..5348ed9 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
 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 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.h b/libavcodec/fits.h
new file mode 100644
index 000..45d1ae2
--- /dev/null
+++ b/libavcodec/fits.h
@@ -0,0 +1,79 @@
+/*
+ * FITS image format
+ * 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
+ */
+
+#ifndef AVCODEC_FITS_H
+#define AVCODEC_FITS_H
+
+typedef enum FITSHeaderState {
+STATE_SIMPLE,
+STATE_XTENSION,
+STATE_BITPIX,
+STATE_NAXIS,
+STATE_NAXIS_N,
+STATE_PCOUNT,
+STATE_GCOUNT,
+STATE_REST,
+} FITSHeaderState;
+
+/**
+ * Structure to store the header keywords in FITS file
+ */
+typedef struct FITSHeader {
+FITSHeaderState state;
+unsigned naxis_index;
+int bitpix;
+int64_t blank;
+

Re: [FFmpeg-devel] [PATCH 4/4] libavcodec/dev: v4l2: add support for v4l2 mem2mem codecs

2017-07-27 Thread Michael Niedermayer
On Thu, Jul 27, 2017 at 08:44:37AM +0200, Jorge Ramirez wrote:
> On 07/26/2017 04:04 PM, Michael Niedermayer wrote:
> >On Mon, Jul 24, 2017 at 09:08:49PM +0200, Jorge Ramirez-Ortiz wrote:
> >>From: Alexis Ballier 
> >>
> >>This patchset enhances Alexis Ballier's original patch and validates
> >>it using Qualcomm's Venus hardware (driver recently landed upstream
> >>[1]).
> >>
> >>This has been tested on Qualcomm's DragonBoard 410c and 820c
> >>
> >>ffplay tested video decoders:
> >>- h264,
> >>- vp8
> >>- mpeg4
> >>
> >>Some of the changes introduced:
> >>- v4l2: some cleanup of the code.
> >>- v4l2: some cleaup before upstreaming.
> >>- v4l2: follow the new decode api.
> >>- v4l2: fix display size for NV12 output pool.
> >>- v4l2: handle EOS.
> >>- v4l2: fix vp8 and mpeg4 decoding.
> >>- v4l2: generate EOF on dequeue errors.
> >>- v4l2: h264_mp4toannexb filtering.
> >>
> >>[1] https://lwn.net/Articles/697956/
> >this with the other patches breaks build
> 
> Hi Michael,
> 
> Could you provide some details of your build environment and kernel please?

this should have been a ubuntu 14.04 LTS with 3.13.0-125-generic which
should be the default for ubuntu 14-04


> What is the oldest kernel that you have to build on?

whatever the oldest kernel used by any supported distribution is


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

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato


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/2] avcodec/dirac_vlc: Fix invalid shift

2017-07-27 Thread Rostislav Pehlivanov
On 28 July 2017 at 02:22, Michael Niedermayer 
wrote:

> Fixes: runtime error: shift exponent 65 is too large for 64-bit type
> 'residual' (aka 'unsigned long')
> Fixes: 2737/clusterfuzz-testcase-minimized-4968639147016192
>
> Found-by: continuous fuzzing process https://github.com/google/oss-
> fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/dirac_vlc.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libavcodec/dirac_vlc.c b/libavcodec/dirac_vlc.c
> index 773f720858..f9a6017ec0 100644
> --- a/libavcodec/dirac_vlc.c
> +++ b/libavcodec/dirac_vlc.c
> @@ -96,6 +96,9 @@ int ff_dirac_golomb_read_16bit(DiracGolombLUT *lut_ctx,
> const uint8_t *buf,
>  if ((c_idx + 1) > coeffs)
>  return c_idx;
>
> +if (res_bits >= RSIZE_BITS)
> +return 0;
> +
>  if (res_bits && l->sign) {
>  int32_t coeff = 1;
>  APPEND_RESIDUE(res, l->preamble);
> --
> 2.13.0
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Empty the residue instead of giving up. That's the better solution I think.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH V3 1/2] avcodec/vorbisenc: Add pre-echo detection

2017-07-27 Thread Tyler Jones
The encoder will attempt to determine the existence of transient
signals by applying a 4th order highpass filter to remove dominant
low frequency waveforms. Frames are then split up into blocks
where the variance is calculated and compared with blocks from
the previous frame. A preecho is only likely to be noticeable when
relatively quiet audio is followed by a loud transient signal.

Signed-off-by: Tyler Jones 
---
V3: Use normal float notation
Don't check before freeing NULL pointers
Remove unnecessary includes 

V2: Provide proper prefix for non-static function

 libavcodec/Makefile|   2 +-
 libavcodec/vorbisenc.c |  27 +++--
 libavcodec/vorbispsy.c | 148 +
 libavcodec/vorbispsy.h |  79 ++
 4 files changed, 251 insertions(+), 5 deletions(-)
 create mode 100644 libavcodec/vorbispsy.c
 create mode 100644 libavcodec/vorbispsy.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 357fa1a361..08acbc723e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -611,7 +611,7 @@ OBJS-$(CONFIG_VMNC_DECODER)+= vmnc.o
 OBJS-$(CONFIG_VORBIS_DECODER)  += vorbisdec.o vorbisdsp.o vorbis.o \
   vorbis_data.o
 OBJS-$(CONFIG_VORBIS_ENCODER)  += vorbisenc.o vorbis.o \
-  vorbis_data.o
+  vorbis_data.o vorbispsy.o
 OBJS-$(CONFIG_VP3_DECODER) += vp3.o
 OBJS-$(CONFIG_VP5_DECODER) += vp5.o vp56.o vp56data.o vp56rac.o
 OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o \
diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c
index bf21a3b1ff..1330b1b376 100644
--- a/libavcodec/vorbisenc.c
+++ b/libavcodec/vorbisenc.c
@@ -33,6 +33,7 @@
 #include "mathops.h"
 #include "vorbis.h"
 #include "vorbis_enc_data.h"
+#include "vorbispsy.h"
 
 #include "audio_frame_queue.h"
 #include "libavfilter/bufferqueue.h"
@@ -136,6 +137,7 @@ typedef struct vorbis_enc_context {
 int64_t next_pts;
 
 AVFloatDSPContext *fdsp;
+VorbisPsyContext *vpctx;
 } vorbis_enc_context;
 
 #define MAX_CHANNELS 2
@@ -272,11 +274,12 @@ static int create_vorbis_context(vorbis_enc_context *venc,
 vorbis_enc_floor   *fc;
 vorbis_enc_residue *rc;
 vorbis_enc_mapping *mc;
-int i, book, ret;
+int i, book, ret, blocks;
 
 venc->channels= avctx->channels;
 venc->sample_rate = avctx->sample_rate;
-venc->log2_blocksize[0] = venc->log2_blocksize[1] = 11;
+venc->log2_blocksize[0] = 8;
+venc->log2_blocksize[1] = 11;
 
 venc->ncodebooks = FF_ARRAY_ELEMS(cvectors);
 venc->codebooks  = av_malloc(sizeof(vorbis_enc_codebook) * 
venc->ncodebooks);
@@ -464,6 +467,12 @@ static int create_vorbis_context(vorbis_enc_context *venc,
 if ((ret = dsp_init(avctx, venc)) < 0)
 return ret;
 
+blocks = 1 << (venc->log2_blocksize[1] - venc->log2_blocksize[0]);
+venc->vpctx = av_mallocz(sizeof(VorbisPsyContext));
+if (!venc->vpctx || (ret = ff_psy_vorbis_init(venc->vpctx, 
venc->sample_rate,
+  venc->channels, blocks)) < 0)
+return AVERROR(ENOMEM);
+
 return 0;
 }
 
@@ -1078,15 +1087,17 @@ static void move_audio(vorbis_enc_context *venc, int 
sf_size)
 av_frame_free();
 }
 venc->have_saved = 1;
-memcpy(venc->scratch, venc->samples, 2 * venc->channels * frame_size);
+memcpy(venc->scratch, venc->samples, sizeof(float) * venc->channels * 2 * 
frame_size);
 }
 
 static int vorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
 {
 vorbis_enc_context *venc = avctx->priv_data;
-int i, ret, need_more;
+int i, ret, need_more, ch;
+int curr_win = 1;
 int frame_size = 1 << (venc->log2_blocksize[1] - 1);
+int block_size = 1 << (venc->log2_blocksize[0] - 1);
 vorbis_enc_mode *mode;
 vorbis_enc_mapping *mapping;
 PutBitContext pb;
@@ -1121,6 +1132,13 @@ static int vorbis_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 
 move_audio(venc, avctx->frame_size);
 
+for (ch = 0; ch < venc->channels; ch++) {
+float *scratch = venc->scratch + 2 * ch * frame_size + frame_size;
+
+if (!ff_psy_vorbis_block_frame(venc->vpctx, scratch, ch, frame_size, 
block_size))
+curr_win = 0;
+}
+
 if (!apply_window_and_mdct(venc))
 return 0;
 
@@ -1252,6 +1270,7 @@ static av_cold int vorbis_encode_close(AVCodecContext 
*avctx)
 ff_mdct_end(>mdct[1]);
 ff_af_queue_close(>afq);
 ff_bufqueue_discard_all(>bufqueue);
+ff_psy_vorbis_close(venc->vpctx);
 
 av_freep(>extradata);
 
diff --git a/libavcodec/vorbispsy.c b/libavcodec/vorbispsy.c
new file mode 100644
index 00..ef48f6ac8c
--- /dev/null
+++ b/libavcodec/vorbispsy.c
@@ -0,0 +1,148 @@
+/*
+ * Vorbis 

Re: [FFmpeg-devel] [PATCH] avcodec/h264_slice: don't sync default_ref[] between threads.

2017-07-27 Thread Ronald S. Bultje
Hi,

On Tue, Jul 18, 2017 at 7:34 PM, Wan-Teh Chang  wrote:

> default_ref[] is unconditionally initialized in h264_initialise_ref_list()
> (called from ff_h264_build_ref_list(), called from h264_slice_init()).
>
> This fixes the following tsan warning when running fate-h264:
>
> WARNING: ThreadSanitizer: data race (pid=31070)
>   Write of size 8 at 0x7bbc82a8 by thread T1 (mutexes: write M1628):
> #0 memcpy /work/release-test/final/llvm.src/projects/compiler-rt/lib/
> tsan/../sanitizer_common/sanitizer_common_interceptors.inc:655:5
> (ffmpeg+0x10de9d)
> #1 h264_initialise_ref_list ffmpeg/libavcodec/h264_refs.c:214:29
> (ffmpeg+0x1186b3f)
> #2 ff_h264_build_ref_list ffmpeg/libavcodec/h264_refs.c:306
> (ffmpeg+0x1186b3f)
> #3 h264_slice_init ffmpeg/libavcodec/h264_slice.c:1900:11
> (ffmpeg+0x1191149)
> [..]
>   Previous read of size 8 at 0x7bbc82a8 by main thread (mutexes:
> write M1630):
> #0 memcpy /work/release-test/final/llvm.src/projects/compiler-rt/lib/
> tsan/../sanitizer_common/sanitizer_common_interceptors.inc:655:5
> (ffmpeg+0x10de9d)
> #1 ff_h264_update_thread_context ffmpeg/libavcodec/h264_slice.c:411:5
> (ffmpeg+0x118b7dc)
>
> Signed-off-by: Wan-Teh Chang 
> ---
>  libavcodec/h264_slice.c | 1 -
>  1 file changed, 1 deletion(-)


Pushed.

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


Re: [FFmpeg-devel] [PATCH V3 1/2] avcodec/vorbisenc: Add pre-echo detection

2017-07-27 Thread James Almer
On 7/27/2017 6:22 PM, Tyler Jones wrote:
> The encoder will attempt to determine the existence of transient
> signals by applying a 4th order highpass filter to remove dominant
> low frequency waveforms. Frames are then split up into blocks
> where the variance is calculated and compared with blocks from
> the previous frame. A preecho is only likely to be noticeable when
> relatively quiet audio is followed by a loud transient signal.
> 
> Signed-off-by: Tyler Jones 
> ---
> V3: Use normal float notation
> Don't check before freeing NULL pointers
> Remove unnecessary includes   
> 
> V2: Provide proper prefix for non-static function
> 
>  libavcodec/Makefile|   2 +-
>  libavcodec/vorbisenc.c |  27 +++--
>  libavcodec/vorbispsy.c | 148 
> +
>  libavcodec/vorbispsy.h |  79 ++
>  4 files changed, 251 insertions(+), 5 deletions(-)
>  create mode 100644 libavcodec/vorbispsy.c
>  create mode 100644 libavcodec/vorbispsy.h
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 357fa1a361..08acbc723e 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -611,7 +611,7 @@ OBJS-$(CONFIG_VMNC_DECODER)+= vmnc.o
>  OBJS-$(CONFIG_VORBIS_DECODER)  += vorbisdec.o vorbisdsp.o vorbis.o \
>vorbis_data.o
>  OBJS-$(CONFIG_VORBIS_ENCODER)  += vorbisenc.o vorbis.o \
> -  vorbis_data.o
> +  vorbis_data.o vorbispsy.o
>  OBJS-$(CONFIG_VP3_DECODER) += vp3.o
>  OBJS-$(CONFIG_VP5_DECODER) += vp5.o vp56.o vp56data.o vp56rac.o
>  OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o \
> diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c
> index bf21a3b1ff..1330b1b376 100644
> --- a/libavcodec/vorbisenc.c
> +++ b/libavcodec/vorbisenc.c
> @@ -33,6 +33,7 @@
>  #include "mathops.h"
>  #include "vorbis.h"
>  #include "vorbis_enc_data.h"
> +#include "vorbispsy.h"
>  
>  #include "audio_frame_queue.h"
>  #include "libavfilter/bufferqueue.h"
> @@ -136,6 +137,7 @@ typedef struct vorbis_enc_context {
>  int64_t next_pts;
>  
>  AVFloatDSPContext *fdsp;
> +VorbisPsyContext *vpctx;

Why a pointer? I don't see the benefit. It means an unnecessary malloc
and free call.

>  } vorbis_enc_context;
>  
>  #define MAX_CHANNELS 2
> @@ -272,11 +274,12 @@ static int create_vorbis_context(vorbis_enc_context 
> *venc,
>  vorbis_enc_floor   *fc;
>  vorbis_enc_residue *rc;
>  vorbis_enc_mapping *mc;
> -int i, book, ret;
> +int i, book, ret, blocks;
>  
>  venc->channels= avctx->channels;
>  venc->sample_rate = avctx->sample_rate;
> -venc->log2_blocksize[0] = venc->log2_blocksize[1] = 11;
> +venc->log2_blocksize[0] = 8;
> +venc->log2_blocksize[1] = 11;
>  
>  venc->ncodebooks = FF_ARRAY_ELEMS(cvectors);
>  venc->codebooks  = av_malloc(sizeof(vorbis_enc_codebook) * 
> venc->ncodebooks);
> @@ -464,6 +467,12 @@ static int create_vorbis_context(vorbis_enc_context 
> *venc,
>  if ((ret = dsp_init(avctx, venc)) < 0)
>  return ret;
>  
> +blocks = 1 << (venc->log2_blocksize[1] - venc->log2_blocksize[0]);
> +venc->vpctx = av_mallocz(sizeof(VorbisPsyContext));
> +if (!venc->vpctx || (ret = ff_psy_vorbis_init(venc->vpctx, 
> venc->sample_rate,
> +  venc->channels, blocks)) < 
> 0)
> +return AVERROR(ENOMEM);
> +
>  return 0;
>  }
>  
> @@ -1078,15 +1087,17 @@ static void move_audio(vorbis_enc_context *venc, int 
> sf_size)
>  av_frame_free();
>  }
>  venc->have_saved = 1;
> -memcpy(venc->scratch, venc->samples, 2 * venc->channels * frame_size);
> +memcpy(venc->scratch, venc->samples, sizeof(float) * venc->channels * 2 
> * frame_size);
>  }
>  
>  static int vorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
> const AVFrame *frame, int *got_packet_ptr)
>  {
>  vorbis_enc_context *venc = avctx->priv_data;
> -int i, ret, need_more;
> +int i, ret, need_more, ch;
> +int curr_win = 1;
>  int frame_size = 1 << (venc->log2_blocksize[1] - 1);
> +int block_size = 1 << (venc->log2_blocksize[0] - 1);
>  vorbis_enc_mode *mode;
>  vorbis_enc_mapping *mapping;
>  PutBitContext pb;
> @@ -1121,6 +1132,13 @@ static int vorbis_encode_frame(AVCodecContext *avctx, 
> AVPacket *avpkt,
>  
>  move_audio(venc, avctx->frame_size);
>  
> +for (ch = 0; ch < venc->channels; ch++) {
> +float *scratch = venc->scratch + 2 * ch * frame_size + frame_size;
> +
> +if (!ff_psy_vorbis_block_frame(venc->vpctx, scratch, ch, frame_size, 
> block_size))
> +curr_win = 0;
> +}
> +
>  if (!apply_window_and_mdct(venc))
>  return 0;
>  
> @@ -1252,6 +1270,7 @@ static av_cold int 

[FFmpeg-devel] [PATCH 1/2] avcodec/takdec: Fix integer overflow in decode_subframe()

2017-07-27 Thread Michael Niedermayer
Fixes: runtime error: signed integer overflow: -536870912 - 1972191120 cannot 
be represented in type 'int'
Fixes: 2711/clusterfuzz-testcase-minimized-4975142398590976

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

diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c
index e555482b23..1676313b7c 100644
--- a/libavcodec/takdec.c
+++ b/libavcodec/takdec.c
@@ -491,7 +491,7 @@ static int decode_subframe(TAKDecContext *s, int32_t 
*decoded,
  s->residues[i + j + 1] * s->filter[j + 1] +
  s->residues[i + j] * s->filter[j];
 }
-v = (av_clip_intp2(v >> filter_quant, 13) * (1 << dshift)) - 
*decoded;
+v = (av_clip_intp2(v >> filter_quant, 13) * (1 << dshift)) - 
(unsigned)*decoded;
 *decoded++ = v;
 s->residues[filter_order + i] = v >> dshift;
 }
-- 
2.13.0

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


[FFmpeg-devel] [PATCH 2/2] avcodec/diracdec: Fix integer overflow in divide3()

2017-07-27 Thread Michael Niedermayer
Fixes: runtime error: signed integer overflow: -1073746548 * 21845 cannot be 
represented in type 'int'
Fixes: 2729/clusterfuzz-testcase-minimized-5902915464069120

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

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index d2262ebbf5..d2aaeab011 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -249,7 +249,7 @@ enum dirac_subband {
 /* magic number division by 3 from schroedinger */
 static inline int divide3(int x)
 {
-return ((x+1)*21845 + 10922) >> 16;
+return (int)((x+1U)*21845 + 10922) >> 16;
 }
 
 static DiracFrame *remove_frame(DiracFrame *framelist[], int picnum)
-- 
2.13.0

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