Re: [FFmpeg-devel] swscale : add bitexact conv for grayf32 and gray16 to f32 conv

2018-09-17 Thread Martin Vignali
> also, have you tried adding a small constant to tmp ?
> i would expect that this or a similar operation would allow moving
> away from all "unstable" points without really changing the output in a
> relevant way.
>
>
Can't find an op, in mult mode, in order to not raise the assert
But if i use add calc instead of mult,
I can have a bigger tolerance without raising the assert

In 8 bits mode
Tolerance
0.1 : pass
0.0001 : fail for i = 1
0.001 : fail for i in [1, 2, 4, 8]
0.01 : fail for i in [1, 2, 4, 8, 16, 32, 64]

In 16 bits mode
0.1 : pass
0.0001 : fail for i in [1, 257, 259, 261, 263, 265, 267, 269, 271,
273, 275, 277, 279, 281, 65407]

using this code :
#define assert_stable_float(x) av_assert0((float)(x+0.1) ==
(float)(x-0.1))
static void inline fill_uint_to_float_lut(SwsContext *c, int bitdepth) {
static const double float_mult8 = 1.0 / 255.0;
static const double float_mult16 = 1.0 / 65535.0;
int i;
double tmp = 0.;

if (bitdepth == 8) { /*! fill uint8 to float lut */
for (i = 0; i < 256; ++i){
c->uint2float_lut[i] = (float)tmp;
tmp += float_mult8;
assert_stable_float(tmp);
}
} else if (bitdepth == 16) { /*! fill uint16 to float lut */
for (i = 0; i < 65536; ++i){
c->uint2float_lut[i] = (float)tmp;
tmp += float_mult16;
assert_stable_float(tmp);
}
} else { /*! unsupported bitdepth */
av_assert0(0);
}
}


Do you think 0.1, is enough for stable result in each supported
platform ?

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


[FFmpeg-devel] [PATCH] avformat/dashenc: Format VP9 level as decimal instead of hexadecimal

2018-09-17 Thread Karthick J
From: Karthick Jeyapal 

Commit ID 63c69d51c7532fb6c2460076329b50ec51a0f290 fixed the bug in vpcc, 
get_vp9_level() function, causing this change.
---
 libavformat/dashenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 9a33321..f429ebc 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -211,7 +211,7 @@ static void set_vp9_codec_str(AVFormatContext *s, 
AVCodecParameters *par,
 VPCC vpcc;
 int ret = ff_isom_get_vpcc_features(s, par, frame_rate, &vpcc);
 if (ret == 0) {
-av_strlcatf(str, size, "vp09.%02x.%02x.%02x",
+av_strlcatf(str, size, "vp09.%02x.%02d.%02x",
 vpcc.profile, vpcc.level, vpcc.bitdepth);
 } else {
 // Default to just vp9 in case of error while finding out profile or 
level
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH] avformat/dashenc: Format VP9 level as decimal instead of hexadecimal

2018-09-17 Thread Hendrik Leppkes
On Mon, Sep 17, 2018 at 9:28 AM Karthick J  wrote:
>
> From: Karthick Jeyapal 
>
> Commit ID 63c69d51c7532fb6c2460076329b50ec51a0f290 fixed the bug in vpcc, 
> get_vp9_level() function, causing this change.
> ---
>  libavformat/dashenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 9a33321..f429ebc 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -211,7 +211,7 @@ static void set_vp9_codec_str(AVFormatContext *s, 
> AVCodecParameters *par,
>  VPCC vpcc;
>  int ret = ff_isom_get_vpcc_features(s, par, frame_rate, &vpcc);
>  if (ret == 0) {
> -av_strlcatf(str, size, "vp09.%02x.%02x.%02x",
> +av_strlcatf(str, size, "vp09.%02x.%02d.%02x",
>  vpcc.profile, vpcc.level, vpcc.bitdepth);
>  } else {
>  // Default to just vp9 in case of error while finding out profile or 
> level

Shouldn't all of those be decimals, instead of hex? For profile its
never going to matter since the values are all low, but bitdepth
should be 10 instead of 0A.

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/zmbv: Check that the raw input is large enough to contain MVs or an intra frame

2018-09-17 Thread Paul B Mahol
On 9/17/18, Michael Niedermayer  wrote:
> On Sun, Sep 16, 2018 at 10:16:05AM +0200, Paul B Mahol wrote:
>> On 9/16/18, Michael Niedermayer  wrote:
>> > Fixes: Timeout
>> > Fixes:
>> > 10182/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZMBV_fuzzer-6245951174344704
>> >
>> > Found-by: continuous fuzzing process
>> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>> > Signed-off-by: Michael Niedermayer 
>> > ---
>> >  libavcodec/zmbv.c | 11 ++-
>> >  1 file changed, 10 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
>> > index 9e27a2caad..1133bdf7ba 100644
>> > --- a/libavcodec/zmbv.c
>> > +++ b/libavcodec/zmbv.c
>> > @@ -409,6 +409,7 @@ static int decode_frame(AVCodecContext *avctx, void
>> > *data, int *got_frame, AVPac
>> >  int zret = Z_OK; // Zlib return code
>> >  int len = buf_size;
>> >  int hi_ver, lo_ver, ret;
>> > +int min_size;
>> >
>> >  /* parse header */
>> >  if (len < 1)
>> > @@ -510,7 +511,11 @@ static int decode_frame(AVCodecContext *avctx,
>> > void
>> > *data, int *got_frame, AVPac
>> >  memset(c->prev, 0, avctx->width * avctx->height * (c->bpp /
>> > 8));
>> >  c->decode_intra= decode_intra;
>> >  }
>> > -
>> > +if (c->flags & ZMBV_KEYFRAME) {
>> > +min_size = avctx->width * avctx->height * (c->bpp / 8);
>>
>> This is pure guessing?
>
> theres a bit of logic behind it but ultimatly yes, its guessing
>
> The logic
> If the input is smaller for a raw keyframe the buffer would not be
> fully updated.
> If the buffer is not fully updated then this should be a inter frame
> not a keyframe.
>
> The 2nd part, is that all files i found
> (http://samples.mplayerhq.hu/V-codecs/ZMBV/)
> follow that assumtation
>
> The 3rd is that the source code for zmbv i could fine (dosbox)
> seems to never write uncompressed keyframes.
>
> The 4th is that the multimedia wiki doesnt seem to say anything about the
> uncompressed keyframe size
>
> so i thought its better to use this as the minimal size and avoid the
> issue the fuzzer found.
>
> Its quite possible that i have missed something.
> Also we could ask for a sample in the failure case or do something else if
> you
> have some other suggestion ?

Yes, drop patch and leave code as is.

Also why this codec needs fuzzing?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 2/2] avformat/dashenc: Format VP9 bitdepth as decimal instead of Hexadecimal

2018-09-17 Thread Karthick J
From: Karthick Jeyapal 

For example bitdepth should be printed as 10 instead of 0A. Thanks to Hendrik 
Leppkes for pointing this out
---
 libavformat/dashenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index f429ebc..1a201c3 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -211,7 +211,7 @@ static void set_vp9_codec_str(AVFormatContext *s, 
AVCodecParameters *par,
 VPCC vpcc;
 int ret = ff_isom_get_vpcc_features(s, par, frame_rate, &vpcc);
 if (ret == 0) {
-av_strlcatf(str, size, "vp09.%02x.%02d.%02x",
+av_strlcatf(str, size, "vp09.%02x.%02d.%02d",
 vpcc.profile, vpcc.level, vpcc.bitdepth);
 } else {
 // Default to just vp9 in case of error while finding out profile or 
level
-- 
2.7.4

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


[FFmpeg-devel] [PATCH v2 1/2] avformat/dashenc: Format VP9 level as decimal instead of hexadecimal

2018-09-17 Thread Karthick J
From: Karthick Jeyapal 

Commit ID 63c69d51c7532fb6c2460076329b50ec51a0f290 fixed the bug in vpcc, 
get_vp9_level() function, causing this change.
---
 libavformat/dashenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 9a33321..f429ebc 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -211,7 +211,7 @@ static void set_vp9_codec_str(AVFormatContext *s, 
AVCodecParameters *par,
 VPCC vpcc;
 int ret = ff_isom_get_vpcc_features(s, par, frame_rate, &vpcc);
 if (ret == 0) {
-av_strlcatf(str, size, "vp09.%02x.%02x.%02x",
+av_strlcatf(str, size, "vp09.%02x.%02d.%02x",
 vpcc.profile, vpcc.level, vpcc.bitdepth);
 } else {
 // Default to just vp9 in case of error while finding out profile or 
level
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH] avformat/dashenc: Format VP9 level as decimal instead of hexadecimal

2018-09-17 Thread Jeyapal, Karthick

On 9/17/18 1:12 PM, Hendrik Leppkes wrote:
> On Mon, Sep 17, 2018 at 9:28 AM Karthick J  wrote:
>>
>> From: Karthick Jeyapal 
>>
>> Commit ID 63c69d51c7532fb6c2460076329b50ec51a0f290 fixed the bug in vpcc, 
>> get_vp9_level() function, causing this change.
>> ---
>>  libavformat/dashenc.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>> index 9a33321..f429ebc 100644
>> --- a/libavformat/dashenc.c
>> +++ b/libavformat/dashenc.c
>> @@ -211,7 +211,7 @@ static void set_vp9_codec_str(AVFormatContext *s, 
>> AVCodecParameters *par,
>>  VPCC vpcc;
>>  int ret = ff_isom_get_vpcc_features(s, par, frame_rate, &vpcc);
>>  if (ret == 0) {
>> -av_strlcatf(str, size, "vp09.%02x.%02x.%02x",
>> +av_strlcatf(str, size, "vp09.%02x.%02d.%02x",
>>  vpcc.profile, vpcc.level, vpcc.bitdepth);
>>  } else {
>>  // Default to just vp9 in case of error while finding out profile 
>> or level
>
> Shouldn't all of those be decimals, instead of hex? For profile its
> never going to matter since the values are all low, but bitdepth
> should be 10 instead of 0A.
You are right. I have sent another patch to fix it. 
Thanks for pointing it out.

Regards,
Karthick
>
> - Hendrik
> ___
> 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] ffmpeg: block output == input for files

2018-09-17 Thread Gyan Doshi

On 07-09-2018 12:21 AM, Gyan Doshi wrote:

On 05-09-2018 06:06 AM, Michael Niedermayer wrote:

On Mon, Sep 03, 2018 at 10:48:45AM +0530, Gyan Doshi wrote:

On 31-08-2018 10:26 AM, Gyan Doshi wrote:

On 31-08-2018 09:57 AM, Gyan Doshi wrote:

On 31-08-2018 04:28 AM, Marton Balint wrote:



Is there any real use case when same source and destination works, so
the option can be used?

If not, then just make ffmpeg fail, like the cp command fails for 
same

source and destination. I am against adding an option if it has no
known use.


Via the file protocol, not that I know of. Will remove.

Gyan


Revised patch attached.


Ping.


no objections though this solution has limitations, so if someone has a
better idea ...


Looks like no one does. Plan to push tomorrow.


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


[FFmpeg-devel] [PATCH] avcodec/mips: [loongson] refine ff_vc1_inv_trans_8x8_mmi.

2018-09-17 Thread Shiyou Yin
Combined 1st and 2nd loop into one inline asm in function 
ff_vc1_inv_trans_8x8_mmi to
reduce memory operation, and made some small optimization in 
ff_vc1_inv_trans_4x8_mmi.
---
 libavcodec/mips/vc1dsp_mmi.c | 227 ++-
 1 file changed, 94 insertions(+), 133 deletions(-)

diff --git a/libavcodec/mips/vc1dsp_mmi.c b/libavcodec/mips/vc1dsp_mmi.c
index 80778a5..db314de 100644
--- a/libavcodec/mips/vc1dsp_mmi.c
+++ b/libavcodec/mips/vc1dsp_mmi.c
@@ -30,10 +30,10 @@
 #define VC1_INV_TRANCS_8_TYPE1(o1, o2, r1, r2, r3, r4, c0)  \
 "li %[tmp0],"#r1" \n\t" \
 "mtc1   %[tmp0],%[ftmp13] \n\t" \
-"pshufh %[ftmp13],  %[ftmp13],  %[ftmp23] \n\t" \
+"punpcklwd  %[ftmp13],  %[ftmp13],  %[ftmp13] \n\t" \
 "li %[tmp0],"#r2" \n\t" \
 "mtc1   %[tmp0],%[ftmp14] \n\t" \
-"pshufh %[ftmp14],  %[ftmp14],  %[ftmp23] \n\t" \
+"punpcklwd  %[ftmp14],  %[ftmp14],  %[ftmp14] \n\t" \
 "pmaddhw%[ftmp1],   %[ftmp5],   %[ftmp13] \n\t" \
 "pmaddhw%[ftmp2],   %[ftmp7],   %[ftmp14] \n\t" \
 "paddw  %[ftmp1],   %[ftmp1],   %[ftmp2]  \n\t" \
@@ -43,10 +43,10 @@
 \
 "li %[tmp0],"#r3" \n\t" \
 "mtc1   %[tmp0],%[ftmp13] \n\t" \
-"pshufh %[ftmp13],  %[ftmp13],  %[ftmp23] \n\t" \
+"punpcklwd  %[ftmp13],  %[ftmp13],  %[ftmp13] \n\t" \
 "li %[tmp0],"#r4" \n\t" \
 "mtc1   %[tmp0],%[ftmp14] \n\t" \
-"pshufh %[ftmp14],  %[ftmp14],  %[ftmp23] \n\t" \
+"punpcklwd  %[ftmp14],  %[ftmp14],  %[ftmp14] \n\t" \
 "pmaddhw%[ftmp3],   %[ftmp9],   %[ftmp13] \n\t" \
 "pmaddhw%[ftmp4],   %[ftmp11],  %[ftmp14] \n\t" \
 "paddw  %[ftmp3],   %[ftmp3],   %[ftmp4]  \n\t" \
@@ -54,14 +54,12 @@
 "pmaddhw%[ftmp13],  %[ftmp12],  %[ftmp14] \n\t" \
 "paddw  %[ftmp4],   %[ftmp4],   %[ftmp13] \n\t" \
 \
+"paddw  %[ftmp1],   %[ftmp1],   "#c0" \n\t" \
+"paddw  %[ftmp2],   %[ftmp2],   "#c0" \n\t" \
 "paddw  %[ftmp13],  %[ftmp1],   %[ftmp3]  \n\t" \
 "psubw  %[ftmp14],  %[ftmp1],   %[ftmp3]  \n\t" \
 "paddw  %[ftmp1],   %[ftmp2],   %[ftmp4]  \n\t" \
 "psubw  %[ftmp3],   %[ftmp2],   %[ftmp4]  \n\t" \
-"paddw  %[ftmp13],  %[ftmp13],  "#c0" \n\t" \
-"paddw  %[ftmp14],  %[ftmp14],  "#c0" \n\t" \
-"paddw  %[ftmp1],   %[ftmp1],   "#c0" \n\t" \
-"paddw  %[ftmp3],   %[ftmp3],   "#c0" \n\t" \
 "psraw  %[ftmp13],  %[ftmp13],  %[ftmp0]  \n\t" \
 "psraw  %[ftmp1],   %[ftmp1],   %[ftmp0]  \n\t" \
 "psraw  %[ftmp14],  %[ftmp14],  %[ftmp0]  \n\t" \
@@ -76,10 +74,10 @@
 #define VC1_INV_TRANCS_8_TYPE2(o1, o2, r1, r2, r3, r4, c0, c1)  \
 "li %[tmp0],"#r1" \n\t" \
 "mtc1   %[tmp0],%[ftmp13] \n\t" \
-"pshufh %[ftmp13],  %[ftmp13],  %[ftmp23] \n\t" \
+"punpcklwd  %[ftmp13],  %[ftmp13],  %[ftmp13] \n\t" \
 "li %[tmp0],"#r2" \n\t" \
 "mtc1   %[tmp0],%[ftmp14] \n\t" \
-"pshufh %[ftmp14],  %[ftmp14],  %[ftmp23] \n\t" \
+"punpcklwd  %[ftmp14],  %[ftmp14],  %[ftmp14] \n\t" \
 "pmaddhw%[ftmp1],   %[ftmp5],   %[ftmp13] \n\t" \
 "pmaddhw%[ftmp2],   %[ftmp7],   %[ftmp14] \n\t" \
 "paddw  %[ftmp1],   %[ftmp1],   %[ftmp2]  \n\t" \
@@ -89,10 +87,10 @@
 \
 "li %[tmp0],"#r3" \n\t" \
 "mtc1   %[tmp0],%[ftmp13] \n\t" \
-"pshufh %[ftmp13],  %[ftmp13],  %[ftmp23]   

Re: [FFmpeg-devel] [PATCH] libavdevice: allow cropping avfoundation screen capture

2018-09-17 Thread Alan.Birtles
2018-09-13 17:52 GMT+02:00, alan.birt...@sony.com 
mailto:alan.birt...@sony.com>>:



> I've developed  a patch to add an option to allow cropping of the

> avfoundation screen capture.

> Note that if the captured width is not a multiple of 16 then

> https://urldefense.proofpoint.com/v2/url?u=https-3A__trac.ffmpeg.org_ticket_5654&d=DwIGaQ&c=fP4tf--1dS0biCFlB0saz0I0kjO5v7-GLPtvShAo4cc&r=DZ-pOCz_nOIJfdxhe1zNBFwbfB1WJzA5E9fM05n7yCs&m=KjmPPiSi2W239ebqa6B1xWjvn3F0kSW7fSlmVx4n70s&s=1a0Z8KLo3pYG0TjLl0zZzlF3E68mO58ssmKjXnW9yYg&e=
>  will be triggered.



Resending patch as Outlook got the mime-type of the original incorrect.

From 96b9cd33022bb6f3147174085c9ff2417cd006bc Mon Sep 17 00:00:00 2001
From: Alan Birtles 
Date: Thu, 13 Sep 2018 15:56:55 +0100
Subject: [PATCH] allow specifying "cropRect" for avfoundation screen capture

---
 libavdevice/avfoundation.m | 21 +
 1 file changed, 21 insertions(+)

diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index fc6428a..c285984 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -97,6 +97,10 @@
 
 int capture_cursor;
 int capture_mouse_clicks;
+int capture_crop_x;
+int capture_crop_y;
+int capture_crop_width;
+int capture_crop_height;
 
 int list_devices;
 int video_device_index;
@@ -750,6 +754,13 @@ static int avf_read_header(AVFormatContext *s)
 capture_screen_input.capturesMouseClicks = NO;
 }
 
+if (ctx->capture_crop_x != 0 ||
+ctx->capture_crop_y != 0 ||
+ctx->capture_crop_width != 0 ||
+ctx->capture_crop_height != 0) {
+capture_screen_input.cropRect = CGRectMake(ctx->capture_crop_x, ctx->capture_crop_y, ctx->capture_crop_width, ctx->capture_crop_height);
+}
+
 video_device = (AVCaptureDevice*) capture_screen_input;
 capture_screen = 1;
 #endif
@@ -799,6 +810,13 @@ static int avf_read_header(AVFormatContext *s)
 } else {
 capture_screen_input.capturesMouseClicks = NO;
 }
+
+if (ctx->capture_crop_x != 0 ||
+ctx->capture_crop_y != 0 ||
+ctx->capture_crop_width != 0 ||
+ctx->capture_crop_height != 0) {
+capture_screen_input.cropRect = CGRectMake(ctx->capture_crop_x, ctx->capture_crop_y, ctx->capture_crop_width, ctx->capture_crop_height);
+}
 }
 }
 #endif
@@ -1069,6 +1087,9 @@ static int avf_close(AVFormatContext *s)
 { "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 },
+{ "capture_crop_x", "crop the screen capture to the specified x offset", offsetof(AVFContext, capture_crop_x), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+{ "capture_crop_y", "crop the screen capture to the specified y offset", offsetof(AVFContext, capture_crop_y), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+{ "capture_crop_size", "crop the screen capture to the specified size", offsetof(AVFContext, capture_crop_width), AV_OPT_TYPE_IMAGE_SIZE,  {.str = NULL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
 
 { NULL },
 };
-- 
2.15.1 (Apple Git-101)

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


[FFmpeg-devel] [PATCH] lavc/mpeg2dec: fix MPEG2 VA-API interlace decoding issue.

2018-09-17 Thread Jun Zhao
From: Jun Zhao 

For interlaced frame, it has to call slice_end() for both fields. And
VASliceParameterBufferMPEG2::slice_vertical_position is supposed to be
the position in the picture but not field in this case.

Signed-off-by: Dong, Jerry 
Signed-off-by: Jun Zhao 
---
 libavcodec/mpeg12dec.c   |9 +
 libavcodec/vaapi_mpeg2.c |2 +-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 83e5378..c21f133 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2546,6 +2546,15 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame 
*picture,
 s2->er.error_count += 
s2->thread_context[i]->er.error_count;
 s->slice_count = 0;
 }
+
+if (s2->first_field) {
+/* slice ends for the first field */
+ret = slice_end(avctx, picture);
+av_assert1(ret == 0);
+if (ret < 0)
+return ret;
+}
+
 if (last_code == 0 || last_code == SLICE_MIN_START_CODE) {
 ret = mpeg_decode_postinit(avctx);
 if (ret < 0) {
diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c
index aaed434..b159f49 100644
--- a/libavcodec/vaapi_mpeg2.c
+++ b/libavcodec/vaapi_mpeg2.c
@@ -156,7 +156,7 @@ static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, 
const uint8_t *buffer
 .slice_data_flag= VA_SLICE_DATA_FLAG_ALL,
 .macroblock_offset  = macroblock_offset,
 .slice_horizontal_position  = s->mb_x,
-.slice_vertical_position= s->mb_y >> (s->picture_structure != 
PICT_FRAME),
+.slice_vertical_position= s->mb_y,
 .quantiser_scale_code   = quantiser_scale_code,
 .intra_slice_flag   = intra_slice_flag,
 };
-- 
1.7.1

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/zmbv: Check that the raw input is large enough to contain MVs or an intra frame

2018-09-17 Thread Carl Eugen Hoyos
2018-09-17 9:58 GMT+02:00, Paul B Mahol :
> Also why this codec needs fuzzing?

Do you believe that this codec is a less likely attack vector
than any other codec?

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/zmbv: Check that the raw input is large enough to contain MVs or an intra frame

2018-09-17 Thread Paul B Mahol
On 9/17/18, Carl Eugen Hoyos  wrote:
> 2018-09-17 9:58 GMT+02:00, Paul B Mahol :
>> Also why this codec needs fuzzing?
>
> Do you believe that this codec is a less likely attack vector
> than any other codec?

It is not possible attack vector at al, becuase there are no
security bugs in this codec that can be fixed in its code.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavc/mpeg2dec: fix MPEG2 VA-API interlace decoding issue.

2018-09-17 Thread Hendrik Leppkes
On Mon, Sep 17, 2018 at 1:22 PM Jun Zhao  wrote:
>
> From: Jun Zhao 
>
> For interlaced frame, it has to call slice_end() for both fields. And
> VASliceParameterBufferMPEG2::slice_vertical_position is supposed to be
> the position in the picture but not field in this case.
>

How does this impact other hwaccels or software decoding? Because
those cases seem to be working just fine the way it is now, from what
I can tell.

Also, in the VA-API calling code, are you setting avctx->slice_flags
to SLICE_FLAG_ALLOW_FIELD? Because that forces an end_frame call for
every field, which may be all that is needed here.

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


[FFmpeg-devel] [PATCH 1/2] lavu/frame: Add missing conversions from side data enum to name

2018-09-17 Thread Jun Zhao
Add missing conversions from side data enum to name.

Signed-off-by: Jun Zhao 
---
 libavutil/frame.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index 6c2c28f..4460325 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -831,9 +831,12 @@ const char *av_frame_side_data_name(enum 
AVFrameSideDataType type)
 case AV_FRAME_DATA_MASTERING_DISPLAY_METADATA:  return "Mastering display 
metadata";
 case AV_FRAME_DATA_CONTENT_LIGHT_LEVEL: return "Content light 
level metadata";
 case AV_FRAME_DATA_GOP_TIMECODE:return "GOP timecode";
+case AV_FRAME_DATA_SPHERICAL:   return "Spherical Mapping";
 case AV_FRAME_DATA_ICC_PROFILE: return "ICC profile";
+#if FF_API_FRAME_QP
 case AV_FRAME_DATA_QP_TABLE_PROPERTIES: return "QP table 
properties";
 case AV_FRAME_DATA_QP_TABLE_DATA:   return "QP table data";
+#endif
 }
 return NULL;
 }
-- 
1.7.1

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


[FFmpeg-devel] [PATCH 2/2] lavc/avpacket: Add missing conversions from side data enum to name.

2018-09-17 Thread Jun Zhao
Add missing conversions from side data enum to name.

Signed-off-by: Jun Zhao 
---
 libavcodec/avpacket.c |6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 99a0c13..002fa0f 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -375,6 +375,9 @@ const char *av_packet_side_data_name(enum 
AVPacketSideDataType type)
 case AV_PKT_DATA_DISPLAYMATRIX:  return "Display Matrix";
 case AV_PKT_DATA_STEREO3D:   return "Stereo 3D";
 case AV_PKT_DATA_AUDIO_SERVICE_TYPE: return "Audio Service Type";
+case AV_PKT_DATA_QUALITY_STATS:  return "Quality stats";
+case AV_PKT_DATA_FALLBACK_TRACK: return "Fallback track";
+case AV_PKT_DATA_CPB_PROPERTIES: return "CPB properties";
 case AV_PKT_DATA_SKIP_SAMPLES:   return "Skip Samples";
 case AV_PKT_DATA_JP_DUALMONO:return "JP Dual Mono";
 case AV_PKT_DATA_STRINGS_METADATA:   return "Strings Metadata";
@@ -388,6 +391,9 @@ const char *av_packet_side_data_name(enum 
AVPacketSideDataType type)
 case AV_PKT_DATA_CONTENT_LIGHT_LEVEL:return "Content light level 
metadata";
 case AV_PKT_DATA_SPHERICAL:  return "Spherical Mapping";
 case AV_PKT_DATA_A53_CC: return "A53 Closed Captions";
+case AV_PKT_DATA_ENCRYPTION_INIT_INFO:   return "Encryption 
initialization data";
+case AV_PKT_DATA_ENCRYPTION_INFO:return "Encryption info";
+case AV_PKT_DATA_AFD:return "Active Format 
Description data";
 }
 return NULL;
 }
-- 
1.7.1

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


[FFmpeg-devel] [PATCH]lavf/webvttenc: Always write hours in timestamps with two characters

2018-09-17 Thread Carl Eugen Hoyos
Hi!

Attached patch fixes ticket #7442 for me.

Please comment, Carl Eugen
From cbec1355c59ff1cfcb5051c8c75c09258d1cc569 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Mon, 17 Sep 2018 18:20:05 +0200
Subject: [PATCH] lavf/webvttenc: Always write hours in the timestamp with two
 characters.

Fixes ticket #7442.
---
 libavformat/webvttenc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/webvttenc.c b/libavformat/webvttenc.c
index 4827de0..61b7f54 100644
--- a/libavformat/webvttenc.c
+++ b/libavformat/webvttenc.c
@@ -38,7 +38,7 @@ static void webvtt_write_time(AVIOContext *pb, int64_t millisec)
 min -= 60 * hour;
 
 if (hour > 0)
-avio_printf(pb, "%"PRId64":", hour);
+avio_printf(pb, "%02"PRId64":", hour);
 
 avio_printf(pb, "%02"PRId64":%02"PRId64".%03"PRId64"", min, sec, millisec);
 }
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH]lavf/webvttenc: Always write hours in timestamps with two characters

2018-09-17 Thread Reto Kromer
Carl Eugen Hoyos wrote:

>Attached patch fixes ticket #7442 for me.

LGTM

Best regards, Reto

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


Re: [FFmpeg-devel] [PATCH v2 2/2] avformat/dashenc: Format VP9 bitdepth as decimal instead of Hexadecimal

2018-09-17 Thread James Almer
On 9/17/2018 5:03 AM, Karthick J wrote:
> From: Karthick Jeyapal 
> 
> For example bitdepth should be printed as 10 instead of 0A. Thanks to Hendrik 
> Leppkes for pointing this out
> ---
>  libavformat/dashenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index f429ebc..1a201c3 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -211,7 +211,7 @@ static void set_vp9_codec_str(AVFormatContext *s, 
> AVCodecParameters *par,
>  VPCC vpcc;
>  int ret = ff_isom_get_vpcc_features(s, par, frame_rate, &vpcc);
>  if (ret == 0) {
> -av_strlcatf(str, size, "vp09.%02x.%02d.%02x",
> +av_strlcatf(str, size, "vp09.%02x.%02d.%02d",
>  vpcc.profile, vpcc.level, vpcc.bitdepth);
>  } else {
>  // Default to just vp9 in case of error while finding out profile or 
> level

Both patches pushed. Thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/zmbv: Check that the raw input is large enough to contain MVs or an intra frame

2018-09-17 Thread Michael Niedermayer
On Mon, Sep 17, 2018 at 09:58:18AM +0200, Paul B Mahol wrote:
> On 9/17/18, Michael Niedermayer  wrote:
> > On Sun, Sep 16, 2018 at 10:16:05AM +0200, Paul B Mahol wrote:
> >> On 9/16/18, Michael Niedermayer  wrote:
> >> > Fixes: Timeout
> >> > Fixes:
> >> > 10182/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZMBV_fuzzer-6245951174344704
> >> >
> >> > Found-by: continuous fuzzing process
> >> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> >> > Signed-off-by: Michael Niedermayer 
> >> > ---
> >> >  libavcodec/zmbv.c | 11 ++-
> >> >  1 file changed, 10 insertions(+), 1 deletion(-)
> >> >
> >> > diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
> >> > index 9e27a2caad..1133bdf7ba 100644
> >> > --- a/libavcodec/zmbv.c
> >> > +++ b/libavcodec/zmbv.c
> >> > @@ -409,6 +409,7 @@ static int decode_frame(AVCodecContext *avctx, void
> >> > *data, int *got_frame, AVPac
> >> >  int zret = Z_OK; // Zlib return code
> >> >  int len = buf_size;
> >> >  int hi_ver, lo_ver, ret;
> >> > +int min_size;
> >> >
> >> >  /* parse header */
> >> >  if (len < 1)
> >> > @@ -510,7 +511,11 @@ static int decode_frame(AVCodecContext *avctx,
> >> > void
> >> > *data, int *got_frame, AVPac
> >> >  memset(c->prev, 0, avctx->width * avctx->height * (c->bpp /
> >> > 8));
> >> >  c->decode_intra= decode_intra;
> >> >  }
> >> > -
> >> > +if (c->flags & ZMBV_KEYFRAME) {
> >> > +min_size = avctx->width * avctx->height * (c->bpp / 8);
> >>
> >> This is pure guessing?
> >
> > theres a bit of logic behind it but ultimatly yes, its guessing
> >
> > The logic
> > If the input is smaller for a raw keyframe the buffer would not be
> > fully updated.
> > If the buffer is not fully updated then this should be a inter frame
> > not a keyframe.
> >
> > The 2nd part, is that all files i found
> > (http://samples.mplayerhq.hu/V-codecs/ZMBV/)
> > follow that assumtation
> >
> > The 3rd is that the source code for zmbv i could fine (dosbox)
> > seems to never write uncompressed keyframes.
> >
> > The 4th is that the multimedia wiki doesnt seem to say anything about the
> > uncompressed keyframe size
> >
> > so i thought its better to use this as the minimal size and avoid the
> > issue the fuzzer found.
> >
> > Its quite possible that i have missed something.
> > Also we could ask for a sample in the failure case or do something else if
> > you
> > have some other suggestion ?
> 

> Yes, drop patch and leave code as is.

I would prefer to fix the issue in some form. Do you have some suggestion
or preferrance about how to fix this issue ?


> 
> Also why this codec needs fuzzing?

it needs fuzzing as much or as little as any other codec. Theres
nothing special on it

Also as i was looking over this earlier today, i could improve the check
by also including compressed frames. And i found a kind of unrelated
bug in the codec. Ill resend the related parts of the patchset

Thanks


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

The smallest minority on earth is the individual. Those who deny 
individual rights cannot claim to be defenders of minorities. - Ayn Rand


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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/zmbv: Check that the raw input is large enough to contain MVs or an intra frame

2018-09-17 Thread Paul B Mahol
On 9/17/18, Michael Niedermayer  wrote:
> On Mon, Sep 17, 2018 at 09:58:18AM +0200, Paul B Mahol wrote:
>> On 9/17/18, Michael Niedermayer  wrote:
>> > On Sun, Sep 16, 2018 at 10:16:05AM +0200, Paul B Mahol wrote:
>> >> On 9/16/18, Michael Niedermayer  wrote:
>> >> > Fixes: Timeout
>> >> > Fixes:
>> >> > 10182/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZMBV_fuzzer-6245951174344704
>> >> >
>> >> > Found-by: continuous fuzzing process
>> >> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>> >> > Signed-off-by: Michael Niedermayer 
>> >> > ---
>> >> >  libavcodec/zmbv.c | 11 ++-
>> >> >  1 file changed, 10 insertions(+), 1 deletion(-)
>> >> >
>> >> > diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
>> >> > index 9e27a2caad..1133bdf7ba 100644
>> >> > --- a/libavcodec/zmbv.c
>> >> > +++ b/libavcodec/zmbv.c
>> >> > @@ -409,6 +409,7 @@ static int decode_frame(AVCodecContext *avctx,
>> >> > void
>> >> > *data, int *got_frame, AVPac
>> >> >  int zret = Z_OK; // Zlib return code
>> >> >  int len = buf_size;
>> >> >  int hi_ver, lo_ver, ret;
>> >> > +int min_size;
>> >> >
>> >> >  /* parse header */
>> >> >  if (len < 1)
>> >> > @@ -510,7 +511,11 @@ static int decode_frame(AVCodecContext *avctx,
>> >> > void
>> >> > *data, int *got_frame, AVPac
>> >> >  memset(c->prev, 0, avctx->width * avctx->height * (c->bpp /
>> >> > 8));
>> >> >  c->decode_intra= decode_intra;
>> >> >  }
>> >> > -
>> >> > +if (c->flags & ZMBV_KEYFRAME) {
>> >> > +min_size = avctx->width * avctx->height * (c->bpp / 8);
>> >>
>> >> This is pure guessing?
>> >
>> > theres a bit of logic behind it but ultimatly yes, its guessing
>> >
>> > The logic
>> > If the input is smaller for a raw keyframe the buffer would not be
>> > fully updated.
>> > If the buffer is not fully updated then this should be a inter frame
>> > not a keyframe.
>> >
>> > The 2nd part, is that all files i found
>> > (http://samples.mplayerhq.hu/V-codecs/ZMBV/)
>> > follow that assumtation
>> >
>> > The 3rd is that the source code for zmbv i could fine (dosbox)
>> > seems to never write uncompressed keyframes.
>> >
>> > The 4th is that the multimedia wiki doesnt seem to say anything about
>> > the
>> > uncompressed keyframe size
>> >
>> > so i thought its better to use this as the minimal size and avoid the
>> > issue the fuzzer found.
>> >
>> > Its quite possible that i have missed something.
>> > Also we could ask for a sample in the failure case or do something else
>> > if
>> > you
>> > have some other suggestion ?
>>
>
>> Yes, drop patch and leave code as is.
>
> I would prefer to fix the issue in some form. Do you have some suggestion
> or preferrance about how to fix this issue ?

No, you are not interested in fixing real issues.
Please do not commit hacks like this patch.

Nothing in zlib guarantees that size will fit under your random constraints.

>
>
>>
>> Also why this codec needs fuzzing?
>
> it needs fuzzing as much or as little as any other codec. Theres
> nothing special on it
>
> Also as i was looking over this earlier today, i could improve the check
> by also including compressed frames. And i found a kind of unrelated
> bug in the codec. Ill resend the related parts of the patchset
>
> Thanks
>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> The smallest minority on earth is the individual. Those who deny
> individual rights cannot claim to be defenders of minorities. - Ayn Rand
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] avcodec/zmbv: Check that the decompressed data is large enough to contain MVs or an intra frame

2018-09-17 Thread Michael Niedermayer
Fixes: Timeout
Fixes: 
10182/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZMBV_fuzzer-6245951174344704

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

diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
index 177993d0a6..0c2daf47c2 100644
--- a/libavcodec/zmbv.c
+++ b/libavcodec/zmbv.c
@@ -409,6 +409,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame, AVPac
 int zret = Z_OK; // Zlib return code
 int len = buf_size;
 int hi_ver, lo_ver, ret;
+int min_size;
 
 /* parse header */
 if (len < 1)
@@ -510,7 +511,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame, AVPac
 memset(c->prev, 0, avctx->width * avctx->height * (c->bpp / 8));
 c->decode_intra= decode_intra;
 }
-
+if (c->flags & ZMBV_KEYFRAME) {
+min_size = avctx->width * avctx->height * (c->bpp / 8);
+} else {
+min_size = (c->bx * c->by * 2 + 3) & ~3;
+}
 if (!c->decode_intra) {
 av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
 return AVERROR_INVALIDDATA;
@@ -539,6 +544,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame, AVPac
 }
 c->decomp_len = c->zstream.total_out;
 }
+if (min_size > c->decomp_len) {
+av_log(avctx, AV_LOG_ERROR, "input too small\n");
+return AVERROR_INVALIDDATA;
+}
 if (c->flags & ZMBV_KEYFRAME) {
 frame->key_frame = 1;
 frame->pict_type = AV_PICTURE_TYPE_I;
-- 
2.18.0

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


[FFmpeg-devel] [PATCH 1/2] avcodec/zmbv: Update decomp_len in raw frames

2018-09-17 Thread Michael Niedermayer
decomp_len is used in raw frames, so it should not be left at the value from
whatever was decoded previously (which may be any other frame)

Signed-off-by: Michael Niedermayer 
---
 libavcodec/zmbv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
index 9e27a2caad..177993d0a6 100644
--- a/libavcodec/zmbv.c
+++ b/libavcodec/zmbv.c
@@ -525,6 +525,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame, AVPac
 return AVERROR_INVALIDDATA;
 }
 memcpy(c->decomp_buf, buf, len);
+c->decomp_len = len;
 } else { // ZLIB-compressed data
 c->zstream.total_in = c->zstream.total_out = 0;
 c->zstream.next_in = (uint8_t*)buf;
-- 
2.18.0

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/zmbv: Check that the decompressed data is large enough to contain MVs or an intra frame

2018-09-17 Thread Paul B Mahol
On 9/17/18, Michael Niedermayer  wrote:
> Fixes: Timeout
> Fixes:
> 10182/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZMBV_fuzzer-6245951174344704
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/zmbv.c | 11 ++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
> index 177993d0a6..0c2daf47c2 100644
> --- a/libavcodec/zmbv.c
> +++ b/libavcodec/zmbv.c
> @@ -409,6 +409,7 @@ static int decode_frame(AVCodecContext *avctx, void
> *data, int *got_frame, AVPac
>  int zret = Z_OK; // Zlib return code
>  int len = buf_size;
>  int hi_ver, lo_ver, ret;
> +int min_size;
>
>  /* parse header */
>  if (len < 1)
> @@ -510,7 +511,11 @@ static int decode_frame(AVCodecContext *avctx, void
> *data, int *got_frame, AVPac
>  memset(c->prev, 0, avctx->width * avctx->height * (c->bpp / 8));
>  c->decode_intra= decode_intra;
>  }
> -
> +if (c->flags & ZMBV_KEYFRAME) {
> +min_size = avctx->width * avctx->height * (c->bpp / 8);

Do you have proof this is really minimal possible thing zlib can
compress single frame?
If not, Drop. It.

> +} else {
> +min_size = (c->bx * c->by * 2 + 3) & ~3;
> +}
>  if (!c->decode_intra) {
>  av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no
> keyframe!\n");
>  return AVERROR_INVALIDDATA;
> @@ -539,6 +544,10 @@ static int decode_frame(AVCodecContext *avctx, void
> *data, int *got_frame, AVPac
>  }
>  c->decomp_len = c->zstream.total_out;
>  }
> +if (min_size > c->decomp_len) {
> +av_log(avctx, AV_LOG_ERROR, "input too small\n");
> +return AVERROR_INVALIDDATA;
> +}
>  if (c->flags & ZMBV_KEYFRAME) {
>  frame->key_frame = 1;
>  frame->pict_type = AV_PICTURE_TYPE_I;
> --
> 2.18.0
>
> ___
> 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] Reduce static table size for VLC tables in h264_cavlc.c

2018-09-17 Thread Dale Curtis
On Sat, Sep 8, 2018 at 5:49 PM Michael Niedermayer 
wrote:

> dont all modern OS assign physical memory only once something is stored
> in these tables?
>

This seems to be correct. I was misreading the tooling which indicated
these were taking up size. So this patch can be abandoned. Sorry for the
noise!

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


Re: [FFmpeg-devel] [PATCH] avformat/utils: Don't parse encrypted packets.

2018-09-17 Thread Jacob Trimble
On Wed, Sep 12, 2018 at 11:50 AM Michael Niedermayer
 wrote:
>
> On Tue, Sep 11, 2018 at 03:50:57PM -0700, Jacob Trimble wrote:
> > [...]
> >
> > So how about, when we see an encrypted frame, we flush the parser
> > before skipping the frame?  Can we just flush the parser and then
> > reuse it later?  Or would we need to create a new parser if we saw
> > clear frames later?
>
> try/test it and review the code. only way to know for sure what works
>
> thanks
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> The bravest are surely those who have the clearest vision
> of what is before them, glory and danger alike, and yet
> notwithstanding go out to meet it. -- Thucydides
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Here is a new patch that flushes the parser before returning the
encrypted packets.  It also logs when it does this.
From 3955dad8070c28b021afc3304939500a09c86fcd Mon Sep 17 00:00:00 2001
From: Jacob Trimble 
Date: Tue, 28 Aug 2018 10:40:29 -0700
Subject: [PATCH] avformat/utils: Don't parse encrypted packets.

If a packet is full-sample encrypted, then packet data can't be parsed
without decrypting it.  So this skips the packet parsing for those
packets.  If the packet has sub-sample encryption, it is assumed that
the headers are in the clear and the parser will only need that info.

Signed-off-by: Jacob Trimble 
---
 libavformat/utils.c | 41 -
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index a72f0a482e..8d84674797 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -27,6 +27,7 @@
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/dict.h"
+#include "libavutil/encryption_info.h"
 #include "libavutil/internal.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
@@ -1576,6 +1577,9 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
 while (!got_packet && !s->internal->parse_queue) {
 AVStream *st;
 AVPacket cur_pkt;
+uint8_t *enc_side_data;
+int enc_side_data_size;
+int is_full_encrypted = 0;
 
 /* read next packet */
 ret = ff_read_packet(s, &cur_pkt);
@@ -1643,7 +1647,23 @@ FF_ENABLE_DEPRECATION_WARNINGS
av_ts2str(cur_pkt.dts),
cur_pkt.size, cur_pkt.duration, cur_pkt.flags);
 
-if (st->need_parsing && !st->parser && !(s->flags & AVFMT_FLAG_NOPARSE)) {
+/* if the packet is full-sample encrypted, we can't parse it.  If the
+ * packet uses sub-sample encryption, assume the headers are clear and
+ * can still be parsed.
+ */
+enc_side_data = av_packet_get_side_data(
+&cur_pkt, AV_PKT_DATA_ENCRYPTION_INFO, &enc_side_data_size);
+if (enc_side_data) {
+AVEncryptionInfo *enc_info =
+av_encryption_info_get_side_data(enc_side_data, enc_side_data_size);
+if (enc_info) {
+is_full_encrypted = enc_info->subsample_count == 0;
+av_encryption_info_free(enc_info);
+}
+}
+
+if (st->need_parsing && !st->parser && !(s->flags & AVFMT_FLAG_NOPARSE) &&
+!is_full_encrypted) {
 st->parser = av_parser_init(st->codecpar->codec_id);
 if (!st->parser) {
 av_log(s, AV_LOG_VERBOSE, "parser not found for codec "
@@ -1659,6 +1679,25 @@ FF_ENABLE_DEPRECATION_WARNINGS
 st->parser->flags |= PARSER_FLAG_USE_CODEC_TS;
 }
 
+if (st->parser && is_full_encrypted) {
+av_log(s, AV_LOG_VERBOSE, "skipping parsing of encrypted packets.\n");
+
+/* flush any packets from the parser. */
+parse_packet(s, NULL, cur_pkt.stream_index);
+if (s->internal->parse_queue) {
+/* if we have other packets, append this packet to the end and read
+ * from the queue instead. */
+compute_pkt_fields(s, st, NULL, &cur_pkt, AV_NOPTS_VALUE, AV_NOPTS_VALUE);
+ret = ff_packet_list_put(&s->internal->parse_queue,
+ &s->internal->parse_queue_end,
+ &cur_pkt, 0);
+if (ret < 0)
+return ret;
+break;
+}
+av_assert2(!st->parser);
+}
+
 if (!st->need_parsing || !st->parser) {
 /* no parsing needed: we just output the packet as is */
 *pkt = cur_pkt;
-- 
2.19.0.397.gdd90340f6a-goog

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/zmbv: Check that the decompressed data is large enough to contain MVs or an intra frame

2018-09-17 Thread Michael Niedermayer
On Mon, Sep 17, 2018 at 09:34:00PM +0200, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 
> 10182/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZMBV_fuzzer-6245951174344704
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/zmbv.c | 11 ++-
>  1 file changed, 10 insertions(+), 1 deletion(-)

will submit a slightly different solution based on discussion with
durandal on IRC

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

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable


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


Re: [FFmpeg-devel] [PATCH 2/2] lavc/libdavs2: fix error type

2018-09-17 Thread Mark Thompson
On 12/09/18 06:53, hwren wrote:
> Signed-off-by: hwren 
> ---
>  libavcodec/libdavs2.c | 6 --
>  1 file changed, 6 deletions(-)

On 12/09/18 06:53, hwren wrote:
> Signed-off-by: hwren 
> ---
>  libavcodec/libdavs2.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
Both applied.

Thanks,

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


[FFmpeg-devel] [PATCH] avcodec/zmbv: Check that the decompressed data size is correct

2018-09-17 Thread Michael Niedermayer
This checks the value exactly for intra frames and checks it against a
minimum for inter frames as they can be variable.

Fixes: Timeout
Fixes: 
10182/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZMBV_fuzzer-6245951174344704

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

diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
index 177993d0a6..79e0892070 100644
--- a/libavcodec/zmbv.c
+++ b/libavcodec/zmbv.c
@@ -409,6 +409,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame, AVPac
 int zret = Z_OK; // Zlib return code
 int len = buf_size;
 int hi_ver, lo_ver, ret;
+int expected_size;
 
 /* parse header */
 if (len < 1)
@@ -510,6 +511,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame, AVPac
 memset(c->prev, 0, avctx->width * avctx->height * (c->bpp / 8));
 c->decode_intra= decode_intra;
 }
+if (c->flags & ZMBV_KEYFRAME) {
+expected_size = avctx->width * avctx->height * (c->bpp / 8);
+} else {
+expected_size = (c->bx * c->by * 2 + 3) & ~3;
+}
+if (avctx->pix_fmt == AV_PIX_FMT_PAL8 &&
+(c->flags & (ZMBV_DELTAPAL | ZMBV_KEYFRAME)))
+expected_size += 768;
 
 if (!c->decode_intra) {
 av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n");
@@ -539,6 +548,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame, AVPac
 }
 c->decomp_len = c->zstream.total_out;
 }
+if (expected_size > c->decomp_len ||
+(c->flags & ZMBV_KEYFRAME) && expected_size < c->decomp_len) {
+av_log(avctx, AV_LOG_ERROR, "decompressed size %d is incorrect, 
expected %d\n", c->decomp_len, expected_size);
+return AVERROR_INVALIDDATA;
+}
 if (c->flags & ZMBV_KEYFRAME) {
 frame->key_frame = 1;
 frame->pict_type = AV_PICTURE_TYPE_I;
-- 
2.18.0

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


Re: [FFmpeg-devel] [PATCH] lavc/libxavs2: remove invalid parameters

2018-09-17 Thread Mark Thompson
On 12/09/18 08:54, hwren wrote:
> Signed-off-by: hwren 
> ---
>  doc/encoders.texi | 3 ---
>  libavcodec/libxavs2.c | 4 
>  2 files changed, 7 deletions(-)
> 
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index 4623f38..0696a7a 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -2761,9 +2761,6 @@ Set the Speed level from 0 to 9 (default 0). Higher is 
> better but slower.
>  Set the log level from -1 to 3 (default 0). -1: none, 0: error,
>  1: warning, 2: info, 3: debug.
>  
> -@item hierarchical_ref
> -Set the hierarchical reference or not (default true).
> -
>  @item xavs2-params
>  Set xavs2 options using a list of @var{key}=@var{value} couples separated
>  by ":".
> diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c
> index e26c90a..2b47d0c 100644
> --- a/libavcodec/libxavs2.c
> +++ b/libavcodec/libxavs2.c
> @@ -78,8 +78,6 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
>  return AVERROR(ENOMEM);
>  }
>  
> -xavs2_opt_set2("rec",   "%d", 0);
> -
>  xavs2_opt_set2("width", "%d", avctx->width);
>  xavs2_opt_set2("height","%d", avctx->height);
>  xavs2_opt_set2("bframes",   "%d", avctx->max_b_frames);
> @@ -92,7 +90,6 @@ static av_cold int xavs2_init(AVCodecContext *avctx)
>  
>  xavs2_opt_set2("thread_frames", "%d", avctx->thread_count);
>  xavs2_opt_set2("thread_rows",   "%d", cae->lcu_row_threads);
> -xavs2_opt_set2("hierarchical_ref",  "%d", cae->hierarchical_reference);
>  
>  xavs2_opt_set2("OpenGOP",  "%d", 1);
>  
> @@ -261,7 +258,6 @@ static const AVOption options[] = {
>  { "min_qp"  ,   "min qp for rate control" , 
> OFFSET(min_qp)  , AV_OPT_TYPE_INT, {.i64 = 20 },  0,  63,  VE },
>  { "speed_level" ,   "Speed level, higher is better but slower", 
> OFFSET(preset_level), AV_OPT_TYPE_INT, {.i64 =  0 },  0,   9,  VE },
>  { "log_level"   ,   "log level: -1: none, 0: error, 1: warning, 2: 
> info, 3: debug", OFFSET(log_level), AV_OPT_TYPE_INT, {.i64 =  0 },  -1,   
> 3,  VE },
> -{ "hierarchical_ref",   "hierarchical reference" ,  
> OFFSET(hierarchical_reference), AV_OPT_TYPE_BOOL,{.i64 =  1 }, 0, 1,  
> VE },
>  { "xavs2-params",   "set the xavs2 configuration using a :-separated 
> list of key=value parameters", OFFSET(xavs2_opts), AV_OPT_TYPE_STRING, { 0 }, 
> 0, 0, VE },
>  { NULL },
>  };
> 

Applied.

From my testing, it seems that hierarchical references are always use - I guess 
there is no reason to want to switch them off in a modern codec if the encoder 
wants to use them?

I suggest that on the libxavs2 side it might be a good idea to make the 
parameter-set function return an error code, or at least log some warning, so 
that this sort of problem is more easily detected.

Thanks,

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


[FFmpeg-devel] [PATCH]lavd/dshow: Interpret negative height as bottom-down frame

2018-09-17 Thread Carl Eugen Hoyos
Hi!

Attached patch was tested by the reporter of ticket #7436.

Please comment, Carl Eugen
From 20f8ee0514a60bcc5a1dc2ddc72e92db66b8f815 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Tue, 18 Sep 2018 00:16:42 +0200
Subject: [PATCH] lavd/dshow: Interpret negative height as bottom-down frame.

Fixes ticket #7436.
---
 libavdevice/dshow.c |4 
 1 file changed, 4 insertions(+)

diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index de910c0..757f7a5 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -996,11 +996,15 @@ dshow_add_device(AVFormatContext *avctx,
 par->codec_id = AV_CODEC_ID_RAWVIDEO;
 if (bih->biCompression == BI_RGB || bih->biCompression == BI_BITFIELDS) {
 par->bits_per_coded_sample = bih->biBitCount;
+if (par->height < 0) {
+par->height *= -1;
+} else {
 par->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE);
 if (par->extradata) {
 par->extradata_size = 9;
 memcpy(par->extradata, "BottomUp", 9);
 }
+}
 }
 }
 } else {
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/libaomdec: export chroma sample location

2018-09-17 Thread Mark Thompson
On 16/09/18 19:29, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  libavcodec/libaomdec.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c
> index 2530c9f76b..a21cace164 100644
> --- a/libavcodec/libaomdec.c
> +++ b/libavcodec/libaomdec.c
> @@ -89,7 +89,11 @@ static int set_pix_fmt(AVCodecContext *avctx, struct 
> aom_image *img)
>  static const enum AVColorRange color_ranges[] = {
>  AVCOL_RANGE_MPEG, AVCOL_RANGE_JPEG
>  };
> +static const enum AVColorRange chroma_locations[] = {
> +AVCHROMA_LOC_UNSPECIFIED, AVCHROMA_LOC_LEFT, AVCHROMA_LOC_TOPLEFT, 
> AVCHROMA_LOC_UNSPECIFIED
> +};
>  avctx->color_range = color_ranges[img->range];
> +avctx->chroma_sample_location = chroma_locations[img->csp];

I would suggest for future compatibility that it probably shouldn't invoke 
undefined behaviour if the value is not in the range 0-3?

(While I assume the limited choice of locations here was deliberate, the fact 
that you can't encode a sequence of JPEGs without resampling seems slightly 
crazy to me so more being added in future would not be a surprise.)

>  avctx->color_primaries = img->cp;
>  avctx->colorspace  = img->mc;
>  avctx->color_trc   = img->tc;
> 

LGTM otherwise.

Thanks,

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


Re: [FFmpeg-devel] [PATCH] libavfilter: Removes stored DNN models. Adds support for native backend model file format in tf backend. Removes scaling and conversion with libswscale and replaces input fo

2018-09-17 Thread Pedro Arthur
Pushed.

2018-09-16 16:21 GMT-03:00 Pedro Arthur :

>
>
> 2018-09-16 15:20 GMT-03:00 Paul B Mahol :
>>
>> When this will be pushed?
>>
> Yes, I did not had time to push it friday.
> I'll do it monday or you could push it if you don't mind.
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/libaomenc: support setting chroma sample location

2018-09-17 Thread Mark Thompson
On 16/09/18 19:29, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  libavcodec/libaomenc.c | 18 ++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> index 6a79d9b873..55d50ded28 100644
> --- a/libavcodec/libaomenc.c
> +++ b/libavcodec/libaomenc.c
> @@ -76,6 +76,7 @@ static const char *const ctlidstr[] = {
>  [AOME_SET_ENABLEAUTOALTREF] = "AOME_SET_ENABLEAUTOALTREF",
>  [AOME_SET_STATIC_THRESHOLD] = "AOME_SET_STATIC_THRESHOLD",
>  [AV1E_SET_COLOR_RANGE]  = "AV1E_SET_COLOR_RANGE",
> +[AV1E_SET_CHROMA_SAMPLE_POSITION] = "AV1E_SET_CHROMA_SAMPLE_POSITION",
>  [AV1E_SET_COLOR_PRIMARIES]  = "AV1E_SET_COLOR_PRIMARIES",
>  [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS",
>  [AV1E_SET_TRANSFER_CHARACTERISTICS] = 
> "AV1E_SET_TRANSFER_CHARACTERISTICS",
> @@ -284,6 +285,22 @@ static void set_color_range(AVCodecContext *avctx)
>  codecctl_int(avctx, AV1E_SET_COLOR_RANGE, aom_cr);
>  }
>  
> +static void set_chroma_location(AVCodecContext *avctx)
> +{
> +enum aom_chroma_sample_position aom_cps;
> +switch (avctx->chroma_sample_location) {
> +case AVCHROMA_LOC_UNSPECIFIED: aom_cps = AOM_CSP_UNKNOWN;   break;
> +case AVCHROMA_LOC_LEFT:aom_cps = AOM_CSP_VERTICAL;  break;
> +case AVCHROMA_LOC_TOPLEFT: aom_cps = AOM_CSP_COLOCATED; break;
> +default:
> +av_log(avctx, AV_LOG_WARNING, "Unsupported chroma sample location 
> (%d)\n",
> +   avctx->chroma_sample_location);
> +return;
> +}
> +
> +codecctl_int(avctx, AV1E_SET_CHROMA_SAMPLE_POSITION, aom_cps);
> +}

I think you should only set this if the input is 4:2:0, since the value is only 
used in that case.

> +
>  static av_cold int aom_init(AVCodecContext *avctx,
>  const struct aom_codec_iface *iface)
>  {
> @@ -452,6 +469,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
>  codecctl_int(avctx, AV1E_SET_COLOR_PRIMARIES, avctx->color_primaries);
>  codecctl_int(avctx, AV1E_SET_MATRIX_COEFFICIENTS, avctx->colorspace);
>  codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, avctx->color_trc);
> +set_chroma_location(avctx);
>  set_color_range(avctx);
>  
>  // provide dummy value to initialize wrapper, values will be updated 
> each _encode()
> 

Otherwise LGTM.

It's somewhat unfortunate that the obvious way of encoding a sequence of JPEGs 
will always hit the warning, but it is correct...

Thanks,

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


Re: [FFmpeg-devel] [PATCH 2/2] avcodec/libaomdec: export chroma sample location

2018-09-17 Thread James Almer
On 9/17/2018 7:52 PM, Mark Thompson wrote:
> On 16/09/18 19:29, James Almer wrote:
>> Signed-off-by: James Almer 
>> ---
>>  libavcodec/libaomdec.c | 4 
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c
>> index 2530c9f76b..a21cace164 100644
>> --- a/libavcodec/libaomdec.c
>> +++ b/libavcodec/libaomdec.c
>> @@ -89,7 +89,11 @@ static int set_pix_fmt(AVCodecContext *avctx, struct 
>> aom_image *img)
>>  static const enum AVColorRange color_ranges[] = {
>>  AVCOL_RANGE_MPEG, AVCOL_RANGE_JPEG
>>  };
>> +static const enum AVColorRange chroma_locations[] = {
>> +AVCHROMA_LOC_UNSPECIFIED, AVCHROMA_LOC_LEFT, AVCHROMA_LOC_TOPLEFT, 
>> AVCHROMA_LOC_UNSPECIFIED
>> +};
>>  avctx->color_range = color_ranges[img->range];
>> +avctx->chroma_sample_location = chroma_locations[img->csp];
> 
> I would suggest for future compatibility that it probably shouldn't invoke 
> undefined behaviour if the value is not in the range 0-3?
> 
> (While I assume the limited choice of locations here was deliberate, the fact 
> that you can't encode a sequence of JPEGs without resampling seems slightly 
> crazy to me so more being added in future would not be a surprise.)

It's unlikely they'll ever implement anything like that. Even assigning
something for the value 3 (like center as you said), which is currently
reserved, might require a new version of the bitstream defining new
profiles. Not to mention adding even more values, which would require
changing the Sequence Header to make the field wider than two bits.

I personally don't really see that happening, but I'll add a img->csp <=
AOM_CSP_COLOCATED check anyway.

> 
>>  avctx->color_primaries = img->cp;
>>  avctx->colorspace  = img->mc;
>>  avctx->color_trc   = img->tc;
>>
> 
> LGTM otherwise.
> 
> Thanks,
> 
> - Mark
> ___
> 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 v2 1/3] libaomenc: Add support for tiles

2018-09-17 Thread Mark Thompson
Adds an option to specify the number of tile rows and columns, then uses
equal-sized tiles to fill the frame.
---
 libavcodec/libaomenc.c | 54 ++
 1 file changed, 54 insertions(+)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 6a79d9b873..3ccff0e0fb 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -68,6 +68,7 @@ typedef struct AOMEncoderContext {
 int static_thresh;
 int drop_threshold;
 int noise_sensitivity;
+int tile_cols, tile_rows;
 } AOMContext;
 
 static const char *const ctlidstr[] = {
@@ -79,6 +80,7 @@ static const char *const ctlidstr[] = {
 [AV1E_SET_COLOR_PRIMARIES]  = "AV1E_SET_COLOR_PRIMARIES",
 [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS",
 [AV1E_SET_TRANSFER_CHARACTERISTICS] = "AV1E_SET_TRANSFER_CHARACTERISTICS",
+[AV1E_SET_SUPERBLOCK_SIZE]  = "AV1E_SET_SUPERBLOCK_SIZE",
 };
 
 static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
@@ -143,6 +145,10 @@ static av_cold void dump_enc_cfg(AVCodecContext *avctx,
width, "kf_mode:", cfg->kf_mode,
width, "kf_min_dist:", cfg->kf_min_dist,
width, "kf_max_dist:", cfg->kf_max_dist);
+av_log(avctx, level, "tile settings\n"
+ "  %*s%d\n  %*s%d\n",
+   width, "tile_width_count:",  cfg->tile_width_count,
+   width, "tile_height_count:", cfg->tile_height_count);
 av_log(avctx, level, "\n");
 }
 
@@ -294,6 +300,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
 int res;
 aom_img_fmt_t img_fmt;
 aom_codec_caps_t codec_caps = aom_codec_get_caps(iface);
+aom_superblock_size_t superblock_size = AOM_SUPERBLOCK_SIZE_DYNAMIC;
 
 av_log(avctx, AV_LOG_INFO, "%s\n", aom_codec_version_str());
 av_log(avctx, AV_LOG_VERBOSE, "%s\n", aom_codec_build_config());
@@ -431,6 +438,50 @@ static av_cold int aom_init(AVCodecContext *avctx,
 
 enccfg.g_error_resilient = ctx->error_resilient;
 
+if (ctx->tile_cols && ctx->tile_rows) {
+int sb_size, sb_width, sb_height;
+int cols_per_tile, cols_step, rows_per_tile, rows_step, i;
+
+// Default to 128x128 superblocks if they fit, otherwise use 64x64.
+if ((avctx->width  + 127) / 128 < ctx->tile_cols ||
+(avctx->height + 127) / 128 < ctx->tile_rows) {
+sb_size = 64;
+superblock_size = AOM_SUPERBLOCK_SIZE_64X64;
+} else {
+sb_size = 128;
+superblock_size = AOM_SUPERBLOCK_SIZE_128X128;
+}
+
+if ((avctx->width  + sb_size - 1) / sb_size < ctx->tile_cols ||
+(avctx->height + sb_size - 1) / sb_size < ctx->tile_rows) {
+av_log(avctx, AV_LOG_ERROR, "Invalid tile sizing: frame not "
+   "large enough to fit specified tile arrangement.\n");
+return AVERROR(EINVAL);
+}
+if (ctx->tile_cols > MAX_TILE_WIDTHS ||
+ctx->tile_rows > MAX_TILE_HEIGHTS) {
+av_log(avctx, AV_LOG_ERROR, "Invalid tile sizing: at most %dx%d "
+   "tiles allowed.\n", MAX_TILE_WIDTHS, MAX_TILE_HEIGHTS);
+return AVERROR(EINVAL);
+}
+
+enccfg.tile_width_count  = ctx->tile_cols;
+enccfg.tile_height_count = ctx->tile_rows;
+
+sb_width  = (avctx->width  + sb_size - 1) / sb_size;
+sb_height = (avctx->height + sb_size - 1) / sb_size;
+
+cols_per_tile = sb_width / ctx->tile_cols;
+cols_step = sb_width % ctx->tile_cols;
+for (i = 0; i < ctx->tile_cols; i++)
+enccfg.tile_widths[i] = cols_per_tile + (i < cols_step);
+
+rows_per_tile = sb_height / ctx->tile_rows;
+rows_step = sb_height % ctx->tile_rows;
+for (i = 0; i < ctx->tile_rows; i++)
+enccfg.tile_heights[i] = rows_per_tile + (i < rows_step);
+}
+
 dump_enc_cfg(avctx, &enccfg);
 /* Construct Encoder Context */
 res = aom_codec_enc_init(&ctx->encoder, iface, &enccfg, flags);
@@ -454,6 +505,8 @@ static av_cold int aom_init(AVCodecContext *avctx,
 codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, avctx->color_trc);
 set_color_range(avctx);
 
+codecctl_int(avctx, AV1E_SET_SUPERBLOCK_SIZE, superblock_size);
+
 // provide dummy value to initialize wrapper, values will be updated each 
_encode()
 aom_img_wrap(&ctx->rawimg, img_fmt, avctx->width, avctx->height, 1,
  (unsigned char*)1);
@@ -742,6 +795,7 @@ static const AVOption options[] = {
 { "static-thresh","A change threshold on blocks below which they will 
be skipped by the encoder", OFFSET(static_thresh), AV_OPT_TYPE_INT, { .i64 = 0 
}, 0, INT_MAX, VE },
 { "drop-threshold",   "Frame drop threshold", offsetof(AOMContext, 
drop_threshold), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, VE },
 { "noise-sensitivity", "Noise sensitivity", OFFSET(noise_sensitivity), 
AV_OPT_TYPE_INT, {.i64 = 0 }

[FFmpeg-devel] [PATCH v2 3/3] lavc: Add AV1 metadata bitstream filter

2018-09-17 Thread Mark Thompson
Can adjust colour and timing information.
---
 configure  |   1 +
 libavcodec/Makefile|   1 +
 libavcodec/av1_metadata_bsf.c  | 267 +
 libavcodec/bitstream_filters.c |   1 +
 4 files changed, 270 insertions(+)
 create mode 100644 libavcodec/av1_metadata_bsf.c

diff --git a/configure b/configure
index 4908831477..9ce6ddb825 100755
--- a/configure
+++ b/configure
@@ -3029,6 +3029,7 @@ vc1_parser_select="vc1dsp"
 
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header"
+av1_metadata_bsf_select="cbs_av1"
 eac3_core_bsf_select="ac3_parser"
 filter_units_bsf_select="cbs"
 h264_metadata_bsf_deps="const_nan"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e8d5f74067..97b0bd6e17 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1051,6 +1051,7 @@ OBJS-$(CONFIG_XMA_PARSER)  += xma_parser.o
 
 # bitstream filters
 OBJS-$(CONFIG_AAC_ADTSTOASC_BSF)  += aac_adtstoasc_bsf.o mpeg4audio.o
+OBJS-$(CONFIG_AV1_METADATA_BSF)   += av1_metadata_bsf.o
 OBJS-$(CONFIG_CHOMP_BSF)  += chomp_bsf.o
 OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o
 OBJS-$(CONFIG_DCA_CORE_BSF)   += dca_core_bsf.o
diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c
new file mode 100644
index 00..ed2f018fb6
--- /dev/null
+++ b/libavcodec/av1_metadata_bsf.c
@@ -0,0 +1,267 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+
+#include "bsf.h"
+#include "cbs.h"
+#include "cbs_av1.h"
+
+typedef struct AV1MetadataContext {
+const AVClass *class;
+
+CodedBitstreamContext *cbc;
+CodedBitstreamFragment access_unit;
+
+int color_primaries;
+int transfer_characteristics;
+int matrix_coefficients;
+
+int color_range;
+int chroma_sample_position;
+
+AVRational tick_rate;
+int num_ticks_per_picture;
+} AV1MetadataContext;
+
+
+static int av1_metadata_update_sequence_header(AVBSFContext *bsf,
+   AV1RawSequenceHeader *seq)
+{
+AV1MetadataContext *ctx = bsf->priv_data;
+AV1RawColorConfig  *clc = &seq->color_config;
+AV1RawTimingInfo   *tim = &seq->timing_info;
+
+if (ctx->color_primaries >= 0  ||
+ctx->transfer_characteristics >= 0 ||
+ctx->matrix_coefficients >= 0) {
+if (!clc->color_description_present_flag) {
+clc->color_description_present_flag = 1;
+clc->color_primaries  = AVCOL_PRI_UNSPECIFIED;
+clc->transfer_characteristics = AVCOL_TRC_UNSPECIFIED;
+clc->matrix_coefficients  = AVCOL_SPC_UNSPECIFIED;
+}
+
+if (ctx->color_primaries >= 0)
+clc->color_primaries = ctx->color_primaries;
+if (ctx->transfer_characteristics >= 0)
+clc->transfer_characteristics = ctx->transfer_characteristics;
+if (ctx->matrix_coefficients >= 0)
+clc->matrix_coefficients = ctx->matrix_coefficients;
+}
+
+if (ctx->color_range >= 0) {
+if (clc->color_primaries  == AVCOL_PRI_BT709&&
+clc->transfer_characteristics == AVCOL_TRC_IEC61966_2_1 &&
+clc->matrix_coefficients  == AVCOL_SPC_RGB) {
+av_log(bsf, AV_LOG_WARNING, "Warning: color_range cannot be set "
+   "on RGB streams encoded in BT.709 sRGB.\n");
+} else {
+clc->color_range = ctx->color_range;
+}
+}
+
+if (ctx->chroma_sample_position >= 0) {
+if (clc->mono_chrome) {
+av_log(bsf, AV_LOG_WARNING, "Warning: chroma_sample_position "
+   "is not meaningful for monochrome streams.\n");
+} else if (clc->subsampling_x == 0 &&
+   clc->subsampling_y == 0) {
+av_log(bsf, AV_LOG_WARNING, "Warning: chroma_sample_position "
+   "is not meaningful for non-chroma-subsampled streams.\n");
+} else {
+clc->chroma_sample_position = ctx->chroma_sample_position;
+}
+}
+
+if (ctx->tick_rate.num && ctx->tick_rate.den) {
+int num, den;
+
+av_reduce(&num, &den, ctx->tick_rate.

Re: [FFmpeg-devel] swscale : add bitexact conv for grayf32 and gray16 to f32 conv

2018-09-17 Thread Michael Niedermayer
On Mon, Sep 17, 2018 at 09:04:06AM +0200, Martin Vignali wrote:
> > also, have you tried adding a small constant to tmp ?
> > i would expect that this or a similar operation would allow moving
> > away from all "unstable" points without really changing the output in a
> > relevant way.
> >
> >
> Can't find an op, in mult mode, in order to not raise the assert
> But if i use add calc instead of mult,
> I can have a bigger tolerance without raising the assert
> 
> In 8 bits mode
> Tolerance
> 0.1 : pass
> 0.0001 : fail for i = 1
> 0.001 : fail for i in [1, 2, 4, 8]
> 0.01 : fail for i in [1, 2, 4, 8, 16, 32, 64]
> 
> In 16 bits mode
> 0.1 : pass
> 0.0001 : fail for i in [1, 257, 259, 261, 263, 265, 267, 269, 271,
> 273, 275, 277, 279, 281, 65407]
> 
> using this code :
> #define assert_stable_float(x) av_assert0((float)(x+0.1) ==
> (float)(x-0.1))
> static void inline fill_uint_to_float_lut(SwsContext *c, int bitdepth) {
> static const double float_mult8 = 1.0 / 255.0;
> static const double float_mult16 = 1.0 / 65535.0;
> int i;
> double tmp = 0.;
> 
> if (bitdepth == 8) { /*! fill uint8 to float lut */
> for (i = 0; i < 256; ++i){
> c->uint2float_lut[i] = (float)tmp;
> tmp += float_mult8;
> assert_stable_float(tmp);
> }
> } else if (bitdepth == 16) { /*! fill uint16 to float lut */
> for (i = 0; i < 65536; ++i){
> c->uint2float_lut[i] = (float)tmp;
> tmp += float_mult16;
> assert_stable_float(tmp);

This is very unstable, alot worse than before, also the C compiler
optimizer can replace it by a float_mult16*(i+1)

The reason why this works is probably because it skips the 0 element
and not for any reason of this being "better" (the table is just shifted by
1 element)
0 will always fail the assert, i missed this before. 0 does not need to
be tested, 0 will stay 0 normally in practice probably

also there are 2 divisions in this that you can trivially eliminate
/255 and /65535 (extra precission beyond IEEE float/double could change
these)

also the whole could be done with fewer floats and no extra complexity
for example:
int64_t tmp2 = 16843009LL * i;
(float)((double)tmp2 / (1LL<<32))
and
int64_t tmp2 = 4295032833LL * i or uint64_t 281479271743489


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

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.


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


Re: [FFmpeg-devel] [PATCH v2 1/3] libaomenc: Add support for tiles

2018-09-17 Thread James Almer
On 9/17/2018 8:47 PM, Mark Thompson wrote:
> Adds an option to specify the number of tile rows and columns, then uses
> equal-sized tiles to fill the frame.
> ---
>  libavcodec/libaomenc.c | 54 ++
>  1 file changed, 54 insertions(+)
> 
> diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> index 6a79d9b873..3ccff0e0fb 100644
> --- a/libavcodec/libaomenc.c
> +++ b/libavcodec/libaomenc.c
> @@ -68,6 +68,7 @@ typedef struct AOMEncoderContext {
>  int static_thresh;
>  int drop_threshold;
>  int noise_sensitivity;
> +int tile_cols, tile_rows;
>  } AOMContext;
>  
>  static const char *const ctlidstr[] = {
> @@ -79,6 +80,7 @@ static const char *const ctlidstr[] = {
>  [AV1E_SET_COLOR_PRIMARIES]  = "AV1E_SET_COLOR_PRIMARIES",
>  [AV1E_SET_MATRIX_COEFFICIENTS] = "AV1E_SET_MATRIX_COEFFICIENTS",
>  [AV1E_SET_TRANSFER_CHARACTERISTICS] = 
> "AV1E_SET_TRANSFER_CHARACTERISTICS",
> +[AV1E_SET_SUPERBLOCK_SIZE]  = "AV1E_SET_SUPERBLOCK_SIZE",
>  };
>  
>  static av_cold void log_encoder_error(AVCodecContext *avctx, const char 
> *desc)
> @@ -143,6 +145,10 @@ static av_cold void dump_enc_cfg(AVCodecContext *avctx,
> width, "kf_mode:", cfg->kf_mode,
> width, "kf_min_dist:", cfg->kf_min_dist,
> width, "kf_max_dist:", cfg->kf_max_dist);
> +av_log(avctx, level, "tile settings\n"
> + "  %*s%d\n  %*s%d\n",
> +   width, "tile_width_count:",  cfg->tile_width_count,
> +   width, "tile_height_count:", cfg->tile_height_count);
>  av_log(avctx, level, "\n");
>  }
>  
> @@ -294,6 +300,7 @@ static av_cold int aom_init(AVCodecContext *avctx,
>  int res;
>  aom_img_fmt_t img_fmt;
>  aom_codec_caps_t codec_caps = aom_codec_get_caps(iface);
> +aom_superblock_size_t superblock_size = AOM_SUPERBLOCK_SIZE_DYNAMIC;
>  
>  av_log(avctx, AV_LOG_INFO, "%s\n", aom_codec_version_str());
>  av_log(avctx, AV_LOG_VERBOSE, "%s\n", aom_codec_build_config());
> @@ -431,6 +438,50 @@ static av_cold int aom_init(AVCodecContext *avctx,
>  
>  enccfg.g_error_resilient = ctx->error_resilient;
>  
> +if (ctx->tile_cols && ctx->tile_rows) {
> +int sb_size, sb_width, sb_height;
> +int cols_per_tile, cols_step, rows_per_tile, rows_step, i;
> +
> +// Default to 128x128 superblocks if they fit, otherwise use 64x64.
> +if ((avctx->width  + 127) / 128 < ctx->tile_cols ||
> +(avctx->height + 127) / 128 < ctx->tile_rows) {
> +sb_size = 64;
> +superblock_size = AOM_SUPERBLOCK_SIZE_64X64;
> +} else {
> +sb_size = 128;
> +superblock_size = AOM_SUPERBLOCK_SIZE_128X128;
> +}
> +
> +if ((avctx->width  + sb_size - 1) / sb_size < ctx->tile_cols ||
> +(avctx->height + sb_size - 1) / sb_size < ctx->tile_rows) {
> +av_log(avctx, AV_LOG_ERROR, "Invalid tile sizing: frame not "
> +   "large enough to fit specified tile arrangement.\n");
> +return AVERROR(EINVAL);
> +}
> +if (ctx->tile_cols > MAX_TILE_WIDTHS ||
> +ctx->tile_rows > MAX_TILE_HEIGHTS) {
> +av_log(avctx, AV_LOG_ERROR, "Invalid tile sizing: at most %dx%d "
> +   "tiles allowed.\n", MAX_TILE_WIDTHS, MAX_TILE_HEIGHTS);
> +return AVERROR(EINVAL);
> +}
> +
> +enccfg.tile_width_count  = ctx->tile_cols;
> +enccfg.tile_height_count = ctx->tile_rows;
> +
> +sb_width  = (avctx->width  + sb_size - 1) / sb_size;
> +sb_height = (avctx->height + sb_size - 1) / sb_size;
> +
> +cols_per_tile = sb_width / ctx->tile_cols;
> +cols_step = sb_width % ctx->tile_cols;
> +for (i = 0; i < ctx->tile_cols; i++)
> +enccfg.tile_widths[i] = cols_per_tile + (i < cols_step);
> +
> +rows_per_tile = sb_height / ctx->tile_rows;
> +rows_step = sb_height % ctx->tile_rows;
> +for (i = 0; i < ctx->tile_rows; i++)
> +enccfg.tile_heights[i] = rows_per_tile + (i < rows_step);
> +}
> +
>  dump_enc_cfg(avctx, &enccfg);
>  /* Construct Encoder Context */
>  res = aom_codec_enc_init(&ctx->encoder, iface, &enccfg, flags);
> @@ -454,6 +505,8 @@ static av_cold int aom_init(AVCodecContext *avctx,
>  codecctl_int(avctx, AV1E_SET_TRANSFER_CHARACTERISTICS, avctx->color_trc);
>  set_color_range(avctx);
>  
> +codecctl_int(avctx, AV1E_SET_SUPERBLOCK_SIZE, superblock_size);
> +
>  // provide dummy value to initialize wrapper, values will be updated 
> each _encode()
>  aom_img_wrap(&ctx->rawimg, img_fmt, avctx->width, avctx->height, 1,
>   (unsigned char*)1);
> @@ -742,6 +795,7 @@ static const AVOption options[] = {
>  { "static-thresh","A change threshold on blocks below which they 
> will be skipped by the encoder", OFFSET(static_thresh), AV_OPT_TYPE_INT, { 
> .i64 = 0 }

Re: [FFmpeg-devel] [PATCH V7 0/3] enable multi-slices in vaapi_h264/265 encoder

2018-09-17 Thread myp...@gmail.com
Ping?
On Wed, Sep 12, 2018 at 8:49 AM myp...@gmail.com  wrote:
>
>
> On Wed, Aug 29, 2018 at 6:47 PM Jun Zhao  wrote:
> >
> > V7: - Fix h264 first_mb_in_slice setting issue. (root cause by Mark)
> > - Refine the error handle
> >
> > V6: - Use rectangular slices and refine the code.
> >
> > V5: - In h265_vaapi encoder, when setting slice number > max slice number
> >   supported by driver, report error and return. Same as h264_vaapi.
> > - Clean the logic when setting first_slice_segment_in_pic_flags.
> >
> > V4: - Change the array malloc function.
> > - Clean the pointless condition check when free the memory.
> >
> > V3: - Making pic->slices be VAAPIEncodeSlice* instead of VAAPIEncodeSlice**.
> > - Fix resource (vaBuffer) lead when realloc pic->param_buffers fail.
> > - Adjust max_slices location in VAAPIEncodeContext.
> > - Re-work distributing the macro-blocks for multi-slices function.
> >
> > V2: - Change the slice/parameter buffers to dynamic alloc and split the 
> > mutil-slice support for AVC/HEVC.
> >
> > Jun Zhao (3):
> >   lavc/vaapi_encode: Add max slices number query.
> >   lavc/vaapi_encode_h264: respect "slices" option in h264 vaapi encoder
> >   lavc/vaapi_encode_h265: respect "slices" option in h265 vaapi encoder
> >
> >  libavcodec/vaapi_encode.c  |4 +++
> >  libavcodec/vaapi_encode.h  |4 +++
> >  libavcodec/vaapi_encode_h264.c |   39 +
> >  libavcodec/vaapi_encode_h265.c |   41 
> > ++-
> >  4 files changed, 77 insertions(+), 11 deletions(-)
> >
>
> Ping, any comments for this patch-sets?



-- 
===
Jun zhao/赵军
+++
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 2/3] lavc: Add coded bitstream read/write support for AV1

2018-09-17 Thread James Almer
On 9/17/2018 8:47 PM, Mark Thompson wrote:
> ---
> On 10/09/18 00:40, James Almer wrote:
>> On 9/9/2018 7:08 PM, Mark Thompson wrote:
>>> +static int cbs_av1_split_fragment(CodedBitstreamContext *ctx,
>>> +  CodedBitstreamFragment *frag,
>>> +  int header)
>> ...
>> This is generating a lot of noise when using the trace_headers bsf.
>> Basically printing the header fields twice per OBU, first when
>> splitting, then again when decomposing.
>>
>> You can get rid of that and simplify this function a lot if you use the
>> ff_av1_packet_split() API from av1_parse.h doing more or less the same
>> to what you're doing for h2645:
> 
> I think I'm going to pass on using the split API here, since it doesn't have 
> the same avoidance of overruns or the precise errors.  (Compared to H.26[45] 
> there is a lot less going on here - we don't need to allocate anything, 
> because there is no step to remove the emulation prevention bytes.)
> 
> So, I just fixed the output noise by switching off tracing inside that 
> function.
> 
> 
> On 10/09/18 20:14, Michael Niedermayer wrote:
>> breaks build on mips:
>> CC   libavcodec/av1_metadata_bsf.o
>> In file included from src/libavcodec/av1_metadata_bsf.c:25:
>> src/libavcodec/cbs_av1.h:364: warning: declaration does not declare anything
>> src/libavcodec/cbs_av1.h:380: warning: declaration does not declare anything
>> ... lots of errors because of anonymous unions ...
> 
> Fixed by giving these unions redundant names.  Anonymous unions would be 
> nice, but they're probably a little too much trouble still for old compilers.

I think GCC 4.8, used in CentOS, had trouble with those as well. But at
some point we should probably just set the minimum version to something
like GCC 4.9 (First version with C11 atomics). It would probably
simplify a lot of code beyond just anonymous unions.

> 
> 
> On 11/09/18 14:15, James Almer wrote:
>> On 9/9/2018 7:08 PM, Mark Thompson wrote:
>>> +static void cbs_av1_free_obu(void *unit, uint8_t *content)
>>> +{
>>> +AV1RawOBU *obu = (AV1RawOBU*)content;
>>> +
>>> +switch (obu->header.obu_type) {
>>> +case AV1_OBU_TILE_GROUP:
>>> +cbs_av1_free_tile_data(&obu->tile_group.tile_data);
>>> +break;
>>> +case AV1_OBU_FRAME:
>>> +cbs_av1_free_tile_data(&obu->frame.tile_group.tile_data);
>>> +break;
>>> +case AV1_OBU_TILE_LIST:
>>> +cbs_av1_free_tile_data(&obu->tile_list.tile_data);
>>> +break;
>>> +case AV1_OBU_METADATA:
>>> +cbs_av1_free_metadata(&obu->metadata);
>>> +break;
>>> +}
>>> +
>>> +av_freep(&obu);
>>
>> Why adding a custom free function for all OBUs when only four types need
>> it? Sounds like unnecessary overhead for all cases.
>> IMO what cbs_h2645 does is better, using the default free function where
>> a custom one isn't needed, then calling a custom free function directly
>> for those that need one.
> 
> I don't think I agree.  Adding separate free functions for each case 
> requiring it would be more complex code overall (since the code making the 
> OBU structures would need to select the right one rather than all using the 
> same allocation as below), and the default free function is completely 
> equivalent to this one in the other cases.
> 
> 
> Thanks,
> 
> - Mark

Looks good now. Thanks!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avcodec: [loongson] optimize get_cabac_inline.

2018-09-17 Thread Shiyou Yin
This optimization improved h264 decoding performance about 4%(from 74fps to 
77fps, tested on loongson 3A3000).
---
 libavcodec/cabac_functions.h |   3 ++
 libavcodec/mips/cabac.h  | 119 +++
 2 files changed, 122 insertions(+)
 create mode 100644 libavcodec/mips/cabac.h

diff --git a/libavcodec/cabac_functions.h b/libavcodec/cabac_functions.h
index fe72a82..bb2b421 100644
--- a/libavcodec/cabac_functions.h
+++ b/libavcodec/cabac_functions.h
@@ -45,6 +45,9 @@
 #if ARCH_X86
 #   include "x86/cabac.h"
 #endif
+#if ARCH_MIPS
+#   include "mips/cabac.h"
+#endif
 
 static const uint8_t * const ff_h264_norm_shift = ff_h264_cabac_tables + 
H264_NORM_SHIFT_OFFSET;
 static const uint8_t * const ff_h264_lps_range = ff_h264_cabac_tables + 
H264_LPS_RANGE_OFFSET;
diff --git a/libavcodec/mips/cabac.h b/libavcodec/mips/cabac.h
new file mode 100644
index 000..82cee29
--- /dev/null
+++ b/libavcodec/mips/cabac.h
@@ -0,0 +1,119 @@
+/*
+ * Loongson SIMD optimized h264chroma
+ *
+ * Copyright (c) 2018 Loongson Technology Corporation Limited
+ * Copyright (c) 2018 Shiyou Yin 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_MIPS_CABAC_H
+#define AVCODEC_MIPS_CABAC_H
+
+#include "libavcodec/cabac.h"
+#include "libavutil/mips/mmiutils.h"
+#include "config.h"
+
+#define get_cabac_inline get_cabac_inline_mips
+static av_always_inline int get_cabac_inline(CABACContext *c,
+ uint8_t * const state){
+mips_reg tmp0, tmp1, tmp2, bit;
+
+__asm__ volatile (
+"lbu  %[bit],0(%[state])   \n\t"
+"and  %[tmp0],   %[c_range], 0xC0  \n\t"
+PTR_ADDU "%[tmp0],   %[tmp0],%[tmp0]   \n\t"
+PTR_ADDU "%[tmp0],   %[tmp0],%[tables] \n\t"
+PTR_ADDU "%[tmp0],   %[tmp0],%[bit]\n\t"
+/* tmp1: RangeLPS */
+"lbu  %[tmp1],   %[lps_off](%[tmp0])   \n\t"
+
+PTR_SUBU "%[c_range],%[c_range], %[tmp1]   \n\t"
+PTR_SLL  "%[tmp0],   %[c_range], 0x11  \n\t"
+PTR_SUBU "%[tmp0],   %[tmp0],%[c_low]  \n\t"
+
+/* tmp2: lps_mask */
+PTR_SRA  "%[tmp2],   %[tmp0],0x1F  \n\t"
+/* If tmp0 < 0, lps_mask ==  0x*/
+/* If tmp0 >= 0, lps_mask ==  0x*/
+"beqz %[tmp2],   1f\n\t"
+PTR_SLL  "%[tmp0],   %[c_range], 0x11  \n\t"
+PTR_SUBU "%[c_low],  %[c_low],   %[tmp0]   \n\t"
+PTR_SUBU "%[tmp0],   %[tmp1],%[c_range]\n\t"
+PTR_ADDU "%[c_range],%[c_range], %[tmp0]   \n\t"
+"xor  %[bit],%[bit], %[tmp2]   \n\t"
+
+"1:\n\t"
+/* tmp1: *state */
+PTR_ADDU "%[tmp0],   %[tables],  %[bit]\n\t"
+"lbu  %[tmp1],   %[mlps_off](%[tmp0])  \n\t"
+/* tmp2: lps_mask */
+PTR_ADDU "%[tmp0],   %[tables],  %[c_range]\n\t"
+"lbu  %[tmp2],   %[norm_off](%[tmp0])  \n\t"
+
+"sb   %[tmp1],   0(%[state])   \n\t"
+"and  %[bit],%[bit], 0x01  \n\t"
+PTR_SLL  "%[c_range],%[c_range], %[tmp2]   \n\t"
+PTR_SLL  "%[c_low],  %[c_low],   %[tmp2]   \n\t"
+
+"and  %[tmp0],   %[c_low],   %[cabac_mask] \n\t"
+"bnez %[tmp0],   1f\n\t"
+PTR_ADDI "%[tmp0],   %[c_low],   -0X01 \n\t"
+"xor  %[tmp0],   %[c_low],   %[tmp0]   \n\t"
+PTR_SRA  "%[tmp0],   %[tmp0],0x0f  \n\t"
+PTR_ADDU "%[tmp0],   %[tmp0],%[tables] \n\t"
+"lbu  %[tmp2],   %[norm_off](%[tmp0])  \n\t"
+#if CABAC_BITS == 16
+"lbu  %[tmp0],   0(%[c_bytestream])\n\t"
+