[FFmpeg-devel] [PATCH] avcodec/ilbcdec: fix integer overflow in energy

2018-12-08 Thread Michael Niedermayer
webrtc uses a int32_t like the existing code in ilbcdec

Fixes: signed integer overflow: 2080245063 + 257939661 cannot be represented in 
type 'int'
Fixes: 
11037/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ILBC_fuzzer-5682976612941824

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

diff --git a/libavcodec/ilbcdec.c b/libavcodec/ilbcdec.c
index 8a6dbe0b75..50012c0231 100644
--- a/libavcodec/ilbcdec.c
+++ b/libavcodec/ilbcdec.c
@@ -1303,7 +1303,8 @@ static int xcorr_coeff(int16_t *target, int16_t 
*regressor,
 pos += step;
 
 /* Do a +/- to get the next energy */
-energy += step * ((*rp_end * *rp_end - *rp_beg * *rp_beg) >> shifts);
+energy += (unsigned)step * ((*rp_end * *rp_end - *rp_beg * *rp_beg) >> 
shifts);
+
 rp_beg += step;
 rp_end += step;
 }
-- 
2.19.2

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


[FFmpeg-devel] AMD Vega 56, UVD and OpenCL

2018-12-08 Thread James Courtier-Dutton
Hi,

I little off topic, but hopefully someone here might be able to help me as
it is video processing related.

I wish to use UVD to send a video stream to the GPU, and then have OpenCL
process the output video frames.

Can anyone point me to example source code to achieve this in Linux.

Kind Regards

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


[FFmpeg-devel] [PATCH] avcodec/libaomenc: add row-mt option

2018-12-08 Thread James Almer
Default to disable, same as aomenc.

Signed-off-by: James Almer 
---
 libavcodec/libaomenc.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 17565017b4..1d3cef73f3 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -78,6 +78,7 @@ typedef struct AOMEncoderContext {
 int tile_cols_log2, tile_rows_log2;
 aom_superblock_size_t superblock_size;
 int uniform_tiles;
+int row_mt;
 } AOMContext;
 
 static const char *const ctlidstr[] = {
@@ -92,6 +93,9 @@ static const char *const ctlidstr[] = {
 [AV1E_SET_SUPERBLOCK_SIZE]  = "AV1E_SET_SUPERBLOCK_SIZE",
 [AV1E_SET_TILE_COLUMNS] = "AV1E_SET_TILE_COLUMNS",
 [AV1E_SET_TILE_ROWS]= "AV1E_SET_TILE_ROWS",
+#ifdef AOM_CTRL_AV1E_SET_ROW_MT
+[AV1E_SET_ROW_MT]   = "AV1E_SET_ROW_MT",
+#endif
 };
 
 static av_cold void log_encoder_error(AVCodecContext *avctx, const char *desc)
@@ -650,6 +654,10 @@ static av_cold int aom_init(AVCodecContext *avctx,
 codecctl_int(avctx, AV1E_SET_TILE_ROWS,ctx->tile_rows_log2);
 }
 
+#ifdef AOM_CTRL_AV1E_SET_ROW_MT
+codecctl_int(avctx, AV1E_SET_ROW_MT, ctx->row_mt);
+#endif
+
 // provide dummy value to initialize wrapper, values will be updated each 
_encode()
 aom_img_wrap(>rawimg, img_fmt, avctx->width, avctx->height, 1,
  (unsigned char*)1);
@@ -983,6 +991,9 @@ static const AVOption options[] = {
 { "tiles","Tile columns x rows", OFFSET(tile_cols), 
AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, VE },
 { "tile-columns", "Log2 of number of tile columns to use", 
OFFSET(tile_cols_log2), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
 { "tile-rows","Log2 of number of tile rows to use",
OFFSET(tile_rows_log2), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 6, VE},
+#ifdef AOM_CTRL_AV1E_SET_ROW_MT
+{ "row-mt",   "Enable row based multi-threading",  
OFFSET(row_mt), AV_OPT_TYPE_BOOL, {.i64 = 0},  0, 1, VE},
+#endif
 { NULL }
 };
 
-- 
2.19.2

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


[FFmpeg-devel] [PATCH] avformat/avio: fix avio_feof documentation

2018-12-08 Thread Marton Balint
It has been this way too long to change behaviour, so let's change the docs
instead.

Signed-off-by: Marton Balint 
---
 libavformat/avio.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index 75912ce6be..dcb8dcdf93 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -236,7 +236,7 @@ typedef struct AVIOContext {
 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
 int64_t (*seek)(void *opaque, int64_t offset, int whence);
 int64_t pos;/**< position in the file of the current buffer */
-int eof_reached;/**< true if eof reached */
+int eof_reached;/**< true if was unable to read due to error or 
eof */
 int write_flag; /**< true if open for writing */
 int max_packet_size;
 unsigned long checksum;
@@ -566,8 +566,8 @@ static av_always_inline int64_t avio_tell(AVIOContext *s)
 int64_t avio_size(AVIOContext *s);
 
 /**
- * feof() equivalent for AVIOContext.
- * @return non zero if and only if end of file
+ * Similar to feof() but also returns nonzero on read errors.
+ * @return non zero if and only if at end of file or a read error happened 
when reading.
  */
 int avio_feof(AVIOContext *s);
 
-- 
2.16.4

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


Re: [FFmpeg-devel] [PATCH 1/4] avformat/concatdec: set seekable flag after opening the last file

2018-12-08 Thread Nicolas George
Marton Balint (2018-12-09):
> Will apply soon.

Sorry, I was busy and it slipped my mind.

I will try hard to have a careful look tomorrow.

Regards,

-- 
  Nicolas Geoge


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


Re: [FFmpeg-devel] [PATCH 1/4] avformat/concatdec: set seekable flag after opening the last file

2018-12-08 Thread Marton Balint



On Sun, 2 Dec 2018, Marton Balint wrote:




On Thu, 22 Nov 2018, Marton Balint wrote:

After finishing the last file all durations and start times should be 

known.


Signed-off-by: Marton Balint 
---
libavformat/concatdec.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index bbe13136fa..a5883ec66e 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -525,6 +525,7 @@ static int open_next_file(AVFormatContext *avf)

if (++fileno >= cat->nb_files) {
cat->eof = 1;
+cat->seekable = 1;
return AVERROR_EOF;
}
return open_file(avf, fileno);
--
2.16.4


Ping for the series...


Will apply soon.

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


[FFmpeg-devel] [PATCH] configure: support dlmalloc custom allocator

2018-12-08 Thread Peter Ross
Doug Lea's Malloc: http://g.oswego.edu/dl/html/malloc.html
---
 configure | 5 +
 1 file changed, 5 insertions(+)

diff --git a/configure b/configure
index 99c4c05347..c6cbd4a33c 100755
--- a/configure
+++ b/configure
@@ -5854,6 +5854,11 @@ check_builtin x264_csp_bgr "stdint.h x264.h" 
"X264_CSP_BGR"
 
 malloc_extralibs=
 case "$custom_allocator" in
+dlmalloc)
+   require libdlmalloc dlmalloc.h dlmalloc -ldlmalloc
+malloc_prefix=dl
+malloc_extralibs=-ldlmalloc
+;;
 jemalloc)
 # jemalloc by default does not use a prefix
 require libjemalloc jemalloc/jemalloc.h malloc -ljemalloc
-- 
2.17.1

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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


[FFmpeg-devel] [PATCH 2/2] configure: djgpp: do not disable memalign when using custom_allocator

2018-12-08 Thread Peter Ross
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 4d7b2b37c3..99c4c05347 100755
--- a/configure
+++ b/configure
@@ -6809,7 +6809,7 @@ haiku)
 disable posix_memalign
 ;;
 *-dos|freedos|opendos)
-if test_cpp_condition sys/version.h "defined(__DJGPP__) && __DJGPP__ == 2 
&& __DJGPP_MINOR__ == 5"; then
+if test -z "$custom_allocator" && test_cpp_condition sys/version.h 
"defined(__DJGPP__) && __DJGPP__ == 2 && __DJGPP_MINOR__ == 5"; then
 disable memalign
 fi
 ;;
-- 
2.17.1

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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


[FFmpeg-devel] [PATCH 1/2] configure: use custom allocator extralibs when testing memalign and posix_memalign

2018-12-08 Thread Peter Ross
the memalign and posix_memalign tests currently fail when using a custom 
allocator,
because configure does not include the custom allocator library.
---
 configure | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 026aee6b25..4d7b2b37c3 100755
--- a/configure
+++ b/configure
@@ -5852,20 +5852,23 @@ check_builtin gmtime_r time.h "time_t *time; struct tm 
*tm; gmtime_r(time, tm)"
 check_builtin localtime_r time.h "time_t *time; struct tm *tm; 
localtime_r(time, tm)"
 check_builtin x264_csp_bgr "stdint.h x264.h" "X264_CSP_BGR"
 
+malloc_extralibs=
 case "$custom_allocator" in
 jemalloc)
 # jemalloc by default does not use a prefix
 require libjemalloc jemalloc/jemalloc.h malloc -ljemalloc
+malloc_extralibs=-ljemalloc
 ;;
 tcmalloc)
 require_pkg_config libtcmalloc libtcmalloc gperftools/tcmalloc.h 
tc_malloc
 malloc_prefix=tc_
+malloc_extralibs=${libtcmalloc_extralibs}
 ;;
 esac
 
 check_func_headers malloc.h _aligned_malloc && enable aligned_malloc
-check_func  ${malloc_prefix}memalign&& enable memalign
-check_func  ${malloc_prefix}posix_memalign  && enable posix_memalign
+check_func  ${malloc_prefix}memalign ${malloc_extralibs} && enable memalign
+check_func  ${malloc_prefix}posix_memalign ${malloc_extralibs} && enable 
posix_memalign
 
 check_func  access
 check_func_headers stdlib.h arc4random
-- 
2.17.1

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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


Re: [FFmpeg-devel] [PATCH] os_support: define socket shutdown SHUT_xxx macros if they are not defined

2018-12-08 Thread Peter Ross
On Wed, Nov 28, 2018 at 10:03:15PM +1100, Peter Ross wrote:
> sys/socket.h (with WIN32 guard) is needed to check if the SHUT_xxx macro 
> exists.
> and because of this, SHUT_xxx defs have been moved into the CONFIG_NETWORK 
> block,
> since they only affect network capable platforms.
> ---
> 
> This is a minor reworking of Dave's suggestion to make it work on *nix and 
> windows.

if no objections i will apply this one in next day or so.

because the patch drags in sys/socket.h, there is a chance it could affect some 
obscure
platform. hence why we have fate.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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


[FFmpeg-devel] [PATCH 2/2] avformat: add gif pipe demuxer

2018-12-08 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/img2dec.c| 15 +++
 3 files changed, 17 insertions(+)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index d0d621de07..0e43a12df5 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -242,6 +242,7 @@ OBJS-$(CONFIG_IMAGE_BMP_PIPE_DEMUXER) += img2dec.o 
img2.o
 OBJS-$(CONFIG_IMAGE_DDS_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_DPX_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_EXR_PIPE_DEMUXER) += img2dec.o img2.o
+OBJS-$(CONFIG_IMAGE_GIF_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_J2K_PIPE_DEMUXER) += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_JPEG_PIPE_DEMUXER)+= img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_JPEGLS_PIPE_DEMUXER)  += img2dec.o img2.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 5fb5bf17c6..df83b04484 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -463,6 +463,7 @@ extern AVInputFormat  ff_image_bmp_pipe_demuxer;
 extern AVInputFormat  ff_image_dds_pipe_demuxer;
 extern AVInputFormat  ff_image_dpx_pipe_demuxer;
 extern AVInputFormat  ff_image_exr_pipe_demuxer;
+extern AVInputFormat  ff_image_gif_pipe_demuxer;
 extern AVInputFormat  ff_image_j2k_pipe_demuxer;
 extern AVInputFormat  ff_image_jpeg_pipe_demuxer;
 extern AVInputFormat  ff_image_jpegls_pipe_demuxer;
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index ff4757e532..e82b1df50b 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -29,6 +29,7 @@
 #include "libavutil/pixdesc.h"
 #include "libavutil/parseutils.h"
 #include "libavutil/intreadwrite.h"
+#include "libavcodec/gif.h"
 #include "avformat.h"
 #include "avio_internal.h"
 #include "internal.h"
@@ -1005,6 +1006,19 @@ static int xwd_probe(AVProbeData *p)
 return AVPROBE_SCORE_MAX / 2 + 1;
 }
 
+static int gif_probe(AVProbeData *p)
+{
+/* check magick */
+if (memcmp(p->buf, gif87a_sig, 6) && memcmp(p->buf, gif89a_sig, 6))
+return 0;
+
+/* width or height contains zero? */
+if (!AV_RL16(>buf[6]) || !AV_RL16(>buf[8]))
+return 0;
+
+return AVPROBE_SCORE_MAX - 1;
+}
+
 #define IMAGEAUTO_DEMUXER(imgname, codecid)\
 static const AVClass imgname ## _class = {\
 .class_name = AV_STRINGIFY(imgname) " demuxer",\
@@ -1028,6 +1042,7 @@ IMAGEAUTO_DEMUXER(bmp, AV_CODEC_ID_BMP)
 IMAGEAUTO_DEMUXER(dds, AV_CODEC_ID_DDS)
 IMAGEAUTO_DEMUXER(dpx, AV_CODEC_ID_DPX)
 IMAGEAUTO_DEMUXER(exr, AV_CODEC_ID_EXR)
+IMAGEAUTO_DEMUXER(gif, AV_CODEC_ID_GIF)
 IMAGEAUTO_DEMUXER(j2k, AV_CODEC_ID_JPEG2000)
 IMAGEAUTO_DEMUXER(jpeg,AV_CODEC_ID_MJPEG)
 IMAGEAUTO_DEMUXER(jpegls,  AV_CODEC_ID_JPEGLS)
-- 
2.17.1

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


[FFmpeg-devel] [PATCH 1/2] avcodec: add gif parser

2018-12-08 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavcodec/Makefile |   1 +
 libavcodec/gif_parser.c | 188 
 libavcodec/parsers.c|   1 +
 3 files changed, 190 insertions(+)
 create mode 100644 libavcodec/gif_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 5feadac729..d53b8ff330 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1026,6 +1026,7 @@ OBJS-$(CONFIG_DVDSUB_PARSER)   += dvdsub_parser.o
 OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o \
   vorbis_data.o
 OBJS-$(CONFIG_G729_PARSER) += g729_parser.o
+OBJS-$(CONFIG_GIF_PARSER)  += gif_parser.o
 OBJS-$(CONFIG_GSM_PARSER)  += gsm_parser.o
 OBJS-$(CONFIG_H261_PARSER) += h261_parser.o
 OBJS-$(CONFIG_H263_PARSER) += h263_parser.o
diff --git a/libavcodec/gif_parser.c b/libavcodec/gif_parser.c
new file mode 100644
index 00..7f4199b285
--- /dev/null
+++ b/libavcodec/gif_parser.c
@@ -0,0 +1,188 @@
+/*
+ * GIF parser
+ * Copyright (c) 2018 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * GIF parser
+ */
+
+#include "libavutil/avassert.h"
+#include "libavutil/bswap.h"
+#include "libavutil/common.h"
+
+#include "gif.h"
+#include "parser.h"
+
+typedef enum GIFParseStates {
+GIF_HEADER = 1,
+GIF_EXTENSION,
+GIF_EXTENSION_BLOCK,
+GIF_IMAGE,
+GIF_IMAGE_BLOCK,
+} gif_states;
+
+typedef struct GIFParseContext {
+ParseContext pc;
+int found_start;
+int found_end;
+int index;
+int state;
+int gct_flag;
+int gct_size;
+int block_size;
+int etype;
+int delay;
+} GIFParseContext;
+
+static int gif_find_frame_end(GIFParseContext *g, const uint8_t *buf,
+  int buf_size, void *logctx)
+{
+int index, next = END_NOT_FOUND;
+
+for (index = 0; index < buf_size; index++) {
+if (!g->state) {
+if (!memcmp(buf + index, gif87a_sig, 6) ||
+!memcmp(buf + index, gif89a_sig, 6)) {
+g->state = GIF_HEADER;
+g->found_start = 1;
+} else if (buf[index] == GIF_EXTENSION_INTRODUCER) {
+g->state = GIF_EXTENSION;
+g->found_start = 1;
+} else if (buf[index] == GIF_IMAGE_SEPARATOR) {
+g->state = GIF_IMAGE;
+g->found_start = 1;
+} else if (buf[index] == GIF_TRAILER) {
+g->state = 0;
+g->found_end = 1;
+} else {
+av_assert0(0);
+}
+}
+
+if (g->state == GIF_HEADER) {
+if (g->index == 10) {
+g->gct_flag = !!(buf[index] & 0x80);
+g->gct_size = 3 * (1 << ((buf[index] & 0x07) + 1));
+}
+if (g->index >= 12 + g->gct_flag * g->gct_size) {
+g->state = 0;
+g->index = 0;
+g->gct_flag = 0;
+g->gct_size = 0;
+continue;
+}
+g->index++;
+} else if (g->state == GIF_EXTENSION) {
+if (g->index == 1) {
+g->etype = buf[index];
+}
+if (g->index >= 2) {
+g->block_size = buf[index];
+g->index = 0;
+g->state = GIF_EXTENSION_BLOCK;
+continue;
+}
+g->index++;
+} else if (g->state == GIF_IMAGE_BLOCK) {
+if (!g->index)
+g->block_size = buf[index];
+if (g->index >= g->block_size) {
+g->index = 0;
+if (!g->block_size) {
+g->state = 0;
+g->found_end = 1;
+}
+continue;
+}
+g->index++;
+} else if (g->state == GIF_EXTENSION_BLOCK) {
+if (g->etype == GIF_GCE_EXT_LABEL) {
+if (g->index == 0)
+g->delay = 0;
+if (g->index >= 1 && g->index <= 2) {
+g->delay |= buf[index] << (8 * (g->index - 1));
+}
+}
+if (g->index >= 

Re: [FFmpeg-devel] [PATCH] libavcodec/zmbvenc.c: don't allow motion estimation out of range.

2018-12-08 Thread Tomas Härdin
lör 2018-12-08 klockan 00:29 + skrev Matthew Fearnley:
> Hi Tomas, thanks for looking through my patch.
> 
> > > Practically, this patch fixes graphical glitches e.g. when reencoding
> 
> the
> > > Commander Keen sample video with me_range 65 or higher:
> > > 
> > > ffmpeg -i keen4e_000.avi -c:v zmbv -me_range 65 keen4e_me65.avi
> > I'd expect this problem to pop up with -me_range 64 too, no?
> 
> I initially thought this would be the case, but taking the tx loop and
> removing the edge constraints:
> 
> for(tx = x - c->range; tx < x + c->range; tx++){
> ...
> dx = tx - x;
> 
> The effective range is (-c->range) <= dx < (c->range), meaning when
> c->range = me_range = 64, the dx value ranges from -64 to 63, which happens
> to be exactly in bounds.
> So I could have just capped me_range to 64, and that would have fixed the
> bug...
> 
> But more generally, I've concluded the '<' sign is a mistake, not just
> because of the general asymmetry, but because of the way it prevents tx,ty
> reaching the bottom/right edges.
> In practice it means, for example, that if the screen pans left to right,
> the bottom edge will have to match against blocks elsewhere in the image.
> 
> > I went over the patch, and it looks fine. But what's up with the xored
> > logic? It seems like it would compute xored always from the bottom-
> > right-most MV. The loop in zmbv_me() should probably have a temporary
> > xored and only output to *xored in if(tv < bv)..
> 
> Hmm, you're right.  In most cases, the code actually works anyway - because
> when *xored==0, the block entropy returned by block_cmp() is supposed to be
> 0 anyway, so it still finishes then.
> But... I've realised there are some exceptions to this:
> - the entropy calculations in block_cmp() use a lookup table
> (score_tab[256]), which assumes each block has 16*16 pixels.  This will
> only be valid when the dimensions are a multiple of 16, otherwise the
> bottom/right edge blocks may be smaller.
> - I've just realised the lookup table only goes up to 255.  If all 16*16
> xored pixels are the same value, it will hit the 256th entry!  (I'm
> surprised valgrind hasn't found this..?)

Static analysis would've caught this, which is something I've harped on
previously on this list (http://ffmpeg.org/pipermail/ffmpeg-devel/2018-
June/231598.html)

> All that said, *xored==0 is actually the most desirable outcome because it
> means the block doesn't need to be output.
> So if *xored is 0, the best thing to do is probably to finish immediately
> (making sure *mx,*my are set), without processing any more MVs.
> And then it doesn't matter (from a correctness point of view, at least) if
> block_cmp() gives bad entropy results, as long as *xored is set correctly.

Oh yeah, that's right. It might also be a good idea to try the MV of
the previous block first for the next block, since consecutive blocks
are likely to have the same MV. Even fancier would be to gather
statistics from the previous frame, and try MVs in order of decreasing
popularity. A threshold might also be useful, like "accept any MV that
results in no more than N bits entropy"

> Note: the code currently exits on bv==0.  It's a very good result, but it
> does not always imply the most desirable case, because it will happen if
> the xored block contains all 42's (etc), not just all 0's.
> It's obviously highly compressible, but it would still be better if the
> block could be omitted entirely.  Maybe it's an acceptable time/space
> tradeoff though.  I don't know...

You could always add !!*xored to the score. That way all 42's -> 1, all
0's -> 0.

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


[FFmpeg-devel] [PATCH] ffmpeg-opt: mark stream disable options as output-only

2018-12-08 Thread Gyan Doshi

I see users with these options set in front of input.

Stream disabling for input requires -discard though one packet tends to 
get smuggled across. But that's for another patch.


Gyan
From f0e78555d6ea5510922e2d543c9b69dff7d480b5 Mon Sep 17 00:00:00 2001
From: Gyan Doshi 
Date: Sat, 8 Dec 2018 18:49:34 +0530
Subject: [PATCH] ffmpeg-opt: mark stream disable options as output-only

-vn/an/sn/dn are only checked by open_output_file()
---
 fftools/ffmpeg_opt.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index d4851a2cd8..d3b11cfb44 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -3522,7 +3522,7 @@ const OptionDef options[] = {
 "set the number of bits per raw sample", "number" },
 { "intra",OPT_VIDEO | OPT_BOOL | OPT_EXPERT,   
  { _only },
 "deprecated use -g 1" },
-{ "vn",   OPT_VIDEO | OPT_BOOL  | OPT_OFFSET | OPT_INPUT | 
OPT_OUTPUT,{ .off = OFFSET(video_disable) },
+{ "vn",   OPT_VIDEO | OPT_BOOL  | OPT_OFFSET | OPT_OUTPUT, 
  { .off = OFFSET(video_disable) },
 "disable video" },
 { "rc_override",  OPT_VIDEO | HAS_ARG | OPT_EXPERT  | OPT_STRING | 
OPT_SPEC |
   OPT_OUTPUT,  
  { .off = OFFSET(rc_overrides) },
@@ -3612,7 +3612,7 @@ const OptionDef options[] = {
 { "ac", OPT_AUDIO | HAS_ARG  | OPT_INT | OPT_SPEC |
 OPT_INPUT | OPT_OUTPUT,
{ .off = OFFSET(audio_channels) },
 "set number of audio channels", "channels" },
-{ "an", OPT_AUDIO | OPT_BOOL | OPT_OFFSET | OPT_INPUT | 
OPT_OUTPUT,{ .off = OFFSET(audio_disable) },
+{ "an", OPT_AUDIO | OPT_BOOL | OPT_OFFSET | OPT_OUTPUT,
{ .off = OFFSET(audio_disable) },
 "disable audio" },
 { "acodec", OPT_AUDIO | HAS_ARG  | OPT_PERFILE |
 OPT_INPUT | OPT_OUTPUT,
{ .func_arg = opt_audio_codec },
@@ -3634,7 +3634,7 @@ const OptionDef options[] = {
   "set the maximum number of channels to try to guess the channel layout" 
},
 
 /* subtitle options */
-{ "sn", OPT_SUBTITLE | OPT_BOOL | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, 
{ .off = OFFSET(subtitle_disable) },
+{ "sn", OPT_SUBTITLE | OPT_BOOL | OPT_OFFSET | OPT_OUTPUT, 
 { .off = OFFSET(subtitle_disable) },
 "disable subtitle" },
 { "scodec", OPT_SUBTITLE | HAS_ARG  | OPT_PERFILE | OPT_INPUT | 
OPT_OUTPUT, { .func_arg = opt_subtitle_codec },
 "force subtitle codec ('copy' to copy stream)", "codec" },
@@ -3690,7 +3690,7 @@ const OptionDef options[] = {
 /* data codec support */
 { "dcodec", HAS_ARG | OPT_DATA | OPT_PERFILE | OPT_EXPERT | OPT_INPUT | 
OPT_OUTPUT, { .func_arg = opt_data_codec },
 "force data codec ('copy' to copy stream)", "codec" },
-{ "dn", OPT_BOOL | OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off 
= OFFSET(data_disable) },
+{ "dn", OPT_BOOL | OPT_VIDEO | OPT_OFFSET | OPT_OUTPUT,  { 
.off = OFFSET(data_disable) },
 "disable data" },
 
 #if CONFIG_VAAPI
-- 
2.19.2___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] cbs_h2645: Avoid memcpy when splitting fragment #2

2018-12-08 Thread Andreas Rheinhardt
Ping.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel