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

2017-07-28 Thread Clément Bœsch
On Fri, Jul 28, 2017 at 12:32:59AM +0530, Paras Chadha wrote:
[...]
> +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;


memcmp(b, "SIMPLE  =T", 30)?

all FITS files start like this?...

[...]

-- 
Clément B.


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


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

2017-07-28 Thread sharpbai
From: sharpbai 

feature: add scaleFactor attribute for avfoundation
added by: siyuan.w...@duobei.com
added by: yiren...@duobei.com
---
 libavdevice/avfoundation.m | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index e2ddf47..22cff1f 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -96,6 +96,7 @@ typedef struct
 
 int capture_cursor;
 int capture_mouse_clicks;
+float   scaleFactor;
 
 int list_devices;
 int video_device_index;
@@ -748,6 +749,9 @@ static int avf_read_header(AVFormatContext *s)
 } else {
 capture_screen_input.capturesMouseClicks = NO;
 }
+if (ctx->scaleFactor != 1 && ctx->scaleFactor > 0) {
+capture_screen_input.scaleFactor = ctx->scaleFactor;
+}
 
 video_device = (AVCaptureDevice*) capture_screen_input;
 capture_screen = 1;
@@ -1025,6 +1029,7 @@ static const AVOption options[] = {
 { "video_size", "set video size", offsetof(AVFContext, width), 
AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
 { "capture_cursor", "capture the screen cursor", offsetof(AVFContext, 
capture_cursor), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
 { "capture_mouse_clicks", "capture the screen mouse clicks", 
offsetof(AVFContext, capture_mouse_clicks), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, 
AV_OPT_FLAG_DECODING_PARAM },
+{ "scaleFactor", "scale screen factor range", offsetof(AVFContext, 
scaleFactor), AV_OPT_TYPE_FLOAT, {.i64=1}, 0, 2, AV_OPT_FLAG_DECODING_PARAM },
 
 { NULL },
 };
-- 
2.2.1

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


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

2017-07-28 Thread Steven Liu
2017-07-28 15:55 GMT+08:00 sharpbai :
> From: sharpbai 
>
> feature: add scaleFactor attribute for avfoundation
> added by: siyuan.w...@duobei.com
> added by: yiren...@duobei.com
> ---
>  libavdevice/avfoundation.m | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
> index e2ddf47..22cff1f 100644
> --- a/libavdevice/avfoundation.m
> +++ b/libavdevice/avfoundation.m
> @@ -96,6 +96,7 @@ typedef struct
>
>  int capture_cursor;
>  int capture_mouse_clicks;
> +float   scaleFactor;
>
>  int list_devices;
>  int video_device_index;
> @@ -748,6 +749,9 @@ static int avf_read_header(AVFormatContext *s)
>  } else {
>  capture_screen_input.capturesMouseClicks = NO;
>  }
> +if (ctx->scaleFactor != 1 && ctx->scaleFactor > 0) {
> +capture_screen_input.scaleFactor = ctx->scaleFactor;
> +}
>
>  video_device = (AVCaptureDevice*) capture_screen_input;
>  capture_screen = 1;
> @@ -1025,6 +1029,7 @@ static const AVOption options[] = {
>  { "video_size", "set video size", offsetof(AVFContext, width), 
> AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
>  { "capture_cursor", "capture the screen cursor", offsetof(AVFContext, 
> capture_cursor), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM 
> },
>  { "capture_mouse_clicks", "capture the screen mouse clicks", 
> offsetof(AVFContext, capture_mouse_clicks), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, 
> AV_OPT_FLAG_DECODING_PARAM },
> +{ "scaleFactor", "scale screen factor range", offsetof(AVFContext, 
> scaleFactor), AV_OPT_TYPE_FLOAT, {.i64=1}, 0, 2, AV_OPT_FLAG_DECODING_PARAM },
>
>  { NULL },
>  };
> --
> 2.2.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Add the option into document please.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] libavcodec/mips: Improve avc dequant-idct luma dc msa function

2017-07-28 Thread kaustubh.raste
From: Kaustubh Raste 

Signed-off-by: Kaustubh Raste 
---
 libavcodec/mips/h264idct_msa.c |   66 +++-
 1 file changed, 32 insertions(+), 34 deletions(-)

diff --git a/libavcodec/mips/h264idct_msa.c b/libavcodec/mips/h264idct_msa.c
index 81e09e9..861befe 100644
--- a/libavcodec/mips/h264idct_msa.c
+++ b/libavcodec/mips/h264idct_msa.c
@@ -40,17 +40,20 @@ static void avc_deq_idct_luma_dc_msa(int16_t *dst, int16_t 
*src,
  int32_t de_q_val)
 {
 #define DC_DEST_STRIDE 16
-int16_t out0, out1, out2, out3;
-v8i16 src0, src1, src2, src3;
+int16_t out0, out1, out2, out3, out4, out5, out6, out7;
+v8i16 src1, src3;
 v8i16 vec0, vec1, vec2, vec3;
+v8i16 tmp0, tmp1, tmp2, tmp3;
 v8i16 hres0, hres1, hres2, hres3;
 v8i16 vres0, vres1, vres2, vres3;
 v4i32 vres0_r, vres1_r, vres2_r, vres3_r;
-v4i32 de_q_vec = __msa_fill_w(de_q_val);
+const v4i32 de_q_vec = __msa_fill_w(de_q_val);
+const v8i16 src0 = LD_SH(src);
+const v8i16 src2 = LD_SH(src + 8);
 
-LD4x4_SH(src, src0, src1, src2, src3);
-TRANSPOSE4x4_SH_SH(src0, src1, src2, src3, src0, src1, src2, src3);
-BUTTERFLY_4(src0, src2, src3, src1, vec0, vec3, vec2, vec1);
+ILVL_D2_SH(src0, src0, src2, src2, src1, src3);
+TRANSPOSE4x4_SH_SH(src0, src1, src2, src3, tmp0, tmp1, tmp2, tmp3);
+BUTTERFLY_4(tmp0, tmp2, tmp3, tmp1, vec0, vec3, vec2, vec1);
 BUTTERFLY_4(vec0, vec1, vec2, vec3, hres0, hres3, hres2, hres1);
 TRANSPOSE4x4_SH_SH(hres0, hres1, hres2, hres3, hres0, hres1, hres2, hres3);
 BUTTERFLY_4(hres0, hres1, hres3, hres2, vec0, vec3, vec2, vec1);
@@ -72,40 +75,35 @@ static void avc_deq_idct_luma_dc_msa(int16_t *dst, int16_t 
*src,
 out1 = __msa_copy_s_h(vec0, 1);
 out2 = __msa_copy_s_h(vec0, 2);
 out3 = __msa_copy_s_h(vec0, 3);
-SH(out0, dst);
-SH(out1, (dst + 2 * DC_DEST_STRIDE));
-SH(out2, (dst + 8 * DC_DEST_STRIDE));
+out4 = __msa_copy_s_h(vec0, 4);
+out5 = __msa_copy_s_h(vec0, 5);
+out6 = __msa_copy_s_h(vec0, 6);
+out7 = __msa_copy_s_h(vec0, 7);
+SH(out0, (dst + 0  * DC_DEST_STRIDE));
+SH(out1, (dst + 2  * DC_DEST_STRIDE));
+SH(out2, (dst + 8  * DC_DEST_STRIDE));
 SH(out3, (dst + 10 * DC_DEST_STRIDE));
-dst += DC_DEST_STRIDE;
-
-out0 = __msa_copy_s_h(vec0, 4);
-out1 = __msa_copy_s_h(vec0, 5);
-out2 = __msa_copy_s_h(vec0, 6);
-out3 = __msa_copy_s_h(vec0, 7);
-SH(out0, dst);
-SH(out1, (dst + 2 * DC_DEST_STRIDE));
-SH(out2, (dst + 8 * DC_DEST_STRIDE));
-SH(out3, (dst + 10 * DC_DEST_STRIDE));
-dst += (3 * DC_DEST_STRIDE);
+SH(out4, (dst + 1  * DC_DEST_STRIDE));
+SH(out5, (dst + 3  * DC_DEST_STRIDE));
+SH(out6, (dst + 9  * DC_DEST_STRIDE));
+SH(out7, (dst + 11 * DC_DEST_STRIDE));
 
 out0 = __msa_copy_s_h(vec1, 0);
 out1 = __msa_copy_s_h(vec1, 1);
 out2 = __msa_copy_s_h(vec1, 2);
 out3 = __msa_copy_s_h(vec1, 3);
-SH(out0, dst);
-SH(out1, (dst + 2 * DC_DEST_STRIDE));
-SH(out2, (dst + 8 * DC_DEST_STRIDE));
-SH(out3, (dst + 10 * DC_DEST_STRIDE));
-dst += DC_DEST_STRIDE;
-
-out0 = __msa_copy_s_h(vec1, 4);
-out1 = __msa_copy_s_h(vec1, 5);
-out2 = __msa_copy_s_h(vec1, 6);
-out3 = __msa_copy_s_h(vec1, 7);
-SH(out0, dst);
-SH(out1, (dst + 2 * DC_DEST_STRIDE));
-SH(out2, (dst + 8 * DC_DEST_STRIDE));
-SH(out3, (dst + 10 * DC_DEST_STRIDE));
+out4 = __msa_copy_s_h(vec1, 4);
+out5 = __msa_copy_s_h(vec1, 5);
+out6 = __msa_copy_s_h(vec1, 6);
+out7 = __msa_copy_s_h(vec1, 7);
+SH(out0, (dst + 4  * DC_DEST_STRIDE));
+SH(out1, (dst + 6  * DC_DEST_STRIDE));
+SH(out2, (dst + 12 * DC_DEST_STRIDE));
+SH(out3, (dst + 14 * DC_DEST_STRIDE));
+SH(out4, (dst + 5  * DC_DEST_STRIDE));
+SH(out5, (dst + 7  * DC_DEST_STRIDE));
+SH(out6, (dst + 13 * DC_DEST_STRIDE));
+SH(out7, (dst + 15 * DC_DEST_STRIDE));
 
 #undef DC_DEST_STRIDE
 }
-- 
1.7.9.5

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


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

2017-07-28 Thread Steven Liu
2017-07-28 16:34 GMT+08:00 Steven Liu :
> 2017-07-28 15:55 GMT+08:00 sharpbai :
>> From: sharpbai 
>>
>> feature: add scaleFactor attribute for avfoundation
>> added by: siyuan.w...@duobei.com
>> added by: yiren...@duobei.com
>> ---
>>  libavdevice/avfoundation.m | 5 +
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
>> index e2ddf47..22cff1f 100644
>> --- a/libavdevice/avfoundation.m
>> +++ b/libavdevice/avfoundation.m
>> @@ -96,6 +96,7 @@ typedef struct
>>
>>  int capture_cursor;
>>  int capture_mouse_clicks;
>> +float   scaleFactor;
I saw the method from :
https://developer.apple.com/documentation/avfoundation/avcapturescreeninput/1390311-scalefactor
said:

SDK

macOS 10.7+

I cannot sure if this attribute need check about the depend version.
>>
>>  int list_devices;
>>  int video_device_index;
>> @@ -748,6 +749,9 @@ static int avf_read_header(AVFormatContext *s)
>>  } else {
>>  capture_screen_input.capturesMouseClicks = NO;
>>  }
>> +if (ctx->scaleFactor != 1 && ctx->scaleFactor > 0) {
>> +capture_screen_input.scaleFactor = ctx->scaleFactor;
>> +}
>>
>>  video_device = (AVCaptureDevice*) capture_screen_input;
>>  capture_screen = 1;
>> @@ -1025,6 +1029,7 @@ static const AVOption options[] = {
>>  { "video_size", "set video size", offsetof(AVFContext, width), 
>> AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
>>  { "capture_cursor", "capture the screen cursor", offsetof(AVFContext, 
>> capture_cursor), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM 
>> },
>>  { "capture_mouse_clicks", "capture the screen mouse clicks", 
>> offsetof(AVFContext, capture_mouse_clicks), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, 
>> AV_OPT_FLAG_DECODING_PARAM },
>> +{ "scaleFactor", "scale screen factor range", offsetof(AVFContext, 
>> scaleFactor), AV_OPT_TYPE_FLOAT, {.i64=1}, 0, 2, AV_OPT_FLAG_DECODING_PARAM 
>> },
>>
>>  { NULL },
>>  };
>> --
>> 2.2.1
>>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> Add the option into document please.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2017-07-28 Thread Jorge Ramirez

On 07/28/2017 12:45 AM, Michael Niedermayer wrote:

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


ok will disable the codecs not supported at configure time (will post 
the fix in v2)





[...]


___
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] avdevice/avfoundation: add scaleFactor attribute for avfoundation

2017-07-28 Thread sharpbai
From: sharpbai 

feature: add scaleFactor attribute for avfoundation
added by: siyuan.w...@duobei.com
added by: yiren...@duobei.com
---
 doc/indevs.texi| 3 +++
 libavdevice/avfoundation.m | 6 ++
 2 files changed, 9 insertions(+)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 09e3321..8873477 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -139,6 +139,9 @@ Capture the mouse pointer. Default is 0.
 @item -capture_mouse_clicks
 Capture the screen mouse clicks. Default is 0.
 
+@item -scale_factor
+Scale factor for capture the screen. Default is 1.
+
 @end table
 
 @subsection Examples
diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index e2ddf47..92e4063 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -96,6 +96,7 @@ typedef struct
 
 int capture_cursor;
 int capture_mouse_clicks;
+float   scale_factor;
 
 int list_devices;
 int video_device_index;
@@ -735,6 +736,10 @@ static int avf_read_header(AVFormatContext *s)
 capture_screen_input.minFrameDuration = 
CMTimeMake(ctx->framerate.den, ctx->framerate.num);
 }
 
+if (ctx->scale_factor != 1 && ctx->scale_factor > 0) {
+capture_screen_input.scaleFactor = ctx->scale_factor;
+}
+
 #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
 if (ctx->capture_cursor) {
 capture_screen_input.capturesCursor = YES;
@@ -1025,6 +1030,7 @@ static const AVOption options[] = {
 { "video_size", "set video size", offsetof(AVFContext, width), 
AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
 { "capture_cursor", "capture the screen cursor", offsetof(AVFContext, 
capture_cursor), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
 { "capture_mouse_clicks", "capture the screen mouse clicks", 
offsetof(AVFContext, capture_mouse_clicks), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, 
AV_OPT_FLAG_DECODING_PARAM },
+{ "scale_factor", "scale screen factor range", offsetof(AVFContext, 
scale_factor), AV_OPT_TYPE_FLOAT, {.i64=1}, 0, 2, AV_OPT_FLAG_DECODING_PARAM },
 
 { NULL },
 };
-- 
2.2.1

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


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

2017-07-28 Thread Paras Chadha
On Fri, Jul 28, 2017 at 1:44 PM, Clément Bœsch  wrote:

> On Fri, Jul 28, 2017 at 12:32:59AM +0530, Paras Chadha wrote:
> [...]
> > +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;
>
>
> memcmp(b, "SIMPLE  =T", 30)?
>

ok, will change to this

>
> all FITS files start like this?...
>

yes, it is the standard signature of FITS files. See
https://en.wikipedia.org/wiki/List_of_file_signatures

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

2017-07-28 Thread Nicolas George
Le decadi 10 thermidor, an CCXXV, Paras Chadha a écrit :
> Signed-off-by: Paras Chadha 
> ---
> 
> Made all the changes suggested.

Nice. There are a few nitpicks, but I like these versions much better.

> 
>  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)

See Clément's comment.

> +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;

Maybe make them unsigned.

> +
> +do {
> +ret = avio_read(s->pb, buf, FITS_BLOCK_SIZE);
> +if (ret < 0) {
> +return ret;

> +} else if (ret < FITS_BLOCK_SIZE) {
> +return AVERROR_EOF;

I would say AVERROR_INVALIDDATA for truncated files.

> +}
> +
> +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 = fit

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

2017-07-28 Thread Nicolas George
Le decadi 10 thermidor, an CCXXV, Paras Chadha a écrit :
> 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

The avpriv part is required unconditionally. You need to either split it
into a separate file, or compile this file always and add "#if
FITS_DECODER" around the optional parts.

>  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 
> U

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

2017-07-28 Thread Moritz Barsnick
On Fri, Jul 28, 2017 at 15:55:01 +0800, sharpbai wrote:
> +float   scaleFactor;

No camelCase in ffmpeg for plain variables.

> +{ "scaleFactor", "scale screen factor range", offsetof(AVFContext, 
> scaleFactor), AV_OPT_TYPE_FLOAT, {.i64=1}, 0, 2, AV_OPT_FLAG_DECODING_PARAM },

No camelCase for ffmpeg options. And shouldn't that be "{.dbl=1}"?

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


Re: [FFmpeg-devel] [PATCH] libavcodec/mips: Improve avc dequant-idct luma dc msa function

2017-07-28 Thread Manojkumar Bhosale
LGTM

-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of 
kaustubh.ra...@imgtec.com
Sent: Friday, July 28, 2017 2:12 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Kaustubh Raste
Subject: [FFmpeg-devel] [PATCH] libavcodec/mips: Improve avc dequant-idct luma 
dc msa function

From: Kaustubh Raste 

Signed-off-by: Kaustubh Raste 
---
 libavcodec/mips/h264idct_msa.c |   66 +++-
 1 file changed, 32 insertions(+), 34 deletions(-)

diff --git a/libavcodec/mips/h264idct_msa.c b/libavcodec/mips/h264idct_msa.c 
index 81e09e9..861befe 100644
--- a/libavcodec/mips/h264idct_msa.c
+++ b/libavcodec/mips/h264idct_msa.c
@@ -40,17 +40,20 @@ static void avc_deq_idct_luma_dc_msa(int16_t *dst, int16_t 
*src,
  int32_t de_q_val)  {  #define 
DC_DEST_STRIDE 16
-int16_t out0, out1, out2, out3;
-v8i16 src0, src1, src2, src3;
+int16_t out0, out1, out2, out3, out4, out5, out6, out7;
+v8i16 src1, src3;
 v8i16 vec0, vec1, vec2, vec3;
+v8i16 tmp0, tmp1, tmp2, tmp3;
 v8i16 hres0, hres1, hres2, hres3;
 v8i16 vres0, vres1, vres2, vres3;
 v4i32 vres0_r, vres1_r, vres2_r, vres3_r;
-v4i32 de_q_vec = __msa_fill_w(de_q_val);
+const v4i32 de_q_vec = __msa_fill_w(de_q_val);
+const v8i16 src0 = LD_SH(src);
+const v8i16 src2 = LD_SH(src + 8);
 
-LD4x4_SH(src, src0, src1, src2, src3);
-TRANSPOSE4x4_SH_SH(src0, src1, src2, src3, src0, src1, src2, src3);
-BUTTERFLY_4(src0, src2, src3, src1, vec0, vec3, vec2, vec1);
+ILVL_D2_SH(src0, src0, src2, src2, src1, src3);
+TRANSPOSE4x4_SH_SH(src0, src1, src2, src3, tmp0, tmp1, tmp2, tmp3);
+BUTTERFLY_4(tmp0, tmp2, tmp3, tmp1, vec0, vec3, vec2, vec1);
 BUTTERFLY_4(vec0, vec1, vec2, vec3, hres0, hres3, hres2, hres1);
 TRANSPOSE4x4_SH_SH(hres0, hres1, hres2, hres3, hres0, hres1, hres2, hres3);
 BUTTERFLY_4(hres0, hres1, hres3, hres2, vec0, vec3, vec2, vec1); @@ -72,40 
+75,35 @@ static void avc_deq_idct_luma_dc_msa(int16_t *dst, int16_t *src,
 out1 = __msa_copy_s_h(vec0, 1);
 out2 = __msa_copy_s_h(vec0, 2);
 out3 = __msa_copy_s_h(vec0, 3);
-SH(out0, dst);
-SH(out1, (dst + 2 * DC_DEST_STRIDE));
-SH(out2, (dst + 8 * DC_DEST_STRIDE));
+out4 = __msa_copy_s_h(vec0, 4);
+out5 = __msa_copy_s_h(vec0, 5);
+out6 = __msa_copy_s_h(vec0, 6);
+out7 = __msa_copy_s_h(vec0, 7);
+SH(out0, (dst + 0  * DC_DEST_STRIDE));
+SH(out1, (dst + 2  * DC_DEST_STRIDE));
+SH(out2, (dst + 8  * DC_DEST_STRIDE));
 SH(out3, (dst + 10 * DC_DEST_STRIDE));
-dst += DC_DEST_STRIDE;
-
-out0 = __msa_copy_s_h(vec0, 4);
-out1 = __msa_copy_s_h(vec0, 5);
-out2 = __msa_copy_s_h(vec0, 6);
-out3 = __msa_copy_s_h(vec0, 7);
-SH(out0, dst);
-SH(out1, (dst + 2 * DC_DEST_STRIDE));
-SH(out2, (dst + 8 * DC_DEST_STRIDE));
-SH(out3, (dst + 10 * DC_DEST_STRIDE));
-dst += (3 * DC_DEST_STRIDE);
+SH(out4, (dst + 1  * DC_DEST_STRIDE));
+SH(out5, (dst + 3  * DC_DEST_STRIDE));
+SH(out6, (dst + 9  * DC_DEST_STRIDE));
+SH(out7, (dst + 11 * DC_DEST_STRIDE));
 
 out0 = __msa_copy_s_h(vec1, 0);
 out1 = __msa_copy_s_h(vec1, 1);
 out2 = __msa_copy_s_h(vec1, 2);
 out3 = __msa_copy_s_h(vec1, 3);
-SH(out0, dst);
-SH(out1, (dst + 2 * DC_DEST_STRIDE));
-SH(out2, (dst + 8 * DC_DEST_STRIDE));
-SH(out3, (dst + 10 * DC_DEST_STRIDE));
-dst += DC_DEST_STRIDE;
-
-out0 = __msa_copy_s_h(vec1, 4);
-out1 = __msa_copy_s_h(vec1, 5);
-out2 = __msa_copy_s_h(vec1, 6);
-out3 = __msa_copy_s_h(vec1, 7);
-SH(out0, dst);
-SH(out1, (dst + 2 * DC_DEST_STRIDE));
-SH(out2, (dst + 8 * DC_DEST_STRIDE));
-SH(out3, (dst + 10 * DC_DEST_STRIDE));
+out4 = __msa_copy_s_h(vec1, 4);
+out5 = __msa_copy_s_h(vec1, 5);
+out6 = __msa_copy_s_h(vec1, 6);
+out7 = __msa_copy_s_h(vec1, 7);
+SH(out0, (dst + 4  * DC_DEST_STRIDE));
+SH(out1, (dst + 6  * DC_DEST_STRIDE));
+SH(out2, (dst + 12 * DC_DEST_STRIDE));
+SH(out3, (dst + 14 * DC_DEST_STRIDE));
+SH(out4, (dst + 5  * DC_DEST_STRIDE));
+SH(out5, (dst + 7  * DC_DEST_STRIDE));
+SH(out6, (dst + 13 * DC_DEST_STRIDE));
+SH(out7, (dst + 15 * DC_DEST_STRIDE));
 
 #undef DC_DEST_STRIDE
 }
--
1.7.9.5

___
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] avfilter: add ADM filter

2017-07-28 Thread Ashish Pratap Singh
From: Ashish Singh 

Signed-off-by: Ashish Singh 
---
 Changelog|   1 +
 doc/filters.texi |  19 ++
 libavfilter/Makefile |   1 +
 libavfilter/adm.h|  88 +
 libavfilter/allfilters.c |   1 +
 libavfilter/vf_adm.c | 819 +++
 6 files changed, 929 insertions(+)
 create mode 100644 libavfilter/adm.h
 create mode 100644 libavfilter/vf_adm.c

diff --git a/Changelog b/Changelog
index 187ae79..5a9b211 100644
--- a/Changelog
+++ b/Changelog
@@ -29,6 +29,7 @@ version :
 - limiter video filter
 - libvmaf video filter
 - Dolby E decoder and SMPTE 337M demuxer
+- adm video filter
 
 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/doc/filters.texi b/doc/filters.texi
index 2324b96..86cf865 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -4604,6 +4604,25 @@ build.
 
 Below is a description of the currently available video filters.
 
+@section adm
+
+Obtain the average ADM/DLM (Detail Loss Metric) between two input videos.
+
+This filter takes two input videos.
+
+Both input videos must have the same resolution and pixel format for
+this filter to work correctly. Also it assumes that both inputs
+have the same number of frames, which are compared one by one.
+
+The obtained average ADM is printed through the logging system.
+
+In the below example the input file @file{main.mpg} being processed is compared
+with the reference file @file{ref.mpg}.
+
+@example
+ffmpeg -i main.mpg -i ref.mpg -lavfi adm -f null -
+@end example
+
 @section alphaextract
 
 Extract the alpha component from the input as a grayscale video. This
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index ee16361..bca3eff 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -126,6 +126,7 @@ OBJS-$(CONFIG_SINE_FILTER)   += asrc_sine.o
 OBJS-$(CONFIG_ANULLSINK_FILTER)  += asink_anullsink.o
 
 # video filters
+OBJS-$(CONFIG_ADM_FILTER)+= vf_adm.o dualinput.o 
framesync.o
 OBJS-$(CONFIG_ALPHAEXTRACT_FILTER)   += vf_extractplanes.o
 OBJS-$(CONFIG_ALPHAMERGE_FILTER) += vf_alphamerge.o
 OBJS-$(CONFIG_ASS_FILTER)+= vf_subtitles.o
diff --git a/libavfilter/adm.h b/libavfilter/adm.h
new file mode 100644
index 000..8b2db8b
--- /dev/null
+++ b/libavfilter/adm.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2017 Ronald S. Bultje 
+ * Copyright (c) 2017 Ashish Pratap Singh 
+ *
+ * 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 AVFILTER_ADM_H
+#define AVFILTER_ADM_H
+
+#define VIEW_DIST 3.0f
+#define REF_DISPLAY_HEIGHT 1080
+/** Percentage of frame to discard on all 4 sides */
+#define ADM_BORDER_FACTOR (0.1)
+
+typedef struct adm_dwt_band_t {
+float *band_a; /** Low-pass V + low-pass H. */
+float *band_v; /** Low-pass V + high-pass H. */
+float *band_h; /** High-pass V + low-pass H. */
+float *band_d; /** High-pass V + high-pass H. */
+} adm_dwt_band_t;
+
+/**
+ * The following dwt visibility threshold parameters are taken from
+ * "Visibility of Wavelet Quantization Noise"
+ * by A. B. Watson, G. Y. Yang, J. A. Solomon and J. Villasenor
+ * IEEE Trans. on Image Processing, Vol. 6, No 8, Aug. 1997
+ * Page 1170, formula (7) and corresponding Table IV
+ * Table IV has 2 entries for Cb and Cr thresholds
+ * Chose those corresponding to subject "sfl" since they are lower
+ * These thresholds were obtained and modeled for the 7-9 biorthogonal wavelet 
basis
+ */
+struct dwt_model_params {
+float a;
+float k;
+float f0;
+float g[4];
+};
+
+static const float dwt2_db2_coeffs_lo[4] = {  0.482962913144690,  
0.836516303737469, 0.224143868041857, -0.129409522550921 };
+static const float dwt2_db2_coeffs_hi[4] = { -0.129409522550921, 
-0.224143868041857, 0.836516303737469, -0.482962913144690 };
+
+/** 0 -> Y, 1 -> Cb, 2 -> Cr */
+static const struct dwt_model_params dwt_7_9_YCbCr_threshold[3] = {
+{ .a = 0.495, .k = 0.466, .f0 = 0.401, .g = { 1.501, 1.0, 0.534, 1.0} },
+{ .a = 1.633, .k = 0.353, .f0 = 0.209, .g = { 1.520, 1.0, 0.502, 1.0} },
+{ .a = 0.944, .k = 0.521, .f0 = 0.404, .g = { 1.868, 1.0, 0.516, 1.0} }
+};
+
+/**
+ * The following dwt basis function amplitudes, A(lambda,theta), are taken

[FFmpeg-devel] Switching of automatically detected libraries

2017-07-28 Thread Clément Bœsch
Creating predictible builds is currentl difficult due to automatically detected
libraries. This patchset adds an option to turn this off. As a side effect, it
regroups all the automatically detected libraries in the same place.

Note: crystalhd, securetransport, schannel and vda changes mostly UNTESTED.

Regards,

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


[FFmpeg-devel] [PATCH 1/8] build: group z libs with other autodetected libraries

2017-07-28 Thread Clément Bœsch
From: Clément Bœsch 

---
 configure | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 5811ee149a..a80f9cb2eb 100755
--- a/configure
+++ b/configure
@@ -3593,6 +3593,9 @@ enable_weak xlib
 
 enable_weak cuda cuvid nvenc vda_framework videotoolbox videotoolbox_encoder
 
+# Enable compression/decompression libraries by default
+enable_weak zlib bzlib lzma
+
 disabled logging && logfile=/dev/null
 
 die_license_disabled() {
@@ -5789,9 +5792,9 @@ fi
 enabled pthreads &&
 check_builtin sem_timedwait semaphore.h "sem_t *s; sem_init(s,0,0); 
sem_timedwait(s,0); sem_destroy(s)"
 
-disabled  zlib || check_lib zlib   zlib.h  zlibVersion-lz
-disabled bzlib || check_lib bzlib bzlib.h BZ2_bzlibVersion-lbz2
-disabled  lzma || check_lib lzma   lzma.h lzma_version_number -llzma
+enabled  zlib && check_lib zlib   zlib.h  zlibVersion-lz
+enabled bzlib && check_lib bzlib bzlib.h BZ2_bzlibVersion-lbz2
+enabled  lzma && check_lib lzma   lzma.h lzma_version_number -llzma
 
 check_lib libm math.h sin -lm && LIBM="-lm"
 disabled crystalhd || check_lib crystalhd "stdint.h 
libcrystalhd/libcrystalhd_if.h" DtsCrystalHDVersion -lcrystalhd
-- 
2.13.3

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


[FFmpeg-devel] [PATCH 2/8] build: treat crystalhd like other hwaccels

2017-07-28 Thread Clément Bœsch
From: Clément Bœsch 

---
 configure | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index a80f9cb2eb..a2ad72f7f4 100755
--- a/configure
+++ b/configure
@@ -1529,7 +1529,6 @@ EXTERNAL_LIBRARY_LIST="
 $EXTERNAL_LIBRARY_VERSION3_LIST
 $EXTERNAL_LIBRARY_GPLV3_LIST
 chromaprint
-crystalhd
 gcrypt
 gnutls
 jni
@@ -1586,6 +1585,7 @@ EXTERNAL_LIBRARY_LIST="
 "
 HWACCEL_AUTODETECT_LIBRARY_LIST="
 audiotoolbox
+crystalhd
 cuda
 cuvid
 d3d11va
@@ -3588,7 +3588,7 @@ done
 enable_weak audiotoolbox
 
 # Enable hwaccels by default.
-enable_weak d3d11va dxva2 vaapi vda vdpau videotoolbox_hwaccel xvmc
+enable_weak crystalhd d3d11va dxva2 vaapi vda vdpau videotoolbox_hwaccel xvmc
 enable_weak xlib
 
 enable_weak cuda cuvid nvenc vda_framework videotoolbox videotoolbox_encoder
@@ -5797,7 +5797,6 @@ enabled bzlib && check_lib bzlib bzlib.h BZ2_bzlibVersion 
   -lbz2
 enabled  lzma && check_lib lzma   lzma.h lzma_version_number -llzma
 
 check_lib libm math.h sin -lm && LIBM="-lm"
-disabled crystalhd || check_lib crystalhd "stdint.h 
libcrystalhd/libcrystalhd_if.h" DtsCrystalHDVersion -lcrystalhd
 
 atan2f_args=2
 copysign_args=2
@@ -6157,6 +6156,8 @@ enabled vdpau &&
 enabled vdpau &&
 check_lib vdpau_x11 "vdpau/vdpau.h vdpau/vdpau_x11.h" 
vdp_device_create_x11 -lvdpau -lX11
 
+enabled crystalhd && check_lib crystalhd "stdint.h 
libcrystalhd/libcrystalhd_if.h" DtsCrystalHDVersion -lcrystalhd
+
 if enabled x86; then
 case $target_os in
 mingw32*|mingw64*|win32|win64|linux|cygwin*)
-- 
2.13.3

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


[FFmpeg-devel] [PATCH 3/8] build: treat iconv like other autodetected libraries

2017-07-28 Thread Clément Bœsch
From: Clément Bœsch 

---
 configure | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index a2ad72f7f4..5ba171d459 100755
--- a/configure
+++ b/configure
@@ -3596,6 +3596,8 @@ enable_weak cuda cuvid nvenc vda_framework videotoolbox 
videotoolbox_encoder
 # Enable compression/decompression libraries by default
 enable_weak zlib bzlib lzma
 
+enable_weak iconv
+
 disabled logging && logfile=/dev/null
 
 die_license_disabled() {
@@ -6179,7 +6181,7 @@ int main(void) { return 0; }
 EOF
 
 # Funny iconv installations are not unusual, so check it after all flags have 
been set
-disabled iconv || check_func_headers iconv.h iconv || check_lib iconv iconv.h 
iconv -liconv
+enabled iconv && check_func_headers iconv.h iconv || check_lib iconv iconv.h 
iconv -liconv
 
 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
 
-- 
2.13.3

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


[FFmpeg-devel] [PATCH 4/8] build: treat libxcb like other autodetected libraries

2017-07-28 Thread Clément Bœsch
From: Clément Bœsch 

---
 configure | 24 +---
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/configure b/configure
index 5ba171d459..d5e05a0eca 100755
--- a/configure
+++ b/configure
@@ -3589,7 +3589,7 @@ enable_weak audiotoolbox
 
 # Enable hwaccels by default.
 enable_weak crystalhd d3d11va dxva2 vaapi vda vdpau videotoolbox_hwaccel xvmc
-enable_weak xlib
+enable_weak xlib libxcb libxcb_shm libxcb_shape libxcb_xfixes
 
 enable_weak cuda cuvid nvenc vda_framework videotoolbox videotoolbox_encoder
 
@@ -6106,31 +6106,17 @@ if enabled libcdio; then
 die "ERROR: No usable libcdio/cdparanoia found"
 fi
 
-if ! disabled libxcb; then
-check_pkg_config "xcb >= 1.4" xcb/xcb.h xcb_connect || {
-enabled libxcb && die "ERROR: libxcb >= 1.4 not found";
-} && enable libxcb
+enabled libxcb && check_pkg_config "xcb >= 1.4" xcb/xcb.h xcb_connect || 
disable libxcb
 
 if enabled libxcb; then
-disabled libxcb_shm || {
-check_pkg_config xcb-shm xcb/shm.h xcb_shm_attach || {
-enabled libxcb_shm && die "ERROR: libxcb_shm not found";
-} && check_header sys/shm.h && enable libxcb_shm; }
 
-disabled libxcb_xfixes || {
-check_pkg_config xcb-xfixes xcb/xfixes.h xcb_xfixes_get_cursor_image 
|| {
-enabled libxcb_xfixes && die "ERROR: libxcb_xfixes not found";
-} && enable libxcb_xfixes; }
-
-disabled libxcb_shape || {
-check_pkg_config xcb-shape xcb/shape.h xcb_shape_get_rectangles || {
-enabled libxcb_shape && die "ERROR: libxcb_shape not found";
-} && enable libxcb_shape; }
+enabled libxcb_shm&& check_pkg_config xcb-shmxcb/shm.h
xcb_shm_attach  || disable libxcb_shm
+enabled libxcb_shape  && check_pkg_config xcb-shape  xcb/shape.h  
xcb_shape_get_rectangles|| disable libxcb_shape
+enabled libxcb_xfixes && check_pkg_config xcb-xfixes xcb/xfixes.h 
xcb_xfixes_get_cursor_image || disable libxcb_xfixes
 
 add_cflags $xcb_cflags $xcb_shm_cflags $xcb_xfixes_cflags $xcb_shape_cflags
 add_extralibs $xcb_extralibs $xcb_shm_extralibs $xcb_xfixes_extralibs 
$xcb_shape_extralibs
 fi
-fi
 
 check_func_headers "windows.h" CreateDIBSection "$gdigrab_indev_extralibs"
 
-- 
2.13.3

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


[FFmpeg-devel] [PATCH 6/8] build: remove vda_framework from enable_weak

2017-07-28 Thread Clément Bœsch
From: Clément Bœsch 

vda_framework is already pulled by the weakly enabled vda and
videotoolbox.
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 296e83926d..6ddda239de 100755
--- a/configure
+++ b/configure
@@ -3591,7 +3591,7 @@ enable_weak audiotoolbox
 enable_weak crystalhd d3d11va dxva2 vaapi vda vdpau videotoolbox_hwaccel xvmc
 enable_weak xlib libxcb libxcb_shm libxcb_shape libxcb_xfixes
 
-enable_weak cuda cuvid nvenc vda_framework videotoolbox videotoolbox_encoder
+enable_weak cuda cuvid nvenc videotoolbox videotoolbox_encoder
 
 # Enable compression/decompression libraries by default
 enable_weak zlib bzlib lzma
-- 
2.13.3

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


[FFmpeg-devel] [PATCH 7/8] build: simplify weak-enabling of autodetected libraries

2017-07-28 Thread Clément Bœsch
From: Clément Bœsch 

---
 configure | 18 +++---
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/configure b/configure
index 6ddda239de..fa1b1d334a 100755
--- a/configure
+++ b/configure
@@ -3583,21 +3583,9 @@ done
 for lib in $AUTODETECT_LIBS; do
 enabled $lib && request $lib
 done
-
-# Enable platform codecs by default.
-enable_weak audiotoolbox
-
-# Enable hwaccels by default.
-enable_weak crystalhd d3d11va dxva2 vaapi vda vdpau videotoolbox_hwaccel xvmc
-enable_weak xlib libxcb libxcb_shm libxcb_shape libxcb_xfixes
-
-enable_weak cuda cuvid nvenc videotoolbox videotoolbox_encoder
-
-# Enable compression/decompression libraries by default
-enable_weak zlib bzlib lzma
-
-enable_weak iconv
-enable_weak securetransport schannel
+#TODO: switch to $AUTODETECT_LIBS when $THREADS_LIST is supported the same way
+enable_weak $EXTERNAL_AUTODETECT_LIBRARY_LIST
+enable_weak $HWACCEL_AUTODETECT_LIBRARY_LIST
 
 disabled logging && logfile=/dev/null
 
-- 
2.13.3

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


[FFmpeg-devel] [PATCH 5/8] build: treat securetransport and schannel like other autodetected libraries

2017-07-28 Thread Clément Bœsch
From: Clément Bœsch 

---
 configure | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/configure b/configure
index d5e05a0eca..296e83926d 100755
--- a/configure
+++ b/configure
@@ -3597,6 +3597,7 @@ enable_weak cuda cuvid nvenc vda_framework videotoolbox 
videotoolbox_encoder
 enable_weak zlib bzlib lzma
 
 enable_weak iconv
+enable_weak securetransport schannel
 
 disabled logging && logfile=/dev/null
 
@@ -6042,11 +6043,16 @@ if enabled decklink; then
 esac
 fi
 
-disabled securetransport || { check_func SecIdentityCreate 
"-Wl,-framework,CoreFoundation -Wl,-framework,Security" &&
-check_lib securetransport "Security/SecureTransport.h Security/Security.h" 
"SSLCreateContext SecItemImport" "-Wl,-framework,CoreFoundation 
-Wl,-framework,Security"; }
+enabled securetransport &&
+check_func SecIdentityCreate "-Wl,-framework,CoreFoundation 
-Wl,-framework,Security" &&
+check_lib securetransport "Security/SecureTransport.h Security/Security.h" 
"SSLCreateContext SecItemImport" "-Wl,-framework,CoreFoundation 
-Wl,-framework,Security" ||
+disable securetransport
 
-disabled schannel || { check_func_headers "windows.h security.h" 
InitializeSecurityContext -DSECURITY_WIN32 -lsecur32 &&
-   check_cpp_condition winerror.h 
"defined(SEC_I_CONTEXT_EXPIRED)" && enable schannel && add_extralibs -lsecur32; 
}
+enabled schannel &&
+check_func_headers "windows.h security.h" InitializeSecurityContext 
-DSECURITY_WIN32 -lsecur32 &&
+check_cpp_condition winerror.h "defined(SEC_I_CONTEXT_EXPIRED)" &&
+add_extralibs -lsecur32 ||
+disable schannel
 
 makeinfo --version > /dev/null 2>&1 && enable makeinfo  || disable makeinfo
 enabled makeinfo \
-- 
2.13.3

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


[FFmpeg-devel] [PATCH 8/8] build: add --disable-autodetect switch

2017-07-28 Thread Clément Bœsch
From: Clément Bœsch 

---
 Changelog | 1 +
 configure | 6 --
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index 187ae7950a..50409118e6 100644
--- a/Changelog
+++ b/Changelog
@@ -29,6 +29,7 @@ version :
 - limiter video filter
 - libvmaf video filter
 - Dolby E decoder and SMPTE 337M demuxer
+- add --disable-autodetect build switch
 
 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/configure b/configure
index fa1b1d334a..ece4a3ab40 100755
--- a/configure
+++ b/configure
@@ -109,6 +109,7 @@ Configuration options:
   --enable-grayenable full grayscale support (slower color)
   --disable-swscale-alpha  disable alpha channel support in swscale
   --disable-alldisable building components, libraries and programs
+  --disable-autodetect disable automatically detected external libraries 
[no]
 
 Program options:
   --disable-programs   do not build command line programs
@@ -1683,6 +1684,7 @@ CONFIG_LIST="
 $LIBRARY_LIST
 $PROGRAM_LIST
 $SUBSYSTEM_LIST
+autodetect
 fontconfig
 memory_poisoning
 neon_clobber_test
@@ -3584,8 +3586,8 @@ for lib in $AUTODETECT_LIBS; do
 enabled $lib && request $lib
 done
 #TODO: switch to $AUTODETECT_LIBS when $THREADS_LIST is supported the same way
-enable_weak $EXTERNAL_AUTODETECT_LIBRARY_LIST
-enable_weak $HWACCEL_AUTODETECT_LIBRARY_LIST
+! disabled autodetect && enable_weak $EXTERNAL_AUTODETECT_LIBRARY_LIST
+! disabled autodetect && enable_weak $HWACCEL_AUTODETECT_LIBRARY_LIST
 
 disabled logging && logfile=/dev/null
 
-- 
2.13.3

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


Re: [FFmpeg-devel] [PATCH 3/8] build: treat iconv like other autodetected libraries

2017-07-28 Thread Nicolas George
Le decadi 10 thermidor, an CCXXV, Clement Boesch a écrit :
> From: Clément Bœsch 
> 
> ---
>  configure | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

I am not sure exactly what the code does, but I think it must make a
difference between iconv provided by the libc on good Unix systems and
iconv provided by GNU libiconv.

When iconv is provided by the system's libc, then I think it should be
enabled automatically. It does not go against reproducible builds, I
think.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH 2/8] build: treat crystalhd like other hwaccels

2017-07-28 Thread Philip Langdale

On 2017-07-28 11:51, Clément Bœsch wrote:

From: Clément Bœsch 

---
 configure | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index a80f9cb2eb..a2ad72f7f4 100755
--- a/configure
+++ b/configure
@@ -1529,7 +1529,6 @@ EXTERNAL_LIBRARY_LIST="
 $EXTERNAL_LIBRARY_VERSION3_LIST
 $EXTERNAL_LIBRARY_GPLV3_LIST
 chromaprint
-crystalhd
 gcrypt
 gnutls
 jni
@@ -1586,6 +1585,7 @@ EXTERNAL_LIBRARY_LIST="
 "
 HWACCEL_AUTODETECT_LIBRARY_LIST="
 audiotoolbox
+crystalhd
 cuda
 cuvid
 d3d11va
@@ -3588,7 +3588,7 @@ done
 enable_weak audiotoolbox

 # Enable hwaccels by default.
-enable_weak d3d11va dxva2 vaapi vda vdpau videotoolbox_hwaccel xvmc
+enable_weak crystalhd d3d11va dxva2 vaapi vda vdpau 
videotoolbox_hwaccel xvmc

 enable_weak xlib

 enable_weak cuda cuvid nvenc vda_framework videotoolbox 
videotoolbox_encoder

@@ -5797,7 +5797,6 @@ enabled bzlib && check_lib bzlib bzlib.h
BZ2_bzlibVersion-lbz2
 enabled  lzma && check_lib lzma   lzma.h lzma_version_number -llzma

 check_lib libm math.h sin -lm && LIBM="-lm"
-disabled crystalhd || check_lib crystalhd "stdint.h
libcrystalhd/libcrystalhd_if.h" DtsCrystalHDVersion -lcrystalhd

 atan2f_args=2
 copysign_args=2
@@ -6157,6 +6156,8 @@ enabled vdpau &&
 enabled vdpau &&
 check_lib vdpau_x11 "vdpau/vdpau.h vdpau/vdpau_x11.h"
vdp_device_create_x11 -lvdpau -lX11

+enabled crystalhd && check_lib crystalhd "stdint.h
libcrystalhd/libcrystalhd_if.h" DtsCrystalHDVersion -lcrystalhd
+
 if enabled x86; then
 case $target_os in
 mingw32*|mingw64*|win32|win64|linux|cygwin*)


Looks fine to me.

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


Re: [FFmpeg-devel] [PATCH 3/8] build: treat iconv like other autodetected libraries

2017-07-28 Thread Clément Bœsch
On Fri, Jul 28, 2017 at 01:57:53PM +0200, Nicolas George wrote:
> Le decadi 10 thermidor, an CCXXV, Clement Boesch a écrit :
> > From: Clément Bœsch 
> > 
> > ---
> >  configure | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> I am not sure exactly what the code does, but I think it must make a
> difference between iconv provided by the libc on good Unix systems and
> iconv provided by GNU libiconv.
> 
> When iconv is provided by the system's libc, then I think it should be
> enabled automatically.

I'm not changing the behaviour here, iconv is already autodetected.

Though, --disable-autodetect will disable its auto-detection, be it
a "system" or a randomly installed library.

> It does not go against reproducible builds, I
> think.

Well, being maintained by the base system or through a normal package
doesn't make much difference since the system can also gets updated with a
new iconv (major bumped).

Here are some exceptions I can think of: libc (well, hard to get around
this one) and pthread. AFAIK the later may be replaced by "native" code; I
think clang doesn't rely on a library for this, so I'm assuming there is
no such thing as a link to libpthread in the final program.

So, unless iconv is a native feature of the compiler causing the final
program not to link against any external library, I don't think iconv
should be enabled by default.

Regards,

-- 
Clément B.


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


Re: [FFmpeg-devel] [PATCH 3/8] build: treat iconv like other autodetected libraries

2017-07-28 Thread Nicolas George
Le decadi 10 thermidor, an CCXXV, Clement Boesch a écrit :
> Though, --disable-autodetect will disable its auto-detection, be it
> a "system" or a randomly installed library.

Yes, and I think it is a bad idea for iconv.

> Well, being maintained by the base system or through a normal package
> doesn't make much difference since the system can also gets updated with a
> new iconv (major bumped).

No, it cannot. I am not talking about a library, I am talking about the
API. When the iconv API is part of the system, it cannot change its
binary interface, unless the system gets bumped as a whole.

> Here are some exceptions I can think of: libc (well, hard to get around
> this one)

Well, iconv is part of the libc, so that is ok. It should be treated as
such, like getaddrinfo, i.e. in the SYSTEM_FUNCS list.

>   and pthread. AFAIK the later may be replaced by "native" code; I
> think clang doesn't rely on a library for this, so I'm assuming there is
> no such thing as a link to libpthread in the final program.

I am rather dubious about that. It is not possible to make real threads
without system calls, and inlining system calls would be very very bad.

> So, unless iconv is a native feature XXX causing the final
> program not to link against any external library

It is exactly that on real Unix systems.

Regards,

-- 
  Nicolas George


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


[FFmpeg-devel] [PATCH 2/2] avformat/rtmppkt: Convert ff_amf_get_field_value() to bytestream2

2017-07-28 Thread Michael Niedermayer
Fixes: out of array accesses

The new function uses ff_ prefix even though its static to ease future
changes toward bytestream2

Found-by: JunDong Xie of Ant-financial Light-Year Security Lab
Signed-off-by: Michael Niedermayer 
---
 libavformat/rtmppkt.c | 57 +--
 1 file changed, 37 insertions(+), 20 deletions(-)

diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 752d92a42b..68c688136c 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -497,53 +497,70 @@ int ff_amf_tag_size(const uint8_t *data, const uint8_t 
*data_end)
 return bytestream2_tell(&gb);
 }
 
-int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end,
+static int ff_amf_get_field_value2(GetByteContext *gb,
const uint8_t *name, uint8_t *dst, int dst_size)
 {
 int namelen = strlen(name);
 int len;
 
-while (*data != AMF_DATA_TYPE_OBJECT && data < data_end) {
-len = ff_amf_tag_size(data, data_end);
-if (len < 0)
-len = data_end - data;
-data += len;
+while (bytestream2_peek_byte(gb) != AMF_DATA_TYPE_OBJECT && 
bytestream2_get_bytes_left(gb) > 0) {
+int ret = ff_amf_tag_skip(gb);
+if (ret < 0)
+return -1;
 }
-if (data_end - data < 3)
+if (bytestream2_get_bytes_left(gb) < 3)
 return -1;
-data++;
+bytestream2_get_byte(gb);
+
 for (;;) {
-int size = bytestream_get_be16(&data);
+int size = bytestream2_get_be16(gb);
 if (!size)
 break;
-if (size < 0 || size >= data_end - data)
+if (size < 0 || size >= bytestream2_get_bytes_left(gb))
 return -1;
-data += size;
-if (size == namelen && !memcmp(data-size, name, namelen)) {
-switch (*data++) {
+bytestream2_skip(gb, size);
+if (size == namelen && !memcmp(gb->buffer-size, name, namelen)) {
+switch (bytestream2_get_byte(gb)) {
 case AMF_DATA_TYPE_NUMBER:
-snprintf(dst, dst_size, "%g", av_int2double(AV_RB64(data)));
+snprintf(dst, dst_size, "%g", 
av_int2double(bytestream2_get_be64(gb)));
 break;
 case AMF_DATA_TYPE_BOOL:
-snprintf(dst, dst_size, "%s", *data ? "true" : "false");
+snprintf(dst, dst_size, "%s", bytestream2_get_byte(gb) ? 
"true" : "false");
 break;
 case AMF_DATA_TYPE_STRING:
-len = bytestream_get_be16(&data);
-av_strlcpy(dst, data, FFMIN(len+1, dst_size));
+len = bytestream2_get_be16(gb);
+if (dst_size < 1)
+return -1;
+if (dst_size < len + 1)
+len = dst_size - 1;
+bytestream2_get_buffer(gb, dst, len);
+dst[len] = 0;
 break;
 default:
 return -1;
 }
 return 0;
 }
-len = ff_amf_tag_size(data, data_end);
-if (len < 0 || len >= data_end - data)
+len = ff_amf_tag_skip(gb);
+if (len < 0 || bytestream2_get_bytes_left(gb) <= 0)
 return -1;
-data += len;
 }
 return -1;
 }
 
+int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end,
+   const uint8_t *name, uint8_t *dst, int dst_size)
+{
+GetByteContext gb;
+
+if (data >= data_end)
+return -1;
+
+bytestream2_init(&gb, data, data_end - data);
+
+return ff_amf_get_field_value2(&gb, name, dst, dst_size);
+}
+
 static const char* rtmp_packet_type(int type)
 {
 switch (type) {
-- 
2.13.0

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


[FFmpeg-devel] [PATCH 1/2] avformat/rtmppkt: Convert ff_amf_tag_size() to bytestream2

2017-07-28 Thread Michael Niedermayer
Fixes: out of array accesses
Fixes: crash-9238fa9e8d4fde3beda1f279626f53812cb001cb-SEGV

Found-by: JunDong Xie of Ant-financial Light-Year Security Lab
Signed-off-by: Michael Niedermayer 
---
 libavformat/rtmppkt.c | 60 ++-
 1 file changed, 40 insertions(+), 20 deletions(-)

diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 833a3dbade..752d92a42b 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -433,50 +433,70 @@ void ff_rtmp_packet_destroy(RTMPPacket *pkt)
 pkt->size = 0;
 }
 
-int ff_amf_tag_size(const uint8_t *data, const uint8_t *data_end)
+static int ff_amf_tag_skip(GetByteContext *gb)
 {
-const uint8_t *base = data;
 AMFDataType type;
 unsigned nb   = -1;
 int parse_key = 1;
 
-if (data >= data_end)
+if (bytestream2_get_bytes_left(gb) < 1)
 return -1;
-switch ((type = *data++)) {
-case AMF_DATA_TYPE_NUMBER:  return 9;
-case AMF_DATA_TYPE_BOOL:return 2;
-case AMF_DATA_TYPE_STRING:  return 3 + AV_RB16(data);
-case AMF_DATA_TYPE_LONG_STRING: return 5 + AV_RB32(data);
-case AMF_DATA_TYPE_NULL:return 1;
-case AMF_DATA_TYPE_DATE:return 11;
+
+switch ((type = bytestream2_get_byte(gb))) {
+case AMF_DATA_TYPE_NUMBER:  bytestream2_get_be64(gb); return 0;
+case AMF_DATA_TYPE_BOOL:bytestream2_get_byte(gb); return 0;
+case AMF_DATA_TYPE_STRING:
+bytestream2_skip(gb, bytestream2_get_be16(gb));
+return 0;
+case AMF_DATA_TYPE_LONG_STRING:
+bytestream2_skip(gb, bytestream2_get_be32(gb));
+return 0;
+case AMF_DATA_TYPE_NULL:return 0;
+case AMF_DATA_TYPE_DATE:bytestream2_skip(gb, 10); return 0;
 case AMF_DATA_TYPE_ARRAY:
 parse_key = 0;
 case AMF_DATA_TYPE_MIXEDARRAY:
-nb = bytestream_get_be32(&data);
+nb = bytestream2_get_be32(gb);
 case AMF_DATA_TYPE_OBJECT:
 while (nb-- > 0 || type != AMF_DATA_TYPE_ARRAY) {
 int t;
 if (parse_key) {
-int size = bytestream_get_be16(&data);
+int size = bytestream2_get_be16(gb);
 if (!size) {
-data++;
+bytestream2_get_byte(gb);
 break;
 }
-if (size < 0 || size >= data_end - data)
+if (size < 0 || size >= bytestream2_get_bytes_left(gb))
 return -1;
-data += size;
+bytestream2_skip(gb, size);
 }
-t = ff_amf_tag_size(data, data_end);
-if (t < 0 || t >= data_end - data)
+t = ff_amf_tag_skip(gb);
+if (t < 0 || bytestream2_get_bytes_left(gb) <= 0)
 return -1;
-data += t;
 }
-return data - base;
-case AMF_DATA_TYPE_OBJECT_END:  return 1;
+return 0;
+case AMF_DATA_TYPE_OBJECT_END:  return 0;
 default:return -1;
 }
 }
 
+int ff_amf_tag_size(const uint8_t *data, const uint8_t *data_end)
+{
+GetByteContext gb;
+int ret;
+
+if (data >= data_end)
+return -1;
+
+bytestream2_init(&gb, data, data_end - data);
+
+ret = ff_amf_tag_skip(&gb);
+if (ret < 0 || bytestream2_get_bytes_left(&gb) <= 0)
+return -1;
+av_assert0(bytestream2_tell(&gb) >= 0 && bytestream2_tell(&gb) <= data_end 
- data);
+return bytestream2_tell(&gb);
+}
+
 int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end,
const uint8_t *name, uint8_t *dst, int dst_size)
 {
-- 
2.13.0

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


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

2017-07-28 Thread Steven Liu
sharpbai 于2017年7月28日 周五下午5:34写道:

> From: sharpbai 
>
> feature: add scaleFactor attribute for avfoundation
> added by: siyuan.w...@duobei.com
> added by: yiren...@duobei.com
> ---
>  doc/indevs.texi| 3 +++
>  libavdevice/avfoundation.m | 6 ++
>  2 files changed, 9 insertions(+)
>
> diff --git a/doc/indevs.texi b/doc/indevs.texi
> index 09e3321..8873477 100644
> --- a/doc/indevs.texi
> +++ b/doc/indevs.texi
> @@ -139,6 +139,9 @@ Capture the mouse pointer. Default is 0.
>  @item -capture_mouse_clicks
>  Capture the screen mouse clicks. Default is 0.
>
> +@item -scale_factor
> +Scale factor for capture the screen. Default is 1.
> +
>  @end table
>
>  @subsection Examples
> diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
> index e2ddf47..92e4063 100644
> --- a/libavdevice/avfoundation.m
> +++ b/libavdevice/avfoundation.m
> @@ -96,6 +96,7 @@ typedef struct
>
>  int capture_cursor;
>  int capture_mouse_clicks;
> +float   scale_factor;
>
>  int list_devices;
>  int video_device_index;
> @@ -735,6 +736,10 @@ static int avf_read_header(AVFormatContext *s)
>  capture_screen_input.minFrameDuration =
> CMTimeMake(ctx->framerate.den, ctx->framerate.num);
>  }
>
> +if (ctx->scale_factor != 1 && ctx->scale_factor > 0) {
> +capture_screen_input.scaleFactor = ctx->scale_factor;
> +}
> +
>  #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
>  if (ctx->capture_cursor) {
>  capture_screen_input.capturesCursor = YES;
> @@ -1025,6 +1030,7 @@ static const AVOption options[] = {
>  { "video_size", "set video size", offsetof(AVFContext, width),
> AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
>  { "capture_cursor", "capture the screen cursor", offsetof(AVFContext,
> capture_cursor), AV_OPT_TYPE_INT, {.i64=0}, 0, 1,
> AV_OPT_FLAG_DECODING_PARAM },
>  { "capture_mouse_clicks", "capture the screen mouse clicks",
> offsetof(AVFContext, capture_mouse_clicks), AV_OPT_TYPE_INT, {.i64=0}, 0,
> 1, AV_OPT_FLAG_DECODING_PARAM },
> +{ "scale_factor", "scale screen factor range", offsetof(AVFContext,
> scale_factor), AV_OPT_TYPE_FLOAT, {.i64=1}, 0, 2,
> AV_OPT_FLAG_DECODING_PARAM },
>
>  { NULL },
>  };
> --
> 2.2.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
LGTM
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 8/8 v2] build: add --disable-autodetect switch

2017-07-28 Thread Clément Bœsch
On Fri, Jul 28, 2017 at 01:51:45PM +0200, Clément Bœsch wrote:
> From: Clément Bœsch 
> 
> ---
>  Changelog | 1 +
>  configure | 6 --
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 

new version attached, fixing link problems.

I still have some stuff I'd like to drop though:

☭ ldd ./ffmpeg
linux-vdso.so.1 (0x7ffce3bc9000)
libjack.so.0 => /usr/lib/libjack.so.0 (0x7f4f96965000)
libasound.so.2 => /usr/lib/libasound.so.2 (0x7f4f96655000)
libm.so.6 => /usr/lib/libm.so.6 (0x7f4f96343000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x7f4f96125000)
libc.so.6 => /usr/lib/libc.so.6 (0x7f4f95d7f000)
libdb-5.3.so => /usr/lib/libdb-5.3.so (0x7f4f959c)
libdl.so.2 => /usr/lib/libdl.so.2 (0x7f4f957bc000)
librt.so.1 => /usr/lib/librt.so.1 (0x7f4f955b4000)
/lib64/ld-linux-x86-64.so.2 (0x7f4f96b86000)

typically jack and asound. Maybe some others.

-- 
Clément B.
From a6000be09142b1a086256dba93ecb17998099c7e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= 
Date: Fri, 28 Jul 2017 13:44:07 +0200
Subject: [PATCH 8/8] build: add --disable-autodetect switch

---
 Changelog |  1 +
 configure | 12 ++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index 187ae7950a..50409118e6 100644
--- a/Changelog
+++ b/Changelog
@@ -29,6 +29,7 @@ version :
 - limiter video filter
 - libvmaf video filter
 - Dolby E decoder and SMPTE 337M demuxer
+- add --disable-autodetect build switch
 
 version 3.3:
 - CrystalHD decoder moved to new decode API
diff --git a/configure b/configure
index fa1b1d334a..4a4c36be34 100755
--- a/configure
+++ b/configure
@@ -109,6 +109,7 @@ Configuration options:
   --enable-grayenable full grayscale support (slower color)
   --disable-swscale-alpha  disable alpha channel support in swscale
   --disable-alldisable building components, libraries and programs
+  --disable-autodetect disable automatically detected external libraries [no]
 
 Program options:
   --disable-programs   do not build command line programs
@@ -1683,6 +1684,7 @@ CONFIG_LIST="
 $LIBRARY_LIST
 $PROGRAM_LIST
 $SUBSYSTEM_LIST
+autodetect
 fontconfig
 memory_poisoning
 neon_clobber_test
@@ -3579,13 +3581,19 @@ for e in $env; do
 eval "export $e"
 done
 
+if disabled autodetect; then
+disable_weak $EXTERNAL_AUTODETECT_LIBRARY_LIST
+disable_weak $HWACCEL_AUTODETECT_LIBRARY_LIST
+fi
 # Mark specifically enabled, but normally autodetected libraries as requested.
 for lib in $AUTODETECT_LIBS; do
 enabled $lib && request $lib
 done
 #TODO: switch to $AUTODETECT_LIBS when $THREADS_LIST is supported the same way
-enable_weak $EXTERNAL_AUTODETECT_LIBRARY_LIST
-enable_weak $HWACCEL_AUTODETECT_LIBRARY_LIST
+if ! disabled autodetect; then
+enable_weak $EXTERNAL_AUTODETECT_LIBRARY_LIST
+enable_weak $HWACCEL_AUTODETECT_LIBRARY_LIST
+fi
 
 disabled logging && logfile=/dev/null
 
-- 
2.13.3



signature.asc
Description: PGP signature
___
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-28 Thread Tyler Jones
> > --- 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.

You're probably right. It's changed now.

> > @@ -1252,6 +1270,7 @@ static av_cold int vorbis_encode_close(AVCodecContext 
> > *avctx)
> >  ff_mdct_end(&venc->mdct[1]);
> >  ff_af_queue_close(&venc->afq);
> >  ff_bufqueue_discard_all(&venc->bufqueue);
> > +ff_psy_vorbis_close(venc->vpctx);
> 
> You should pass a pointer to venc->vpctx instead, regardless of what you
> do with the comment above.

I'm not sure I understand what you mean. It is passing a pointer to a
VorbisPsyContext, please see the prototype:

av_cold void ff_psy_vorbis_close(VorbisPsyContext *vpctx);

> > +/**
> > + * Calculate the variance of a block of samples
> > + *
> > + * @param in Array of input samples
> > + * @param length Number of input samples being analyzed
> > + * @return   The variance for the current block
> > + */
> > +static float variance(const float *in, int length)
> > +{
> > +int i;
> > +float mean = 0.0f, square_sum = 0.0f;
> > +
> > +for (i = 0; i < length; i++) {
> > +mean += in[i];
> > +square_sum += in[i] * in[i];
> 
> Can't you use AVFloatDSPContext's scalarproduct_float for square_sum?
> The constrains are lax. 16 byte alignment for in and length a multiple
> of 4. You can pad the buffer if needed to achieve that.

You are correct, it is switched over now.

> > +}
> > +
> > +mean /= length;
> > +return (square_sum - length * mean * mean) / (length - 1);
> > +}
> > +
> > +av_cold int ff_psy_vorbis_init(VorbisPsyContext *vpctx, int sample_rate,
> > +   int channels, int blocks)
> > +{
> > +int crit_freq;
> > +float Q[2] = {.54, 1.31}; // Quality values for maximally flat 
> > cascaded filters
> 
> const float Q[2]

Fixed.

Thank you for catching these mistakes and providing suggestions. A new version
of this patch will be sent soon.

Thanks again,

Tyler Jones


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


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

2017-07-28 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 
---
V4: Use AVFloatDSPContext for variance calculation
Correctly change quality factors to const
Remove unnecessary malloc and free for VorbisPsyContext

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 | 147 +
 libavcodec/vorbispsy.h |  82 +++
 4 files changed, 253 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..6da5f012c2 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,11 @@ 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]);
+if ((ret = ff_psy_vorbis_init(&venc->vpctx, venc->sample_rate,
+  venc->channels, blocks, venc->fdsp)) < 0)
+return ret;
+
 return 0;
 }
 
@@ -1078,15 +1086,17 @@ static void move_audio(vorbis_enc_context *venc, int 
sf_size)
 av_frame_free(&cur);
 }
 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 +1131,14 @@ 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(&venc->mdct[1]);
 ff_af_queue_close(&venc->afq);
 ff_bufqueue_discard_all(&venc->bufqueue);
+ff_psy_vorbis_close(&venc->vpctx);
 
 av_freep(&avctx->extradata);
 
diff --git a/libavcodec/vorbispsy.c b/libavcodec/vorbispsy.c
new file mode 

[FFmpeg-devel] [PATCH V4 2/2] avcodec/vorbisenc: Apply dynamic frame lengths

2017-07-28 Thread Tyler Jones
Additional codebooks are added for shorter 128-sample frames. Changes in
codeword generation are made to handle valid values of 0 that prepend some
codebooks, otherwise books are classified incorrectly and cause unreadable
streams.

A second residue, floor, and mapping is created for short window lengths
so that values are partitioned correctly for transient frames.

Signed-off-by: Tyler Jones 
---
V4: No changes
V3: Switch 'bits[p] == 0' to '!bits[p]' in vlc gen
V2: Fix double arithmetic in window scale

 libavcodec/vorbis.c  |  10 +-
 libavcodec/vorbis_enc_data.h | 289 +++--
 libavcodec/vorbisenc.c   | 424 ++-
 tests/fate/vorbis.mak|   2 +-
 4 files changed, 454 insertions(+), 271 deletions(-)

diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c
index 399020eec5..d8c4b006e7 100644
--- a/libavcodec/vorbis.c
+++ b/libavcodec/vorbis.c
@@ -59,7 +59,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, 
unsigned num)
 unsigned i, j, p, code;
 
 for (p = 0; (bits[p] == 0) && (p < num); ++p)
-;
+codes[p] = 0;
 if (p == num)
 return 0;
 
@@ -78,9 +78,11 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, 
unsigned num)
 
 for (; p < num; ++p) {
 if (bits[p] > 32)
- return AVERROR_INVALIDDATA;
-if (bits[p] == 0)
- continue;
+return AVERROR_INVALIDDATA;
+if (!bits[p]) {
+codes[p] = 0;
+continue;
+}
 // find corresponding exit(node which the tree can grow further from)
 for (i = bits[p]; i > 0; --i)
 if (exit_at_level[i])
diff --git a/libavcodec/vorbis_enc_data.h b/libavcodec/vorbis_enc_data.h
index a51aaec978..eca43dfded 100644
--- a/libavcodec/vorbis_enc_data.h
+++ b/libavcodec/vorbis_enc_data.h
@@ -23,15 +23,78 @@
 
 #include 
 
-static const uint8_t codebook0[] = {
+static const uint8_t floor_128_c0[] = {
+10,  7,  8, 13,  9,  6,  7, 11, 10,  8,  8, 12, 17, 17, 17,
+17,  7,  5,  5,  9,  6,  4,  4,  8,  8,  5,  5,  8, 16, 14,
+13, 16,  7,  5,  5,  7,  6,  3,  3,  5,  8,  5,  4,  7, 14,
+12, 12, 15, 10,  7,  8,  9,  7,  5,  5,  6,  9,  6,  5,  5,
+15, 12,  9, 10,
+};
+
+static const uint8_t floor_128_c1[] = {
+ 8, 13, 17, 17,  8, 11, 17, 17, 11, 13, 17, 17, 17, 17, 17,
+17,  6, 10, 16, 17,  6, 10, 15, 17,  8, 10, 16, 17, 17, 17,
+17, 17,  9, 13, 15, 17,  8, 11, 17, 17, 10, 12, 17, 17, 17,
+17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+17, 17, 17, 17,  6, 11, 15, 17,  7, 10, 15, 17,  8, 10, 17,
+17, 17, 15, 17, 17,  4,  8, 13, 17,  4,  7, 13, 17,  6,  8,
+15, 17, 16, 15, 17, 17,  6, 11, 15, 17,  6,  9, 13, 17,  8,
+10, 17, 17, 15, 17, 17, 17, 16, 17, 17, 17, 12, 14, 15, 17,
+13, 14, 15, 17, 17, 17, 17, 17,  5, 10, 14, 17,  5,  9, 14,
+17,  7,  9, 15, 17, 15, 15, 17, 17,  3,  7, 12, 17,  3,  6,
+11, 17,  5,  7, 13, 17, 12, 12, 17, 17,  5,  9, 14, 17,  3,
+ 7, 11, 17,  5,  8, 13, 17, 13, 11, 16, 17, 12, 17, 17, 17,
+ 9, 14, 15, 17, 10, 11, 14, 17, 16, 14, 17, 17,  8, 12, 17,
+17,  8, 12, 17, 17, 10, 12, 17, 17, 17, 17, 17, 17,  5, 10,
+17, 17,  5,  9, 15, 17,  7,  9, 17, 17, 13, 13, 17, 17,  7,
+11, 17, 17,  6, 10, 15, 17,  7,  9, 15, 17, 12, 11, 17, 17,
+12, 15, 17, 17, 11, 14, 17, 17, 11, 10, 15, 17, 17, 16, 17,
+17,
+};
+
+static const uint8_t floor_128_0sub1[] = {
+ 0,  3,  3,  3,  3,  3,  3,  3,  3,
+};
+
+static const uint8_t floor_128_0sub2[] = {
+ 0,  0,  0,  0,  0,  0,  0,  0,  0,  3,  3,  3,  4,  4,  4,
+ 4,  5,  4,  5,  4,  5,  4,  6,  4,  6,
+};
+
+static const uint8_t floor_128_0sub3[] = {
+ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  3,  5,  3,  5,  3,
+ 5,  4,  5,  4,  5,  5,  5,  5,  6,  5,  6,  5,  6,  5,  6,
+ 5,  6,  5,  7,  8,  9, 11, 13, 13, 13, 13, 13, 13, 13, 13,
+13, 13, 13, 13,
+};
+
+static const uint8_t floor_128_1sub1[] = {
+ 0,  3,  3,  2,  3,  3,  4,  3,  4,
+};
+
+static const uint8_t floor_128_1sub2[] = {
+ 0,  0,  0,  0,  0,  0,  0,  0,  0,  3,  4,  3,  6,  3,  6,
+ 3,  6,  3,  7,  3,  8,  4,  9,  4,  9,
+};
+
+static const uint8_t floor_128_1sub3[] = {
+ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  7,  2,  7,  3,
+ 8,  4,  9,  5,  9,  8, 10, 11, 11, 12, 14, 14, 14, 14, 14,
+14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+13, 13, 13, 13,
+};
+
+static const uint8_t floor_1024_c1[] = {
 2, 10,  8, 14,  7, 12, 11, 14,  1,  5,  3,  7,  4,  9,  7, 13,
 };
 
-static const uint8_t codebook1[] = {
+static const uint8_t floor_1024_c2[] = {
 1,  4,  2,  6,  3,  7,  5,  7,
 };
 
-static const uint8_t codebook2[] = {
+static const uint8_t floor_1024_c3[] = {
  1,  5,  7, 21,  5,  8,  9, 21, 10,  9, 12, 20, 20, 16, 20,
 20,  4,  8, 

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

2017-07-28 Thread James Almer
On 7/28/2017 11:59 AM, Tyler Jones wrote:
>>> --- 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.
> 
> You're probably right. It's changed now.
> 
>>> @@ -1252,6 +1270,7 @@ static av_cold int vorbis_encode_close(AVCodecContext 
>>> *avctx)
>>>  ff_mdct_end(&venc->mdct[1]);
>>>  ff_af_queue_close(&venc->afq);
>>>  ff_bufqueue_discard_all(&venc->bufqueue);
>>> +ff_psy_vorbis_close(venc->vpctx);
>>
>> You should pass a pointer to venc->vpctx instead, regardless of what you
>> do with the comment above.
> 
> I'm not sure I understand what you mean. It is passing a pointer to a
> VorbisPsyContext, please see the prototype:
> 
> av_cold void ff_psy_vorbis_close(VorbisPsyContext *vpctx);

For this version (but not V4) it should have been a pointer to the
pointer in vorbis_enc_context, that is **vpctx. Otherwise, the
av_freep() call in ff_psy_vorbis_close() would have zeroed a copy of
said pointer.

> 
>>> +/**
>>> + * Calculate the variance of a block of samples
>>> + *
>>> + * @param in Array of input samples
>>> + * @param length Number of input samples being analyzed
>>> + * @return   The variance for the current block
>>> + */
>>> +static float variance(const float *in, int length)
>>> +{
>>> +int i;
>>> +float mean = 0.0f, square_sum = 0.0f;
>>> +
>>> +for (i = 0; i < length; i++) {
>>> +mean += in[i];
>>> +square_sum += in[i] * in[i];
>>
>> Can't you use AVFloatDSPContext's scalarproduct_float for square_sum?
>> The constrains are lax. 16 byte alignment for in and length a multiple
>> of 4. You can pad the buffer if needed to achieve that.
> 
> You are correct, it is switched over now.
> 
>>> +}
>>> +
>>> +mean /= length;
>>> +return (square_sum - length * mean * mean) / (length - 1);
>>> +}
>>> +
>>> +av_cold int ff_psy_vorbis_init(VorbisPsyContext *vpctx, int sample_rate,
>>> +   int channels, int blocks)
>>> +{
>>> +int crit_freq;
>>> +float Q[2] = {.54, 1.31}; // Quality values for maximally flat 
>>> cascaded filters
>>
>> const float Q[2]
> 
> Fixed.
> 
> Thank you for catching these mistakes and providing suggestions. A new version
> of this patch will be sent soon.
> 
> Thanks again,
> 
> Tyler Jones
> 
> 
> 
> ___
> 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 1/2] avcodec/dirac_vlc: Fix invalid shift

2017-07-28 Thread Michael Niedermayer
On Fri, Jul 28, 2017 at 02:44:34AM +0100, Rostislav Pehlivanov wrote:
> 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.

you mean "res_bits = res = 0;" ?

if so ill push that

thx

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

I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates


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


Re: [FFmpeg-devel] [PATCH] libavcodec/mips: Improve avc dequant-idct luma dc msa function

2017-07-28 Thread Michael Niedermayer
On Fri, Jul 28, 2017 at 11:17:26AM +, Manojkumar Bhosale wrote:
> LGTM

will be in my next git push

thx

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

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


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


Re: [FFmpeg-devel] [PATCH 7/8] build: simplify weak-enabling of autodetected libraries

2017-07-28 Thread Michael Niedermayer
On Fri, Jul 28, 2017 at 01:51:44PM +0200, Clément Bœsch wrote:
> From: Clément Bœsch 
> 
> ---
>  configure | 18 +++---
>  1 file changed, 3 insertions(+), 15 deletions(-)

breaks mingw64 build

configure --cc='ccache x86_64-w64-mingw32-gcc'   --enable-xmm-clobber-test  
--samples=/home/michael/fatesamples/fate/fate-suite/ --arch=x86_64 
--target-os=mingw32 --cross-prefix=x86_64-w64-mingw32- --enable-gpl 
--target_exec=wine
...

src/libavdevice/sdl2.c:26:17: fatal error: SDL.h: No such file or directory
 #include 
 ^
compilation terminated.
CC  libavdevice/utils.o
make: *** [libavdevice/sdl2.o] Error 1
make: *** Waiting for unfinished jobs
src/libavdevice/dshow.c: In function ‘dshow_show_filter_properties’:
src/libavdevice/dshow.c:516:5: warning: missing braces around initializer 
[-Wmissing-braces]
 FILTER_INFO filter_info = {0}; /* a warning on this line is false positive 
GCC bug 53119 AFAICT */
 ^
src/libavdevice/dshow.c:516:5: warning: (near initialization for 
‘filter_info.achName’) [-Wmissing-braces]

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


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


[FFmpeg-devel] [PATCH] build: Allow libffmpeg to be built for Chromium-based browsers

2017-07-28 Thread James Le Cuirot
Google Chrome ships with support for proprietary codecs and Chromium
can be built with support for them, either using the bundled FFmpeg or
a system copy.

This leaves other browsers such as Opera and Vivaldi, which ship with
a libffmpeg that does not support proprietary codecs, presumably for
cost reasons. These projects actively encourage users to swap this
library with an alternative.

Official instructions say to download the very large Chromium tarball
and use its build system to configure and build libffmpeg. This
involves building a lot of extra baggage that simply isn't needed
because libffmpeg is literally just the main FFmpeg libraries
combined. Binary-based distributions can easily take this hit but for
source-based distributions, this hit is passed onto the end user.

This Makefile snippet allows libffmpeg to be created without the help
of Chromium's build system. It uses the CONFIG_SHARED variable to
decide whether to link the FFmpeg libraries statically or
dynamically. In the latter case, libffmpeg is just a wrapper with no
symbols of its own.

At this current time, recent Chromium versions support the 3.x ABI
with just one major exception. Unless built against the system copy,
-DFF_API_CONVERGENCE_DURATION=0 is used. This means that, other
factors notwithstanding, full compatibility will not be seen until
libavcodec hits 59. This is why I have provided the ability to link
FFmpeg statically.

This is how to build libffmpeg for a recent Chromium-based release:

 ./configure --disable-shared --enable-static --enable-pic 
--extra-cflags="-DFF_API_CONVERGENCE_DURATION=0"
 make libffmpeg
 make install-libffmpeg

I have tested this with FFmpeg 3.3.2 and latest master. I have tested
it against current Opera Stable, Opera Beta, Opera Developer, Vivaldi
Stable, and Vivaldi Snapshot.
---
 Makefile  |  1 +
 ffbuild/libffmpeg.mak | 21 +
 2 files changed, 22 insertions(+)
 create mode 100644 ffbuild/libffmpeg.mak

diff --git a/Makefile b/Makefile
index 29870d7..1e267e7 100644
--- a/Makefile
+++ b/Makefile
@@ -65,6 +65,7 @@ all: all-yes
 
 include $(SRC_PATH)/tools/Makefile
 include $(SRC_PATH)/ffbuild/common.mak
+include $(SRC_PATH)/ffbuild/libffmpeg.mak
 
 FF_EXTRALIBS := $(FFEXTRALIBS)
 FF_DEP_LIBS  := $(DEP_LIBS)
diff --git a/ffbuild/libffmpeg.mak b/ffbuild/libffmpeg.mak
new file mode 100644
index 000..992cf3c
--- /dev/null
+++ b/ffbuild/libffmpeg.mak
@@ -0,0 +1,21 @@
+LIBFFMPEG = $(SLIBPREF)ffmpeg$(SLIBSUF)
+LIBFFMPEG_LINK = $(LD) -shared -Wl,-soname,$(LIBFFMPEG) -Wl,-Bsymbolic 
-Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--gc-sections $(LDFLAGS) $(LDLIBFLAGS) 
-o $(LIBFFMPEG)
+
+libffmpeg-: libavcodec/$(LIBPREF)avcodec$(LIBSUF) 
libavformat/$(LIBPREF)avformat$(LIBSUF) libavutil/$(LIBPREF)avutil$(LIBSUF) 
libswresample/$(LIBPREF)swresample$(LIBSUF)
+   $(LIBFFMPEG_LINK) -Wl,--whole-archive $^ -Wl,--no-whole-archive 
$(FFEXTRALIBS)
+
+libffmpeg-yes: libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) 
libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavutil/$(SLIBPREF)avutil$(SLIBSUF)
+   $(LIBFFMPEG_LINK) -Wl,--no-as-needed -lavcodec -lavformat -lavutil
+
+$(LIBFFMPEG): libffmpeg-$(CONFIG_SHARED)
+libffmpeg: $(LIBFFMPEG)
+
+install-libffmpeg: $(LIBFFMPEG)
+   $(Q)mkdir -p "$(SHLIBDIR)/chromium"
+   $(INSTALL) -m 755 $< "$(SHLIBDIR)/chromium/$<"
+   $(STRIP) "$(SHLIBDIR)/chromium/$<"
+
+uninstall-libffmpeg:
+   $(RM) "$(SHLIBDIR)/chromium/$(LIBFFMPEG)"
+
+.PHONY: libffmpeg libffmpeg-* install-libffmpeg
-- 
2.13.1

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


[FFmpeg-devel] [PATCH] speedhq: fix behavior of single-field decoding

2017-07-28 Thread Steinar H. Gunderson
The height convention for decoding frames with only a single field made sense
for compatibility with legacy decoders, but doesn't really match the convention
used by NDI, which is the primary (only?) user. Thus, change it to simply
assuming that if the two fields overlap, the frame is meant to be a single
field and the frame height matches the field height.
---
 libavcodec/speedhq.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c
index 60efb0222b..eca45beb67 100644
--- a/libavcodec/speedhq.c
+++ b/libavcodec/speedhq.c
@@ -448,12 +448,15 @@ static int speedhq_decode_frame(AVCodecContext *avctx,
 frame->key_frame = 1;
 
 if (second_field_offset == 4) {
-/*
- * Overlapping first and second fields is used to signal
- * encoding only a single field (the second field then comes
- * as a separate, later frame).
- */
-frame->height >>= 1;
+   /*
+* Overlapping first and second fields is used to signal
+* encoding only a single field. In this case, "height"
+* is ambiguous; it could mean either the height of the
+* frame as a whole, or of the field. The former would make
+* more sense for compatibility with legacy decoders,
+* but this matches the convention used in NDI, which is
+* the primary user of this trick.
+*/
 if ((ret = decode_speedhq_field(s, buf, buf_size, frame, 0, 4, 
buf_size, 1)) < 0)
 return ret;
 } else {
-- 
2.13.3

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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/rtmppkt: Convert ff_amf_tag_size() to bytestream2

2017-07-28 Thread James Almer
On 7/28/2017 10:47 AM, Michael Niedermayer wrote:
> Fixes: out of array accesses
> Fixes: crash-9238fa9e8d4fde3beda1f279626f53812cb001cb-SEGV
> 
> Found-by: JunDong Xie of Ant-financial Light-Year Security Lab
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/rtmppkt.c | 60 
> ++-
>  1 file changed, 40 insertions(+), 20 deletions(-)
> 
> diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
> index 833a3dbade..752d92a42b 100644
> --- a/libavformat/rtmppkt.c
> +++ b/libavformat/rtmppkt.c
> @@ -433,50 +433,70 @@ void ff_rtmp_packet_destroy(RTMPPacket *pkt)
>  pkt->size = 0;
>  }
>  
> -int ff_amf_tag_size(const uint8_t *data, const uint8_t *data_end)
> +static int ff_amf_tag_skip(GetByteContext *gb)

It's static, so no ff_ prefix.

>  {
> -const uint8_t *base = data;
>  AMFDataType type;
>  unsigned nb   = -1;
>  int parse_key = 1;
>  
> -if (data >= data_end)
> +if (bytestream2_get_bytes_left(gb) < 1)
>  return -1;
> -switch ((type = *data++)) {
> -case AMF_DATA_TYPE_NUMBER:  return 9;
> -case AMF_DATA_TYPE_BOOL:return 2;
> -case AMF_DATA_TYPE_STRING:  return 3 + AV_RB16(data);
> -case AMF_DATA_TYPE_LONG_STRING: return 5 + AV_RB32(data);
> -case AMF_DATA_TYPE_NULL:return 1;
> -case AMF_DATA_TYPE_DATE:return 11;
> +
> +switch ((type = bytestream2_get_byte(gb))) {

type = bytestream2_get_byte(gb);
switch(type) {

> +case AMF_DATA_TYPE_NUMBER:  bytestream2_get_be64(gb); return 0;
> +case AMF_DATA_TYPE_BOOL:bytestream2_get_byte(gb); return 0;
> +case AMF_DATA_TYPE_STRING:
> +bytestream2_skip(gb, bytestream2_get_be16(gb));
> +return 0;
> +case AMF_DATA_TYPE_LONG_STRING:
> +bytestream2_skip(gb, bytestream2_get_be32(gb));
> +return 0;
> +case AMF_DATA_TYPE_NULL:return 0;
> +case AMF_DATA_TYPE_DATE:bytestream2_skip(gb, 10); return 0;

Use separate lines for all the above or reorder them, for readability's
sake.

>  case AMF_DATA_TYPE_ARRAY:
>  parse_key = 0;
>  case AMF_DATA_TYPE_MIXEDARRAY:
> -nb = bytestream_get_be32(&data);
> +nb = bytestream2_get_be32(gb);
>  case AMF_DATA_TYPE_OBJECT:
>  while (nb-- > 0 || type != AMF_DATA_TYPE_ARRAY) {
>  int t;
>  if (parse_key) {
> -int size = bytestream_get_be16(&data);
> +int size = bytestream2_get_be16(gb);
>  if (!size) {
> -data++;
> +bytestream2_get_byte(gb);
>  break;
>  }
> -if (size < 0 || size >= data_end - data)
> +if (size < 0 || size >= bytestream2_get_bytes_left(gb))
>  return -1;
> -data += size;
> +bytestream2_skip(gb, size);
>  }
> -t = ff_amf_tag_size(data, data_end);
> -if (t < 0 || t >= data_end - data)
> +t = ff_amf_tag_skip(gb);
> +if (t < 0 || bytestream2_get_bytes_left(gb) <= 0)
>  return -1;
> -data += t;
>  }
> -return data - base;
> -case AMF_DATA_TYPE_OBJECT_END:  return 1;
> +return 0;
> +case AMF_DATA_TYPE_OBJECT_END:  return 0;
>  default:return -1;
>  }
>  }
>  
> +int ff_amf_tag_size(const uint8_t *data, const uint8_t *data_end)
> +{
> +GetByteContext gb;
> +int ret;
> +
> +if (data >= data_end)
> +return -1;
> +
> +bytestream2_init(&gb, data, data_end - data);
> +
> +ret = ff_amf_tag_skip(&gb);
> +if (ret < 0 || bytestream2_get_bytes_left(&gb) <= 0)
> +return -1;
> +av_assert0(bytestream2_tell(&gb) >= 0 && bytestream2_tell(&gb) <= 
> data_end - data);
> +return bytestream2_tell(&gb);
> +}
> +
>  int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end,
> const uint8_t *name, uint8_t *dst, int dst_size)
>  {
> 

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


Re: [FFmpeg-devel] [PATCH] build: Allow libffmpeg to be built for Chromium-based browsers

2017-07-28 Thread Hendrik Leppkes
On Fri, Jul 28, 2017 at 12:07 PM, James Le Cuirot  wrote:
> Google Chrome ships with support for proprietary codecs and Chromium
> can be built with support for them, either using the bundled FFmpeg or
> a system copy.
>
> This leaves other browsers such as Opera and Vivaldi, which ship with
> a libffmpeg that does not support proprietary codecs, presumably for
> cost reasons. These projects actively encourage users to swap this
> library with an alternative.
>
> Official instructions say to download the very large Chromium tarball
> and use its build system to configure and build libffmpeg. This
> involves building a lot of extra baggage that simply isn't needed
> because libffmpeg is literally just the main FFmpeg libraries
> combined. Binary-based distributions can easily take this hit but for
> source-based distributions, this hit is passed onto the end user.
>
> This Makefile snippet allows libffmpeg to be created without the help
> of Chromium's build system. It uses the CONFIG_SHARED variable to
> decide whether to link the FFmpeg libraries statically or
> dynamically. In the latter case, libffmpeg is just a wrapper with no
> symbols of its own.
>
> At this current time, recent Chromium versions support the 3.x ABI
> with just one major exception. Unless built against the system copy,
> -DFF_API_CONVERGENCE_DURATION=0 is used. This means that, other
> factors notwithstanding, full compatibility will not be seen until
> libavcodec hits 59. This is why I have provided the ability to link
> FFmpeg statically.
>
> This is how to build libffmpeg for a recent Chromium-based release:
>
>

I don't think ffmpeg is the right place to maintain special makefiles
for Chromium.

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


Re: [FFmpeg-devel] [PATCH] build: Allow libffmpeg to be built for Chromium-based browsers

2017-07-28 Thread Dominik 'Rathann' Mierzejewski
On Saturday, 29 July 2017 at 00:20, Hendrik Leppkes wrote:
> On Fri, Jul 28, 2017 at 12:07 PM, James Le Cuirot  wrote:
[...]
> > This Makefile snippet allows libffmpeg to be created without the help
> > of Chromium's build system. It uses the CONFIG_SHARED variable to
> > decide whether to link the FFmpeg libraries statically or
> > dynamically. In the latter case, libffmpeg is just a wrapper with no
> > symbols of its own.
[...]
> I don't think ffmpeg is the right place to maintain special makefiles
> for Chromium.

I concur. Instead, Chromium should be fixed to link against individual
FFmpeg libraries properly.

Regards,
Dominik 
-- 
Fedora   https://getfedora.org  |  RPMFusion   http://rpmfusion.org
There should be a science of discontent. People need hard times and
oppression to develop psychic muscles.
-- from "Collected Sayings of Muad'Dib" by the Princess Irulan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/vp9: tile threading v1

2017-07-28 Thread Michael Niedermayer
On Fri, Jul 28, 2017 at 10:31:26PM +0700, Ilia Valiakhmetov wrote:
> Signed-off-by: Ilia Valiakhmetov 
> ---
>  libavcodec/vp9.c | 441 +++-
>  libavcodec/vp9_mc_template.c | 126 ++--
>  libavcodec/vp9block.c| 470 
> +--
>  libavcodec/vp9dec.h  |  97 ++---
>  libavcodec/vp9mvs.c  |  97 -
>  libavcodec/vp9recon.c|  97 -
>  6 files changed, 759 insertions(+), 569 deletions(-)

breaks build with mips-linux-gnu-gcc-4.4 (Debian 4.4.5-8) 4.4.5

In file included from src/libavcodec/vp9data.h:28,
 from src/libavcodec/vp9.c:33:
src/libavcodec/vp9dec.h:242: error: redefinition of typedef ‘VP9TileData’
src/libavcodec/vp9dec.h:87: note: previous declaration of ‘VP9TileData’ was here
src/libavcodec/vp9.c: In function ‘decode_tiles’:
src/libavcodec/vp9.c:1142: warning: ISO C90 forbids mixed declarations and code
src/libavcodec/vp9.c:1190: warning: ISO C90 forbids mixed declarations and code
src/libavcodec/vp9.c: In function ‘vp9_decode_frame’:
src/libavcodec/vp9.c:1252: warning: ‘pkt_pts’ is deprecated (declared at 
src/libavutil/frame.h:302)
src/libavcodec/vp9.c:1378: warning: ISO C90 forbids mixed declarations and code
src/libavcodec/vp9.c:1384: warning: ISO C90 forbids mixed declarations and code
make: *** [libavcodec/vp9.o] Error 1

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

Does the universe only have a finite lifespan? No, its going to go on
forever, its just that you wont like living in it. -- Hiranya Peiri


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


Re: [FFmpeg-devel] [PATCH] build: Allow libffmpeg to be built for Chromium-based browsers

2017-07-28 Thread Ivan Kalvachev
On 7/29/17, Dominik 'Rathann' Mierzejewski  wrote:
> On Saturday, 29 July 2017 at 00:20, Hendrik Leppkes wrote:
>> On Fri, Jul 28, 2017 at 12:07 PM, James Le Cuirot 
>> wrote:
> [...]
>> > This Makefile snippet allows libffmpeg to be created without the help
>> > of Chromium's build system. It uses the CONFIG_SHARED variable to
>> > decide whether to link the FFmpeg libraries statically or
>> > dynamically. In the latter case, libffmpeg is just a wrapper with no
>> > symbols of its own.
> [...]
>> I don't think ffmpeg is the right place to maintain special makefiles
>> for Chromium.
>
> I concur. Instead, Chromium should be fixed to link against individual
> FFmpeg libraries properly.

To be honest, I do not find the combined library such a bad idea.

Actually I think that going this way has been discussed before,
long before Chromium existed.

For example, if you have to dlopen ffmpeg libs, it takes a lot of care
to load all the interlinked libraries in the correct order.
And imagine the fun if you have multiple versions installed.

Having one front-end to load all correct libraries is
logical improvement and simplification.
This is why Chromium has done it on their own.
This is why FFmpeg should do it too.


Also, the changes are isolated to a separate file in the build system,
it should not interfere with normal build process or merges.

I do however object on hardcoding "chromium" codepaths in it.

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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/rtmppkt: Convert ff_amf_tag_size() to bytestream2

2017-07-28 Thread Michael Niedermayer
On Fri, Jul 28, 2017 at 07:11:35PM -0300, James Almer wrote:
> On 7/28/2017 10:47 AM, Michael Niedermayer wrote:
> > Fixes: out of array accesses
> > Fixes: crash-9238fa9e8d4fde3beda1f279626f53812cb001cb-SEGV
> > 
> > Found-by: JunDong Xie of Ant-financial Light-Year Security Lab
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/rtmppkt.c | 60 
> > ++-
> >  1 file changed, 40 insertions(+), 20 deletions(-)
> > 
> > diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
> > index 833a3dbade..752d92a42b 100644
> > --- a/libavformat/rtmppkt.c
> > +++ b/libavformat/rtmppkt.c
> > @@ -433,50 +433,70 @@ void ff_rtmp_packet_destroy(RTMPPacket *pkt)
> >  pkt->size = 0;
> >  }
> >  
> > -int ff_amf_tag_size(const uint8_t *data, const uint8_t *data_end)
> > +static int ff_amf_tag_skip(GetByteContext *gb)
> 
> It's static, so no ff_ prefix.
> 
> >  {
> > -const uint8_t *base = data;
> >  AMFDataType type;
> >  unsigned nb   = -1;
> >  int parse_key = 1;
> >  
> > -if (data >= data_end)
> > +if (bytestream2_get_bytes_left(gb) < 1)
> >  return -1;
> > -switch ((type = *data++)) {
> > -case AMF_DATA_TYPE_NUMBER:  return 9;
> > -case AMF_DATA_TYPE_BOOL:return 2;
> > -case AMF_DATA_TYPE_STRING:  return 3 + AV_RB16(data);
> > -case AMF_DATA_TYPE_LONG_STRING: return 5 + AV_RB32(data);
> > -case AMF_DATA_TYPE_NULL:return 1;
> > -case AMF_DATA_TYPE_DATE:return 11;
> > +
> > +switch ((type = bytestream2_get_byte(gb))) {
> 
> type = bytestream2_get_byte(gb);
> switch(type) {
> 
> > +case AMF_DATA_TYPE_NUMBER:  bytestream2_get_be64(gb); return 0;
> > +case AMF_DATA_TYPE_BOOL:bytestream2_get_byte(gb); return 0;
> > +case AMF_DATA_TYPE_STRING:
> > +bytestream2_skip(gb, bytestream2_get_be16(gb));
> > +return 0;
> > +case AMF_DATA_TYPE_LONG_STRING:
> > +bytestream2_skip(gb, bytestream2_get_be32(gb));
> > +return 0;
> > +case AMF_DATA_TYPE_NULL:return 0;
> > +case AMF_DATA_TYPE_DATE:bytestream2_skip(gb, 10); return 0;
> 
> Use separate lines for all the above or reorder them, for readability's
> sake.

changes made
applied

thanks

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

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus


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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/rtmppkt: Convert ff_amf_get_field_value() to bytestream2

2017-07-28 Thread Michael Niedermayer
On Fri, Jul 28, 2017 at 03:47:05PM +0200, Michael Niedermayer wrote:
> Fixes: out of array accesses
> 

> The new function uses ff_ prefix even though its static to ease future
> changes toward bytestream2

applied without this and also the ff_ prefix removed as requested
for the other patch, so its consistent

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

"I am not trying to be anyone's saviour, I'm trying to think about the
 future and not be sad" - Elon Musk



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/takdec: Fix integer overflow in decode_subframe()

2017-07-28 Thread Michael Niedermayer
On Thu, Jul 27, 2017 at 11:49:26PM +0200, Michael Niedermayer wrote:
> 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(-)

patchset applied

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

Never trust a computer, one day, it may think you are the virus. -- Compn


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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/rtmppkt: Convert ff_amf_get_field_value() to bytestream2

2017-07-28 Thread James Almer
On 7/28/2017 10:57 PM, Michael Niedermayer wrote:
> On Fri, Jul 28, 2017 at 03:47:05PM +0200, Michael Niedermayer wrote:
>> Fixes: out of array accesses
>>
> 
>> The new function uses ff_ prefix even though its static to ease future
>> changes toward bytestream2
> 
> applied without this and also the ff_ prefix removed as requested
> for the other patch, so its consistent

I had actually not looked at this patch when i wrote that suggestion.

I'm not sure how the ff_ prefix would ease future changes to bytestream2
with a static function, but if you think it's worth doing then you can
keep it. It was mostly a nit.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/atrac3p: use float_dsp in ff_atrac3p_power_compensation

2017-07-28 Thread James Almer
On 7/20/2017 4:01 PM, James Almer wrote:
> Signed-off-by: James Almer 
> ---
> Fate passes, so i guess the aligment requirements are met.
> 
>  libavcodec/atrac3plus.h|  5 +++--
>  libavcodec/atrac3plusdec.c | 36 ++--
>  libavcodec/atrac3plusdsp.c |  8 
>  3 files changed, 25 insertions(+), 24 deletions(-)

Will push soon unless someone objects.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avutil/frame: allow only one element per type in frame side data

2017-07-28 Thread James Almer
On 7/25/2017 9:10 PM, James Almer wrote:
> Same rationale as with packet side data, it was never meant to do otherwise
> as av_frame_get_side_data returns the first entry it finds of a given type.
> 
> Based on code from libavformat's av_stream_add_side_data().
> 
> Signed-off-by: James Almer 
> ---
>  libavutil/frame.c | 14 ++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index 24d5d5f184..c41d4be8cc 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -638,10 +638,24 @@ static AVFrameSideData *frame_new_side_data(AVFrame 
> *frame,
>  AVBufferRef *buf)
>  {
>  AVFrameSideData *ret, **tmp;
> +int i;
>  
>  if (!buf)
>  return NULL;
>  
> +for (i = 0; i < frame->nb_side_data; i++) {
> +AVFrameSideData *sd = frame->side_data[i];
> +
> +if (sd->type == type) {
> +av_buffer_unref(&sd->buf);
> +av_dict_free(&sd->metadata);
> +sd->buf  = buf;
> +sd->data = sd->buf->data;
> +sd->size = buf->size;
> +return sd;
> +}
> +}
> +
>  if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1)
>  goto fail;

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