Re: [FFmpeg-devel] [PATCH] avcodec/rl2: set dimensions

2019-07-26 Thread Michael Niedermayer
On Thu, Jul 25, 2019 at 05:55:02PM +0200, Paul B Mahol wrote:
> On 7/25/19, Michael Niedermayer  wrote:
> > On Wed, Jul 24, 2019 at 02:42:24PM +0200, Lynne wrote:
> >> Jul 24, 2019, 11:08 AM by mich...@niedermayer.cc:
> >>
> >> >
> >> > What did you expect ? IIRC you have asked for whole classes of security
> >> > issues to be not fixed.
> >> >
> >> > Something like that would require a vote and majority of developers.
> >> >
> >>
> >> The way I interpret this: "Of course I ignored you, you're mental!",
> >> doesn't help. And I don't think its just me.
> >
> > You are reading something into this that i have never meant or written
> >
> >
> >> And you do remember incorrectly in saying that I want this whole class of
> >> security issues not fixed. In this thread I specifically raised the issue
> >> of what is considered to be a security issue by asking whether a speedup
> >> of failing to decode from 2 to 0.4 seconds is considered such or what's
> >> considered acceptable in general.
> >> And I think I'll disagree that it is. 16 seconds to 2 seconds I can
> >> accept, but not 2 to 0.4.
> >
> > These durations are the testcases found by the fuzzer, they say nothing
> > about
> > what the worst case for an issue is.
> > The fuzzer builds a testcase trying to exceed a timeout it stops trying to
> > "improve" it once it found something that takes a few seconds.
> >
> > You can in general make these cases significantly longer running.
> >
> > The reason why the fuzzer doesnt produce hour or day long timeouts is just
> > because
> > it doesnt search for anything longer than a few seconds.
> >
> >
> >>
> >>
> >>
> >> >> These patches affect decoding of real world broken files in favor of
> >> >> fixing specially crafted fuzzed files.
> >> >>
> >> >
> >> > Iam happy to look into such cases. Can you provide me with such
> >> > "real world broken files"?
> >> > Its not intended to worsen the output from such files
> >> >
> >>
> >> Simple logical analysis, "if file is somewhat broken, don't try decoding"
> >> does very well indicate that it won't only apply for _this_ broken file,
> >> but in general.
> >> Thus, this is for you to prove. I've said it before that otherwise its a
> >> burden to other developers to have to screen all of these patches.
> >
> > The changes i do in general, i think about potential effects on
> > slightly broken files and try to test with what iam able to find as
> > matching
> > input material.
> > I find it a bit rude from you that you assume i would not already consider
> > this
> > case.
> > Do i never make a mistake ? well i wish so but iam a human. So again if you
> > know of specific cases where theres a problem, tell me about them please
> >
> >
> >>
> >>
> >>
> >> >> Sure, protecting against ddos attacts is important, but not important
> >> >> enough to make decoders give up early and return nothing. Especially in
> >> >> cases where the timeout speedup is of the order of 2s to 400ms.
> >> >> Yet in all of those timeout patches all you've cared about is shutting
> >> >> up the tool. You've never once shown any figures if this could affect
> >> >> decoding, because its a lot harder than just showing they fix something
> >> >> some tool calls a timeout and forgetting about it. You haven't even
> >> >> commented on this when I asked you on IRC.
> >> >> You also sneak this type of patches in when there's an overflow later
> >> >> on during decoding, which is completely incorrect in almost all cases,
> >> >> for the same reason above.
> >> >>
> >> >
> >> > if you know of issues in a patch or commit you should report this
> >> > during patch review or as soon as you find out about the issue
> >> > as a reply to that patch or commit or as mail to the author.
> >> >
> >>
> >> That's what I'm doing.
> >> That aside, you've completely ignored my statements on what's considered
> >> acceptable, showing figures, and sneaking this type of patches to fix
> >> undefined behavior.
> >> Making your reply a simple refutation, rather than addressing anything
> >> I've said.
> >> So I'm asking you again, what is considered a security issue and what is
> >> considered acceptable? And what is considered not a security issue but a
> >> complaint from an overzealous automated tool.
> >
> > undefined behavior is unacceptable. Its not allowed in C. It doesnt matter
> > here if its a security issue or not.
> >
> > Timeouts can in general be used for denial of service attacks. While this
> > is less critical than many other security issues it is a security issue.
> > Also for Timeouts many point to bugs, to missing end of input checks, to
> > missing
> > checks in or before loops, to missing EOF checks, to missing checks that
> > the input actually contains enough data resembling a fraction of the
> > smallest
> > half valid frame.
> >
> > We can spend many hours and days arguing if a issue is critical enough to
> > be
> > a security issue. maybe the one we would look at is not but then i still
> > would
> > t

Re: [FFmpeg-devel] [PATCH v7 2/2] lavc/tiff: Decode embedded JPEGs in DNG images

2019-07-26 Thread Nick Renieris
Στις Παρ, 26 Ιουλ 2019 στις 2:21 π.μ., ο/η Reimar Döffinger
 έγραψε:
>
> On 25.07.2019, at 17:35, velocit...@gmail.com wrote:
>
> > +// Lookup table lookup
> > +if (lut)
> > +value = lut[value];
>
> As this function is in the innermost loop, doing the if here instead of 
> having 2 different implementations is likely not ideal speed-wise.

If this were C++ this'd be trivial, but as it stands I don't see a way
to do this without sacrificing code readability and/or size.
I believe branch prediction and instruction pipelining will hide this
delay. I doubt it has any measurable effect on performance.

> > +// Color scaling
> > +value = av_clip_uint16_c((unsigned)(((float)value * scale_factor) * 
> > 0x));
>
> As input and output are both 16 bit I wonder if floating-point isn't rather 
> overkill compared to doing fixed-point arithmetic.

Scaling in the [0.0, 1.0] range is mentioned in the DNG spec and it's
also what dcraw does.

> >
> > +if (is_u16) {
> > +for (line = 0; line < height; line++) {
> > +uint16_t *dst_u16 = (uint16_t *)dst;
> > +uint16_t *src_u16 = (uint16_t *)src;
> > +
> > +for (col = 0; col < width; col++)
> > +*dst_u16++ = dng_raw_to_linear16(*src_u16++, s->dng_lut, 
> > s->black_level, scale_factor);
> > +
> > +dst += dst_stride * sizeof(uint16_t);
> > +src += src_stride * sizeof(uint16_t);
>
> Is all this casting working correctly on e.g. big-endian?

Not sure, I don't see why not, considering I've seen such casting in
other parts of ffmpeg.

> Also using sizeof on uint16_t and uint8_t seems a bit overkill.

It makes the programmer's intention clear, I think that's worth the
few extra characters.

> Also not sure if since these are essentially brightness/contrast adjustments 
> if we should't rather just have a way to export the transform to use...

Export to where? I don't see why you'd need to complicate this by
calling into other components, the transformation code is concise,
clear and accurate for this use case.

>
> > @@ -1519,6 +1773,26 @@ again:
> > return AVERROR_INVALIDDATA;
> > }
> >
> > +/* Handle DNG images with JPEG-compressed tiles */
> > +
> > +if (s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == 
> > TIFF_TYPE_CINEMADNG) {
> > +if (s->is_jpeg) {
> > +if (s->is_bayer) {
> > +if ((ret = dng_decode(avctx, (AVFrame*)data, avpkt)) > 0)
> > +*got_frame = 1;
> > +return ret;
> > +} else {
> > +avpriv_report_missing_feature(avctx, "DNG JPG-compressed 
> > non-bayer-encoded images");
> > +return AVERROR_PATCHWELCOME;
> > +}
> > +} else if (s->is_tiled) {
> > +avpriv_report_missing_feature(avctx, "DNG uncompressed tiled 
> > images");
> > +return AVERROR_PATCHWELCOME;
> > +}
>
> There is no need for an "else" block if the "if" block ends in a return.

Indeed, but in my opinion it makes the code clearer on first glance
(if you miss the return). I can change it if you insist.

> Also putting the error handling first/at the deepest indentation level 
> results in more readable code generally.

That's true, I will do that.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v8 2/2] lavc/tiff: Decode embedded JPEGs in DNG images

2019-07-26 Thread velocityra
From: Nick Renieris 

Used a technique similar to lavc/tdsc.c for invoking the MJPEG decoder.

This commit adds support for:
- DNG tiles
- DNG tile huffman lossless JPEG decoding
- DNG 8-bpp ("packed" as dcraw calls it) decoding
- DNG color scaling [1]
  - LinearizationTable tag
  - BlackLevel tag

[1]: As specified in the DNG Specification - Chapter 5

Signed-off-by: Nick Renieris 
---
 configure   |   1 +
 libavcodec/Makefile |   2 +-
 libavcodec/tiff.c   | 315 +++-
 libavcodec/tiff.h   |   2 +
 4 files changed, 312 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index 5a4f507246..6726883d5b 100755
--- a/configure
+++ b/configure
@@ -2811,6 +2811,7 @@ tdsc_decoder_deps="zlib"
 tdsc_decoder_select="mjpeg_decoder"
 theora_decoder_select="vp3_decoder"
 thp_decoder_select="mjpeg_decoder"
+tiff_decoder_select="mjpeg_decoder"
 tiff_decoder_suggest="zlib lzma"
 tiff_encoder_suggest="zlib"
 truehd_decoder_select="mlp_parser"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3cd73fbcc6..f814c69996 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -616,7 +616,7 @@ OBJS-$(CONFIG_TARGA_ENCODER)   += targaenc.o rle.o
 OBJS-$(CONFIG_TARGA_Y216_DECODER)  += targa_y216dec.o
 OBJS-$(CONFIG_TDSC_DECODER)+= tdsc.o
 OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o
-OBJS-$(CONFIG_TIFF_DECODER)+= tiff.o lzw.o faxcompr.o tiff_data.o 
tiff_common.o
+OBJS-$(CONFIG_TIFF_DECODER)+= tiff.o lzw.o faxcompr.o tiff_data.o 
tiff_common.o mjpegdec.o
 OBJS-$(CONFIG_TIFF_ENCODER)+= tiffenc.o rle.o lzwenc.o tiff_data.o
 OBJS-$(CONFIG_TMV_DECODER) += tmv.o cga_data.o
 OBJS-$(CONFIG_TRUEHD_DECODER)  += mlpdec.o mlpdsp.o
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index c520d7df83..09cec2 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -35,6 +35,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/avstring.h"
+#include "libavutil/error.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
@@ -46,6 +47,7 @@
 #include "mathops.h"
 #include "tiff.h"
 #include "tiff_data.h"
+#include "mjpegdec.h"
 #include "thread.h"
 #include "get_bits.h"
 
@@ -54,6 +56,10 @@ typedef struct TiffContext {
 AVCodecContext *avctx;
 GetByteContext gb;
 
+/* JPEG decoding for DNG */
+AVCodecContext *avctx_mjpeg; // wrapper context for MJPEG
+AVFrame *jpgframe;   // decoded JPEG tile
+
 int get_subimage;
 uint16_t get_page;
 int get_thumbnail;
@@ -76,7 +82,9 @@ typedef struct TiffContext {
 
 int is_bayer;
 uint8_t pattern[4];
+unsigned black_level;
 unsigned white_level;
+const uint16_t *dng_lut; // Pointer to DNG linearization table
 
 uint32_t sub_ifd;
 uint16_t cur_page;
@@ -86,6 +94,14 @@ typedef struct TiffContext {
 int stripsizesoff, stripsize, stripoff, strippos;
 LZWState *lzw;
 
+/* Tile support */
+int is_tiled;
+int tile_byte_counts_offset, tile_offsets_offset;
+int tile_width, tile_length;
+int tile_count;
+
+int is_jpeg;
+
 uint8_t *deinvert_buf;
 int deinvert_buf_size;
 uint8_t *yuv_line;
@@ -257,6 +273,9 @@ static int add_metadata(int count, int type,
 };
 }
 
+static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
+  const uint8_t *src, int src_stride, int 
width, int height, int is_u16);
+
 static void av_always_inline horizontal_fill(TiffContext *s,
  unsigned int bpp, uint8_t* dst,
  int usePtr, const uint8_t *src,
@@ -712,6 +731,204 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 return 0;
 }
 
+/**
+ * Map stored raw sensor values into linear reference values.
+ * See: DNG Specification - Chapter 5
+ */
+static uint16_t av_always_inline dng_raw_to_linear16(uint16_t value,
+const uint16_t *lut,
+uint16_t black_level,
+float scale_factor) {
+// Lookup table lookup
+if (lut)
+value = lut[value];
+
+// Black level subtraction
+value = av_clip_uint16_c((unsigned)value - black_level);
+
+// Color scaling
+value = av_clip_uint16_c((unsigned)(((float)value * scale_factor) * 
0x));
+
+return value;
+}
+
+static uint16_t av_always_inline dng_raw_to_linear8(uint16_t value,
+const uint16_t *lut,
+uint16_t black_level,
+float scale_factor) {
+return dng_raw_to_linear16(value, lut, black_level, scale_factor) >> 8;
+}
+
+static void dng_blit(TiffContext *s,

[FFmpeg-devel] [PATCH v8 1/2] lavc/mjpegdec: Decode Huffman-coded lossless JPEGs embedded in DNGs

2019-07-26 Thread velocityra
From: Nick Renieris 

Main image data in DNGs is usually comprised of tiles, each of which is a 
Huffman-encoded lossless JPEG.

Tested for ljpeg regressions with:
`ffmpeg -f lavfi -i testsrc=d=1 -vcodec ljpeg test.avi`
`ffmpeg test.avi out.avi`
The modified code in ljpeg_decode_rgb_scan runs without issues.

Signed-off-by: Nick Renieris 
---
 libavcodec/mjpegdec.c | 52 +--
 libavcodec/mjpegdec.h |  1 +
 2 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index a65bc8df15..6391107f78 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -412,6 +412,14 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 return AVERROR_PATCHWELCOME;
 }
 
+/* Lossless JPEGs encoded in DNGs are commonly bayer-encoded. They contain 
2
+   interleaved components and the width stored in their SOF3 markers is the
+   width of each one.  We only output a single component, therefore we need
+   to adjust the output image width. */
+if (s->lossless == 1 && nb_components == 2) {
+s->bayer = 1;
+width *= 2;
+}
 
 /* if different size, realloc/alloc picture */
 if (width != s->width || height != s->height || bits != s->bits ||
@@ -488,6 +496,9 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 }
 
 switch (pix_fmt_id) {
+case 0x: /* for bayer-encoded huffman lossless JPEGs embedded 
in DNGs */
+s->avctx->pix_fmt = AV_PIX_FMT_GRAY16LE;
+break;
 case 0x1100:
 if (s->rgb)
 s->avctx->pix_fmt = s->bits <= 9 ? AV_PIX_FMT_BGR24 : 
AV_PIX_FMT_BGR48;
@@ -1041,17 +1052,20 @@ static int handle_rstn(MJpegDecodeContext *s, int 
nb_components)
 return reset;
 }
 
+/* Handles 1 to 4 components */
 static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int 
predictor, int point_transform)
 {
 int i, mb_x, mb_y;
+unsigned width;
 uint16_t (*buffer)[4];
 int left[4], top[4], topleft[4];
 const int linesize = s->linesize[0];
 const int mask = ((1 << s->bits) - 1) << point_transform;
 int resync_mb_y = 0;
 int resync_mb_x = 0;
+int vpred[6];
 
-if (s->nb_components != 3 && s->nb_components != 4)
+if (s->nb_components <= 0 || s->nb_components > 4)
 return AVERROR_INVALIDDATA;
 if (s->v_max != 1 || s->h_max != 1 || !s->lossless)
 return AVERROR_INVALIDDATA;
@@ -1059,8 +1073,15 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 
 s->restart_count = s->restart_interval;
 
-av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size,
-   (unsigned)s->mb_width * 4 * sizeof(s->ljpeg_buffer[0][0]));
+if (s->restart_interval == 0)
+s->restart_interval = INT_MAX;
+
+if (s->bayer)
+width = s->mb_width / nb_components; /* Interleaved, width stored is 
the total so need to divide */
+else
+width = s->mb_width;
+
+av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size, width * 4 * 
sizeof(s->ljpeg_buffer[0][0]));
 if (!s->ljpeg_buffer)
 return AVERROR(ENOMEM);
 
@@ -1078,7 +1099,12 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 for (i = 0; i < 4; i++)
 top[i] = left[i] = topleft[i] = buffer[0][i];
 
-for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
+if ((mb_y * s->width) % s->restart_interval == 0) {
+for (i = 0; i < 6; i++)
+vpred[i] = 1 << (s->bits-1);
+}
+
+for (mb_x = 0; mb_x < width; mb_x++) {
 int modified_predictor = predictor;
 
 if (get_bits_left(&s->gb) < 1) {
@@ -1102,12 +1128,19 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 topleft[i] = top[i];
 top[i] = buffer[mb_x][i];
 
-PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
-
 dc = mjpeg_decode_dc(s, s->dc_index[i]);
 if(dc == 0xF)
 return -1;
 
+if (!s->bayer || mb_x) {
+pred = left[i];
+} else { /* This path runs only for the first line in bayer 
images */
+vpred[i] += dc;
+pred = vpred[i] - dc;
+}
+
+PREDICT(pred, topleft[i], top[i], pred, modified_predictor);
+
 left[i] = buffer[mb_x][i] =
 mask & (pred + (unsigned)(dc * (1 << point_transform)));
 }
@@ -1151,6 +1184,11 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
 ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
 }
+} else if (s->bayer && nb_components == 2) {
+for (mb_x = 0; mb

[FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: fix the memory leak

2019-07-26 Thread Linjie Fu
av_dict_free child_device_opts to fix the memory leak.

Signed-off-by: Linjie Fu 
---
 libavutil/hwcontext_qsv.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 59e4ed9157..0329a81ec3 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -1240,6 +1240,8 @@ static int qsv_device_create(AVHWDeviceContext *ctx, 
const char *device,
 
 ret = av_hwdevice_ctx_create(&priv->child_device_ctx, child_device_type,
  e ? e->value : NULL, child_device_opts, 0);
+
+av_dict_free(&child_device_opts);
 if (ret < 0)
 return ret;
 
-- 
2.17.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v9 1/2] lavc/mjpegdec: Decode Huffman-coded lossless JPEGs embedded in DNGs

2019-07-26 Thread velocityra
From: Nick Renieris 

Main image data in DNGs is usually comprised of tiles, each of which is a 
Huffman-encoded lossless JPEG.

Tested for ljpeg regressions with:
`ffmpeg -f lavfi -i testsrc=d=1 -vcodec ljpeg test.avi`
`ffmpeg test.avi out.avi`
The modified code in ljpeg_decode_rgb_scan runs without issues.

Signed-off-by: Nick Renieris 
---
 libavcodec/mjpegdec.c | 52 +--
 libavcodec/mjpegdec.h |  1 +
 2 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index a65bc8df15..6391107f78 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -412,6 +412,14 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 return AVERROR_PATCHWELCOME;
 }
 
+/* Lossless JPEGs encoded in DNGs are commonly bayer-encoded. They contain 
2
+   interleaved components and the width stored in their SOF3 markers is the
+   width of each one.  We only output a single component, therefore we need
+   to adjust the output image width. */
+if (s->lossless == 1 && nb_components == 2) {
+s->bayer = 1;
+width *= 2;
+}
 
 /* if different size, realloc/alloc picture */
 if (width != s->width || height != s->height || bits != s->bits ||
@@ -488,6 +496,9 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
 }
 
 switch (pix_fmt_id) {
+case 0x: /* for bayer-encoded huffman lossless JPEGs embedded 
in DNGs */
+s->avctx->pix_fmt = AV_PIX_FMT_GRAY16LE;
+break;
 case 0x1100:
 if (s->rgb)
 s->avctx->pix_fmt = s->bits <= 9 ? AV_PIX_FMT_BGR24 : 
AV_PIX_FMT_BGR48;
@@ -1041,17 +1052,20 @@ static int handle_rstn(MJpegDecodeContext *s, int 
nb_components)
 return reset;
 }
 
+/* Handles 1 to 4 components */
 static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int 
predictor, int point_transform)
 {
 int i, mb_x, mb_y;
+unsigned width;
 uint16_t (*buffer)[4];
 int left[4], top[4], topleft[4];
 const int linesize = s->linesize[0];
 const int mask = ((1 << s->bits) - 1) << point_transform;
 int resync_mb_y = 0;
 int resync_mb_x = 0;
+int vpred[6];
 
-if (s->nb_components != 3 && s->nb_components != 4)
+if (s->nb_components <= 0 || s->nb_components > 4)
 return AVERROR_INVALIDDATA;
 if (s->v_max != 1 || s->h_max != 1 || !s->lossless)
 return AVERROR_INVALIDDATA;
@@ -1059,8 +1073,15 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 
 s->restart_count = s->restart_interval;
 
-av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size,
-   (unsigned)s->mb_width * 4 * sizeof(s->ljpeg_buffer[0][0]));
+if (s->restart_interval == 0)
+s->restart_interval = INT_MAX;
+
+if (s->bayer)
+width = s->mb_width / nb_components; /* Interleaved, width stored is 
the total so need to divide */
+else
+width = s->mb_width;
+
+av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size, width * 4 * 
sizeof(s->ljpeg_buffer[0][0]));
 if (!s->ljpeg_buffer)
 return AVERROR(ENOMEM);
 
@@ -1078,7 +1099,12 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 for (i = 0; i < 4; i++)
 top[i] = left[i] = topleft[i] = buffer[0][i];
 
-for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
+if ((mb_y * s->width) % s->restart_interval == 0) {
+for (i = 0; i < 6; i++)
+vpred[i] = 1 << (s->bits-1);
+}
+
+for (mb_x = 0; mb_x < width; mb_x++) {
 int modified_predictor = predictor;
 
 if (get_bits_left(&s->gb) < 1) {
@@ -1102,12 +1128,19 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 topleft[i] = top[i];
 top[i] = buffer[mb_x][i];
 
-PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
-
 dc = mjpeg_decode_dc(s, s->dc_index[i]);
 if(dc == 0xF)
 return -1;
 
+if (!s->bayer || mb_x) {
+pred = left[i];
+} else { /* This path runs only for the first line in bayer 
images */
+vpred[i] += dc;
+pred = vpred[i] - dc;
+}
+
+PREDICT(pred, topleft[i], top[i], pred, modified_predictor);
+
 left[i] = buffer[mb_x][i] =
 mask & (pred + (unsigned)(dc * (1 << point_transform)));
 }
@@ -1151,6 +1184,11 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, 
int nb_components, int p
 ptr[3*mb_x + 0] = buffer[mb_x][1] + ptr[3*mb_x + 1];
 ptr[3*mb_x + 2] = buffer[mb_x][2] + ptr[3*mb_x + 1];
 }
+} else if (s->bayer && nb_components == 2) {
+for (mb_x = 0; mb

[FFmpeg-devel] [PATCH v9 2/2] lavc/tiff: Decode embedded JPEGs in DNG images

2019-07-26 Thread velocityra
From: Nick Renieris 

Used a technique similar to lavc/tdsc.c for invoking the MJPEG decoder.

This commit adds support for:
- DNG tiles
- DNG tile huffman lossless JPEG decoding
- DNG 8-bpp ("packed" as dcraw calls it) decoding
- DNG color scaling [1]
  - LinearizationTable tag
  - BlackLevel tag

[1]: As specified in the DNG Specification - Chapter 5

Signed-off-by: Nick Renieris 
---
 configure   |   1 +
 libavcodec/Makefile |   2 +-
 libavcodec/tiff.c   | 315 +++-
 libavcodec/tiff.h   |   2 +
 4 files changed, 312 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index 5a4f507246..6726883d5b 100755
--- a/configure
+++ b/configure
@@ -2811,6 +2811,7 @@ tdsc_decoder_deps="zlib"
 tdsc_decoder_select="mjpeg_decoder"
 theora_decoder_select="vp3_decoder"
 thp_decoder_select="mjpeg_decoder"
+tiff_decoder_select="mjpeg_decoder"
 tiff_decoder_suggest="zlib lzma"
 tiff_encoder_suggest="zlib"
 truehd_decoder_select="mlp_parser"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3cd73fbcc6..f814c69996 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -616,7 +616,7 @@ OBJS-$(CONFIG_TARGA_ENCODER)   += targaenc.o rle.o
 OBJS-$(CONFIG_TARGA_Y216_DECODER)  += targa_y216dec.o
 OBJS-$(CONFIG_TDSC_DECODER)+= tdsc.o
 OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o
-OBJS-$(CONFIG_TIFF_DECODER)+= tiff.o lzw.o faxcompr.o tiff_data.o 
tiff_common.o
+OBJS-$(CONFIG_TIFF_DECODER)+= tiff.o lzw.o faxcompr.o tiff_data.o 
tiff_common.o mjpegdec.o
 OBJS-$(CONFIG_TIFF_ENCODER)+= tiffenc.o rle.o lzwenc.o tiff_data.o
 OBJS-$(CONFIG_TMV_DECODER) += tmv.o cga_data.o
 OBJS-$(CONFIG_TRUEHD_DECODER)  += mlpdec.o mlpdsp.o
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index c520d7df83..db68690736 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -35,6 +35,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/avstring.h"
+#include "libavutil/error.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
@@ -46,6 +47,7 @@
 #include "mathops.h"
 #include "tiff.h"
 #include "tiff_data.h"
+#include "mjpegdec.h"
 #include "thread.h"
 #include "get_bits.h"
 
@@ -54,6 +56,10 @@ typedef struct TiffContext {
 AVCodecContext *avctx;
 GetByteContext gb;
 
+/* JPEG decoding for DNG */
+AVCodecContext *avctx_mjpeg; // wrapper context for MJPEG
+AVFrame *jpgframe;   // decoded JPEG tile
+
 int get_subimage;
 uint16_t get_page;
 int get_thumbnail;
@@ -76,7 +82,9 @@ typedef struct TiffContext {
 
 int is_bayer;
 uint8_t pattern[4];
+unsigned black_level;
 unsigned white_level;
+const uint16_t *dng_lut; // Pointer to DNG linearization table
 
 uint32_t sub_ifd;
 uint16_t cur_page;
@@ -86,6 +94,14 @@ typedef struct TiffContext {
 int stripsizesoff, stripsize, stripoff, strippos;
 LZWState *lzw;
 
+/* Tile support */
+int is_tiled;
+int tile_byte_counts_offset, tile_offsets_offset;
+int tile_width, tile_length;
+int tile_count;
+
+int is_jpeg;
+
 uint8_t *deinvert_buf;
 int deinvert_buf_size;
 uint8_t *yuv_line;
@@ -257,6 +273,9 @@ static int add_metadata(int count, int type,
 };
 }
 
+static void av_always_inline dng_blit(TiffContext *s, uint8_t *dst, int 
dst_stride,
+  const uint8_t *src, int src_stride, int 
width, int height, int is_u16);
+
 static void av_always_inline horizontal_fill(TiffContext *s,
  unsigned int bpp, uint8_t* dst,
  int usePtr, const uint8_t *src,
@@ -712,6 +731,204 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, 
uint8_t *dst, int strid
 return 0;
 }
 
+/**
+ * Map stored raw sensor values into linear reference values.
+ * See: DNG Specification - Chapter 5
+ */
+static uint16_t av_always_inline dng_raw_to_linear16(uint16_t value,
+const uint16_t *lut,
+uint16_t black_level,
+float scale_factor) {
+// Lookup table lookup
+if (lut)
+value = lut[value];
+
+// Black level subtraction
+value = av_clip_uint16_c((unsigned)value - black_level);
+
+// Color scaling
+value = av_clip_uint16_c((unsigned)(((float)value * scale_factor) * 
0x));
+
+return value;
+}
+
+static uint16_t av_always_inline dng_raw_to_linear8(uint16_t value,
+const uint16_t *lut,
+uint16_t black_level,
+float scale_factor) {
+return dng_raw_to_linear16(value, lut, black_level, scale_factor) >> 8;
+}
+
+static void dng_blit(TiffContext *s,

[FFmpeg-devel] [PATCH] avcodec/mips: [loongson] refine process of setting block as 0 in h264dsp_mmi.

2019-07-26 Thread Shiyou Yin
1. Refine setting zero process in function ff_h264_add_pixels4_8_mmi and
   ff_h264_idct_add_8_mmi.
2. Remove redundant setting zeor process in function ff_h264_idct_add_8_mmi
   and ff_h264_idct8_add_8_mmi.
---
 libavcodec/mips/h264dsp_mmi.c | 44 +--
 1 file changed, 13 insertions(+), 31 deletions(-)

diff --git a/libavcodec/mips/h264dsp_mmi.c b/libavcodec/mips/h264dsp_mmi.c
index ac65a20..0459711 100644
--- a/libavcodec/mips/h264dsp_mmi.c
+++ b/libavcodec/mips/h264dsp_mmi.c
@@ -38,6 +38,9 @@ void ff_h264_add_pixels4_8_mmi(uint8_t *dst, int16_t *src, 
int stride)
 MMI_LDC1(%[ftmp2], %[src], 0x08)
 MMI_LDC1(%[ftmp3], %[src], 0x10)
 MMI_LDC1(%[ftmp4], %[src], 0x18)
+/* memset(src, 0, 32); */
+"gssqc1 %[ftmp0],   %[ftmp0],   0x00(%[src])\n\t"
+"gssqc1 %[ftmp0],   %[ftmp0],   0x10(%[src])\n\t"
 MMI_ULWC1(%[ftmp5], %[dst0], 0x00)
 MMI_ULWC1(%[ftmp6], %[dst1], 0x00)
 MMI_ULWC1(%[ftmp7], %[dst2], 0x00)
@@ -58,11 +61,6 @@ void ff_h264_add_pixels4_8_mmi(uint8_t *dst, int16_t *src, 
int stride)
 MMI_SWC1(%[ftmp2], %[dst1], 0x00)
 MMI_SWC1(%[ftmp3], %[dst2], 0x00)
 MMI_SWC1(%[ftmp4], %[dst3], 0x00)
-
-/* memset(src, 0, 32); */
-"xor%[ftmp0],   %[ftmp0],   %[ftmp0]\n\t"
-"gssqc1 %[ftmp0],   %[ftmp0],   0x00(%[src])\n\t"
-"gssqc1 %[ftmp0],   %[ftmp0],   0x10(%[src])\n\t"
 : [ftmp0]"=&f"(ftmp[0]),[ftmp1]"=&f"(ftmp[1]),
   [ftmp2]"=&f"(ftmp[2]),[ftmp3]"=&f"(ftmp[3]),
   [ftmp4]"=&f"(ftmp[4]),[ftmp5]"=&f"(ftmp[5]),
@@ -85,15 +83,19 @@ void ff_h264_idct_add_8_mmi(uint8_t *dst, int16_t *block, 
int stride)
 DECLARE_VAR_ADDRT;
 
 __asm__ volatile (
-"dli%[tmp0],0x01\n\t"
 MMI_LDC1(%[ftmp0], %[block], 0x00)
-"mtc1   %[tmp0],%[ftmp8]\n\t"
 MMI_LDC1(%[ftmp1], %[block], 0x08)
-"dli%[tmp0],0x06\n\t"
 MMI_LDC1(%[ftmp2], %[block], 0x10)
+MMI_LDC1(%[ftmp3], %[block], 0x18)
+/* memset(block, 0, 32) */
+"xor%[ftmp4],   %[ftmp4],   %[ftmp4]\n\t"
+"gssqc1 %[ftmp4],   %[ftmp4],   0x00(%[block])  \n\t"
+"gssqc1 %[ftmp4],   %[ftmp4],   0x10(%[block])  \n\t"
+"dli%[tmp0],0x01\n\t"
+"mtc1   %[tmp0],%[ftmp8]\n\t"
+"dli%[tmp0],0x06\n\t"
 "mtc1   %[tmp0],%[ftmp9]\n\t"
 "psrah  %[ftmp4],   %[ftmp1],   %[ftmp8]\n\t"
-MMI_LDC1(%[ftmp3], %[block], 0x18)
 "psrah  %[ftmp5],   %[ftmp3],   %[ftmp8]\n\t"
 "psubh  %[ftmp4],   %[ftmp4],   %[ftmp3]\n\t"
 "paddh  %[ftmp5],   %[ftmp5],   %[ftmp1]\n\t"
@@ -121,15 +123,11 @@ void ff_h264_idct_add_8_mmi(uint8_t *dst, int16_t *block, 
int stride)
 "paddh  %[ftmp10],  %[ftmp3],   %[ftmp1]\n\t"
 "psubh  %[ftmp1],   %[ftmp1],   %[ftmp3]\n\t"
 "paddh  %[ftmp11],  %[ftmp4],   %[ftmp5]\n\t"
-"xor%[ftmp7],   %[ftmp7],   %[ftmp7]\n\t"
 "psubh  %[ftmp5],   %[ftmp5],   %[ftmp4]\n\t"
-MMI_SDC1(%[ftmp7], %[block], 0x00)
-MMI_SDC1(%[ftmp7], %[block], 0x08)
-MMI_SDC1(%[ftmp7], %[block], 0x10)
-MMI_SDC1(%[ftmp7], %[block], 0x18)
 MMI_ULWC1(%[ftmp2], %[dst], 0x00)
-"psrah  %[ftmp3],   %[ftmp10],  %[ftmp9]\n\t"
 MMI_LWXC1(%[ftmp0], %[dst], %[stride], 0x00)
+"xor%[ftmp7],   %[ftmp7],   %[ftmp7]\n\t"
+"psrah  %[ftmp3],   %[ftmp10],  %[ftmp9]\n\t"
 "psrah  %[ftmp4],   %[ftmp11],  %[ftmp9]\n\t"
 "punpcklbh  %[ftmp2],   %[ftmp2],   %[ftmp7]\n\t"
 "punpcklbh  %[ftmp0],   %[ftmp0],   %[ftmp7]\n\t"
@@ -153,11 +151,6 @@ void ff_h264_idct_add_8_mmi(uint8_t *dst, int16_t *block, 
int stride)
 MMI_SWC1(%[ftmp2], %[dst], 0x00)
 "packushb   %[ftmp0],   %[ftmp0],   %[ftmp7]\n\t"
 MMI_SWXC1(%[ftmp0], %[dst], %[stride], 0x00)
-
-/* memset(block, 0, 32) */
-"xor%[ftmp0],   %[ftmp0],   %[ftmp0]\n\t"
-"gssqc1 %[ftmp0],   %[ftmp0],   0x00(%[block])  \n\t"
-"gssqc1 %[ftmp0],   %[ftm

[FFmpeg-devel] Patchwork: how to reset password?

2019-07-26 Thread Andreas Håkon
Hi,

I'm sorry to post this on this mailing list. However, I need to clean my patches
on the Patchwork's FFmpeg server, but the "Reset Password" service doesn't
seem to work. After days of selecting the Reset Form with the correct email
address (if I try to register again, the email address is in use), I never 
received
any email (I've also checked for the Spam folder).

So, please, can anyone verify it?
Thank you.
A.H.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avdevice/decklink: adjust for timecode lag

2019-07-26 Thread Gyan


Patch supported by and tested at Google.

Gyan
From e51bd8201ddf618dce33ada70a9bc6ce2f33b07b Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Mon, 1 Jul 2019 23:43:44 +0530
Subject: [PATCH] avdevice/decklink: adjust for timecode lag

The decklink demuxer may not start receiving timecode with
the first frame, but only some frames later.

The demuxer, at present, naively stores the first received timecode.
This patch monitors the lag in video frames, and adjusts the timecode
before saving it in stream metadata.
---
 libavdevice/decklink_common.h |  4 +++
 libavdevice/decklink_dec.cpp  | 53 +--
 2 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h
index 921818ba41..f149e7ff66 100644
--- a/libavdevice/decklink_common.h
+++ b/libavdevice/decklink_common.h
@@ -149,6 +149,10 @@ struct decklink_ctx {
 
 int channels;
 int audio_depth;
+
+/* Fields for timecode correction */
+unsigned long vidframeCount;//  frameCount tracks audio-only 
packets as well
+unsigned long firstframeIndex;  //  value of frameCount for first 
successfully demuxed video frame
 };
 
 typedef enum { DIRECTION_IN, DIRECTION_OUT} decklink_direction_t;
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 4da9122bff..d0ebd0ac0a 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -41,6 +41,7 @@ extern "C" {
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/time.h"
+#include "libavutil/timecode.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/reverse.h"
 #include "avdevice.h"
@@ -736,6 +737,8 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 videoFrame->GetStreamTime(&frameTime, &frameDuration,
   ctx->video_st->time_base.den);
 
+ctx->vidframeCount++;
+
 if (videoFrame->GetFlags() & bmdFrameHasNoInputSource) {
 if (ctx->draw_bars && videoFrame->GetPixelFormat() == 
bmdFormat8BitYUV) {
 unsigned bars[8] = {
@@ -765,6 +768,8 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 
 // Handle Timecode (if requested)
 if (ctx->tc_format) {
+if (!ctx->firstframeIndex)
+ctx->firstframeIndex = ctx->vidframeCount;
 IDeckLinkTimecode *timecode;
 if (videoFrame->GetTimecode(ctx->tc_format, &timecode) == 
S_OK) {
 const char *tc = NULL;
@@ -778,7 +783,9 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 AVDictionary* metadata_dict = NULL;
 int metadata_len;
 uint8_t* packed_metadata;
+unsigned long offset = ctx->firstframeIndex - 
ctx->vidframeCount;  // represents offset of first returned frame relative to 
first frame with timecode
 if (av_dict_set(&metadata_dict, "timecode", tc, 
AV_DICT_DONT_STRDUP_VAL) >= 0) {
+av_dict_set_int(&metadata_dict, "tc_offset", 
offset, 0);
 packed_metadata = 
av_packet_pack_dictionary(metadata_dict, &metadata_len);
 av_dict_free(&metadata_dict);
 if (packed_metadata) {
@@ -880,6 +887,8 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 videoFrame->AddRef();
 
 if (avpacket_queue_put(&ctx->queue, &pkt) < 0) {
+if (ctx->firstframeIndex == ctx->vidframeCount)
+ctx->firstframeIndex = 0;
 ++ctx->dropped;
 }
 }
@@ -1266,10 +1275,48 @@ int ff_decklink_read_packet(AVFormatContext *avctx, 
AVPacket *pkt)
 if (ctx->tc_format && !(av_dict_get(ctx->video_st->metadata, "timecode", 
NULL, 0))) {
 int size;
 const uint8_t *side_metadata = av_packet_get_side_data(pkt, 
AV_PKT_DATA_STRINGS_METADATA, &size);
+
 if (side_metadata) {
-   if (av_packet_unpack_dictionary(side_metadata, size, 
&ctx->video_st->metadata) < 0)
-   av_log(avctx, AV_LOG_ERROR, "Unable to set timecode\n");
-}
+char offset_tc[AV_TIMECODE_STR_SIZE];
+int ret;
+AVTimecode tc;
+AVRational vid_rate = ctx->video_st->r_frame_rate;
+int64_t offset = 0;
+AVDictionary *first_tc = NULL;
+AVDictionaryEntry *tcstr = NULL;
+AVDictionaryEntry *offsetstr = NULL;
+
+if (av_packet_unpack_dictionary(side_metadata, size, &first_tc) < 
0 ||
+!(tcstr = av_dict_get(first_tc, "timecode", NULL, 0)) ) {
+av_log(avctx, AV_LOG_ERROR, "Unable to find timecode\n");
+return 0;
+}
+
+if (tcstr)
+av_log(avctx, AV_LOG_DEBUG, "Serial frame timecode is %s.\n", 
tcstr->value);
+
+

Re: [FFmpeg-devel] [PATCH] avcodec/adxenc: add EOF header

2019-07-26 Thread James Almer
On 7/24/2019 6:37 AM, Paul B Mahol wrote:
> Hi,
> 
> patch attached.

> From dc6473383580af963a120a7de89bdc34c460d000 Mon Sep 17 00:00:00 2001
> From: Paul B Mahol 
> Date: Wed, 24 Jul 2019 11:11:35 +0200
> Subject: [PATCH] avcodec/adxenc: add EOF header
> 
> Fixes #8031.
> 
> ---
>  libavcodec/adxenc.c| 21 -
>  tests/ref/acodec/adpcm-adx |  4 ++--
>  tests/ref/acodec/adpcm-adx-trellis |  4 ++--
>  3 files changed, 24 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c
> index f1ba5911b3..a781151b44 100644
> --- a/libavcodec/adxenc.c
> +++ b/libavcodec/adxenc.c
> @@ -141,10 +141,26 @@ static int adx_encode_frame(AVCodecContext *avctx, 
> AVPacket *avpkt,
>  const AVFrame *frame, int *got_packet_ptr)
>  {
>  ADXContext *c  = avctx->priv_data;
> -const int16_t *samples = (const int16_t *)frame->data[0];
> +const int16_t *samples = frame ? (const int16_t *)frame->data[0] : NULL;
>  uint8_t *dst;
>  int ch, out_size, ret;
>  
> +if (!samples) {
> +if (c->eof)
> +return 0;
> +if ((ret = ff_alloc_packet2(avctx, avpkt, 18, 0)) < 0)
> +return ret;
> +c->eof = 1;
> +dst = avpkt->data;
> +bytestream_put_be16(&dst, 0x8001);
> +bytestream_put_be16(&dst, 0x000E);
> +bytestream_put_be64(&dst, 0x0);
> +bytestream_put_be32(&dst, 0x0);
> +bytestream_put_be16(&dst, 0x0);
> +*got_packet_ptr = 1;
> +return 0;
> +}
> +
>  out_size = BLOCK_SIZE * avctx->channels + !c->header_parsed * 
> HEADER_SIZE;
>  if ((ret = ff_alloc_packet2(avctx, avpkt, out_size, 0)) < 0)
>  return ret;
> @@ -165,6 +181,8 @@ static int adx_encode_frame(AVCodecContext *avctx, 
> AVPacket *avpkt,
>  dst += BLOCK_SIZE;
>  }
>  
> +avpkt->pts = frame->pts;
> +avpkt->duration = frame->nb_samples;
>  *got_packet_ptr = 1;
>  return 0;
>  }
> @@ -177,6 +195,7 @@ AVCodec ff_adpcm_adx_encoder = {
>  .priv_data_size = sizeof(ADXContext),
>  .init   = adx_encode_init,
>  .encode2= adx_encode_frame,
> +.capabilities   = AV_CODEC_CAP_DELAY,
>  .sample_fmts= (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16,
>AV_SAMPLE_FMT_NONE },
>  };
> diff --git a/tests/ref/acodec/adpcm-adx b/tests/ref/acodec/adpcm-adx
> index 8c401001b8..2c8550fb72 100644
> --- a/tests/ref/acodec/adpcm-adx
> +++ b/tests/ref/acodec/adpcm-adx
> @@ -1,4 +1,4 @@
> -6bf1a8e5ec9cc958a31cb2b1b66bfc75 *tests/data/fate/acodec-adpcm-adx.adx
> -297720 tests/data/fate/acodec-adpcm-adx.adx
> +c257001314241b469a6512616fd56548 *tests/data/fate/acodec-adpcm-adx.adx
> +297738 tests/data/fate/acodec-adpcm-adx.adx
>  5b5a436ec9d528d6eb0bebaf667521b0 *tests/data/fate/acodec-adpcm-adx.out.wav
>  stddev: 2549.93 PSNR: 28.20 MAXDIFF:57514 bytes:  1058400/  1058432
> diff --git a/tests/ref/acodec/adpcm-adx-trellis 
> b/tests/ref/acodec/adpcm-adx-trellis
> index 039f69f9db..f6f5d768f5 100644
> --- a/tests/ref/acodec/adpcm-adx-trellis
> +++ b/tests/ref/acodec/adpcm-adx-trellis
> @@ -1,4 +1,4 @@
> -6bf1a8e5ec9cc958a31cb2b1b66bfc75 
> *tests/data/fate/acodec-adpcm-adx-trellis.adx
> -297720 tests/data/fate/acodec-adpcm-adx-trellis.adx
> +c257001314241b469a6512616fd56548 
> *tests/data/fate/acodec-adpcm-adx-trellis.adx
> +297738 tests/data/fate/acodec-adpcm-adx-trellis.adx
>  5b5a436ec9d528d6eb0bebaf667521b0 
> *tests/data/fate/acodec-adpcm-adx-trellis.out.wav
>  stddev: 2549.93 PSNR: 28.20 MAXDIFF:57514 bytes:  1058400/  1058432

adx is not using avctx->trellis, so the two tests are the same.

IMO, unless the trellis code in adpcmenc.c can be shared and used for
adx, i'd just remove the test.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] dnn: add layer pad which is equivalent to tf.pad

2019-07-26 Thread Pedro Arthur
Hi,

Em seg, 1 de jul de 2019 às 05:10, Guo, Yejun  escreveu:
>
> the reason to add this layer first is that vf_sr uses it in its
> tensorflow model, and the next plan is to update the python script
> to convert tf.pad into native model.
>
> Signed-off-by: Guo, Yejun 
> ---
>  libavfilter/dnn/Makefile   |   1 +
>  libavfilter/dnn/dnn_backend_native_layer_pad.c | 211 
> +
>  libavfilter/dnn/dnn_backend_native_layer_pad.h |  40 +
>  3 files changed, 252 insertions(+)
>  create mode 100644 libavfilter/dnn/dnn_backend_native_layer_pad.c
>  create mode 100644 libavfilter/dnn/dnn_backend_native_layer_pad.h
>
> diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile
> index 1d12ade..83938e5 100644
> --- a/libavfilter/dnn/Makefile
> +++ b/libavfilter/dnn/Makefile
> @@ -1,5 +1,6 @@
>  OBJS-$(CONFIG_DNN)   += dnn/dnn_interface.o
>  OBJS-$(CONFIG_DNN)   += dnn/dnn_backend_native.o
> +OBJS-$(CONFIG_DNN)   += 
> dnn/dnn_backend_native_layer_pad.o
>
>  DNN-OBJS-$(CONFIG_LIBTENSORFLOW) += dnn/dnn_backend_tf.o
>
> diff --git a/libavfilter/dnn/dnn_backend_native_layer_pad.c 
> b/libavfilter/dnn/dnn_backend_native_layer_pad.c
> new file mode 100644
> index 000..aa12f7f
> --- /dev/null
> +++ b/libavfilter/dnn/dnn_backend_native_layer_pad.c
> @@ -0,0 +1,211 @@
> +/*
> + * Copyright (c) 2019 Guo Yejun
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +#include 
> +#include "libavutil/avassert.h"
> +#include "dnn_backend_native_layer_pad.h"
> +
> +static int before_get_buddy(int given, int paddings, LayerPadModeParam mode)
> +{
> +if (mode == LPMP_SYMMETRIC) {
> +return (2 * paddings - 1 - given);
> +} else if (mode == LPMP_REFLECT) {
> +return (2 * paddings - given);
> +} else {
> +av_assert0(!"should not reach here");
> +return 0;
> +}
> +}
> +
> +static int after_get_buddy(int given, int border, LayerPadModeParam mode)
> +{
> +if (mode == LPMP_SYMMETRIC) {
> +int offset = given - border;
> +return (border - 1 - offset);
> +} else if (mode == LPMP_REFLECT) {
> +int offset = given - border;
> +return (border - 2 - offset);
> +} else {
> +av_assert0(!"should not reach here");
> +return 0;
> +}
> +}
> +
> +void dnn_execute_layer_pad(const float *input, float *output, const 
> LayerPadParams *params, int number, int height, int width, int channel)
> +{
> +int32_t before_paddings;
> +int32_t after_paddings;
> +
> +// suppose format is 
> +int new_number = number + params->paddings[0][0] + 
> params->paddings[0][1];
> +int new_height = height + params->paddings[1][0] + 
> params->paddings[1][1];
> +int new_width = width + params->paddings[2][0] + params->paddings[2][1];
> +int new_channel = channel + params->paddings[3][0] + 
> params->paddings[3][1];
> +
> +int c_stride = channel;
> +int wc_stride = c_stride * width;
> +int hwc_stride = wc_stride * height;
> +
> +int new_c_stride = new_channel;
> +int new_wc_stride = new_c_stride * new_width;
> +int new_hwc_stride = new_wc_stride * new_height;
> +
> +// copy the original data
> +for (int n = 0; n < number; n++) {
> +for (int h = 0; h < height; h++) {
> +for (int w = 0; w < width; w++) {
> +const float *src = input + n * hwc_stride + h * wc_stride + 
> w * c_stride;
> +float *dst = output + (n + params->paddings[0][0]) * 
> new_hwc_stride
> ++ (h + params->paddings[1][0]) * 
> new_wc_stride
> ++ (w + params->paddings[2][0]) * 
> new_c_stride
> ++ params->paddings[3][0];
> +memcpy(dst, src, channel * sizeof(float));
> +}
> +}
> +}
> +
> +// handle the first dimension
> +before_paddings = params->paddings[0][0];
> +after_paddings = params->paddings[0][1];
> +for (int n = 0; n < before_paddings; n++) {
> +float *dst = output + n * new_hwc_stride;
> +if (params->mode == LPMP_CONSTANT) {
> 

[FFmpeg-devel] [PATCH] avfilter: add arnndn filter

2019-07-26 Thread Paul B Mahol
Hi,

patch attached.


0001-avfilter-add-arnndn-filter.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/4] libavfilter/dnn: move dnn files from libavfilter to libavfilter/dnn

2019-07-26 Thread Pedro Arthur
Hi,
It fails fate source guard header tests,
The headers should be changed from AVFILTER_DNN_BACKEND_xxx to
AVFILTER_DNN_DNN_BACKEND_xxx.
Other than that it LGTM.

Em ter, 16 de jul de 2019 às 02:58, Guo, Yejun  escreveu:
>
> it is expected that there will be more files to support native mode,
> so put all the dnn codes under libavfilter/dnn
>
> The main change of this patch is to move the file location, see below:
> modified:   libavfilter/Makefile
> new file:   libavfilter/dnn/Makefile
> renamed:libavfilter/dnn_backend_native.c -> 
> libavfilter/dnn/dnn_backend_native.c
> renamed:libavfilter/dnn_backend_native.h -> 
> libavfilter/dnn/dnn_backend_native.h
> renamed:libavfilter/dnn_backend_tf.c -> libavfilter/dnn/dnn_backend_tf.c
> renamed:libavfilter/dnn_backend_tf.h -> libavfilter/dnn/dnn_backend_tf.h
> renamed:libavfilter/dnn_interface.c -> libavfilter/dnn/dnn_interface.c
>
> Signed-off-by: Guo, Yejun 
> ---
>  libavfilter/Makefile |   3 +-
>  libavfilter/dnn/Makefile |   6 +
>  libavfilter/dnn/dnn_backend_native.c | 389 ++
>  libavfilter/dnn/dnn_backend_native.h |  74 +
>  libavfilter/dnn/dnn_backend_tf.c | 603 
> +++
>  libavfilter/dnn/dnn_backend_tf.h |  38 +++
>  libavfilter/dnn/dnn_interface.c  |  63 
>  libavfilter/dnn_backend_native.c | 389 --
>  libavfilter/dnn_backend_native.h |  74 -
>  libavfilter/dnn_backend_tf.c | 603 
> ---
>  libavfilter/dnn_backend_tf.h |  38 ---
>  libavfilter/dnn_interface.c  |  63 
>  12 files changed, 1174 insertions(+), 1169 deletions(-)
>  create mode 100644 libavfilter/dnn/Makefile
>  create mode 100644 libavfilter/dnn/dnn_backend_native.c
>  create mode 100644 libavfilter/dnn/dnn_backend_native.h
>  create mode 100644 libavfilter/dnn/dnn_backend_tf.c
>  create mode 100644 libavfilter/dnn/dnn_backend_tf.h
>  create mode 100644 libavfilter/dnn/dnn_interface.c
>  delete mode 100644 libavfilter/dnn_backend_native.c
>  delete mode 100644 libavfilter/dnn_backend_native.h
>  delete mode 100644 libavfilter/dnn_backend_tf.c
>  delete mode 100644 libavfilter/dnn_backend_tf.h
>  delete mode 100644 libavfilter/dnn_interface.c
>
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 455c809..450d781 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -26,9 +26,8 @@ OBJS-$(HAVE_THREADS) += pthread.o
>
>  # subsystems
>  OBJS-$(CONFIG_QSVVPP)+= qsvvpp.o
> -DNN-OBJS-$(CONFIG_LIBTENSORFLOW) += dnn_backend_tf.o
> -OBJS-$(CONFIG_DNN)   += dnn_interface.o 
> dnn_backend_native.o $(DNN-OBJS-yes)
>  OBJS-$(CONFIG_SCENE_SAD) += scene_sad.o
> +include $(SRC_PATH)/libavfilter/dnn/Makefile
>
>  # audio filters
>  OBJS-$(CONFIG_ABENCH_FILTER) += f_bench.o
> diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile
> new file mode 100644
> index 000..1d12ade
> --- /dev/null
> +++ b/libavfilter/dnn/Makefile
> @@ -0,0 +1,6 @@
> +OBJS-$(CONFIG_DNN)   += dnn/dnn_interface.o
> +OBJS-$(CONFIG_DNN)   += dnn/dnn_backend_native.o
> +
> +DNN-OBJS-$(CONFIG_LIBTENSORFLOW) += dnn/dnn_backend_tf.o
> +
> +OBJS-$(CONFIG_DNN)   += $(DNN-OBJS-yes)
> diff --git a/libavfilter/dnn/dnn_backend_native.c 
> b/libavfilter/dnn/dnn_backend_native.c
> new file mode 100644
> index 000..82e900b
> --- /dev/null
> +++ b/libavfilter/dnn/dnn_backend_native.c
> @@ -0,0 +1,389 @@
> +/*
> + * Copyright (c) 2018 Sergey Lavrushkin
> + *
> + * 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
> + * DNN native backend implementation.
> + */
> +
> +#include "dnn_backend_native.h"
> +#include "libavutil/avassert.h"
> +
> +static DNNReturnType set_input_output_native(void *model, DNNInputData 
> *input, const char *input_name, const char **output_names, uint32_t nb_output)
> +{
> +ConvolutionalNetwork *network = (ConvolutionalNetwork *)model;
> +InputParams *input_params;
> +ConvolutionalParams *conv_params

Re: [FFmpeg-devel] [PATCH 1/4] libavfilter/dnn: move dnn files from libavfilter to libavfilter/dnn

2019-07-26 Thread Pedro Arthur
Em sex, 26 de jul de 2019 às 13:02, Pedro Arthur  escreveu:
>
> Hi,
> It fails fate source guard header tests,
> The headers should be changed from AVFILTER_DNN_BACKEND_xxx to
> AVFILTER_DNN_DNN_BACKEND_xxx.
Changed locally and pushed.

> Other than that it LGTM.
>
> Em ter, 16 de jul de 2019 às 02:58, Guo, Yejun  escreveu:
> >
> > it is expected that there will be more files to support native mode,
> > so put all the dnn codes under libavfilter/dnn
> >
> > The main change of this patch is to move the file location, see below:
> > modified:   libavfilter/Makefile
> > new file:   libavfilter/dnn/Makefile
> > renamed:libavfilter/dnn_backend_native.c -> 
> > libavfilter/dnn/dnn_backend_native.c
> > renamed:libavfilter/dnn_backend_native.h -> 
> > libavfilter/dnn/dnn_backend_native.h
> > renamed:libavfilter/dnn_backend_tf.c -> libavfilter/dnn/dnn_backend_tf.c
> > renamed:libavfilter/dnn_backend_tf.h -> libavfilter/dnn/dnn_backend_tf.h
> > renamed:libavfilter/dnn_interface.c -> libavfilter/dnn/dnn_interface.c
> >
> > Signed-off-by: Guo, Yejun 
> > ---
> >  libavfilter/Makefile |   3 +-
> >  libavfilter/dnn/Makefile |   6 +
> >  libavfilter/dnn/dnn_backend_native.c | 389 ++
> >  libavfilter/dnn/dnn_backend_native.h |  74 +
> >  libavfilter/dnn/dnn_backend_tf.c | 603 
> > +++
> >  libavfilter/dnn/dnn_backend_tf.h |  38 +++
> >  libavfilter/dnn/dnn_interface.c  |  63 
> >  libavfilter/dnn_backend_native.c | 389 --
> >  libavfilter/dnn_backend_native.h |  74 -
> >  libavfilter/dnn_backend_tf.c | 603 
> > ---
> >  libavfilter/dnn_backend_tf.h |  38 ---
> >  libavfilter/dnn_interface.c  |  63 
> >  12 files changed, 1174 insertions(+), 1169 deletions(-)
> >  create mode 100644 libavfilter/dnn/Makefile
> >  create mode 100644 libavfilter/dnn/dnn_backend_native.c
> >  create mode 100644 libavfilter/dnn/dnn_backend_native.h
> >  create mode 100644 libavfilter/dnn/dnn_backend_tf.c
> >  create mode 100644 libavfilter/dnn/dnn_backend_tf.h
> >  create mode 100644 libavfilter/dnn/dnn_interface.c
> >  delete mode 100644 libavfilter/dnn_backend_native.c
> >  delete mode 100644 libavfilter/dnn_backend_native.h
> >  delete mode 100644 libavfilter/dnn_backend_tf.c
> >  delete mode 100644 libavfilter/dnn_backend_tf.h
> >  delete mode 100644 libavfilter/dnn_interface.c
> >
> > diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> > index 455c809..450d781 100644
> > --- a/libavfilter/Makefile
> > +++ b/libavfilter/Makefile
> > @@ -26,9 +26,8 @@ OBJS-$(HAVE_THREADS) += pthread.o
> >
> >  # subsystems
> >  OBJS-$(CONFIG_QSVVPP)+= qsvvpp.o
> > -DNN-OBJS-$(CONFIG_LIBTENSORFLOW) += dnn_backend_tf.o
> > -OBJS-$(CONFIG_DNN)   += dnn_interface.o 
> > dnn_backend_native.o $(DNN-OBJS-yes)
> >  OBJS-$(CONFIG_SCENE_SAD) += scene_sad.o
> > +include $(SRC_PATH)/libavfilter/dnn/Makefile
> >
> >  # audio filters
> >  OBJS-$(CONFIG_ABENCH_FILTER) += f_bench.o
> > diff --git a/libavfilter/dnn/Makefile b/libavfilter/dnn/Makefile
> > new file mode 100644
> > index 000..1d12ade
> > --- /dev/null
> > +++ b/libavfilter/dnn/Makefile
> > @@ -0,0 +1,6 @@
> > +OBJS-$(CONFIG_DNN)   += dnn/dnn_interface.o
> > +OBJS-$(CONFIG_DNN)   += dnn/dnn_backend_native.o
> > +
> > +DNN-OBJS-$(CONFIG_LIBTENSORFLOW) += dnn/dnn_backend_tf.o
> > +
> > +OBJS-$(CONFIG_DNN)   += $(DNN-OBJS-yes)
> > diff --git a/libavfilter/dnn/dnn_backend_native.c 
> > b/libavfilter/dnn/dnn_backend_native.c
> > new file mode 100644
> > index 000..82e900b
> > --- /dev/null
> > +++ b/libavfilter/dnn/dnn_backend_native.c
> > @@ -0,0 +1,389 @@
> > +/*
> > + * Copyright (c) 2018 Sergey Lavrushkin
> > + *
> > + * 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
> > + * DNN native backend implementation.
> > + */
> > +
> > +#include "dnn_backend_native.h"
> > +#include "libavutil/av

[FFmpeg-devel] [PATCH 5/5] avcodec/alsdec: fix mantisse shift

2019-07-26 Thread Michael Niedermayer
Fixes: shift exponent -1 is negative
Fixes: 
16039/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5656825657032704

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

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index c1f26426c6..26c496c769 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -1404,7 +1404,11 @@ static SoftFloat_IEEE754 multiply(SoftFloat_IEEE754 a, 
SoftFloat_IEEE754 b) {
 }
 }
 
-mantissa = (unsigned int)(mantissa_temp >> cutoff_bit_count);
+if (cutoff_bit_count >= 0) {
+mantissa = (unsigned int)(mantissa_temp >> cutoff_bit_count);
+} else {
+mantissa = (unsigned int)(mantissa_temp <<-cutoff_bit_count);
+}
 
 // Need one more shift?
 if (mantissa & 0x0100ul) {
-- 
2.22.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/5] avcodec/alsdec: Check for block_length <= 0 in read_var_block_data()

2019-07-26 Thread Michael Niedermayer
Fixes: left shift of negative value -1
Fixes: 
15719/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5685731105701888

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

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index ac3eca42c7..888e8d4cf8 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -657,7 +657,7 @@ static int read_var_block_data(ALSDecContext *ctx, 
ALSBlockData *bd)
 
 // do not continue in case of a damaged stream since
 // block_length must be evenly divisible by sub_blocks
-if (bd->block_length & (sub_blocks - 1)) {
+if (bd->block_length & (sub_blocks - 1) || bd->block_length <= 0) {
 av_log(avctx, AV_LOG_WARNING,
"Block length is not evenly divisible by the number of 
subblocks.\n");
 return AVERROR_INVALIDDATA;
-- 
2.22.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/5] avcodec/alsdec: Fix integer overflow of raw_samples in decode_blocks()

2019-07-26 Thread Michael Niedermayer
Fixes: signed integer overflow: 2147483424 - -1772303236 cannot be represented 
in type 'int'
Fixes: 
15708/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5067890362941440

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

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 6b5774175b..ac3eca42c7 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -1175,10 +1175,10 @@ static int decode_blocks(ALSDecContext *ctx, unsigned 
int ra_frame,
 av_log(ctx->avctx, AV_LOG_WARNING, "Invalid channel pair.\n");
 
 for (s = 0; s < div_blocks[b]; s++)
-bd[0].raw_samples[s] = bd[1].raw_samples[s] - 
bd[0].raw_samples[s];
+bd[0].raw_samples[s] = bd[1].raw_samples[s] - 
(unsigned)bd[0].raw_samples[s];
 } else if (bd[1].js_blocks) {
 for (s = 0; s < div_blocks[b]; s++)
-bd[1].raw_samples[s] = bd[1].raw_samples[s] + 
bd[0].raw_samples[s];
+bd[1].raw_samples[s] = bd[1].raw_samples[s] + 
(unsigned)bd[0].raw_samples[s];
 }
 
 offset  += div_blocks[b];
-- 
2.22.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/5] avcodec/brenderpix: Check input size before allocating image

2019-07-26 Thread Michael Niedermayer
An incomplete image is not supported prior to this and will
not produce any output. This commit moves the failure before
time consuming operations.

Fixes: Timeout (81sec -> 76ms)
Fixes: 
15723/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BRENDER_PIX_fuzzer-5147265653538816

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

diff --git a/libavcodec/brenderpix.c b/libavcodec/brenderpix.c
index 0556858de1..46b7a59aa4 100644
--- a/libavcodec/brenderpix.c
+++ b/libavcodec/brenderpix.c
@@ -204,6 +204,10 @@ static int pix_decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
 avpriv_request_sample(avctx, "Format %d", hdr.format);
 return AVERROR_PATCHWELCOME;
 }
+bytes_per_scanline = bytes_pp * hdr.width;
+
+if (bytestream2_get_bytes_left(&gb) < hdr.height * bytes_per_scanline)
+return AVERROR_INVALIDDATA;
 
 if ((ret = ff_set_dimensions(avctx, hdr.width, hdr.height)) < 0)
 return ret;
@@ -261,7 +265,6 @@ static int pix_decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
 bytestream2_skip(&gb, 8);
 
 // read the image data to the buffer
-bytes_per_scanline = bytes_pp * hdr.width;
 bytes_left = bytestream2_get_bytes_left(&gb);
 
 if (chunk_type != IMAGE_DATA_CHUNK || data_len != bytes_left ||
-- 
2.22.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 4/5] avcodec/alsdec: Fix integer overflows of raw_samples in decode_var_block_data()

2019-07-26 Thread Michael Niedermayer
This also makes the code consistent with the existing similar MUL64()
in decode_var_block_data()

Fixes: signed integer overflow: -7277630735906765035 + -3272193951413647896 
cannot be represented in type 'long'
Fixes: 
16015/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5666552818434048

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

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 888e8d4cf8..c1f26426c6 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -918,7 +918,7 @@ static int decode_var_block_data(ALSDecContext *ctx, 
ALSBlockData *bd)
 y = 1 << 6;
 
 for (base = begin; base < end; base++, tab++)
-y += MUL64(bd->ltp_gain[tab], raw_samples[base]);
+y += (uint64_t)MUL64(bd->ltp_gain[tab], raw_samples[base]);
 
 raw_samples[ltp_smp] += y >> 7;
 }
@@ -930,7 +930,7 @@ static int decode_var_block_data(ALSDecContext *ctx, 
ALSBlockData *bd)
 y = 1 << 19;
 
 for (sb = 0; sb < smp; sb++)
-y += MUL64(lpc_cof[sb], raw_samples[-(sb + 1)]);
+y += (uint64_t)MUL64(lpc_cof[sb], raw_samples[-(sb + 1)]);
 
 *raw_samples++ -= y >> 20;
 parcor_to_lpc(smp, quant_cof, lpc_cof);
-- 
2.22.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 4/4] avcodec/mediacodec_wrapper: remove unused local variables in ff_AMediaCodec_getCodecNameByType()

2019-07-26 Thread Matthieu Bouron
On Tue, Jul 23, 2019 at 01:09:41AM +0200, Michael Niedermayer wrote:
> On Mon, Jul 22, 2019 at 09:02:15AM +0200, Matthieu Bouron wrote:
> > On Fri, Jul 19, 2019 at 09:40:52AM +0200, Matthieu Bouron wrote:
> > > On Sun, Jul 14, 2019 at 08:17:03PM +0200, Matthieu Bouron wrote:
> > > > On Thu, Jul 04, 2019 at 03:43:48PM +0200, Matthieu Bouron wrote:
> > > > > ---
> > > > >  libavcodec/mediacodec_wrapper.c | 10 --
> > > > >  1 file changed, 10 deletions(-)
> > > > > 
> > > > > diff --git a/libavcodec/mediacodec_wrapper.c 
> > > > > b/libavcodec/mediacodec_wrapper.c
> > > > > index 70e1e7cae1..5213cf640a 100644
> > > > > --- a/libavcodec/mediacodec_wrapper.c
> > > > > +++ b/libavcodec/mediacodec_wrapper.c
> > > > > @@ -392,8 +392,6 @@ char *ff_AMediaCodecList_getCodecNameByType(const 
> > > > > char *mime, int profile, int e
> > > > >  struct JNIAMediaCodecListFields jfields = { 0 };
> > > > >  struct JNIAMediaFormatFields mediaformat_jfields = { 0 };
> > > > >  
> > > > > -jobject format = NULL;
> > > > > -jobject codec = NULL;
> > > > >  jobject codec_name = NULL;
> > > > >  
> > > > >  jobject info = NULL;
> > > > > @@ -571,14 +569,6 @@ done_with_info:
> > > > >  }
> > > > >  
> > > > >  done:
> > > > > -if (format) {
> > > > > -(*env)->DeleteLocalRef(env, format);
> > > > > -}
> > > > > -
> > > > > -if (codec) {
> > > > > -(*env)->DeleteLocalRef(env, codec);
> > > > > -}
> > > > > -
> > > > >  if (codec_name) {
> > > > >  (*env)->DeleteLocalRef(env, codec_name);
> > > > >  }
> > > > > -- 
> > > > > 2.22.0
> > > > > 
> > > > 
> > > > Ping for the patch set.
> > > 
> > > If there is no objection, I will push the patchset in a few days.
> > > 
> > 
> > Pushed to master. Is it still on time to also be pushed to the 4.2 release
> > branch ?
> 
> i found no time today for working on the release so theres still time for
> any backports of bug fixes, yes

Pushed to the release/4.2 branch. Thanks.

-- 
Matthieu B.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 0/3] avformat: Use s337m subdemux inside mxf/wav

2019-07-26 Thread Nicolas Gaullier
In case of an mxf or wav file having stereo tracks, the new 'dolbyeprobe' flag
enables detection of dolby_e.
The probing is done on the first sample and its guard band must be clean (to 
avoid wrong detection).

Tests samples for fate-suite/dolby_e uploaded here:
https://framadrop.org/r/u_JxHeVIRc#Fs2PXutr7geTBoTpnnJ/4+dTDNGBUuGT1Gf/wh00ZDw=
https://framadrop.org/r/nmjF4PbdxV#Flq5vPoRMrdfPKuM5+zdf3itUamIeWCVDriZaSKPkPQ=

Thank you for the review


Nicolas Gaullier (3):
  avformat/s337m: Make available as subdemuxer
  avformat: Support s337m in mxf/wav/w64
  avformat/s337m: Test mxf subdemux

 libavformat/avformat.h  |  7 ++
 libavformat/mxfdec.c| 20 +++-
 libavformat/options_table.h |  1 +
 libavformat/s337m.c | 57 +
 libavformat/s337m.h | 48 ++
 libavformat/wavdec.c|  7 +-
 tests/Makefile  |  1 +
 tests/fate-run.sh   |  4 
 tests/fate/audio.mak|  5 
 9 files changed, 138 insertions(+), 12 deletions(-)
 create mode 100644 libavformat/s337m.h

-- 
2.14.1.windows.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/3] avformat/s337m: Make available as subdemuxer

2019-07-26 Thread Nicolas Gaullier
---
 libavformat/s337m.c | 57 +++--
 libavformat/s337m.h | 48 
 2 files changed, 95 insertions(+), 10 deletions(-)
 create mode 100644 libavformat/s337m.h

diff --git a/libavformat/s337m.c b/libavformat/s337m.c
index 48ab66a6da..589fec53a9 100644
--- a/libavformat/s337m.c
+++ b/libavformat/s337m.c
@@ -21,15 +21,7 @@
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "spdif.h"
-
-#define MARKER_16LE 0x72F81F4E
-#define MARKER_20LE 0x20876FF0E154
-#define MARKER_24LE 0x72F8961F4EA5
-
-#define IS_16LE_MARKER(state)   ((state & 0x) == MARKER_16LE)
-#define IS_20LE_MARKER(state)   ((state & 0xF0F0) == MARKER_20LE)
-#define IS_24LE_MARKER(state)   ((state & 0x) == MARKER_24LE)
-#define IS_LE_MARKER(state) (IS_16LE_MARKER(state) || 
IS_20LE_MARKER(state) || IS_24LE_MARKER(state))
+#include "s337m.h"
 
 static int s337m_get_offset_and_codec(AVFormatContext *s,
   uint64_t state,
@@ -141,7 +133,7 @@ static void bswap_buf24(uint8_t *data, int size)
 FFSWAP(uint8_t, data[0], data[2]);
 }
 
-static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
+int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
 AVIOContext *pb = s->pb;
 uint64_t state = 0;
@@ -204,3 +196,48 @@ AVInputFormat ff_s337m_demuxer = {
 .read_packet= s337m_read_packet,
 .flags  = AVFMT_GENERIC_INDEX,
 };
+
+int s337m_probe_stream(AVFormatContext *s, AVStream **st)
+{
+if (((*st)->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE || 
(*st)->codecpar->codec_id == AV_CODEC_ID_PCM_S24LE) &&
+   (*st)->codecpar->channels == 2)
+{
+int64_t avio_current_offset;
+int bufsize, pos = 0;
+double s337m_phase;
+uint8_t *buf = av_mallocz(S337M_MAX_OFFSET);
+if (!buf)
+return AVERROR(ENOMEM);
+avio_current_offset = avio_tell(s->pb);
+bufsize = avio_read(s->pb, buf, S337M_MAX_OFFSET);
+avio_seek(s->pb, avio_current_offset, SEEK_SET);
+while (pos < bufsize - 5 && buf[pos] == 0)
+pos++;
+s337m_phase = (double)pos * 4 / (*st)->codecpar->bits_per_coded_sample 
/ (*st)->codecpar->sample_rate;
+if (s337m_phase >= S337M_PHASE_PROBE_MIN && pos < bufsize - 5) {
+uint64_t state;
+int data_type = -1, data_size, offset;
+if ((*st)->codecpar->bits_per_coded_sample == 16) {
+state = AV_RB32(buf + pos);
+if (IS_16LE_MARKER(state)) {
+data_type = AV_RL16(buf + pos + 4);
+data_size = AV_RL16(buf + pos + 6);
+}
+} else if ((*st)->codecpar->bits_per_coded_sample == 24) {
+state = AV_RB48(buf + pos);
+if (IS_20LE_MARKER(state) || IS_24LE_MARKER(state)) {
+data_type = AV_RL24(buf + pos + 6);
+data_size = AV_RL24(buf + pos + 9);
+}
+}
+av_freep(&buf);
+if (data_type >= 0 && !s337m_get_offset_and_codec(s, state, 
data_type, data_size, &offset, &(*st)->codecpar->codec_id))
+{
+av_log(s, AV_LOG_INFO, "s337m detected with phase = %.6fs\n", 
s337m_phase);
+if ((*st)->codecpar->codec_id == AV_CODEC_ID_DOLBY_E && 
(s337m_phase < DOLBY_E_PHASE_MIN || s337m_phase > DOLBY_E_PHASE_MAX))
+av_log(s, AV_LOG_WARNING, "Dolby E phase is out of 
valid range (%.6fs-%.6fs)\n", DOLBY_E_PHASE_MIN, DOLBY_E_PHASE_MAX);
+}
+}
+}
+return 0;
+}
diff --git a/libavformat/s337m.h b/libavformat/s337m.h
new file mode 100644
index 00..900b966233
--- /dev/null
+++ b/libavformat/s337m.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2017 foo86
+ *
+ * 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 AVFORMAT_S337M_H
+#define AVFORMAT_S337M_H
+
+#define MARKER_16LE 0x72F81F4E
+#define MARKER_20LE 0x20876FF0E154
+#define MARKER_24LE 0x72F8961F4EA5
+
+#define IS_16LE_MARKER(state)   ((state & 0x) == MARKER_16LE)
+#define IS_20LE_MARKER(state)   ((state & 

Re: [FFmpeg-devel] [PATCH 2/3] avformat: Support s337m in mxf/wav/w64

2019-07-26 Thread Paul B Mahol
On Fri, Jul 26, 2019 at 6:45 PM Nicolas Gaullier <
nicolas.gaull...@arkena.com> wrote:

> ---
>  libavformat/avformat.h  |  7 +++
>  libavformat/mxfdec.c| 20 +++-
>  libavformat/options_table.h |  1 +
>  libavformat/wavdec.c|  7 ++-
>  4 files changed, 33 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 6eb329f13f..42bb094d81 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1951,6 +1951,13 @@ typedef struct AVFormatContext {
>   * - decoding: set by user
>   */
>  int skip_estimate_duration_from_pts;
> +
> +/**
> + * Probe dolby_e in PCM streams
> + * - encoding: unused
> + * - decoding: set by user
> + */
> +int dolby_e_probe;
>

Unacceptable addition. Use AVOptions.



>  } AVFormatContext;
>
>  #if FF_API_FORMAT_GET_SET
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index bb72fb9841..5b6eb9d756 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -56,6 +56,7 @@
>  #include "avformat.h"
>  #include "internal.h"
>  #include "mxf.h"
> +#include "s337m.h"
>
>  #define MXF_MAX_CHUNK_SIZE (32 << 20)
>
> @@ -302,6 +303,8 @@ typedef struct MXFMetadataReadTableEntry {
>  enum MXFMetadataSetType type;
>  } MXFMetadataReadTableEntry;
>
> +static int mxf_read_packet_init = 0;
> +static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt);
>  static int mxf_read_close(AVFormatContext *s);
>
>  /* partial keys to match */
> @@ -3247,6 +3250,19 @@ static int mxf_read_header(AVFormatContext *s)
>  if ((ret = mxf_parse_structural_metadata(mxf)) < 0)
>  goto fail;
>
> +if (mxf->fc->dolby_e_probe)
> +{
> +int i;
> +AVPacket *pkt = av_packet_alloc();
> +av_init_packet(pkt);
> +mxf_read_packet_init = 1;
> +for (i = 0; i < mxf->fc->nb_streams; i++)
> +mxf_read_packet(mxf->fc, pkt);
> +mxf_read_packet_init = 0;
> +av_freep(pkt);
> +avio_seek(s->pb, essence_offset, SEEK_SET);
> +}
> +
>  for (int i = 0; i < s->nb_streams; i++)
>  mxf_handle_missing_index_segment(mxf, s->streams[i]);
>
> @@ -3539,7 +3555,9 @@ static int mxf_read_packet(AVFormatContext *s,
> AVPacket *pkt)
>  return ret;
>  }
>  } else {
> -ret = av_get_packet(s->pb, pkt, klv.length);
> +if (mxf_read_packet_init)
> +s337m_probe_stream(mxf->fc, &st);
> +ret = st->codecpar->codec_id == AV_CODEC_ID_DOLBY_E ?
> s337m_read_packet(s, pkt) : av_get_packet(s->pb, pkt, klv.length);
>  if (ret < 0) {
>  mxf->current_klv_data = (KLVPacket){{0}};
>  return ret;
> diff --git a/libavformat/options_table.h b/libavformat/options_table.h
> index f2f077b34f..7f3c22d6bb 100644
> --- a/libavformat/options_table.h
> +++ b/libavformat/options_table.h
> @@ -111,6 +111,7 @@ static const AVOption avformat_options[] = {
>  {"protocol_blacklist", "List of protocols that are not allowed to be
> used", OFFSET(protocol_blacklist), AV_OPT_TYPE_STRING, { .str = NULL },
> CHAR_MIN, CHAR_MAX, D },
>  {"max_streams", "maximum number of streams", OFFSET(max_streams),
> AV_OPT_TYPE_INT, { .i64 = 1000 }, 0, INT_MAX, D },
>  {"skip_estimate_duration_from_pts", "skip duration calculation in
> estimate_timings_from_pts", OFFSET(skip_estimate_duration_from_pts),
> AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D},
> +{"dolbyeprobe", "probe dolby_e in PCM streams", OFFSET(dolby_e_probe),
> AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, D},
>  {NULL},
>  };
>
> diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
> index 52194f54ef..501c21f220 100644
> --- a/libavformat/wavdec.c
> +++ b/libavformat/wavdec.c
> @@ -41,6 +41,7 @@
>  #include "riff.h"
>  #include "w64.h"
>  #include "spdif.h"
> +#include "s337m.h"
>
>  typedef struct WAVDemuxContext {
>  const AVClass *class;
> @@ -593,6 +594,8 @@ break_loop:
>  } else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS &&
> st->codecpar->channels > 2) {
>  st->codecpar->block_align *= st->codecpar->channels;
>  }
> +if (s->dolby_e_probe)
> +s337m_probe_stream(s, &st);
>
>  ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
>  ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv);
> @@ -708,7 +711,7 @@ smv_out:
>  size = (size / st->codecpar->block_align) *
> st->codecpar->block_align;
>  }
>  size = FFMIN(size, left);
> -ret  = av_get_packet(s->pb, pkt, size);
> +ret  = st->codecpar->codec_id == AV_CODEC_ID_DOLBY_E ?
> s337m_read_packet(s, pkt) : av_get_packet(s->pb, pkt, size);
>  if (ret < 0)
>  return ret;
>  pkt->stream_index = 0;
> @@ -895,6 +898,8 @@ static int w64_read_header(AVFormatContext *s)
>  st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
>
>  avio_seek(pb, data_ofs, SEEK_SET);
> +if (s->dolby_e_probe)
> +

[FFmpeg-devel] [PATCH 2/3] avformat: Support s337m in mxf/wav/w64

2019-07-26 Thread Nicolas Gaullier
---
 libavformat/avformat.h  |  7 +++
 libavformat/mxfdec.c| 20 +++-
 libavformat/options_table.h |  1 +
 libavformat/wavdec.c|  7 ++-
 4 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 6eb329f13f..42bb094d81 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1951,6 +1951,13 @@ typedef struct AVFormatContext {
  * - decoding: set by user
  */
 int skip_estimate_duration_from_pts;
+
+/**
+ * Probe dolby_e in PCM streams
+ * - encoding: unused
+ * - decoding: set by user
+ */
+int dolby_e_probe;
 } AVFormatContext;
 
 #if FF_API_FORMAT_GET_SET
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index bb72fb9841..5b6eb9d756 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -56,6 +56,7 @@
 #include "avformat.h"
 #include "internal.h"
 #include "mxf.h"
+#include "s337m.h"
 
 #define MXF_MAX_CHUNK_SIZE (32 << 20)
 
@@ -302,6 +303,8 @@ typedef struct MXFMetadataReadTableEntry {
 enum MXFMetadataSetType type;
 } MXFMetadataReadTableEntry;
 
+static int mxf_read_packet_init = 0;
+static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt);
 static int mxf_read_close(AVFormatContext *s);
 
 /* partial keys to match */
@@ -3247,6 +3250,19 @@ static int mxf_read_header(AVFormatContext *s)
 if ((ret = mxf_parse_structural_metadata(mxf)) < 0)
 goto fail;
 
+if (mxf->fc->dolby_e_probe)
+{
+int i;
+AVPacket *pkt = av_packet_alloc();
+av_init_packet(pkt);
+mxf_read_packet_init = 1;
+for (i = 0; i < mxf->fc->nb_streams; i++)
+mxf_read_packet(mxf->fc, pkt);
+mxf_read_packet_init = 0;
+av_freep(pkt);
+avio_seek(s->pb, essence_offset, SEEK_SET);
+}
+
 for (int i = 0; i < s->nb_streams; i++)
 mxf_handle_missing_index_segment(mxf, s->streams[i]);
 
@@ -3539,7 +3555,9 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 return ret;
 }
 } else {
-ret = av_get_packet(s->pb, pkt, klv.length);
+if (mxf_read_packet_init)
+s337m_probe_stream(mxf->fc, &st);
+ret = st->codecpar->codec_id == AV_CODEC_ID_DOLBY_E ? 
s337m_read_packet(s, pkt) : av_get_packet(s->pb, pkt, klv.length);
 if (ret < 0) {
 mxf->current_klv_data = (KLVPacket){{0}};
 return ret;
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index f2f077b34f..7f3c22d6bb 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -111,6 +111,7 @@ static const AVOption avformat_options[] = {
 {"protocol_blacklist", "List of protocols that are not allowed to be used", 
OFFSET(protocol_blacklist), AV_OPT_TYPE_STRING, { .str = NULL },  CHAR_MIN, 
CHAR_MAX, D },
 {"max_streams", "maximum number of streams", OFFSET(max_streams), 
AV_OPT_TYPE_INT, { .i64 = 1000 }, 0, INT_MAX, D },
 {"skip_estimate_duration_from_pts", "skip duration calculation in 
estimate_timings_from_pts", OFFSET(skip_estimate_duration_from_pts), 
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, D},
+{"dolbyeprobe", "probe dolby_e in PCM streams", OFFSET(dolby_e_probe), 
AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, D},
 {NULL},
 };
 
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 52194f54ef..501c21f220 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -41,6 +41,7 @@
 #include "riff.h"
 #include "w64.h"
 #include "spdif.h"
+#include "s337m.h"
 
 typedef struct WAVDemuxContext {
 const AVClass *class;
@@ -593,6 +594,8 @@ break_loop:
 } else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS && 
st->codecpar->channels > 2) {
 st->codecpar->block_align *= st->codecpar->channels;
 }
+if (s->dolby_e_probe)
+s337m_probe_stream(s, &st);
 
 ff_metadata_conv_ctx(s, NULL, wav_metadata_conv);
 ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv);
@@ -708,7 +711,7 @@ smv_out:
 size = (size / st->codecpar->block_align) * st->codecpar->block_align;
 }
 size = FFMIN(size, left);
-ret  = av_get_packet(s->pb, pkt, size);
+ret  = st->codecpar->codec_id == AV_CODEC_ID_DOLBY_E ? 
s337m_read_packet(s, pkt) : av_get_packet(s->pb, pkt, size);
 if (ret < 0)
 return ret;
 pkt->stream_index = 0;
@@ -895,6 +898,8 @@ static int w64_read_header(AVFormatContext *s)
 st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
 
 avio_seek(pb, data_ofs, SEEK_SET);
+if (s->dolby_e_probe)
+s337m_probe_stream(s, &st);
 
 set_spdif(s, wav);
 
-- 
2.14.1.windows.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/3] avformat/s337m: Test mxf subdemux

2019-07-26 Thread Nicolas Gaullier
incl. 24bits 5.1+2 dolby_e decoding
---
 tests/Makefile   | 1 +
 tests/fate-run.sh| 4 
 tests/fate/audio.mak | 5 +
 3 files changed, 10 insertions(+)

diff --git a/tests/Makefile b/tests/Makefile
index 624292d451..e8e23085eb 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -74,6 +74,7 @@ ENCDEC2 = $(call ALLYES, $(firstword $(1))_ENCODER $(lastword 
$(1))_DECODER  \
  $(firstword $(3))_MUXER   $(lastword $(3))_DEMUXER)
 
 DEMDEC  = $(call ALLYES, $(1)_DEMUXER $(2:%=%_DECODER))
+DEMDEMDEC  = $(call ALLYES, $(1)_DEMUXER $(2)_DEMUXER $(3:%=%_DECODER))
 ENCMUX  = $(call ALLYES, $(1:%=%_ENCODER) $(2)_MUXER)
 
 DEMMUX  = $(call ALLYES, $(1)_DEMUXER $(2)_MUXER)
diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index 2f1991da52..8ecb2b6cfa 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -162,6 +162,10 @@ pcm(){
 ffmpeg "$@" -vn -f s16le -
 }
 
+dolbye2pcm16(){
+ffmpeg -dolbyeprobe 1 "$@" -vn -f s16le -
+}
+
 fmtstdout(){
 fmt=$1
 shift 1
diff --git a/tests/fate/audio.mak b/tests/fate/audio.mak
index c41958ea2d..b00493637e 100644
--- a/tests/fate/audio.mak
+++ b/tests/fate/audio.mak
@@ -24,6 +24,11 @@ fate-dolby-e: CMD = pcm -i $(TARGET_SAMPLES)/dolby_e/16-11
 fate-dolby-e: CMP = oneoff
 fate-dolby-e: REF = $(SAMPLES)/dolby_e/16-11.pcm
 
+FATE_SAMPLES_AUDIO-$(call DEMDEMDEC, MXF, S337M, DOLBY_E) += fate-dolby-e-mxf
+fate-dolby-e-mxf: CMD = dolbye2pcm16 -i $(TARGET_SAMPLES)/dolby_e/512.mxf
+fate-dolby-e-mxf: CMP = oneoff
+fate-dolby-e-mxf: REF = $(SAMPLES)/dolby_e/512.mxf.pcm
+
 FATE_SAMPLES_AUDIO-$(call DEMDEC, DSS, DSS_SP) += fate-dss-lp fate-dss-sp
 fate-dss-lp: CMD = framecrc -i $(TARGET_SAMPLES)/dss/lp.dss -frames 30
 fate-dss-sp: CMD = framecrc -i $(TARGET_SAMPLES)/dss/sp.dss -frames 30
-- 
2.14.1.windows.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avcodec/assdec: undefined use of memcpy()

2019-07-26 Thread Michael Niedermayer
On Thu, Jul 25, 2019 at 11:38:48AM +0200, Paul B Mahol wrote:
> On 7/24/19, Michael Niedermayer  wrote:
> > Fixes: null pointer passed as argument 2, which is declared to never be null
> > Fixes:
> > 16008/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SSA_fuzzer-5650582821404672
> > (this is a separate issue found in this testcase)
> >
> > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/assdec.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/assdec.c b/libavcodec/assdec.c
> > index 3178f2953c..f0b1069cd2 100644
> > --- a/libavcodec/assdec.c
> > +++ b/libavcodec/assdec.c
> > @@ -31,7 +31,8 @@ static av_cold int ass_decode_init(AVCodecContext *avctx)
> >  avctx->subtitle_header = av_malloc(avctx->extradata_size + 1);
> >  if (!avctx->subtitle_header)
> >  return AVERROR(ENOMEM);
> > -memcpy(avctx->subtitle_header, avctx->extradata,
> > avctx->extradata_size);
> > +if (avctx->extradata_size)
> > +memcpy(avctx->subtitle_header, avctx->extradata,
> > avctx->extradata_size);
> >  avctx->subtitle_header[avctx->extradata_size] = 0;
> >  avctx->subtitle_header_size = avctx->extradata_size;
> >  return 0;
> > --
> > 2.22.0
> >
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> 
> i guess it is fine

will apply

Thank you!

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

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2] libavfilter: Update derain filter doc.

2019-07-26 Thread Michael Niedermayer
On Fri, Jul 26, 2019 at 10:54:27AM +0800, Xuewei Meng wrote:
> Add the usage of tensorflow model in derain filter. Training scripts
> as well as scripts for tf/native model generation are provided in the
> repository at https://github.com/XueweiMeng/derain_filter.git.
> 
> Signed-off-by: Xuewei Meng 
> ---
>  doc/filters.texi | 16 
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index c4ba907981..8e67dddecf 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -8367,9 +8367,12 @@ Recurrent Squeeze-and-Excitation Context Aggregation
> Net (RESCAN).
>  See @url{
> http://openaccess.thecvf.com/content_ECCV_2018/papers/Xia_Li_Recurrent_Squeeze-and-Excitation_Context_ECCV_2018_paper.pdf
> }.
>  @end itemize
> 
> -Training scripts as well as scripts for model generation are provided in
> +Training as well as model generation scripts are provided in
>  the repository at @url{https://github.com/XueweiMeng/derain_filter.git}.
> 
> +Native model files (.model) can be generated from TensorFlow model
> +files (.pb) by using tools/python/convert.py
> +
>  The filter accepts the following options:
> 
>  @table @option
> @@ -8380,14 +8383,19 @@ the following values:
>  @table @samp
>  @item native
>  Native implementation of DNN loading and execution.
> +
> +@item tensorflow
> +TensorFlow backend. To enable this backend you
> +need to install the TensorFlow for C library (see
> +@url{https://www.tensorflow.org/install/install_c}) and configure FFmpeg
> with
> +@code{--enable-libtensorflow}

patch corrupted by newlines

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

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/brenderpix: Check input size before allocating image

2019-07-26 Thread Paul B Mahol
I guess it is fine.

On Fri, Jul 26, 2019 at 6:28 PM Michael Niedermayer 
wrote:

> An incomplete image is not supported prior to this and will
> not produce any output. This commit moves the failure before
> time consuming operations.
>
> Fixes: Timeout (81sec -> 76ms)
> Fixes:
> 15723/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BRENDER_PIX_fuzzer-5147265653538816
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by
> :
> Michael Niedermayer 
> ---
>  libavcodec/brenderpix.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/brenderpix.c b/libavcodec/brenderpix.c
> index 0556858de1..46b7a59aa4 100644
> --- a/libavcodec/brenderpix.c
> +++ b/libavcodec/brenderpix.c
> @@ -204,6 +204,10 @@ static int pix_decode_frame(AVCodecContext *avctx,
> void *data, int *got_frame,
>  avpriv_request_sample(avctx, "Format %d", hdr.format);
>  return AVERROR_PATCHWELCOME;
>  }
> +bytes_per_scanline = bytes_pp * hdr.width;
> +
> +if (bytestream2_get_bytes_left(&gb) < hdr.height * bytes_per_scanline)
> +return AVERROR_INVALIDDATA;
>
>  if ((ret = ff_set_dimensions(avctx, hdr.width, hdr.height)) < 0)
>  return ret;
> @@ -261,7 +265,6 @@ static int pix_decode_frame(AVCodecContext *avctx,
> void *data, int *got_frame,
>  bytestream2_skip(&gb, 8);
>
>  // read the image data to the buffer
> -bytes_per_scanline = bytes_pp * hdr.width;
>  bytes_left = bytestream2_get_bytes_left(&gb);
>
>  if (chunk_type != IMAGE_DATA_CHUNK || data_len != bytes_left ||
> --
> 2.22.0
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/brenderpix: Check input size before allocating image

2019-07-26 Thread Michael Niedermayer
On Fri, Jul 26, 2019 at 07:46:10PM +0200, Paul B Mahol wrote:
> I guess it is fine.

will apply

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
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avfilter: add square audio source filter

2019-07-26 Thread Paul B Mahol
Nicolas, are you fine with this changes?

On Wed, Jul 24, 2019 at 1:29 PM Paul B Mahol  wrote:

> On 7/14/19, Paul B Mahol  wrote:
> > Signed-off-by: Paul B Mahol 
> > ---
> >  doc/filters.texi | 44 
> >  libavfilter/Makefile |  1 +
> >  libavfilter/allfilters.c |  1 +
> >  libavfilter/asrc_sine.c  | 86 ++--
> >  4 files changed, 119 insertions(+), 13 deletions(-)
> >
>
> Will apply ASAP!
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] Patchwork: how to reset password?

2019-07-26 Thread Darren Mo
I have the same problem. Hopefully someone with access is able to fix it.

> On Jul 26, 2019, at 4:38 AM, Andreas Håkon  
> wrote:
> 
> Hi,
> 
> I'm sorry to post this on this mailing list. However, I need to clean my 
> patches
> on the Patchwork's FFmpeg server, but the "Reset Password" service doesn't
> seem to work. After days of selecting the Reset Form with the correct email
> address (if I try to register again, the email address is in use), I never 
> received
> any email (I've also checked for the Spam folder).
> 
> So, please, can anyone verify it?
> Thank you.
> A.H.
> 
> --
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 3/3] lavfi: add deshake_opencl filter

2019-07-26 Thread Jarek Samic
---

This filter is the subject of my GSoC project.

This is a video stabilization / deshake filter (name undetermined, feel free to 
discuss) that uses feature
point matching and RANSAC to determine a camera path, smooths the camera path 
with a gaussian filter, and
then applies the new path to the video.

There are a number of debug features that can be turned on (viewing point 
matches, viewing transform
details, viewing average kernel execution times). See the bottom of the file.

Since the last version of the patch, I have:

* Cleaned up some more things
* Made the changes pointed out in the review comments on the previous patch
* Improved the performance of the harris_response kernel (average execution 
times went from ~21 ms to ~3.5 ms on my machine)
* Improved the accuracy of the RANSAC model generation for decreased jitter in 
the rendered output

The last remaining major item I need to take care of is:

* Improve the performance of the match_descriptors kernel

Besides responding to review comments and fixing bugs, of course.

 configure   |1 +
 doc/filters.texi|   69 +
 libavfilter/Makefile|2 +
 libavfilter/allfilters.c|1 +
 libavfilter/opencl/deshake.cl   |  648 +
 libavfilter/opencl_source.h |1 +
 libavfilter/vf_deshake_opencl.c | 2190 +++
 7 files changed, 2912 insertions(+)
 create mode 100644 libavfilter/opencl/deshake.cl
 create mode 100644 libavfilter/vf_deshake_opencl.c

diff --git a/configure b/configure
index 5a4f507246..6516b91845 100755
--- a/configure
+++ b/configure
@@ -3441,6 +3441,7 @@ delogo_filter_deps="gpl"
 denoise_vaapi_filter_deps="vaapi"
 derain_filter_select="dnn"
 deshake_filter_select="pixelutils"
+deshake_opencl_filter_deps="opencl"
 dilation_opencl_filter_deps="opencl"
 drawtext_filter_deps="libfreetype"
 drawtext_filter_suggest="libfontconfig libfribidi"
diff --git a/doc/filters.texi b/doc/filters.texi
index 604e44d569..d4d2c0911f 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -19530,6 +19530,75 @@ Make every semi-green pixel in the input transparent 
with some slight blending:
 @end example
 @end itemize
 
+@section deshake_opencl
+Feature-point based video stabilization filter.
+
+The filter accepts the following options:
+
+@table @option
+@item tripod
+Simulates a tripod by preventing any camera movement whatsoever from the 
original frame. Defaults to @code{0}.
+
+@item debug
+Whether or not additional debug info should be displayed, both in the 
processed output and in the console.
+
+Note that in order to see console debug output you will also need to pass 
@code{-v verbose} to ffmpeg.
+
+Viewing point matches in the output video is only supported for RGB input.
+
+Defaults to @code{0}.
+
+@item adaptive_crop
+Whether or not to do a tiny bit of cropping at the borders to cut down on the 
amount of mirrored pixels.
+
+Defaults to @code{1}.
+
+@item refine_features
+Whether or not feature points should be refined at a sub-pixel level.
+
+This can be turned off for a slight performance gain at the cost of precision.
+
+Defaults to @code{1}.
+
+@item smooth_strength
+The strength of the smoothing applied to the camera path from @code{0.0} to 
@code{1.0}.
+
+@code{1.0} is the maximum smoothing strength while values less than that 
result in less smoothing.
+
+@code{0.0} causes the filter to adaptively choose a smoothing strength on a 
per-frame basis.
+
+Defaults to @code{0.0}.
+
+@item smooth_window_multiplier
+Controls the size of the smoothing window (the number of frames buffered to 
determine motion information from).
+
+The size of the smoothing window is determined by multiplying the framerate of 
the video by this number.
+
+Acceptable values range from @code{0.1} to @code{10.0}.
+
+Larger values increase the amount of motion data available for determining how 
to smooth the camera path,
+potentially improving smoothness, but also increase latency and memory usage.
+
+Defaults to @code{2.0}.
+
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Stabilize a video with a fixed, medium smoothing strength:
+@example
+-i INPUT -vf "hwupload, deshake_opencl=smooth_strength=0.5, hwdownload" OUTPUT
+@end example
+
+@item
+Stabilize a video with debugging (both in console and in rendered video):
+@example
+-i INPUT -filter_complex "[0:v]format=rgba, hwupload, deshake_opencl=debug=1, 
hwdownload, format=rgba, format=yuv420p" -v verbose OUTPUT
+@end example
+@end itemize
+
 @section nlmeans_opencl
 
 Non-local Means denoise filter through OpenCL, this filter accepts same 
options as @ref{nlmeans}.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 455c809b15..d167841f44 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -211,6 +211,8 @@ OBJS-$(CONFIG_DEINTERLACE_VAAPI_FILTER)  += 
vf_deinterlace_vaapi.o vaapi_vpp
 OBJS-$(CONFIG_DEJUDDER_FILTER)   += vf_dejudder.o
 OBJS-$(CONFIG_DELOGO_FILTER) 

[FFmpeg-devel] [PATCH v2 1/3] lavfi: add utilities to reduce OpenCL boilerplate code

2019-07-26 Thread Jarek Samic
---
 libavfilter/opencl.c |  10 +++
 libavfilter/opencl.h | 142 +--
 2 files changed, 146 insertions(+), 6 deletions(-)

diff --git a/libavfilter/opencl.c b/libavfilter/opencl.c
index 95f0bfc604..8e96543467 100644
--- a/libavfilter/opencl.c
+++ b/libavfilter/opencl.c
@@ -350,3 +350,13 @@ void ff_opencl_print_const_matrix_3x3(AVBPrint *buf, const 
char *name_str,
 }
 av_bprintf(buf, "};\n");
 }
+
+cl_ulong ff_opencl_get_event_time(cl_event event) {
+cl_ulong time_start;
+cl_ulong time_end;
+
+clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_START, 
sizeof(time_start), &time_start, NULL);
+clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END, sizeof(time_end), 
&time_end, NULL);
+
+return time_end - time_start;
+}
diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h
index 973b6d82dd..7487e60241 100644
--- a/libavfilter/opencl.h
+++ b/libavfilter/opencl.h
@@ -47,6 +47,11 @@ typedef struct OpenCLFilterContext {
 intoutput_height;
 } OpenCLFilterContext;
 
+// Groups together information about a kernel argument
+typedef struct OpenCLKernelArg {
+size_t arg_size;
+const void *arg_val;
+} OpenCLKernelArg;
 
 /**
  * set argument to specific Kernel.
@@ -73,9 +78,26 @@ typedef struct OpenCLFilterContext {
 goto fail; \
 }  \
 } while(0)
+
+/**
+ * Create a kernel with the given name.
+ *
+ * The kernel variable in the context structure must have a name of the form
+ * kernel_.
+ *
+ * The OpenCLFilterContext variable in the context structure must be named ocf.
+ *
+ * Requires the presence of a local cl_int variable named cle and a fail label 
for error
+ * handling.
+ */
+#define CL_CREATE_KERNEL(ctx, kernel_name) do {
 \
+ctx->kernel_ ## kernel_name = clCreateKernel(ctx->ocf.program, 
#kernel_name, &cle); \
+CL_FAIL_ON_ERROR(AVERROR(EIO), "Failed to create %s kernel: %d.\n", 
#kernel_name, cle); \
+} while(0)
+
 /**
-  * release an OpenCL Kernel
-  */
+ * release an OpenCL Kernel
+ */
 #define CL_RELEASE_KERNEL(k)  \
 do {  \
 if (k) {  \
@@ -87,8 +109,8 @@ do { 
 \
 } while(0)
 
 /**
-  * release an OpenCL Memory Object
-  */
+ * release an OpenCL Memory Object
+ */
 #define CL_RELEASE_MEMORY(m)  \
 do {  \
 if (m) {  \
@@ -100,8 +122,8 @@ do {
  \
 } while(0)
 
 /**
-  * release an OpenCL Command Queue
-  */
+ * release an OpenCL Command Queue
+ */
 #define CL_RELEASE_QUEUE(q)   \
 do {  \
 if (q) {  \
@@ -112,6 +134,108 @@ do {  
\
 } \
 } while(0)
 
+/**
+ * Enqueue a kernel with the given information.
+ *
+ * Kernel arguments are provided as KernelArg structures and are set in the 
order
+ * that they are passed.
+ *
+ * Requires the presence of a local cl_int variable named cle and a fail label 
for error
+ * handling.
+ */
+#define CL_ENQUEUE_KERNEL_WITH_ARGS(queue, kernel, global_work_size, 
local_work_size, event, ...)   \
+do {   
 \
+OpenCLKernelArg args[] = {__VA_ARGS__};
 \
+for (int i = 0; i < FF_ARRAY_ELEMS(args); i++) {   
 \
+cle = clSetKernelArg(kernel, i, args[i].arg_size, args[i].arg_val);
 \
+if (cle != CL_SUCCESS) {   
 \
+av_log(avctx, AV_LOG_ERROR, "Failed to set kernel "
 \
+"argument %d: error %d.\n", i, cle);   
 \
+err = AVERROR(EIO);
 \
+goto fail; 
 \
+}  
 \
+}  
 \
+   
 \
+cle = clEnqueueNDRangeKernel(

[FFmpeg-devel] [PATCH v2 2/3] lavfi: modify avfilter_get_matrix to support separate scale factors

2019-07-26 Thread Jarek Samic
---

I have renamed `avfilter_get_matrix` to `ff_get_matrix` as per the comments on 
the last patch.

 libavfilter/transform.c  | 13 ++---
 libavfilter/transform.h  | 30 +++---
 libavfilter/vf_deshake.c |  7 +--
 3 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/libavfilter/transform.c b/libavfilter/transform.c
index f92fc4d42f..f4f9e0a47d 100644
--- a/libavfilter/transform.c
+++ b/libavfilter/transform.c
@@ -103,12 +103,19 @@ INTERPOLATE_METHOD(interpolate_biquadratic)
 }
 }
 
-void avfilter_get_matrix(float x_shift, float y_shift, float angle, float 
zoom, float *matrix) {
-matrix[0] = zoom * cos(angle);
+void ff_get_matrix(
+float x_shift,
+float y_shift,
+float angle,
+float scale_x,
+float scale_y,
+float *matrix
+) {
+matrix[0] = scale_x * cos(angle);
 matrix[1] = -sin(angle);
 matrix[2] = x_shift;
 matrix[3] = -matrix[1];
-matrix[4] = matrix[0];
+matrix[4] = scale_y * cos(angle);
 matrix[5] = y_shift;
 matrix[6] = 0;
 matrix[7] = 0;
diff --git a/libavfilter/transform.h b/libavfilter/transform.h
index 07436bfccb..9b0c19ceca 100644
--- a/libavfilter/transform.h
+++ b/libavfilter/transform.h
@@ -60,20 +60,28 @@ enum FillMethod {
 #define FILL_DEFAULT FILL_ORIGINAL
 
 /**
- * Get an affine transformation matrix from a given translation, rotation, and
- * zoom factor. The matrix will look like:
+ * Get an affine transformation matrix from given translation, rotation, and
+ * zoom factors. The matrix will look like:
  *
- * [ zoom * cos(angle),   -sin(angle), x_shift,
- *  sin(angle), zoom * cos(angle), y_shift,
- *   0, 0,   1 ]
+ * [ scale_x * cos(angle),   -sin(angle), x_shift,
+ * sin(angle),  scale_y * cos(angle), y_shift,
+ *  0, 0,   1 ]
  *
- * @param x_shift horizontal translation
- * @param y_shift vertical translation
- * @param angle   rotation in radians
- * @param zoomscale percent (1.0 = 100%)
- * @param matrix  9-item affine transformation matrix
+ * @param x_shift   horizontal translation
+ * @param y_shift   vertical translation
+ * @param angle rotation in radians
+ * @param scale_x   x scale percent (1.0 = 100%)
+ * @param scale_y   y scale percent (1.0 = 100%)
+ * @param matrix9-item affine transformation matrix
  */
-void avfilter_get_matrix(float x_shift, float y_shift, float angle, float 
zoom, float *matrix);
+void ff_get_matrix(
+float x_shift,
+float y_shift,
+float angle,
+float scale_x,
+float scale_y,
+float *matrix
+);
 
 /**
  * Add two matrices together. result = m1 + m2.
diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
index c8480e74dd..b516ea2d59 100644
--- a/libavfilter/vf_deshake.c
+++ b/libavfilter/vf_deshake.c
@@ -421,6 +421,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 const int chroma_width  = AV_CEIL_RSHIFT(link->w, desc->log2_chroma_w);
 const int chroma_height = AV_CEIL_RSHIFT(link->h, desc->log2_chroma_h);
 int aligned;
+float transform_zoom;
 
 out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
 if (!out) {
@@ -505,10 +506,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 deshake->last.angle = t.angle;
 deshake->last.zoom = t.zoom;
 
+transform_zoom = 1.0 + t.zoom / 100.0;
+
 // Generate a luma transformation matrix
-avfilter_get_matrix(t.vec.x, t.vec.y, t.angle, 1.0 + t.zoom / 100.0, 
matrix_y);
+ff_get_matrix(t.vec.x, t.vec.y, t.angle, transform_zoom, transform_zoom, 
matrix_y);
 // Generate a chroma transformation matrix
-avfilter_get_matrix(t.vec.x / (link->w / chroma_width), t.vec.y / (link->h 
/ chroma_height), t.angle, 1.0 + t.zoom / 100.0, matrix_uv);
+ff_get_matrix(t.vec.x / (link->w / chroma_width), t.vec.y / (link->h / 
chroma_height), t.angle, transform_zoom, transform_zoom, matrix_uv);
 // Transform the luma and chroma planes
 ret = deshake->transform(link->dst, link->w, link->h, chroma_width, 
chroma_height,
  matrix_y, matrix_uv, INTERPOLATE_BILINEAR, 
deshake->edge, in, out);
-- 
2.22.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] Fix for closed connection with http_persistent

2019-07-26 Thread Ian Klassen
Hi,

Here is a potential fix for this bug: https://trac.ffmpeg.org/ticket/7975

Before reusing the connection the headers are checked to see if the server is 
closing the connection. Also, the server may respond with "Connection: 
Keep-alive, close" so the patch also handles this.

Thanks.

Ian



0001-recognize-server-closing-http-connection.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/3] avformat: Support s337m in mxf/wav/w64

2019-07-26 Thread Michael Niedermayer
On Fri, Jul 26, 2019 at 06:45:16PM +0200, Nicolas Gaullier wrote:
> ---
>  libavformat/avformat.h  |  7 +++
>  libavformat/mxfdec.c| 20 +++-
>  libavformat/options_table.h |  1 +
>  libavformat/wavdec.c|  7 ++-
>  4 files changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index 6eb329f13f..42bb094d81 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1951,6 +1951,13 @@ typedef struct AVFormatContext {
>   * - decoding: set by user
>   */
>  int skip_estimate_duration_from_pts;
> +
> +/**
> + * Probe dolby_e in PCM streams
> + * - encoding: unused
> + * - decoding: set by user
> + */
> +int dolby_e_probe;
>  } AVFormatContext;
>  
>  #if FF_API_FORMAT_GET_SET
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index bb72fb9841..5b6eb9d756 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -56,6 +56,7 @@
>  #include "avformat.h"
>  #include "internal.h"
>  #include "mxf.h"
> +#include "s337m.h"
>  
>  #define MXF_MAX_CHUNK_SIZE (32 << 20)
>  

> @@ -302,6 +303,8 @@ typedef struct MXFMetadataReadTableEntry {
>  enum MXFMetadataSetType type;
>  } MXFMetadataReadTableEntry;
>  
> +static int mxf_read_packet_init = 0;

non constant static, 
container instance based variables should be in the context


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

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


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/3] avformat/s337m: Make available as subdemuxer

2019-07-26 Thread Michael Niedermayer
On Fri, Jul 26, 2019 at 06:45:15PM +0200, Nicolas Gaullier wrote:
> ---
>  libavformat/s337m.c | 57 
> +++--
>  libavformat/s337m.h | 48 
>  2 files changed, 95 insertions(+), 10 deletions(-)
>  create mode 100644 libavformat/s337m.h
> 
> diff --git a/libavformat/s337m.c b/libavformat/s337m.c
> index 48ab66a6da..589fec53a9 100644
> --- a/libavformat/s337m.c
> +++ b/libavformat/s337m.c
> @@ -21,15 +21,7 @@
>  #include "libavutil/intreadwrite.h"
>  #include "avformat.h"
>  #include "spdif.h"
> -
> -#define MARKER_16LE 0x72F81F4E
> -#define MARKER_20LE 0x20876FF0E154
> -#define MARKER_24LE 0x72F8961F4EA5
> -
> -#define IS_16LE_MARKER(state)   ((state & 0x) == MARKER_16LE)
> -#define IS_20LE_MARKER(state)   ((state & 0xF0F0) == MARKER_20LE)
> -#define IS_24LE_MARKER(state)   ((state & 0x) == MARKER_24LE)
> -#define IS_LE_MARKER(state) (IS_16LE_MARKER(state) || 
> IS_20LE_MARKER(state) || IS_24LE_MARKER(state))
> +#include "s337m.h"
>  
>  static int s337m_get_offset_and_codec(AVFormatContext *s,
>uint64_t state,
> @@ -141,7 +133,7 @@ static void bswap_buf24(uint8_t *data, int size)
>  FFSWAP(uint8_t, data[0], data[2]);
>  }
>  
> -static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)
> +int s337m_read_packet(AVFormatContext *s, AVPacket *pkt)

this would need a ff or avpriv prefix 

thx

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

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/5] cbs: Add some common code for read/write of miscellaneous user data

2019-07-26 Thread Aman Gupta
On Sun, Mar 25, 2018 at 10:41 AM Mark Thompson  wrote:

> Supports closed captions, active format and bar data as defined by
> SCTE 128 part 1 or A/53 part 4, suitable for use with both MPEG-2
> and H.264.
> ---
>  libavcodec/cbs_misc.c | 216
> ++
>  libavcodec/cbs_misc.h | 109 +
>  libavcodec/cbs_misc_syntax_template.c | 150 +++
>  3 files changed, 475 insertions(+)
>  create mode 100644 libavcodec/cbs_misc.c
>  create mode 100644 libavcodec/cbs_misc.h
>  create mode 100644 libavcodec/cbs_misc_syntax_template.c
>
> diff --git a/libavcodec/cbs_misc.c b/libavcodec/cbs_misc.c
> new file mode 100644
> index 00..cdf01fe229
> --- /dev/null
> +++ b/libavcodec/cbs_misc.c
> @@ -0,0 +1,216 @@
> +/*
> + * 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/attributes.h"
> +#include "libavutil/avassert.h"
> +
> +#include "cbs.h"
> +#include "cbs_internal.h"
> +#include "cbs_misc.h"
> +
> +#define CHECK(call) do { \
> +err = (call); \
> +if (err < 0) \
> +return err; \
> +} while (0)
> +
> +#define FUNC_NAME(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name
> +#define FUNC_MISC(rw, name) FUNC_NAME(rw, misc, name)
> +#define FUNC(name) FUNC_MISC(READWRITE, name)
> +
> +
> +#define READWRITE read
> +#define RWContext GetBitContext
> +
> +#define xui(width, name, var) do { \
> +uint32_t value = 0; \
> +CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \
> +   &value, 0, MAX_UINT_BITS(width))); \
> +var = value; \
> +} while (0)
> +
> +#define ui(width, name) \
> +xui(width, name, current->name)
> +
> +#define fixed(width, name, expected) do { \
> +av_unused uint32_t value; \
> +CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, &value, \
> +   expected, expected)); \
> +} while (0)
> +
> +#include "cbs_misc_syntax_template.c"
> +
> +#undef READWRITE
> +#undef RWContext
> +#undef xui
> +#undef ui
> +#undef fixed
> +
> +
> +#define READWRITE write
> +#define RWContext PutBitContext
> +
> +#define xui(width, name, var) do { \
> +CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \
> +var, 0, MAX_UINT_BITS(width))); \
> +} while (0)
> +
> +#define ui(width, name) \
> +xui(width, name, current->name)
> +
> +#define fixed(width, name, value) do { \
> +CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, value, \
> +value, value)); \
> +} while (0)
> +
> +#include "cbs_misc_syntax_template.c"
> +
> +#undef READWRITE
> +#undef RWContext
> +#undef xui
> +#undef ui
> +#undef fixed
> +
> +
> +int ff_cbs_read_a53_user_data(CodedBitstreamContext *ctx,
> +  A53UserData *data,
> +  const uint8_t *read_buffer, size_t length)
> +{
> +GetBitContext gbc;
> +int err;
> +
> +err = init_get_bits(&gbc, read_buffer, 8 * length);
> +if (err < 0)
> +return err;
> +
> +return cbs_misc_read_a53_user_data(ctx, &gbc, data);
> +}
> +
> +int ff_cbs_write_a53_user_data(CodedBitstreamContext *ctx,
> +   uint8_t *write_buffer, size_t *length,
> +   A53UserData *data)
> +{
> +PutBitContext pbc;
> +int err;
> +
> +init_put_bits(&pbc, write_buffer, *length);
> +
> +err = cbs_misc_write_a53_user_data(ctx, &pbc, data);
> +if (err < 0) {
> +// Includes AVERROR(ENOSPC).
> +return err;
> +}
> +
> +// That output must be aligned.
> +av_assert0(put_bits_count(&pbc) % 8 == 0);
> +
> +*length = put_bits_count(&pbc) / 8;
> +
> +flush_put_bits(&pbc);
> +
> +return 0;
> +}
> +
> +int ff_cbs_read_a53_cc_side_data(CodedBitstreamContext *ctx,
> + A53UserData *data,
> + const uint8_t *side_data,
> + size_t side_data_size)
> +{
> +GetBitContext gbc;
> +CEA708CCData *cc;
> +int err, i, cc_count;
> +
> +if (side_data_size % 3) {
> +av_log(c

[FFmpeg-devel] [PATCH v3] libavfilter: Update derain filter doc.

2019-07-26 Thread Xuewei Meng
Add the usage of tensorflow model in derain filter. Training scripts
as well as scripts for tf/native model generation are provided in the
repository at https://github.com/XueweiMeng/derain_filter.git.

Signed-off-by: Xuewei Meng 
---
 doc/filters.texi | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index c4ba907981..8e67dddecf 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8367,9 +8367,12 @@ Recurrent Squeeze-and-Excitation Context Aggregation Net 
(RESCAN).
 See 
@url{http://openaccess.thecvf.com/content_ECCV_2018/papers/Xia_Li_Recurrent_Squeeze-and-Excitation_Context_ECCV_2018_paper.pdf}.
 @end itemize
 
-Training scripts as well as scripts for model generation are provided in
+Training as well as model generation scripts are provided in
 the repository at @url{https://github.com/XueweiMeng/derain_filter.git}.
 
+Native model files (.model) can be generated from TensorFlow model
+files (.pb) by using tools/python/convert.py
+
 The filter accepts the following options:
 
 @table @option
@@ -8380,14 +8383,19 @@ the following values:
 @table @samp
 @item native
 Native implementation of DNN loading and execution.
+
+@item tensorflow
+TensorFlow backend. To enable this backend you
+need to install the TensorFlow for C library (see
+@url{https://www.tensorflow.org/install/install_c}) and configure FFmpeg with
+@code{--enable-libtensorflow}
 @end table
 Default value is @samp{native}.
 
 @item model
 Set path to model file specifying network architecture and its parameters.
-Note that different backends use different file formats. TensorFlow backend
-can load files for both formats, while native backend can load files for only
-its format.
+Note that different backends use different file formats. TensorFlow and native 
+backend can load files for only its format.
 @end table
 
 @section deshake
-- 
2.17.1

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] libavfilter/vf_drawtext: Avoid undefined behavior from GET_UTF8

2019-07-26 Thread Aaron Boushley
The vf_drawtext filter uses the GET_UTF8 macro in multiple locations.
Each of these use `continue;` as the error handler. However the
documentation for the GET_UTF8 macro states "ERROR should not contain
a loop control statement which could interact with the internal while
loop, and should force an exit from the macro code (e.g. through a
goto or a return) in order to prevent undefined results."

This patch adjusts vf_drawtext to use goto error handlers similar to
other locations in ffmpeg.

Aaron


libavfilter-drawtext-avoid-undefined-behavior.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".