[FFmpeg-devel] [PATCH] Check return value of read in ff_rtsp_read_reply()

2017-04-16 Thread Daniel Richard G.
In the course of testing RTSP streaming of CCTV video via the FFmpeg
API, I have found some Valgrind uninitialized-memory errors due to what
appear to be short/failed reads in ffurl_read_complete().

The calling function ff_rtsp_read_reply() was not checking the return
value, and so the library went on to parse garbage in an
uninitialized heap-allocated buffer.

The attached patch adds logic to check the return value and bail
out on error.


--Daniel


-- 
Daniel Richard G. || sk...@iskunk.org
My ASCII-art .sig got a bad case of Times New Roman.
From 544c2f4628d1c8923880219de190caa96d672100 Mon Sep 17 00:00:00 2001
From: Daniel Richard G 
Date: Sun, 16 Apr 2017 23:12:53 -0400
Subject: [PATCH] Check return value of read in ff_rtsp_read_reply()

Signed-off-by: Daniel Richard G 
---
 libavformat/rtsp.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 261e970..da962fb 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1218,7 +1218,11 @@ start:
 content = av_malloc(content_length + 1);
 if (!content)
 return AVERROR(ENOMEM);
-ffurl_read_complete(rt->rtsp_hd, content, content_length);
+ret = ffurl_read_complete(rt->rtsp_hd, content, content_length);
+if (ret != content_length) {
+av_freep();
+return AVERROR_EOF;
+}
 content[content_length] = '\0';
 }
 if (content_ptr)
-- 
2.9.0

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


[FFmpeg-devel] Fwd: [PATCH] added expr evaluation to drawtext - fontsize

2017-04-16 Thread Brett Harrison
Any comments on this patch?

-- Forwarded message --
From: Brett Harrison 
Date: Tue, Apr 11, 2017 at 1:37 PM
Subject: Re: [FFmpeg-devel] [PATCH] added expr evaluation to drawtext -
fontsize
To: FFmpeg development discussions and patches 


Pinging for comments / review...

On Tue, Apr 4, 2017 at 3:45 PM, Brett Harrison 
wrote:

> Resurrecting this patch.
>
> On Thu, Sep 15, 2016 at 3:20 AM, Michael Niedermayer <
> mich...@niedermayer.cc> wrote:
>
>> On Fri, Sep 09, 2016 at 05:26:03PM -0700, Brett Harrison wrote:
>> > Here are the changes requested
>> [...]
>> > +static av_cold int parse_fontsize(AVFilterContext *ctx)
>> > +{
>> > +DrawTextContext *s = ctx->priv;
>> > +int err;
>> > +
>> > +if (s->fontsize_expr == NULL)
>> > +return AVERROR(EINVAL);
>> > +
>> > +av_expr_free(s->fontsize_pexpr);
>> > +s->fontsize_pexpr = NULL;
>> > +
>> > +if ((err = av_expr_parse(>fontsize_pexpr, s->fontsize_expr,
>> var_names,
>> > + NULL, NULL, fun2_names, fun2, 0, ctx)) <
>> 0)
>> > +return err;
>> > +
>> > +return 0;
>> > +}
>>
>> why is av_expr_parse() not executed where the other av_expr_parse()
>> are ?
>>
>
> I needed to perform av_expr_parse() during init() to resolve the default
> fontsize.  init() is called before config_input() where the other
> av_expr_parse() calls are.
>
>


0001-added-expr-evaluation-to-drawtext-fontsize.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] this is the gsos qualification task which use psychoacoustic system to detect transients in vorbis encoder.

2017-04-16 Thread 汲如意
Hi, I am sorry for my mistakes. I have fixed them. And attachment is the
patch which fix error in first one. Thanks.


2017-04-16 15:25 GMT-04:00 Michael Niedermayer :

> On Sun, Apr 16, 2017 at 09:19:33AM -0400, Ruyi Ji wrote:
> > Signed-off-by: Ruyi Ji 
> > ---
> >  libavcodec/psymodel.c|   1 +
> >  libavcodec/vorbis_enc_data.h | 111 ++
> +
> >  libavcodec/vorbisenc.c   |  60 +++
> >  3 files changed, 172 insertions(+)
>
> This seems to fail to build here
>
> CC  libavcodec/vorbisenc.o
> libavcodec/vorbisenc.c:133:45: error: ‘MAX_CHANNELS’ undeclared here (not
> in a function)
> libavcodec/vorbisenc.c: In function ‘vorbis_encode_frame’:
> libavcodec/vorbisenc.c:1057:25: error: expected ‘;’ before ‘if’
> libavcodec/vorbisenc.c: In function ‘vorbis_encode_close’:
> libavcodec/vorbisenc.c:1196:9: error: incompatible type for argument 1 of
> ‘ff_psy_end’
> libavcodec/psymodel.h:176:6: note: expected ‘struct FFPsyContext *’ but
> argument is of type ‘FFPsyContext’
> make: *** [libavcodec/vorbisenc.o] Error 1
> make: Target `all' not remade because of errors.
>
>
> >
> > diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c
> > index 2b5f111..2e11c48 100644
> > --- a/libavcodec/psymodel.c
> > +++ b/libavcodec/psymodel.c
> > @@ -62,6 +62,7 @@ av_cold int ff_psy_init(FFPsyContext *ctx,
> AVCodecContext *avctx, int num_lens,
> >
> >  switch (ctx->avctx->codec_id) {
> >  case AV_CODEC_ID_AAC:
> > + case AV_CODEC_ID_VORBIS:
> >  ctx->model = _aac_psy_model;
>
> tabs are forbidden in ffmpeg-git except where needed for syntax
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> In fact, the RIAA has been known to suggest that students drop out
> of college or go to community college in order to be able to afford
> settlements. -- The RIAA
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
From 2629cada2ed6aa843736762cfe536c4489628272 Mon Sep 17 00:00:00 2001
From: Ruyi Ji 
Date: Sun, 16 Apr 2017 21:41:44 -0400
Subject: [PATCH 2/2] this patch is one can build.

Signed-off-by: Ruyi Ji 
---
 libavcodec/vorbisenc.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c
index 9f1adf8..09ad446 100644
--- a/libavcodec/vorbisenc.c
+++ b/libavcodec/vorbisenc.c
@@ -98,6 +98,8 @@ typedef struct vorbis_enc_mode {
 int mapping;
 } vorbis_enc_mode;
 
+#define MAX_CHANNELS 2
+
 typedef struct vorbis_enc_context {
 int channels;
 int sample_rate;
@@ -133,7 +135,6 @@ typedef struct vorbis_enc_context {
 	enum WindowSequence window_sequence[MAX_CHANNELS];
 } vorbis_enc_context;
 
-#define MAX_CHANNELS 2
 #define MAX_CODEBOOK_DIM 8
 
 #define MAX_FLOOR_CLASS_DIM  4
@@ -1053,7 +1054,7 @@ static int vorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
 			cur_channel = start_ch + ch;
 			overlap = [cur_channel][0];
 			samples2 = overlap + 1024;
-			la = samples2 + (448 + 64)
+			la = samples2 + (448 + 64);
 			if (!frame)
 la = NULL;
 			wi[ch] = venc->psy.model->window(>psy, samples2, la, cur_channel, venc->window_sequence[0]);
@@ -1193,7 +1194,7 @@ static av_cold int vorbis_encode_close(AVCodecContext *avctx)
 ff_mdct_end(>mdct[0]);
 ff_mdct_end(>mdct[1]);
 
-	ff_psy_end(venc->psy);
+	ff_psy_end(>psy);
 	
 	if (venc->psypp)
 		ff_psy_preprocess_end(venc->psypp);
-- 
1.9.1

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


[FFmpeg-devel] [PATCH 1/2] cmdutils_opencl: Fix read of uninitialized pointer

2017-04-16 Thread Michael Niedermayer
Fixes: CID1396856

Signed-off-by: Michael Niedermayer 
---
 cmdutils_opencl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmdutils_opencl.c b/cmdutils_opencl.c
index 655d1c9546..f141d1e243 100644
--- a/cmdutils_opencl.c
+++ b/cmdutils_opencl.c
@@ -129,7 +129,7 @@ static int64_t run_opencl_bench(AVOpenCLExternalEnv 
*ext_opencl_env)
 cl_int status;
 size_t kernel_len;
 char *inbuf;
-int *mask;
+int *mask = NULL;
 int buf_size = width * height * sizeof(char);
 int mask_size = sizeof(uint32_t) * 128;
 
-- 
2.11.0

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


[FFmpeg-devel] [PATCH 2/2] cmdutils_opencl: Fix read of uinitialized cl_mem

2017-04-16 Thread Michael Niedermayer
Fixes CID1396856, CID1396860, CID1396861

Signed-off-by: Michael Niedermayer 
---
 cmdutils_opencl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmdutils_opencl.c b/cmdutils_opencl.c
index f141d1e243..906aef4836 100644
--- a/cmdutils_opencl.c
+++ b/cmdutils_opencl.c
@@ -133,7 +133,7 @@ static int64_t run_opencl_bench(AVOpenCLExternalEnv 
*ext_opencl_env)
 int buf_size = width * height * sizeof(char);
 int mask_size = sizeof(uint32_t) * 128;
 
-cl_mem cl_mask, cl_inbuf, cl_outbuf;
+cl_mem cl_mask = NULL, cl_inbuf = NULL, cl_outbuf = NULL;
 cl_kernel kernel = NULL;
 cl_program program = NULL;
 size_t local_work_size_2d[2] = {16, 16};
-- 
2.11.0

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


[FFmpeg-devel] [PATCH] libavutil/thread.h: Fixed g++ build error when ASSERT_LEVEL is greater than 1

2017-04-16 Thread Aaron Levinson
From 9e6a9e2b8d58f17c661a3f455e03c95587ec7b18 Mon Sep 17 00:00:00 2001
From: Aaron Levinson 
Date: Sun, 16 Apr 2017 17:13:31 -0700
Subject: [PATCH] libavutil/thread.h:  Fixed g++ build error when
 ASSERT_LEVEL is greater than 1

Purpose: libavutil/thread.h: Fixed g++ build error when ASSERT_LEVEL
is greater than 1.  This is only relevant when thread.h is included by
C++ files.  In this case, the relevant code is only defined if
HAVE_PTHREADS is defined as 1.  Use configure --assert-level=2 to do
so.

Note: Issue discovered as a result of Coverity build failure.  Cause
of build failure pinpointed by Hendrik Leppkes.

Comments:

-- libavutil/thread.h: Altered ASSERT_PTHREAD_NORET definition such
   that it uses av_make_error_string instead of av_err2str().
   av_err2str() uses a "parenthesized type followed by an initializer
   list", which is apparently not valid C++.  This issue started
   occurring because thread.h is now included by the DeckLink C++
   files.  The alteration does the equivalent of what av_err2str()
   does, but instead declares the character buffer as a local
   variable.
---
 libavutil/thread.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavutil/thread.h b/libavutil/thread.h
index 6e57447..f108e20 100644
--- a/libavutil/thread.h
+++ b/libavutil/thread.h
@@ -36,8 +36,11 @@
 #define ASSERT_PTHREAD_NORET(func, ...) do {\
 int ret = func(__VA_ARGS__);\
 if (ret) {  \
+char errbuf[AV_ERROR_MAX_STRING_SIZE] = ""; \
 av_log(NULL, AV_LOG_FATAL, AV_STRINGIFY(func)   \
-   " failed with error: %s\n", av_err2str(AVERROR(ret)));   \
+   " failed with error: %s\n",  \
+   av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE,   \
+AVERROR(ret))); \
 abort();\
 }   \
 } while (0)
-- 
2.10.1.windows.1

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


Re: [FFmpeg-devel] libavutil/thread.h: Fixed g++ build error when ASSERT_LEVEL is greater than 1

2017-04-16 Thread Aaron Levinson

I'll try that again with [PATCH] in the subject line.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] libavutil/thread.h: Fixed g++ build error when ASSERT_LEVEL is greater than 1

2017-04-16 Thread Aaron Levinson
From 9e6a9e2b8d58f17c661a3f455e03c95587ec7b18 Mon Sep 17 00:00:00 2001
From: Aaron Levinson 
Date: Sun, 16 Apr 2017 17:13:31 -0700
Subject: [PATCH] libavutil/thread.h:  Fixed g++ build error when
 ASSERT_LEVEL is greater than 1

Purpose: libavutil/thread.h: Fixed g++ build error when ASSERT_LEVEL
is greater than 1.  This is only relevant when thread.h is included by
C++ files.  In this case, the relevant code is only defined if
HAVE_PTHREADS is defined as 1.  Use configure --assert-level=2 to do
so.

Note: Issue discovered as a result of Coverity build failure.  Cause
of build failure pinpointed by Hendrik Leppkes.

Comments:

-- libavutil/thread.h: Altered ASSERT_PTHREAD_NORET definition such
   that it uses av_make_error_string instead of av_err2str().
   av_err2str() uses a "parenthesized type followed by an initializer
   list", which is apparently not valid C++.  This issue started
   occurring because thread.h is now included by the DeckLink C++
   files.  The alteration does the equivalent of what av_err2str()
   does, but instead declares the character buffer as a local
   variable.
---
 libavutil/thread.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavutil/thread.h b/libavutil/thread.h
index 6e57447..f108e20 100644
--- a/libavutil/thread.h
+++ b/libavutil/thread.h
@@ -36,8 +36,11 @@
 #define ASSERT_PTHREAD_NORET(func, ...) do {\
 int ret = func(__VA_ARGS__);\
 if (ret) {  \
+char errbuf[AV_ERROR_MAX_STRING_SIZE] = ""; \
 av_log(NULL, AV_LOG_FATAL, AV_STRINGIFY(func)   \
-   " failed with error: %s\n", av_err2str(AVERROR(ret)));   \
+   " failed with error: %s\n",  \
+   av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE,   \
+AVERROR(ret))); \
 abort();\
 }   \
 } while (0)
-- 
2.10.1.windows.1

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


Re: [FFmpeg-devel] [PATCH] avdevice/decklink: Removed pthread dependency

2017-04-16 Thread Aaron Levinson

On 4/16/2017 4:25 PM, Aaron Levinson wrote:

On 4/16/2017 3:31 PM, Hendrik Leppkes wrote:

On Mon, Apr 17, 2017 at 12:26 AM, Aaron Levinson
 wrote:

On 4/16/2017 1:33 PM, Timo Rothenpieler wrote:


Thanks, applied.

Regards,
Marton



This seems to have broken the coverity builds:
https://travis-ci.org/FFmpeg/FFmpeg-Coverity/builds/222597943#L1103



It was suggested on IRC by James Almer that "it seems to complain about
ubitux's 'strict' pthread implementation (for assert levels above 0).
Maybe
it needs to be disabled for C++ sources."



The real problem is in av_err2str, which uses a temporary array, which
is either not valid in C++ (likely), or not supported by MSVC for
reasons (although in contrast to C support, its C++ support is
generally pretty good).
But considering how little C++ code we have, its probably best to
somehow avoid using it instead of trying to fix it.

- Hendrik


I don't think this has much to do with MSVC here, because coverity is
doing a gcc/g++ build.  I suspect that it is failing with any gcc/g++
build because of the patch.  I'll work on this now.

Aaron


The build issue occurs with g++ and an assert level greater than 1, 
although it would also occur with MSVC++ if pthreads is enabled.  I will 
submit a separate patch e-mail that fixes the build error.


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


Re: [FFmpeg-devel] [PATCH] avdevice/decklink: Removed pthread dependency

2017-04-16 Thread Aaron Levinson

On 4/16/2017 3:31 PM, Hendrik Leppkes wrote:

On Mon, Apr 17, 2017 at 12:26 AM, Aaron Levinson  wrote:

On 4/16/2017 1:33 PM, Timo Rothenpieler wrote:


Thanks, applied.

Regards,
Marton



This seems to have broken the coverity builds:
https://travis-ci.org/FFmpeg/FFmpeg-Coverity/builds/222597943#L1103



It was suggested on IRC by James Almer that "it seems to complain about
ubitux's 'strict' pthread implementation (for assert levels above 0). Maybe
it needs to be disabled for C++ sources."



The real problem is in av_err2str, which uses a temporary array, which
is either not valid in C++ (likely), or not supported by MSVC for
reasons (although in contrast to C support, its C++ support is
generally pretty good).
But considering how little C++ code we have, its probably best to
somehow avoid using it instead of trying to fix it.

- Hendrik


I don't think this has much to do with MSVC here, because coverity is 
doing a gcc/g++ build.  I suspect that it is failing with any gcc/g++ 
build because of the patch.  I'll work on this now.


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


Re: [FFmpeg-devel] [PATCH] Made minor changes to get the decklink avdevice code to build using Visual C++

2017-04-16 Thread Aaron Levinson
On 4/15/2017 6:13 AM, Aaron Levinson wrote:
> On 4/15/2017 4:19 AM, Marton Balint wrote:
>>
>> On Thu, 13 Apr 2017, Aaron Levinson wrote:
>>
>>> On 4/13/2017 1:23 PM, Hendrik Leppkes wrote:
>> [...]
>>
>>> 
>>>
>>>
>>> From 00fdc9d15414a92a155eb7d1394bac3736dc9405 Mon Sep 17 00:00:00 2001
>>> From: Aaron Levinson 
>>> Date: Thu, 13 Apr 2017 14:22:19 -0700
>>> Subject: [PATCH] Made minor changes to get the decklink avdevice code
>>> to build using Visual C++.
>>>
>>
>> Maybe it just me, but as I mentioned earlier, I don't like too verbose
>> comments in the code, see below:
>>
>>> diff --git a/libavdevice/decklink_common.cpp
>>> b/libavdevice/decklink_common.cpp
>>> index f01fba9..523217c 100644
>>> --- a/libavdevice/decklink_common.cpp
>>> +++ b/libavdevice/decklink_common.cpp
>>> @@ -19,6 +19,15 @@
>>>  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
>>> 02110-1301 USA
>>>  */
>>>
>>> +// Moved inclusion of internal.h here in order to get it to build
>>> successfully
>>> +// when using Visual C++ to build--otherwise, compilation errors result
>>> +// due to winsock.h (which is included indirectly by DeckLinkAPI.h and
>>> +// DeckLinkAPI_i.c) conflicting with winsock2.h, which is included by
>>> +// internal.h.  If winsock2.h is included first, then the conflict is
>>> resolved.
>>
>> This can be as short as this:
>>
>> /* Include internal.h first to avoid conflict of winsock.h (used by
>>  * DeckLink) and winsock2.h (used by libavformat) in MSVC++ builds */
>>
>> (for multiline comments I think /* */ is preferred)
>>
>> Although since you do this in multiple headers, maybe it is enough if
>> you specify the reason in the commit message, and delete the comment
>> from here entirely.
> 
> I think it is a good idea to have a comment in the code, as then it is
> front in center if someone in the future wonders why internal.h precedes
> the other includes and decides to move it because it will look cleaner,
> thereby breaking the MSVC build.  Although, in that case, maybe it would
> be preferable to have the same comment in each of the three places, as
> opposed to just one.
> 
> A shorter comment is fine, and your example comment explains things well
> enough, although I tend to think that more information is better than
> less for comments in code.  From my perspective, "used by DeckLink" is a
> bit vague, since technically, DeckLinkAPI.h and DeckLinkAPI_i.c would be
> generated by the user if the actual Blackmagic DeckLink SDK were used
> (these files are not actually supplied with the Blackmagic DeckLink
> SDK), which is how I got DeckLinkAPI.h and DeckLinkAPI_c.h when I built
> ffmpeg.  Well, DeckLinkAPI.h is included in the Linux header files in
> the Blackmagic DeckLink SDK, but the _i.c file is not, and on Windows,
> neither file is provided.
> 
> Regarding multi-line comments being wrapped in /* */ vs using // on each
> line, it doesn't so much matter in this case, but I personally find //
> more versatile because then it makes it easier to comment out blocks of
> code.  But, if that's the standard for the ffmpeg code base, then I'll
> make that change.
> 
>>> @@ -262,8 +265,18 @@ static int64_t
>>> get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame,
>>> res =
>>> videoFrame->GetHardwareReferenceTimestamp(time_base.den, _pts,
>>> _duration);
>>> break;
>>> case PTS_SRC_WALLCLOCK:
>>> -pts = av_rescale_q(wallclock, AV_TIME_BASE_Q, time_base);
>>> +{
>>> +// doing the following rather than using AV_TIME_BASE_Q
>>> because
>>> +// AV_TIME_BASE_Q doesn't work when building with Visual
>>> C++
>>> +// for C++ files (works for C files).  When building C++
>>> files,
>>> +// it results in compiler error C4576.  At least, this is
>>> the case
>>> +// with Visual C++ 2015.
>>
>> And this is:
>>
>> // MSVC does not support compound literals like AV_TIME_BASE_Q in C++
>> code
>>
>>> +AVRational timebase;
>>> +timebase.num = 1;
>>> +timebase.den = AV_TIME_BASE;
>>> +pts = av_rescale_q(wallclock, timebase, time_base);
>>> break;
>>> +}
>>
>> This whole block needs to be indented 1 column more I think.
> 
> I'll double-check later today to make sure that it is indented properly,
> adjust the comment, and submit a new patch then.
> 
>> Regards,
>> Marton
> 
> Thanks,
> Aaron

A new version of the patch (generated against the latest code in git) can be 
found below.  Basically, I just improved the comments.  There was nothing wrong 
with the spacing--I think it just looks off because the "break;" line is left 
alone.

Thanks,
Aaron Levinson

--

From f62e33366bd38e3eb15c37d6363d1862b34f5b9e Mon Sep 17 00:00:00 2001
From: Aaron Levinson 

Re: [FFmpeg-devel] [PATCH] avdevice/decklink: Removed pthread dependency

2017-04-16 Thread Hendrik Leppkes
On Mon, Apr 17, 2017 at 12:26 AM, Aaron Levinson  wrote:
> On 4/16/2017 1:33 PM, Timo Rothenpieler wrote:
>>>
>>> Thanks, applied.
>>>
>>> Regards,
>>> Marton
>>
>>
>> This seems to have broken the coverity builds:
>> https://travis-ci.org/FFmpeg/FFmpeg-Coverity/builds/222597943#L1103
>
>
> It was suggested on IRC by James Almer that "it seems to complain about
> ubitux's 'strict' pthread implementation (for assert levels above 0). Maybe
> it needs to be disabled for C++ sources."
>

The real problem is in av_err2str, which uses a temporary array, which
is either not valid in C++ (likely), or not supported by MSVC for
reasons (although in contrast to C support, its C++ support is
generally pretty good).
But considering how little C++ code we have, its probably best to
somehow avoid using it instead of trying to fix it.

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


Re: [FFmpeg-devel] [PATCH] avdevice/decklink: Removed pthread dependency

2017-04-16 Thread Aaron Levinson

On 4/16/2017 1:33 PM, Timo Rothenpieler wrote:

Thanks, applied.

Regards,
Marton


This seems to have broken the coverity builds:
https://travis-ci.org/FFmpeg/FFmpeg-Coverity/builds/222597943#L1103


It was suggested on IRC by James Almer that "it seems to complain about 
ubitux's 'strict' pthread implementation (for assert levels above 0). 
Maybe it needs to be disabled for C++ sources."


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


Re: [FFmpeg-devel] [PATCH] avdevice/decklink: Removed pthread dependency

2017-04-16 Thread Timo Rothenpieler

Thanks, applied.

Regards,
Marton


This seems to have broken the coverity builds:
https://travis-ci.org/FFmpeg/FFmpeg-Coverity/builds/222597943#L1103
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avdevice/decklink: Removed pthread dependency

2017-04-16 Thread Aaron Levinson

On 4/16/2017 12:15 PM, wm4 wrote:

On Sun, 16 Apr 2017 15:23:15 -0300
James Almer  wrote:


On 4/16/2017 2:17 PM, Aaron Levinson wrote:

On 4/15/2017 9:32 PM, James Almer wrote:

On 4/15/2017 7:41 AM, Marton Balint wrote:


On Thu, 13 Apr 2017, Aaron Levinson wrote:


On 4/13/2017 3:40 PM, Marton Balint wrote:


On Thu, 13 Apr 2017, Aaron Levinson wrote:


On 4/13/2017 2:12 AM, Hendrik Leppkes wrote:

On Thu, Apr 13, 2017 at 10:36 AM, Aaron Levinson 

wrote:

Give it some time for the other changes to be reviewed by the people
that actually know decklink itself, you can include that in any new
versions of the patch then, no need to send one for that right now.

- Hendrik


Actually, the coding changes made to the decklink source files in this
patch have pretty much nothing to do with decklink itself, and anyone
with familiarity with semaphores and pthread could review those changes.
 In fact, all I really did was use already existing approaches for
replacing a semaphore with the combination of a condition variable,
mutex, and counter, and there are plenty of examples of how to do this
on the Web.



Yeah, the changes look fine, please send an updated patch, I will apply
it after some final testing.

Thanks,
Marton


Here's a new version of the patch with the pthreads dependency replaced with 
threads.



Thanks, applied.


Wouldn't it be simpler to add posix semaphore emulation to w32threads
and os2threads?
The former should be trivial, and probably even without the need to
use mutexes or conditional variables given there's CreateSemaphore
and ReleaseSemaphore for this purpose. Not sure about the latter.


I addressed this in one of the commit log messages:


Yes. I made the mistake of reading the commit message after
reading the code and writing a reply, sorry about that :P



-

-- libavdevice/decklink_enc.cpp:
a) Eliminated include of pthread.h and semaphore.h.
b) Replaced use of semaphore with the equivalent using a combination
   of a mutex, condition variable, and a counter
   (frames_buffer_available_spots).  In theory, libavutil/thread.h and
   the associated code could have been modified instead to add
   cross-platform implementations of the sem_ functions, but an
   inspection of the ffmpeg source base indicates that there are only
   two cases in which semaphores are used (including this one that was
   replaced), so it was deemed to not be worth the effort.

--

I considered this approach, but the thought of having to do this in 
os2threads.h pretty much dissuaded me.  I had thought that OS/2 was pretty much 
dead, but it appears that I was wrong.  There is a yearly conference, and a new 
version of OS/2 will soon be released.

However, the two places in ffmpeg that the sem_ functions were/are used are 
likely not relevant to OS/2 anyway:

-- DeckLink:  Blackmagic only provides drivers/kernel modules for Windows, 
Linux, and OS/X
-- avdevice/jack.c:  This pertains to www.jackaudio.org, and at least based on 
what I can see at https://github.com/jackaudio/jack2, there doesn't appear to 
be any build configuration for OS/2.  jack support also apparently needs 
sem_timedwait().

As such, someone could likely get away with just implementing the sem_ 
functions in w32threads.h.

Aaron


We have a developer that keeps os2threads.h up to date, so he
will probably add sem_t compat wrappers to it, if not now when
a module that works on OS/2 needs it.

IMO, if you can and want then add win32 wrappers to w32threads
right now. The pthread_once wrapper was added for one use case
then as soon as it became available it started to see more use
elsewhere in the tree. The same might happen to Semaphores.


Beware that semaphores don't work on OSX.


I believe that semaphores on OS X are handled via dispatch semaphore. 
See instances of "dispatch" in configure and compat/dispatch_semaphore.


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


Re: [FFmpeg-devel] [PATCH] this is the gsos qualification task which use psychoacoustic system to detect transients in vorbis encoder.

2017-04-16 Thread Michael Niedermayer
On Sun, Apr 16, 2017 at 09:19:33AM -0400, Ruyi Ji wrote:
> Signed-off-by: Ruyi Ji 
> ---
>  libavcodec/psymodel.c|   1 +
>  libavcodec/vorbis_enc_data.h | 111 
> +++
>  libavcodec/vorbisenc.c   |  60 +++
>  3 files changed, 172 insertions(+)

This seems to fail to build here

CC  libavcodec/vorbisenc.o
libavcodec/vorbisenc.c:133:45: error: ‘MAX_CHANNELS’ undeclared here (not in a 
function)
libavcodec/vorbisenc.c: In function ‘vorbis_encode_frame’:
libavcodec/vorbisenc.c:1057:25: error: expected ‘;’ before ‘if’
libavcodec/vorbisenc.c: In function ‘vorbis_encode_close’:
libavcodec/vorbisenc.c:1196:9: error: incompatible type for argument 1 of 
‘ff_psy_end’
libavcodec/psymodel.h:176:6: note: expected ‘struct FFPsyContext *’ but 
argument is of type ‘FFPsyContext’
make: *** [libavcodec/vorbisenc.o] Error 1
make: Target `all' not remade because of errors.


> 
> diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c
> index 2b5f111..2e11c48 100644
> --- a/libavcodec/psymodel.c
> +++ b/libavcodec/psymodel.c
> @@ -62,6 +62,7 @@ av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext 
> *avctx, int num_lens,
>  
>  switch (ctx->avctx->codec_id) {
>  case AV_CODEC_ID_AAC:
> + case AV_CODEC_ID_VORBIS:
>  ctx->model = _aac_psy_model;

tabs are forbidden in ffmpeg-git except where needed for syntax

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

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA


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


Re: [FFmpeg-devel] [PATCH] avdevice/decklink: Removed pthread dependency

2017-04-16 Thread wm4
On Sun, 16 Apr 2017 15:23:15 -0300
James Almer  wrote:

> On 4/16/2017 2:17 PM, Aaron Levinson wrote:
> > On 4/15/2017 9:32 PM, James Almer wrote:  
> >> On 4/15/2017 7:41 AM, Marton Balint wrote:  
> >>>
> >>> On Thu, 13 Apr 2017, Aaron Levinson wrote:
> >>>  
>  On 4/13/2017 3:40 PM, Marton Balint wrote:  
> >
> > On Thu, 13 Apr 2017, Aaron Levinson wrote:
> >  
> >> On 4/13/2017 2:12 AM, Hendrik Leppkes wrote:  
> >>> On Thu, Apr 13, 2017 at 10:36 AM, Aaron Levinson 
> >>>   
> >> wrote:  
> >>> Give it some time for the other changes to be reviewed by the people
> >>> that actually know decklink itself, you can include that in any new
> >>> versions of the patch then, no need to send one for that right now.
> >>>
> >>> - Hendrik  
> >>
> >> Actually, the coding changes made to the decklink source files in this
> >> patch have pretty much nothing to do with decklink itself, and anyone
> >> with familiarity with semaphores and pthread could review those 
> >> changes.
> >>  In fact, all I really did was use already existing approaches for
> >> replacing a semaphore with the combination of a condition variable,
> >> mutex, and counter, and there are plenty of examples of how to do this
> >> on the Web.
> >>  
> >
> > Yeah, the changes look fine, please send an updated patch, I will apply
> > it after some final testing.
> >
> > Thanks,
> > Marton  
> 
>  Here's a new version of the patch with the pthreads dependency replaced 
>  with threads.
>   
> >>>
> >>> Thanks, applied.  
> >>
> >> Wouldn't it be simpler to add posix semaphore emulation to w32threads
> >> and os2threads?
> >> The former should be trivial, and probably even without the need to
> >> use mutexes or conditional variables given there's CreateSemaphore
> >> and ReleaseSemaphore for this purpose. Not sure about the latter.  
> > 
> > I addressed this in one of the commit log messages:  
> 
> Yes. I made the mistake of reading the commit message after
> reading the code and writing a reply, sorry about that :P
> 
> > 
> > -
> > 
> > -- libavdevice/decklink_enc.cpp:
> > a) Eliminated include of pthread.h and semaphore.h.
> > b) Replaced use of semaphore with the equivalent using a combination
> >of a mutex, condition variable, and a counter
> >(frames_buffer_available_spots).  In theory, libavutil/thread.h and
> >the associated code could have been modified instead to add
> >cross-platform implementations of the sem_ functions, but an
> >inspection of the ffmpeg source base indicates that there are only
> >two cases in which semaphores are used (including this one that was
> >replaced), so it was deemed to not be worth the effort.
> > 
> > --
> > 
> > I considered this approach, but the thought of having to do this in 
> > os2threads.h pretty much dissuaded me.  I had thought that OS/2 was pretty 
> > much dead, but it appears that I was wrong.  There is a yearly conference, 
> > and a new version of OS/2 will soon be released.
> > 
> > However, the two places in ffmpeg that the sem_ functions were/are used are 
> > likely not relevant to OS/2 anyway:
> > 
> > -- DeckLink:  Blackmagic only provides drivers/kernel modules for Windows, 
> > Linux, and OS/X
> > -- avdevice/jack.c:  This pertains to www.jackaudio.org, and at least based 
> > on what I can see at https://github.com/jackaudio/jack2, there doesn't 
> > appear to be any build configuration for OS/2.  jack support also 
> > apparently needs sem_timedwait().
> > 
> > As such, someone could likely get away with just implementing the sem_ 
> > functions in w32threads.h.
> > 
> > Aaron  
> 
> We have a developer that keeps os2threads.h up to date, so he
> will probably add sem_t compat wrappers to it, if not now when
> a module that works on OS/2 needs it.
> 
> IMO, if you can and want then add win32 wrappers to w32threads
> right now. The pthread_once wrapper was added for one use case
> then as soon as it became available it started to see more use
> elsewhere in the tree. The same might happen to Semaphores.

Beware that semaphores don't work on OSX.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avdevice/decklink: Removed pthread dependency

2017-04-16 Thread James Almer
On 4/16/2017 2:17 PM, Aaron Levinson wrote:
> On 4/15/2017 9:32 PM, James Almer wrote:
>> On 4/15/2017 7:41 AM, Marton Balint wrote:
>>>
>>> On Thu, 13 Apr 2017, Aaron Levinson wrote:
>>>
 On 4/13/2017 3:40 PM, Marton Balint wrote:
>
> On Thu, 13 Apr 2017, Aaron Levinson wrote:
>
>> On 4/13/2017 2:12 AM, Hendrik Leppkes wrote:
>>> On Thu, Apr 13, 2017 at 10:36 AM, Aaron Levinson 
>> wrote:
>>> Give it some time for the other changes to be reviewed by the people
>>> that actually know decklink itself, you can include that in any new
>>> versions of the patch then, no need to send one for that right now.
>>>
>>> - Hendrik
>>
>> Actually, the coding changes made to the decklink source files in this
>> patch have pretty much nothing to do with decklink itself, and anyone
>> with familiarity with semaphores and pthread could review those changes.
>>  In fact, all I really did was use already existing approaches for
>> replacing a semaphore with the combination of a condition variable,
>> mutex, and counter, and there are plenty of examples of how to do this
>> on the Web.
>>
>
> Yeah, the changes look fine, please send an updated patch, I will apply
> it after some final testing.
>
> Thanks,
> Marton

 Here's a new version of the patch with the pthreads dependency replaced 
 with threads.

>>>
>>> Thanks, applied.
>>
>> Wouldn't it be simpler to add posix semaphore emulation to w32threads
>> and os2threads?
>> The former should be trivial, and probably even without the need to
>> use mutexes or conditional variables given there's CreateSemaphore
>> and ReleaseSemaphore for this purpose. Not sure about the latter.
> 
> I addressed this in one of the commit log messages:

Yes. I made the mistake of reading the commit message after
reading the code and writing a reply, sorry about that :P

> 
> -
> 
> -- libavdevice/decklink_enc.cpp:
> a) Eliminated include of pthread.h and semaphore.h.
> b) Replaced use of semaphore with the equivalent using a combination
>of a mutex, condition variable, and a counter
>(frames_buffer_available_spots).  In theory, libavutil/thread.h and
>the associated code could have been modified instead to add
>cross-platform implementations of the sem_ functions, but an
>inspection of the ffmpeg source base indicates that there are only
>two cases in which semaphores are used (including this one that was
>replaced), so it was deemed to not be worth the effort.
> 
> --
> 
> I considered this approach, but the thought of having to do this in 
> os2threads.h pretty much dissuaded me.  I had thought that OS/2 was pretty 
> much dead, but it appears that I was wrong.  There is a yearly conference, 
> and a new version of OS/2 will soon be released.
> 
> However, the two places in ffmpeg that the sem_ functions were/are used are 
> likely not relevant to OS/2 anyway:
> 
> -- DeckLink:  Blackmagic only provides drivers/kernel modules for Windows, 
> Linux, and OS/X
> -- avdevice/jack.c:  This pertains to www.jackaudio.org, and at least based 
> on what I can see at https://github.com/jackaudio/jack2, there doesn't appear 
> to be any build configuration for OS/2.  jack support also apparently needs 
> sem_timedwait().
> 
> As such, someone could likely get away with just implementing the sem_ 
> functions in w32threads.h.
> 
> Aaron

We have a developer that keeps os2threads.h up to date, so he
will probably add sem_t compat wrappers to it, if not now when
a module that works on OS/2 needs it.

IMO, if you can and want then add win32 wrappers to w32threads
right now. The pthread_once wrapper was added for one use case
then as soon as it became available it started to see more use
elsewhere in the tree. The same might happen to Semaphores.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] wmv2: NEON intrinsics wmv2dsp

2017-04-16 Thread zeas


0001-wmv2-NEON-intrinsics-wmv2dsp.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] Debug builds and if (ARCH_...) linking issues

2017-04-16 Thread Aaron Levinson

On 4/16/2017 10:08 AM, Ronald S. Bultje wrote:

Hi,

On Sun, Apr 16, 2017 at 12:59 PM, Aaron Levinson 
wrote:


I like using this approach, but I think such files should only be added to
the build if --disable-optimizations is passed into configure.



Or you could detect in configure if the compiler supports DCE?

Ronald


All the compilers that are supported by ffmpeg (including MSVC) 
_already_ support DCE.  They must in order to be able to do any 
successful optimized builds.  So, I think this is really only relevant 
when optimizations are deliberately disabled, and I think it is 
reasonable to expect that DCE will be disabled if optimizations are 
disabled.


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


Re: [FFmpeg-devel] Debug builds and if (ARCH_...) linking issues

2017-04-16 Thread Ronald S. Bultje
Hi,

On Sun, Apr 16, 2017 at 12:59 PM, Aaron Levinson 
wrote:

> I like using this approach, but I think such files should only be added to
> the build if --disable-optimizations is passed into configure.
>

Or you could detect in configure if the compiler supports DCE?

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


Re: [FFmpeg-devel] Debug builds and if (ARCH_...) linking issues

2017-04-16 Thread Aaron Levinson

On 4/16/2017 8:57 AM, Matt Oliver wrote:

On 14 April 2017 at 08:05, Hendrik Leppkes  wrote:


On Fri, Apr 14, 2017 at 12:00 AM, Ronald S. Bultje 
wrote:

Hi Aaron,

On Thu, Apr 13, 2017 at 4:47 PM, Aaron Levinson 
wrote:


#if ARCH_AARCH64
if (ARCH_AARCH64)
return ff_get_cpu_flags_aarch64();
#endif



If you add #if, at least replace the if with it. #if + if is redundant.



Such a script could be reviewed and checked into the source base, then
applied to the source base, and possibly reused in the future as

necessary.



Why not use the script as a preprocessor during compilation? We did that
for pre-2013 MSVC compilation and that worked """fine""".

Or why not ask Microsoft to add a CLI option to cl.exe for enabling DCE

but

otherwise disabling optimizations? All other compilers seem capable of
this, so it's odd to see that big Microsoft is incompetent whereas a

bunch

of opensource hippies could do the same 10+ yrs ago.



Its not a MSVC-exclusive problem. Many compilers don't perform DCE in
full debug builds, which are as such not possible with ffmpeg, making
debuging sometimes a bit annoying when a bunch of variables are
optimized out and stuff gets inlined.



Unfortunately writing a script is a rather complex task as there are many
DCE blocks that are actually generated by macro expansion and various
pre-processor trickery (swresample is full of this sort of stuff). Combine
that with DCE blocks being nested within each other and it becomes a rather
complex task to find them all. Much more complex than what a simple regex
script can handle.

If people object to changing the current code base then the only solution
would be a program/script that can generate some empty definitions for all
the functions/variables that are used in DCE blocks so as to avoid the
errors about them not existing. These empty definitions would have to be
maintained in a set of external files or generated at compile time.

There are actually a considerable number of missing funcs/vars used in DCE
blocks. As an example i have attached a list of empty funcs/vars that I
have been able to programmatically detect (there are a lot! and i may have
missed some).


I like using this approach, but I think such files should only be added 
to the build if --disable-optimizations is passed into configure.  I 
think that's the sort of approach that most people could get behind 
since it won't affect the regular build.  I think it is okay if these .c 
files aren't perfect from the start, and while it would be nice if 
people that add new functions (or change existing function definitions) 
to arch (or similar) were to make appropriate changes to these files, if 
they don't, that's okay too.  There are likely a limited number of 
people that would choose to employ --disable-optimizations, and it is 
not a big deal to add a function or two to these files as they crop up 
and submit a patch for the changes.


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


[FFmpeg-devel] [PATCH 2/2] avcodec: add Screen Recorder Gold Codec decoder

2017-04-16 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 configure   |  1 +
 libavcodec/Makefile |  1 +
 libavcodec/allcodecs.c  |  1 +
 libavcodec/avcodec.h|  1 +
 libavcodec/codec_desc.c |  7 +++
 libavcodec/mscc.c   | 24 +---
 libavformat/riff.c  |  1 +
 7 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 6d4eb2b..6f0d3ba 100755
--- a/configure
+++ b/configure
@@ -2531,6 +2531,7 @@ sonic_decoder_select="golomb rangecoder"
 sonic_encoder_select="golomb rangecoder"
 sonic_ls_encoder_select="golomb rangecoder"
 sp5x_decoder_select="mjpeg_decoder"
+srgc_decoder_select="zlib"
 svq1_decoder_select="hpeldsp"
 svq1_encoder_select="aandcttables hpeldsp me_cmp mpegvideoenc"
 svq3_decoder_select="golomb h264dsp h264parse h264pred hpeldsp tpeldsp 
videodsp"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index cf5317d..86bc8fd 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -541,6 +541,7 @@ OBJS-$(CONFIG_SONIC_ENCODER)   += sonic.o
 OBJS-$(CONFIG_SONIC_LS_ENCODER)+= sonic.o
 OBJS-$(CONFIG_SPEEDHQ_DECODER) += speedhq.o simple_idct.o
 OBJS-$(CONFIG_SP5X_DECODER)+= sp5xdec.o
+OBJS-$(CONFIG_SRGC_DECODER)+= mscc.o
 OBJS-$(CONFIG_SRT_DECODER) += srtdec.o ass.o htmlsubtitles.o
 OBJS-$(CONFIG_SRT_ENCODER) += srtenc.o ass_split.o
 OBJS-$(CONFIG_STL_DECODER) += textdec.o ass.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 5a708b3..7fcc26f 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -317,6 +317,7 @@ static void register_all(void)
 REGISTER_ENCDEC (SNOW,  snow);
 REGISTER_DECODER(SP5X,  sp5x);
 REGISTER_DECODER(SPEEDHQ,   speedhq);
+REGISTER_DECODER(SRGC,  srgc);
 REGISTER_ENCDEC (SUNRAST,   sunrast);
 REGISTER_ENCDEC (SVQ1,  svq1);
 REGISTER_DECODER(SVQ3,  svq3);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index da9d9dc..fc928a1 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -444,6 +444,7 @@ enum AVCodecID {
 AV_CODEC_ID_AV1,
 AV_CODEC_ID_BITPACKED,
 AV_CODEC_ID_MSCC,
+AV_CODEC_ID_SRGC,
 
 /* 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 e342db7..2d28f84 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1395,6 +1395,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("Mandsoft Screen Capture Codec"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_SRGC,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "srgc",
+.long_name = NULL_IF_CONFIG_SMALL("Screen Recorder Gold Codec"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
 
 /* image codecs */
 {
diff --git a/libavcodec/mscc.c b/libavcodec/mscc.c
index c42889a..6e4dbb0 100644
--- a/libavcodec/mscc.c
+++ b/libavcodec/mscc.c
@@ -121,6 +121,8 @@ static int decode_frame(AVCodecContext *avctx,
 {
 MSCCContext *s = avctx->priv_data;
 AVFrame *frame = data;
+uint8_t *buf = avpkt->data;
+int buf_size = avpkt->size;
 GetByteContext gb;
 PutByteContext pb;
 int ret, j;
@@ -130,15 +132,19 @@ static int decode_frame(AVCodecContext *avctx,
 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
 return ret;
 
-avpkt->data[2] ^= avpkt->data[0];
+if (avctx->codec_id == AV_CODEC_ID_MSCC) {
+avpkt->data[2] ^= avpkt->data[0];
+buf += 2;
+buf_size -= 2;
+}
 
 ret = inflateReset(>zstream);
 if (ret != Z_OK) {
 av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", ret);
 return AVERROR_UNKNOWN;
 }
-s->zstream.next_in   = avpkt->data + 2;
-s->zstream.avail_in  = avpkt->size - 2;
+s->zstream.next_in   = buf;
+s->zstream.avail_in  = buf_size;
 s->zstream.next_out  = s->decomp_buf;
 s->zstream.avail_out = s->decomp_size;
 ret = inflate(>zstream, Z_FINISH);
@@ -229,3 +235,15 @@ AVCodec ff_mscc_decoder = {
 .decode   = decode_frame,
 .capabilities = AV_CODEC_CAP_DR1,
 };
+
+AVCodec ff_srgc_decoder = {
+.name = "srgc",
+.long_name= NULL_IF_CONFIG_SMALL("Screen Recorder Gold Codec"),
+.type = AVMEDIA_TYPE_VIDEO,
+.id   = AV_CODEC_ID_SRGC,
+.priv_data_size   = sizeof(MSCCContext),
+.init = decode_init,
+.close= decode_close,
+.decode   = decode_frame,
+.capabilities = AV_CODEC_CAP_DR1,
+};
diff --git a/libavformat/riff.c b/libavformat/riff.c
index 294d11b..ac902fd 100644
--- a/libavformat/riff.c
+++ 

[FFmpeg-devel] [PATCH 1/2] avcodec: add Mandsoft Screen Capture Codec decoder

2017-04-16 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 configure   |   1 +
 doc/general.texi|   1 +
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/avcodec.h|   1 +
 libavcodec/codec_desc.c |   7 ++
 libavcodec/mscc.c   | 231 
 libavformat/riff.c  |   1 +
 8 files changed, 244 insertions(+)
 create mode 100644 libavcodec/mscc.c

diff --git a/configure b/configure
index e6fe05a..6d4eb2b 100755
--- a/configure
+++ b/configure
@@ -2488,6 +2488,7 @@ mpeg2video_encoder_select="aandcttables mpegvideoenc 
h263dsp"
 mpeg4_decoder_select="h263_decoder mpeg4video_parser"
 mpeg4_encoder_select="h263_encoder"
 msa1_decoder_select="mss34dsp"
+mscc_decoder_select="zlib"
 msmpeg4v1_decoder_select="h263_decoder"
 msmpeg4v2_decoder_select="h263_decoder"
 msmpeg4v2_encoder_select="h263_encoder"
diff --git a/doc/general.texi b/doc/general.texi
index a02437b..72f02b1 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -789,6 +789,7 @@ following image formats are supported:
 @tab Used in LucasArts games / SMUSH animations.
 @item lossless MJPEG @tab  X  @tab  X
 @item MagicYUV Video @tab @tab  X
+@item Mandsoft Screen Capture Codec  @tab @tab  X
 @item Microsoft ATC Screen   @tab @tab  X
 @tab Also known as Microsoft Screen 3.
 @item Microsoft Expression Encoder Screen  @tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c745454..cf5317d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -429,6 +429,7 @@ OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec.o
 OBJS-$(CONFIG_MPEG4_OMX_ENCODER)   += omx.o
 OBJS-$(CONFIG_MPL2_DECODER)+= mpl2dec.o ass.o
 OBJS-$(CONFIG_MSA1_DECODER)+= mss3.o
+OBJS-$(CONFIG_MSCC_DECODER)+= mscc.o
 OBJS-$(CONFIG_MSMPEG4V1_DECODER)   += msmpeg4dec.o msmpeg4.o msmpeg4data.o
 OBJS-$(CONFIG_MSMPEG4V2_DECODER)   += msmpeg4dec.o msmpeg4.o msmpeg4data.o
 OBJS-$(CONFIG_MSMPEG4V2_ENCODER)   += msmpeg4enc.o msmpeg4.o msmpeg4data.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 379bd6e..5a708b3 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -258,6 +258,7 @@ static void register_all(void)
 REGISTER_DECODER(MPEG2_CRYSTALHD,   mpeg2_crystalhd);
 REGISTER_DECODER(MPEG2_QSV, mpeg2_qsv);
 REGISTER_DECODER(MSA1,  msa1);
+REGISTER_DECODER(MSCC,  mscc);
 REGISTER_DECODER(MSMPEG4V1, msmpeg4v1);
 REGISTER_ENCDEC (MSMPEG4V2, msmpeg4v2);
 REGISTER_ENCDEC (MSMPEG4V3, msmpeg4v3);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index ee13371..da9d9dc 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -443,6 +443,7 @@ enum AVCodecID {
 AV_CODEC_ID_XPM,
 AV_CODEC_ID_AV1,
 AV_CODEC_ID_BITPACKED,
+AV_CODEC_ID_MSCC,
 
 /* 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 7b2a1b9..e342db7 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1388,6 +1388,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("Bitpacked"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_MSCC,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "mscc",
+.long_name = NULL_IF_CONFIG_SMALL("Mandsoft Screen Capture Codec"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
 
 /* image codecs */
 {
diff --git a/libavcodec/mscc.c b/libavcodec/mscc.c
new file mode 100644
index 000..c42889a
--- /dev/null
+++ b/libavcodec/mscc.c
@@ -0,0 +1,231 @@
+/*
+ * Mandsoft Screen Capture Codec decoder
+ *
+ * Copyright (c) 2017 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+#include 
+#include 
+
+#include "avcodec.h"
+#include "bytestream.h"
+#include "internal.h"
+
+#include 
+
+typedef struct MSCCContext {
+unsigned  bpp;
+unsigned int  decomp_size;
+uint8_t

[FFmpeg-devel] [PATCH] doc/fftools-common-opts: Fixed a typo in the common arguments list

2017-04-16 Thread Mickael Maison
- Fixed a typo for the -sources argument

Signed-off-by: Mickael Maison 
---
 doc/fftools-common-opts.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi
index 7269aeece9..2eff33a36f 100644
--- a/doc/fftools-common-opts.texi
+++ b/doc/fftools-common-opts.texi
@@ -153,7 +153,7 @@ Show channel names and standard channel layouts.
 Show recognized color names.
 
 @item -sources @var{device}[,@var{opt1}=@var{val1}[,@var{opt2}=@var{val2}]...]
-Show autodetected sources of the intput device.
+Show autodetected sources of the input device.
 Some devices may provide system-dependent source names that cannot be 
autodetected.
 The returned list cannot be assumed to be always complete.
 @example
-- 
2.11.0

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


[FFmpeg-devel] [PATCH] this is the gsos qualification task which use psychoacoustic system to detect transients in vorbis encoder.

2017-04-16 Thread Ruyi Ji
Signed-off-by: Ruyi Ji 
---
 libavcodec/psymodel.c|   1 +
 libavcodec/vorbis_enc_data.h | 111 +++
 libavcodec/vorbisenc.c   |  60 +++
 3 files changed, 172 insertions(+)

diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c
index 2b5f111..2e11c48 100644
--- a/libavcodec/psymodel.c
+++ b/libavcodec/psymodel.c
@@ -62,6 +62,7 @@ av_cold int ff_psy_init(FFPsyContext *ctx, AVCodecContext 
*avctx, int num_lens,
 
 switch (ctx->avctx->codec_id) {
 case AV_CODEC_ID_AAC:
+   case AV_CODEC_ID_VORBIS:
 ctx->model = _aac_psy_model;
 break;
 }
diff --git a/libavcodec/vorbis_enc_data.h b/libavcodec/vorbis_enc_data.h
index a51aaec..5102d30 100644
--- a/libavcodec/vorbis_enc_data.h
+++ b/libavcodec/vorbis_enc_data.h
@@ -501,4 +501,115 @@ static const struct {
 { 3, 2, 3, { -1, 12, 13, 14 } },
 };
 
+
+static const uint8_t swb_size_128_96[] = {
+4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 36
+};
+
+static const uint8_t swb_size_128_64[] = {
+4, 4, 4, 4, 4, 4, 8, 8, 8, 16, 28, 36
+};
+
+static const uint8_t swb_size_128_48[] = {
+4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 12, 16, 16, 16
+};
+
+static const uint8_t swb_size_128_24[] = {
+4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 12, 12, 16, 16, 20
+};
+
+static const uint8_t swb_size_128_16[] = {
+4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 12, 12, 16, 20, 20
+};
+
+static const uint8_t swb_size_128_8[] = {
+4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 12, 16, 20, 20
+};
+
+static const uint8_t swb_size_1024_96[] = {
+4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8,
+12, 12, 12, 12, 12, 16, 16, 24, 28, 36, 44,
+64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64
+};
+
+static const uint8_t swb_size_1024_64[] = {
+4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8,
+12, 12, 12, 16, 16, 16, 20, 24, 24, 28, 36,
+40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40
+};
+
+static const uint8_t swb_size_1024_48[] = {
+4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8,
+12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28,
+32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+96
+};
+
+static const uint8_t swb_size_1024_32[] = {
+4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8,
+12, 12, 12, 12, 16, 16, 20, 20, 24, 24, 28, 28,
+32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 
32, 32, 32, 32
+};
+
+static const uint8_t swb_size_1024_24[] = {
+4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+12, 12, 12, 12, 16, 16, 16, 20, 20, 24, 24, 28, 28,
+32, 36, 36, 40, 44, 48, 52, 52, 64, 64, 64, 64, 64
+};
+
+static const uint8_t swb_size_1024_16[] = {
+8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+12, 12, 12, 12, 12, 12, 12, 12, 12, 16, 16, 16, 16, 20, 20, 20, 24, 24, 
28, 28,
+32, 36, 40, 40, 44, 48, 52, 56, 60, 64, 64, 64
+};
+
+static const uint8_t swb_size_1024_8[] = {
+12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+16, 16, 16, 16, 16, 16, 16, 20, 20, 20, 20, 24, 24, 24, 28, 28,
+32, 36, 36, 40, 44, 48, 52, 56, 60, 64, 80
+};
+
+const uint8_t *ff_vorbis_swb_size_128[] = {
+swb_size_128_96, swb_size_128_96, swb_size_128_64,
+swb_size_128_48, swb_size_128_48, swb_size_128_48,
+swb_size_128_24, swb_size_128_24, swb_size_128_16,
+swb_size_128_16, swb_size_128_16, swb_size_128_8,
+swb_size_128_8
+};
+
+const uint8_t *ff_vorbis_swb_size_1024[] = {
+swb_size_1024_96, swb_size_1024_96, swb_size_1024_64,
+swb_size_1024_48, swb_size_1024_48, swb_size_1024_32,
+swb_size_1024_24, swb_size_1024_24, swb_size_1024_16,
+swb_size_1024_16, swb_size_1024_16, swb_size_1024_8,
+swb_size_1024_8
+};
+
+const int ff_vorbis_swb_size_128_len  = FF_ARRAY_ELEMS(ff_vorbis_swb_size_128);
+const int ff_vorbis_swb_size_1024_len = 
FF_ARRAY_ELEMS(ff_vorbis_swb_size_1024);
+
+/* duplicated from avpriv_mpeg4audio_sample_rates to avoid shared build
+ * failures */
+static const int mpeg4audio_sample_rates[16] = {
+96000, 88200, 64000, 48000, 44100, 32000,
+24000, 22050, 16000, 12000, 11025, 8000, 7350
+};
+
+enum WindowSequence {
+ONLY_LONG_SEQUENCE,
+LONG_START_SEQUENCE,
+EIGHT_SHORT_SEQUENCE,
+LONG_STOP_SEQUENCE,
+};
+
+const uint8_t ff_vorbis_num_swb_1024[] = {
+41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40, 40
+};
+
+const uint8_t ff_vorbis_num_swb_128[] = {
+12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15
+};
+
+
+
 #endif /* AVCODEC_VORBIS_ENC_DATA_H */
diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c
index 2974ca2..9f1adf8 100644
--- a/libavcodec/vorbisenc.c
+++ b/libavcodec/vorbisenc.c
@@ -32,6 +32,7 @@
 #include "mathops.h"
 #include "vorbis.h"
 #include "vorbis_enc_data.h"
+#include "psymodel.h"
 
 #define BITSTREAM_WRITER_LE
 #include "put_bits.h"
@@ -126,6 +127,10 @@ typedef struct vorbis_enc_context {
 vorbis_enc_mode *modes;
 
 int64_t next_pts;
+   //stuff 

Re: [FFmpeg-devel] [PATCH] ffserver: fix memory leaks pointed out by valgrind.

2017-04-16 Thread Zalewa

Hello,

Approach 2.

This one reverses the shared state created by unlayer_stream() by 
nullifying the pointers to shared objects and then passes the "cleaned" 
AVFormatContext to avformat_free_context(). In result we have less code 
and less meddling with internals. See close_unlayered_format_context() 
function in ffserver.c.


The drawback of this approach is that I also had to modify free_stream() 
in libavformat/utils.c because it was not expecting that the "codec" 
pointer in AVStream can be null.


Let me know what you think.

Best regards,
Z.
From 4af94953f03989447e10f9aae013b4afb158c2e0 Mon Sep 17 00:00:00 2001
From: Zalewa 
Date: Fri, 14 Apr 2017 09:26:18 +0200
Subject: [PATCH] ffserver: fix memory leaks pointed out by valgrind.

Many memory leaks were created upon HTTP client disconnect.
Many clients connecting & disconnecting rapidly could very
quickly create leaks going into Gigabytes of memory.
---
 ffserver.c  | 40 +++-
 libavformat/utils.c |  8 +---
 2 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/ffserver.c b/ffserver.c
index 8b819b6..1748d81 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -270,6 +270,22 @@ static void unlayer_stream(AVStream *st, LayeredAVStream 
*lst)
 COPY(recommended_encoder_configuration)
 }
 
+/* NULLify all shared state that was applied in unlayer_stream. */
+static void detach_unlayered_stream(AVStream *st)
+{
+st->codec = 0;
+st->codecpar = 0;
+st->recommended_encoder_configuration = 0;
+}
+
+static void close_unlayered_format_context(AVFormatContext *ctx)
+{
+int i = 0;
+for (i = 0; i < ctx->nb_streams; ++i)
+detach_unlayered_stream(ctx->streams[i]);
+avformat_free_context(ctx);
+}
+
 static inline void cp_html_entity (char *buffer, const char *entity) {
 if (!buffer || !entity)
 return;
@@ -936,9 +952,7 @@ static void close_connection(HTTPContext *c)
 ctx = c->rtp_ctx[i];
 if (ctx) {
 av_write_trailer(ctx);
-av_dict_free(>metadata);
-av_freep(>streams[0]);
-av_freep();
+avformat_free_context(ctx);
 }
 ffurl_close(c->rtp_handles[i]);
 }
@@ -954,11 +968,9 @@ static void close_connection(HTTPContext *c)
 avio_close_dyn_buf(ctx->pb, >pb_buffer);
 }
 }
-for(i=0; inb_streams; i++)
-av_freep(>streams[i]);
-av_freep(>streams);
-av_freep(>priv_data);
-}
+close_unlayered_format_context(ctx);
+c->pfmt_ctx = 0;
+}
 
 if (c->stream && !c->post && c->stream->stream_type == STREAM_TYPE_LIVE)
 current_bandwidth -= c->stream->bandwidth;
@@ -3836,7 +3848,7 @@ drop:
 }
 s->oformat = feed->fmt;
 for (i = 0; inb_streams; i++) {
-AVStream *st = avformat_new_stream(s, NULL); // FIXME free this
+AVStream *st = avformat_new_stream(s, NULL);
 if (!st) {
 http_log("Failed to allocate stream\n");
 goto bail;
@@ -3846,17 +3858,11 @@ drop:
 if (avformat_write_header(s, NULL) < 0) {
 http_log("Container doesn't support the required 
parameters\n");
 avio_closep(>pb);
-s->streams = NULL;
-s->nb_streams = 0;
-avformat_free_context(s);
+close_unlayered_format_context(s);
 goto bail;
 }
-/* XXX: need better API */
-av_freep(>priv_data);
 avio_closep(>pb);
-s->streams = NULL;
-s->nb_streams = 0;
-avformat_free_context(s);
+close_unlayered_format_context(s);
 }
 
 /* get feed size and write index */
diff --git a/libavformat/utils.c b/libavformat/utils.c
index ba82a76..a392743 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4266,9 +4266,11 @@ static void free_stream(AVStream **pst)
 av_freep(>index_entries);
 #if FF_API_LAVF_AVCTX
 FF_DISABLE_DEPRECATION_WARNINGS
-av_freep(>codec->extradata);
-av_freep(>codec->subtitle_header);
-av_freep(>codec);
+if (st->codec) {
+av_freep(>codec->extradata);
+av_freep(>codec->subtitle_header);
+av_freep(>codec);
+}
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 av_freep(>priv_data);
-- 
2.1.4

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