Changes of Revision 3

ffmpeg-3.changes Changed
x
 
1
@@ -1,12 +1,12 @@
2
 -------------------------------------------------------------------
3
-Sun Oct  1 15:31:56 UTC 2023 - Manfred Hollstein <manfred.h@gmx.net>
4
+Tue Dec 12 12:12:12 UTC 2023 - olaf@aepfle.de
5
 
6
-- Add ffmpeg-x86-mathops.patch
7
+- Version update to 3.4.13
8
 
9
 -------------------------------------------------------------------
10
-Fri Mar  3 03:03:03 UTC 2023 - olaf@aepfle.de
11
+Sun Oct  1 15:31:56 UTC 2023 - Manfred Hollstein <manfred.h@gmx.net>
12
 
13
-- Version update to 3.4.12
14
+- Add ffmpeg-x86-mathops.patch
15
 
16
 -------------------------------------------------------------------
17
 Mon Feb 11 21:43:44 UTC 2019 - bjorn.lie@gmail.com
18
ffmpeg-3.spec Changed
10
 
1
@@ -55,7 +55,7 @@
2
 %define _major_version 3
3
 %define _major_expected 4
4
 Name:           ffmpeg-3
5
-Version:        3.4.12
6
+Version:        3.4.13
7
 Release:        0
8
 Summary:        Library for working with various multimedia formats
9
 License:        LGPL-2.1-or-later AND GPL-2.0-or-later
10
_service Changed
10
 
1
@@ -1,7 +1,7 @@
2
 <services>
3
   <service name="tar_scm" mode="disabled">
4
     <param name="filename">ffmpeg-3</param>
5
-    <param name="revision">872001459cf0a20c6f44105f485d125c8e22fc76</param>
6
+    <param name="revision">c7210207555effd194b60dee424fd5632bb388f4</param>
7
     <param name="scm">git</param>
8
     <param name="submodules">disable</param>
9
     <param name="url">https://git.ffmpeg.org/ffmpeg.git</param>
10
ffmpeg-3-3.4.12.tar.xz/CREDITS -> ffmpeg-3-3.4.13.tar.xz/CREDITS Changed
10
 
1
@@ -1,6 +1,6 @@
2
-See the Git history of the project (git://source.ffmpeg.org/ffmpeg) to
3
+See the Git history of the project (https://git.ffmpeg.org/ffmpeg) to
4
 get the names of people who have contributed to FFmpeg.
5
 
6
 To check the log, you can type the command "git log" in the FFmpeg
7
 source directory, or browse the online repository at
8
-http://source.ffmpeg.org.
9
+https://git.ffmpeg.org/ffmpeg
10
ffmpeg-3-3.4.12.tar.xz/Changelog -> ffmpeg-3-3.4.13.tar.xz/Changelog Changed
62
 
1
@@ -1,6 +1,60 @@
2
 Entries are sorted chronologically from oldest to youngest within each release,
3
 releases are sorted from youngest to oldest.
4
 
5
+version 3.4.13:
6
+ avcodec/noise_bsf: Check for wrapped frames
7
+ avcodec/pngdec: Do not pass AVFrame into global header decode
8
+ avformat/wavdec: Check that smv block fits in available space
9
+ avcodec/tak: Check remaining bits in ff_tak_decode_frame_header()
10
+ avcodec/utils: the IFF_ILBM implementation assumes that there are a multiple of 16 allocated
11
+ avcodec/vorbisdec: Check codebook float values to be finite
12
+ avcodec/g2meet: Replace fake allocation avoidance for framebuf
13
+ avcodec/lcldec: More space for rgb24
14
+ avcodec/lcldec: Support 4:1:1 and 4:2:2 with odd width
15
+ libavcodec/lcldec: width and height should not be unsigned
16
+ avcodec/escape124: Check that blocks are allocated before use
17
+ avcodec/huffyuvdec: Fix undefined behavior with shift
18
+ avcodec/j2kenc: fix 5/3 DWT identifer
19
+ avcodec/vp3: Check width to avoid assertion failure
20
+ avcodec/g729postfilter: Limit shift in long term filter
21
+ configure: update copyright year
22
+ avcodec/tests/snowenc: Fix 2nd test
23
+ avcodec/tests/snowenc: return a failure if DWT/IDWT mismatches
24
+ avcodec/snowenc: Fix visual weight calculation
25
+ avcodec/tests/snowenc: unbreak DWT tests
26
+ avcodec/vp3: Add missing check for av_malloc
27
+ avcodec/escape124: Fix some return codes
28
+ avcodec/escape124: fix signdness of end of input check
29
+ Use https for repository links
30
+ avcodec/motionpixels: Mask pixels to valid values
31
+ avcodec/xpmdec: Check size before allocation to avoid truncation
32
+ avcodec/bink: Avoid undefined out of array end pointers in binkb_decode_plane()
33
+ avcodec/bink: Fix off by 1 error in ref end
34
+ avcodec/utils: Ensure linesize for SVQ3
35
+ avcodec/utils: allocate a line more for VC1 and WMV3
36
+ avcodec/videodsp_template: Adjust pointers to avoid undefined pointer things
37
+ avcodec/pngdec: Check deloco index more exactly
38
+ avcodec/ffv1dec: Check that num h/v slices is supported
39
+ avformat/mov: Check samplesize and offset to avoid integer overflow
40
+ avcodec/pictordec: Remove mid exit branch
41
+ avcodec/eac3dec: avoid float noise in fixed mode addition to overflow
42
+ avcodec/utils: use 32pixel alignment for bink
43
+ avcodec/012v: Order operations for odd size handling
44
+ avcodec/eatgq: : Check index increments in tgq_decode_block()
45
+ avcodec/scpr: Test bx before use
46
+ avcodec/sunrast: Fix maplength check
47
+ avcodec/wavpack: Avoid undefined shift in get_tail()
48
+ avformat/id3v2: Check taglen in read_uslt()
49
+ avcodec/ffv1dec: restructure slice coordinate reading a bit
50
+ avcodec/mlpdec: Check max matrix instead of max channel in noise check
51
+ swscale/input: Use more unsigned intermediates
52
+ avcodec/alsdec: The minimal block is at least 7 bits
53
+ avformat/replaygain: avoid undefined / negative abs
54
+ swscale/output: Bias 16bps output calculations to improve non overflowing range
55
+ avcodec/speedhq: Check buf_size to be big enough for DC
56
+ avcodec/ffv1dec: Fail earlier if prior context is corrupted
57
+ swscale: aarch64: Fix yuv2rgb with negative strides
58
+
59
 version 3.4.12:
60
  avcodec/dstdec: Check for overflow in build_filter()
61
  avformat/spdifdec: Use 64bit to compute bit rate
62
ffmpeg-3-3.4.12.tar.xz/RELEASE -> ffmpeg-3-3.4.13.tar.xz/RELEASE Changed
4
 
1
@@ -1,1 +1,1 @@
2
-3.4.12
3
+3.4.13
4
ffmpeg-3-3.4.12.tar.xz/configure -> ffmpeg-3-3.4.13.tar.xz/configure Changed
10
 
1
@@ -7000,7 +7000,7 @@
2
 #define FFMPEG_CONFIG_H
3
 #define FFMPEG_CONFIGURATION "$(c_escape $FFMPEG_CONFIGURATION)"
4
 #define FFMPEG_LICENSE "$(c_escape $license)"
5
-#define CONFIG_THIS_YEAR 2022
6
+#define CONFIG_THIS_YEAR 2023
7
 #define FFMPEG_DATADIR "$(eval c_escape $datadir)"
8
 #define AVCONV_DATADIR "$(eval c_escape $datadir)"
9
 #define CC_IDENT "$(c_escape ${cc_ident:-Unknown compiler})"
10
ffmpeg-3-3.4.12.tar.xz/doc/Doxyfile -> ffmpeg-3-3.4.13.tar.xz/doc/Doxyfile Changed
10
 
1
@@ -38,7 +38,7 @@
2
 # could be handy for archiving the generated documentation or if some version
3
 # control system is used.
4
 
5
-PROJECT_NUMBER         = 3.4.12
6
+PROJECT_NUMBER         = 3.4.13
7
 
8
 # Using the PROJECT_BRIEF tag one can provide an optional one line description
9
 # for a project that appears at the top of each page and should give viewer a
10
ffmpeg-3-3.4.12.tar.xz/doc/authors.texi -> ffmpeg-3-3.4.13.tar.xz/doc/authors.texi Changed
13
 
1
@@ -3,9 +3,9 @@
2
 The FFmpeg developers.
3
 
4
 For details about the authorship, see the Git history of the project
5
-(git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
6
+(https://git.ffmpeg.org/ffmpeg), e.g. by typing the command
7
 @command{git log} in the FFmpeg source directory, or browsing the
8
-online repository at @url{http://source.ffmpeg.org}.
9
+online repository at @url{https://git.ffmpeg.org/ffmpeg}.
10
 
11
 Maintainers for the specific components are listed in the file
12
 @file{MAINTAINERS} in the source code tree.
13
ffmpeg-3-3.4.12.tar.xz/doc/git-howto.texi -> ffmpeg-3-3.4.13.tar.xz/doc/git-howto.texi Changed
10
 
1
@@ -53,7 +53,7 @@
2
 @section Cloning the source tree
3
 
4
 @example
5
-git clone git://source.ffmpeg.org/ffmpeg <target>
6
+git clone https://git.ffmpeg.org/ffmpeg.git <target>
7
 @end example
8
 
9
 This will put the FFmpeg sources into the directory @var{<target>}.
10
ffmpeg-3-3.4.12.tar.xz/libavcodec/012v.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/012v.c Changed
12
 
1
@@ -131,8 +131,8 @@
2
             u = x/2 + (uint16_t *)(pic->data1 + line * pic->linesize1);
3
             v = x/2 + (uint16_t *)(pic->data2 + line * pic->linesize2);
4
             memcpy(y, y_temp, sizeof(*y) * (width - x));
5
-            memcpy(u, u_temp, sizeof(*u) * (width - x + 1) / 2);
6
-            memcpy(v, v_temp, sizeof(*v) * (width - x + 1) / 2);
7
+            memcpy(u, u_temp, sizeof(*u) * ((width - x + 1) / 2));
8
+            memcpy(v, v_temp, sizeof(*v) * ((width - x + 1) / 2));
9
         }
10
 
11
         line_end += stride;
12
ffmpeg-3-3.4.12.tar.xz/libavcodec/ac3.h -> ffmpeg-3-3.4.13.tar.xz/libavcodec/ac3.h Changed
17
 
1
@@ -74,6 +74,7 @@
2
 #define AC3_DYNAMIC_RANGE1      0
3
 
4
 typedef int                     INTFLOAT;
5
+typedef unsigned int            UINTFLOAT;
6
 typedef int16_t                 SHORTFLOAT;
7
 
8
 #else /* USE_FIXED */
9
@@ -93,6 +94,7 @@
10
 #define AC3_DYNAMIC_RANGE1      1.0f
11
 
12
 typedef float                   INTFLOAT;
13
+typedef float                   UINTFLOAT;
14
 typedef float                   SHORTFLOAT;
15
 
16
 #endif /* USE_FIXED */
17
ffmpeg-3-3.4.12.tar.xz/libavcodec/alsdec.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/alsdec.c Changed
10
 
1
@@ -1021,7 +1021,7 @@
2
 
3
     *bd->shift_lsbs = 0;
4
 
5
-    if (get_bits_left(gb) < 1)
6
+    if (get_bits_left(gb) < 7)
7
         return AVERROR_INVALIDDATA;
8
 
9
     // read block type flag and read the samples accordingly
10
ffmpeg-3-3.4.12.tar.xz/libavcodec/bink.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/bink.c Changed
37
 
1
@@ -825,7 +825,7 @@
2
 
3
     binkb_init_bundles(c);
4
     ref_start = frame->dataplane_idx;
5
-    ref_end   = frame->dataplane_idx + (bh * frame->linesizeplane_idx + bw) * 8;
6
+    ref_end   = frame->dataplane_idx + ((bh - 1) * frame->linesizeplane_idx + bw - 1) * 8;
7
 
8
     for (i = 0; i < 64; i++)
9
         coordmapi = (i & 7) + (i >> 3) * stride;
10
@@ -879,7 +879,7 @@
11
                 xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
12
                 yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
13
                 ref = dst + xoff + yoff * stride;
14
-                if (ref < ref_start || ref + 8*stride > ref_end) {
15
+                if (ref < ref_start || ref > ref_end) {
16
                     av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
17
                 } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
18
                     c->hdsp.put_pixels_tab10(dst, ref, stride, 8);
19
@@ -895,7 +895,7 @@
20
                 xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
21
                 yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
22
                 ref = dst + xoff + yoff * stride;
23
-                if (ref < ref_start || ref + 8 * stride > ref_end) {
24
+                if (ref < ref_start || ref > ref_end) {
25
                     av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
26
                 } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
27
                     c->hdsp.put_pixels_tab10(dst, ref, stride, 8);
28
@@ -925,7 +925,7 @@
29
                 xoff = binkb_get_value(c, BINKB_SRC_X_OFF);
30
                 yoff = binkb_get_value(c, BINKB_SRC_Y_OFF) + ybias;
31
                 ref = dst + xoff + yoff * stride;
32
-                if (ref < ref_start || ref + 8 * stride > ref_end) {
33
+                if (ref < ref_start || ref > ref_end) {
34
                     av_log(c->avctx, AV_LOG_WARNING, "Reference block is out of bounds\n");
35
                 } else if (ref + 8*stride < dst || ref >= dst + 8*stride) {
36
                     c->hdsp.put_pixels_tab10(dst, ref, stride, 8);
37
ffmpeg-3-3.4.12.tar.xz/libavcodec/eac3dec.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/eac3dec.c Changed
14
 
1
@@ -146,9 +146,11 @@
2
             // spx_noise_blend and spx_signal_blend are both FP.23
3
             nscale *= 1.0 / (1<<23);
4
             sscale *= 1.0 / (1<<23);
5
+            if (nscale < -1.0)
6
+                nscale = -1.0;
7
 #endif
8
             for (i = 0; i < s->spx_band_sizesbnd; i++) {
9
-                float noise  = nscale * (int32_t)av_lfg_get(&s->dith_state);
10
+                UINTFLOAT noise = (INTFLOAT)(nscale * (int32_t)av_lfg_get(&s->dith_state));
11
                 s->transform_coeffschbin   *= sscale;
12
                 s->transform_coeffschbin++ += noise;
13
             }
14
ffmpeg-3-3.4.12.tar.xz/libavcodec/eatgq.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/eatgq.c Changed
50
 
1
@@ -58,7 +58,7 @@
2
     return 0;
3
 }
4
 
5
-static void tgq_decode_block(TgqContext *s, int16_t block64, GetBitContext *gb)
6
+static int tgq_decode_block(TgqContext *s, int16_t block64, GetBitContext *gb)
7
 {
8
     uint8_t *perm = s->scantable.permutated;
9
     int i, j, value;
10
@@ -66,6 +66,8 @@
11
     for (i = 1; i < 64;) {
12
         switch (show_bits(gb, 3)) {
13
         case 4:
14
+            if (i >= 63)
15
+                return AVERROR_INVALIDDATA;
16
             blockpermi++ = 0;
17
         case 0:
18
             blockpermi++ = 0;
19
@@ -75,6 +77,8 @@
20
         case 1:
21
             skip_bits(gb, 2);
22
             value = get_bits(gb, 6);
23
+            if (value > 64 - i)
24
+                return AVERROR_INVALIDDATA;
25
             for (j = 0; j < value; j++)
26
                 blockpermi++ = 0;
27
             break;
28
@@ -102,6 +106,7 @@
29
         }
30
     }
31
     block0 += 128 << 4;
32
+    return 0;
33
 }
34
 
35
 static void tgq_idct_put_mb(TgqContext *s, int16_t (*block)64, AVFrame *frame,
36
@@ -161,8 +166,11 @@
37
         if (ret < 0)
38
             return ret;
39
 
40
-        for (i = 0; i < 6; i++)
41
-            tgq_decode_block(s, s->blocki, &gb);
42
+        for (i = 0; i < 6; i++) {
43
+            int ret = tgq_decode_block(s, s->blocki, &gb);
44
+            if (ret < 0)
45
+                return ret;
46
+        }
47
         tgq_idct_put_mb(s, s->block, frame, mb_x, mb_y);
48
         bytestream2_skip(&s->gb, mode);
49
     } else {
50
ffmpeg-3-3.4.12.tar.xz/libavcodec/escape124.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/escape124.c Changed
47
 
1
@@ -88,11 +88,6 @@
2
     unsigned i, j;
3
     CodeBook cb = { 0 };
4
 
5
-    if (size >= INT_MAX / 34 || get_bits_left(gb) < size * 34)
6
-        return cb;
7
-
8
-    if (size >= INT_MAX / sizeof(MacroBlock))
9
-        return cb;
10
     cb.blocks = av_malloc(size ? size * sizeof(MacroBlock) : 1);
11
     if (!cb.blocks)
12
         return cb;
13
@@ -162,7 +157,7 @@
14
 
15
     // This condition can occur with invalid bitstreams and
16
     // *codebook_index == 2
17
-    if (block_index >= s->codebooks*codebook_index.size)
18
+    if (block_index >= s->codebooks*codebook_index.size || !s->codebooks*codebook_index.blocks)
19
         return (MacroBlock) { { 0 } };
20
 
21
     return s->codebooks*codebook_index.blocksblock_index;
22
@@ -226,7 +221,7 @@
23
     // represent a lower bound of the space needed for skipped superblocks. Non
24
     // skipped SBs need more space.
25
     if (get_bits_left(&gb) < 64 + s->num_superblocks * 23LL / 4320)
26
-        return -1;
27
+        return AVERROR_INVALIDDATA;
28
 
29
     frame_flags = get_bits_long(&gb, 32);
30
     frame_size  = get_bits_long(&gb, 32);
31
@@ -277,9 +272,14 @@
32
             }
33
 
34
             av_freep(&s->codebooksi.blocks);
35
+            if (cb_size >= INT_MAX / 34 || get_bits_left(&gb) < (int)cb_size * 34)
36
+                return AVERROR_INVALIDDATA;
37
+
38
+            if (cb_size >= INT_MAX / sizeof(MacroBlock))
39
+                return AVERROR_INVALIDDATA;
40
             s->codebooksi = unpack_codebook(&gb, cb_depth, cb_size);
41
             if (!s->codebooksi.blocks)
42
-                return -1;
43
+                return AVERROR(ENOMEM);
44
         }
45
     }
46
 
47
ffmpeg-3-3.4.12.tar.xz/libavcodec/ffv1dec.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/ffv1dec.c Changed
111
 
1
@@ -169,24 +169,31 @@
2
     RangeCoder *c = &fs->c;
3
     uint8_t stateCONTEXT_SIZE;
4
     unsigned ps, i, context_count;
5
+    int sx, sy, sw, sh;
6
+
7
     memset(state, 128, sizeof(state));
8
+    sx = get_symbol(c, state, 0);
9
+    sy = get_symbol(c, state, 0);
10
+    sw = get_symbol(c, state, 0) + 1U;
11
+    sh = get_symbol(c, state, 0) + 1U;
12
 
13
     av_assert0(f->version > 2);
14
 
15
-    fs->slice_x      =  get_symbol(c, state, 0)      * f->width ;
16
-    fs->slice_y      =  get_symbol(c, state, 0)      * f->height;
17
-    fs->slice_width  = (get_symbol(c, state, 0) + 1) * f->width  + fs->slice_x;
18
-    fs->slice_height = (get_symbol(c, state, 0) + 1) * f->height + fs->slice_y;
19
-
20
-    fs->slice_x /= f->num_h_slices;
21
-    fs->slice_y /= f->num_v_slices;
22
-    fs->slice_width  = fs->slice_width /f->num_h_slices - fs->slice_x;
23
-    fs->slice_height = fs->slice_height/f->num_v_slices - fs->slice_y;
24
-    if ((unsigned)fs->slice_width > f->width || (unsigned)fs->slice_height > f->height)
25
-        return -1;
26
-    if (    (unsigned)fs->slice_x + (uint64_t)fs->slice_width  > f->width
27
-         || (unsigned)fs->slice_y + (uint64_t)fs->slice_height > f->height)
28
-        return -1;
29
+
30
+    if (sx < 0 || sy < 0 || sw <= 0 || sh <= 0)
31
+        return AVERROR_INVALIDDATA;
32
+    if (sx > f->num_h_slices - sw || sy > f->num_v_slices - sh)
33
+        return AVERROR_INVALIDDATA;
34
+
35
+    fs->slice_x      =  sx       * (int64_t)f->width  / f->num_h_slices;
36
+    fs->slice_y      =  sy       * (int64_t)f->height / f->num_v_slices;
37
+    fs->slice_width  = (sx + sw) * (int64_t)f->width  / f->num_h_slices - fs->slice_x;
38
+    fs->slice_height = (sy + sh) * (int64_t)f->height / f->num_v_slices - fs->slice_y;
39
+
40
+    av_assert0((unsigned)fs->slice_width  <= f->width &&
41
+                (unsigned)fs->slice_height <= f->height);
42
+    av_assert0 (   (unsigned)fs->slice_x + (uint64_t)fs->slice_width  <= f->width
43
+                && (unsigned)fs->slice_y + (uint64_t)fs->slice_height <= f->height);
44
 
45
     if (fs->ac == AC_GOLOMB_RICE && fs->slice_width >= (1<<23))
46
         return AVERROR_INVALIDDATA;
47
@@ -304,8 +311,11 @@
48
     }
49
     if ((ret = ff_ffv1_init_slice_state(f, fs)) < 0)
50
         return ret;
51
-    if (f->cur->key_frame || fs->slice_reset_contexts)
52
+    if (f->cur->key_frame || fs->slice_reset_contexts) {
53
         ff_ffv1_clear_slice_state(f, fs);
54
+    } else if (fs->slice_damaged) {
55
+        return AVERROR_INVALIDDATA;
56
+    }
57
 
58
     width  = fs->slice_width;
59
     height = fs->slice_height;
60
@@ -466,6 +476,11 @@
61
         return AVERROR_INVALIDDATA;
62
     }
63
 
64
+    if (f->num_h_slices > MAX_SLICES / f->num_v_slices) {
65
+        av_log(f->avctx, AV_LOG_ERROR, "slice count unsupported\n");
66
+        return AVERROR_PATCHWELCOME;
67
+    }
68
+
69
     f->quant_table_count = get_symbol(c, state, 0);
70
     if (f->quant_table_count > (unsigned)MAX_QUANT_TABLES || !f->quant_table_count) {
71
         av_log(f->avctx, AV_LOG_ERROR, "quant table count %d is invalid\n", f->quant_table_count);
72
@@ -742,21 +757,25 @@
73
         fs->slice_damaged = 0;
74
 
75
         if (f->version == 2) {
76
-            fs->slice_x      =  get_symbol(c, state, 0)      * f->width ;
77
-            fs->slice_y      =  get_symbol(c, state, 0)      * f->height;
78
-            fs->slice_width  = (get_symbol(c, state, 0) + 1) * f->width  + fs->slice_x;
79
-            fs->slice_height = (get_symbol(c, state, 0) + 1) * f->height + fs->slice_y;
80
-
81
-            fs->slice_x     /= f->num_h_slices;
82
-            fs->slice_y     /= f->num_v_slices;
83
-            fs->slice_width  = fs->slice_width  / f->num_h_slices - fs->slice_x;
84
-            fs->slice_height = fs->slice_height / f->num_v_slices - fs->slice_y;
85
-            if ((unsigned)fs->slice_width  > f->width ||
86
-                (unsigned)fs->slice_height > f->height)
87
+            int sx = get_symbol(c, state, 0);
88
+            int sy = get_symbol(c, state, 0);
89
+            int sw = get_symbol(c, state, 0) + 1U;
90
+            int sh = get_symbol(c, state, 0) + 1U;
91
+
92
+            if (sx < 0 || sy < 0 || sw <= 0 || sh <= 0)
93
                 return AVERROR_INVALIDDATA;
94
-            if (   (unsigned)fs->slice_x + (uint64_t)fs->slice_width  > f->width
95
-                || (unsigned)fs->slice_y + (uint64_t)fs->slice_height > f->height)
96
+            if (sx > f->num_h_slices - sw || sy > f->num_v_slices - sh)
97
                 return AVERROR_INVALIDDATA;
98
+
99
+            fs->slice_x      =  sx       * (int64_t)f->width  / f->num_h_slices;
100
+            fs->slice_y      =  sy       * (int64_t)f->height / f->num_v_slices;
101
+            fs->slice_width  = (sx + sw) * (int64_t)f->width  / f->num_h_slices - fs->slice_x;
102
+            fs->slice_height = (sy + sh) * (int64_t)f->height / f->num_v_slices - fs->slice_y;
103
+
104
+            av_assert0((unsigned)fs->slice_width  <= f->width &&
105
+                       (unsigned)fs->slice_height <= f->height);
106
+            av_assert0 (   (unsigned)fs->slice_x + (uint64_t)fs->slice_width  <= f->width
107
+                        && (unsigned)fs->slice_y + (uint64_t)fs->slice_height <= f->height);
108
         }
109
 
110
         for (i = 0; i < f->plane_count; i++) {
111
ffmpeg-3-3.4.12.tar.xz/libavcodec/g2meet.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/g2meet.c Changed
41
 
1
@@ -143,7 +143,8 @@
2
     int        got_header;
3
 
4
     uint8_t    *framebuf;
5
-    int        framebuf_stride, old_width, old_height;
6
+    int        framebuf_stride;
7
+    unsigned int framebuf_allocated;
8
 
9
     uint8_t    *synth_tile, *jpeg_tile, *epic_buf, *epic_buf_base;
10
     int        tile_stride, epic_buf_stride, old_tile_w, old_tile_h;
11
@@ -1179,14 +1180,13 @@
12
 {
13
     int aligned_height;
14
 
15
-    if (!c->framebuf || c->old_width < c->width || c->old_height < c->height) {
16
-        c->framebuf_stride = FFALIGN(c->width + 15, 16) * 3;
17
-        aligned_height     = c->height + 15;
18
-        av_free(c->framebuf);
19
-        c->framebuf = av_mallocz_array(c->framebuf_stride, aligned_height);
20
-        if (!c->framebuf)
21
-            return AVERROR(ENOMEM);
22
-    }
23
+    c->framebuf_stride = FFALIGN(c->width + 15, 16) * 3;
24
+    aligned_height = c->height + 15;
25
+
26
+    av_fast_mallocz(&c->framebuf, &c->framebuf_allocated, c->framebuf_stride * aligned_height);
27
+    if (!c->framebuf)
28
+        return AVERROR(ENOMEM);
29
+
30
     if (!c->synth_tile || !c->jpeg_tile ||
31
         (c->compression == 2 && !c->epic_buf_base) ||
32
         c->old_tile_w < c->tile_width ||
33
@@ -1638,6 +1638,7 @@
34
     av_freep(&c->jpeg_tile);
35
     av_freep(&c->cursor);
36
     av_freep(&c->framebuf);
37
+    c->framebuf_allocated = 0;
38
 
39
     return 0;
40
 }
41
ffmpeg-3-3.4.12.tar.xz/libavcodec/g729postfilter.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/g729postfilter.c Changed
10
 
1
@@ -350,7 +350,7 @@
2
         if (tmp > 0)
3
             L_temp0 >>= tmp;
4
         else
5
-            L_temp1 >>= -tmp;
6
+            L_temp1 >>= FFMIN(-tmp, 31);
7
 
8
         /* Check if longer filter increases the values of R'(k). */
9
         if (L_temp1 > L_temp0) {
10
ffmpeg-3-3.4.12.tar.xz/libavcodec/huffyuvdec.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/huffyuvdec.c Changed
13
 
1
@@ -691,9 +691,9 @@
2
 /* TODO instead of restarting the read when the code isn't in the first level
3
  * of the joint table, jump into the 2nd level of the individual table. */
4
 #define READ_2PIX_PLANE16(dst0, dst1, plane){\
5
-    dst0 = get_vlc2(&s->gb, s->vlcplane.table, VLC_BITS, 3)<<2;\
6
+    dst0 = get_vlc2(&s->gb, s->vlcplane.table, VLC_BITS, 3)*4;\
7
     dst0 += get_bits(&s->gb, 2);\
8
-    dst1 = get_vlc2(&s->gb, s->vlcplane.table, VLC_BITS, 3)<<2;\
9
+    dst1 = get_vlc2(&s->gb, s->vlcplane.table, VLC_BITS, 3)*4;\
10
     dst1 += get_bits(&s->gb, 2);\
11
 }
12
 static void decode_plane_bitstream(HYuvContext *s, int width, int plane)
13
ffmpeg-3-3.4.12.tar.xz/libavcodec/j2kenc.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/j2kenc.c Changed
10
 
1
@@ -1188,7 +1188,7 @@
2
     { "tile_height",   "Tile Height",       OFFSET(tile_height),   AV_OPT_TYPE_INT,   { .i64 = 256         }, 1,     1<<30,           VE, },
3
     { "pred",          "DWT Type",          OFFSET(pred),          AV_OPT_TYPE_INT,   { .i64 = 0           }, 0,         1,           VE, "pred"        },
4
     { "dwt97int",      NULL,                0,                     AV_OPT_TYPE_CONST, { .i64 = 0           }, INT_MIN, INT_MAX,       VE, "pred"        },
5
-    { "dwt53",         NULL,                0,                     AV_OPT_TYPE_CONST, { .i64 = 0           }, INT_MIN, INT_MAX,       VE, "pred"        },
6
+    { "dwt53",         NULL,                0,                     AV_OPT_TYPE_CONST, { .i64 = 1           }, INT_MIN, INT_MAX,       VE, "pred"        },
7
 
8
     { NULL }
9
 };
10
ffmpeg-3-3.4.12.tar.xz/libavcodec/lcldec.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/lcldec.c Changed
108
 
1
@@ -148,6 +148,8 @@
2
     if (expected != (unsigned int)c->zstream.total_out) {
3
         av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %lu)\n",
4
                expected, c->zstream.total_out);
5
+        if (expected > (unsigned int)c->zstream.total_out)
6
+            return (unsigned int)c->zstream.total_out;
7
         return AVERROR_UNKNOWN;
8
     }
9
     return c->zstream.total_out;
10
@@ -166,8 +168,8 @@
11
     int row, col;
12
     unsigned char *encoded = avpkt->data, *outptr;
13
     uint8_t *y_out, *u_out, *v_out;
14
-    unsigned int width = avctx->width; // Real image width
15
-    unsigned int height = avctx->height; // Real image height
16
+    int width = avctx->width; // Real image width
17
+    int height = avctx->height; // Real image height
18
     unsigned int mszh_dlen;
19
     unsigned char yq, y1q, uq, vq;
20
     int uqvq, ret;
21
@@ -274,12 +276,13 @@
22
             ret = zlib_decomp(avctx, buf + 8 + mthread_inlen, len - 8 - mthread_inlen,
23
                               mthread_outlen, mthread_outlen);
24
             if (ret < 0) return ret;
25
+            len = c->decomp_size;
26
         } else {
27
             int ret = zlib_decomp(avctx, buf, len, 0, c->decomp_size);
28
             if (ret < 0) return ret;
29
+            len = ret;
30
         }
31
         encoded = c->decomp_buf;
32
-        len = c->decomp_size;
33
         break;
34
 #endif
35
     default:
36
@@ -399,6 +402,11 @@
37
                 v_out col >> 1      = *encoded++ + 128;
38
                 v_out(col >> 1) + 1 = *encoded++ + 128;
39
             }
40
+            if (col && col < width) {
41
+                u_out col >> 1      = u_out(col>>1) - 1;
42
+                v_out col >> 1      = v_out(col>>1) - 1;
43
+            }
44
+
45
             y_out -= frame->linesize0;
46
             u_out -= frame->linesize1;
47
             v_out -= frame->linesize2;
48
@@ -420,6 +428,10 @@
49
                 u_outcol >> 2 = *encoded++ + 128;
50
                 v_outcol >> 2 = *encoded++ + 128;
51
             }
52
+            if (col && col < width) {
53
+                u_outcol >> 2 = u_out(col>>2) - 1;
54
+                v_outcol >> 2 = v_out(col>>2) - 1;
55
+            }
56
             y_out -= frame->linesize0;
57
             u_out -= frame->linesize1;
58
             v_out -= frame->linesize2;
59
@@ -477,6 +489,7 @@
60
                                 FFALIGN(avctx->height, 4);
61
     unsigned int max_decomp_size;
62
     int subsample_h, subsample_v;
63
+    int partial_h_supported = 0;
64
 
65
     if (avctx->extradata_size < 8) {
66
         av_log(avctx, AV_LOG_ERROR, "Extradata size too small.\n");
67
@@ -498,26 +511,24 @@
68
         av_log(avctx, AV_LOG_DEBUG, "Image type is YUV 1:1:1.\n");
69
         break;
70
     case IMGTYPE_YUV422:
71
-        c->decomp_size = basesize * 2;
72
+        c->decomp_size = (avctx->width & ~3) * avctx->height * 2;
73
         max_decomp_size = max_basesize * 2;
74
         avctx->pix_fmt = AV_PIX_FMT_YUV422P;
75
         av_log(avctx, AV_LOG_DEBUG, "Image type is YUV 4:2:2.\n");
76
-        if (avctx->width % 4) {
77
-            avpriv_request_sample(avctx, "Unsupported dimensions");
78
-            return AVERROR_INVALIDDATA;
79
-        }
80
+        partial_h_supported = 1;
81
         break;
82
     case IMGTYPE_RGB24:
83
-        c->decomp_size = basesize * 3;
84
+        c->decomp_size = FFALIGN(avctx->width*3, 4) * avctx->height;
85
         max_decomp_size = max_basesize * 3;
86
         avctx->pix_fmt = AV_PIX_FMT_BGR24;
87
         av_log(avctx, AV_LOG_DEBUG, "Image type is RGB 24.\n");
88
         break;
89
     case IMGTYPE_YUV411:
90
-        c->decomp_size = basesize / 2 * 3;
91
+        c->decomp_size = (avctx->width & ~3) * avctx->height / 2 * 3;
92
         max_decomp_size = max_basesize / 2 * 3;
93
         avctx->pix_fmt = AV_PIX_FMT_YUV411P;
94
         av_log(avctx, AV_LOG_DEBUG, "Image type is YUV 4:1:1.\n");
95
+        partial_h_supported = 1;
96
         break;
97
     case IMGTYPE_YUV211:
98
         c->decomp_size = basesize * 2;
99
@@ -537,7 +548,7 @@
100
     }
101
 
102
     av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &subsample_h, &subsample_v);
103
-    if (avctx->width % (1<<subsample_h) || avctx->height % (1<<subsample_v)) {
104
+    if ((avctx->width % (1<<subsample_h) && !partial_h_supported) || avctx->height % (1<<subsample_v)) {
105
         avpriv_request_sample(avctx, "Unsupported dimensions");
106
         return AVERROR_INVALIDDATA;
107
     }
108
ffmpeg-3-3.4.12.tar.xz/libavcodec/mlpdec.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/mlpdec.c Changed
10
 
1
@@ -515,7 +515,7 @@
2
 
3
     /* This should happen for TrueHD streams with >6 channels and MLP's noise
4
      * type. It is not yet known if this is allowed. */
5
-    if (max_channel > MAX_MATRIX_CHANNEL_MLP && !noise_type) {
6
+    if (max_matrix_channel > MAX_MATRIX_CHANNEL_MLP && !noise_type) {
7
         avpriv_request_sample(m->avctx,
8
                               "%d channels (more than the "
9
                               "maximum supported by the decoder)",
10
ffmpeg-3-3.4.12.tar.xz/libavcodec/motionpixels.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/motionpixels.c Changed
10
 
1
@@ -185,7 +185,7 @@
2
     int color;
3
 
4
     color = *(uint16_t *)&mp->frame->data0y * mp->frame->linesize0 + x * 2;
5
-    return mp_rgb_yuv_tablecolor;
6
+    return mp_rgb_yuv_tablecolor & 0x7FFF;
7
 }
8
 
9
 static void mp_set_rgb_from_yuv(MotionPixelsContext *mp, int x, int y, const YuvPixel *p)
10
ffmpeg-3-3.4.12.tar.xz/libavcodec/noise_bsf.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/noise_bsf.c Changed
13
 
1
@@ -45,6 +45,11 @@
2
     if (amount <= 0)
3
         return AVERROR(EINVAL);
4
 
5
+    if (ctx->par_in->codec_id == AV_CODEC_ID_WRAPPED_AVFRAME) {
6
+        av_log(ctx, AV_LOG_ERROR, "Wrapped AVFrame noising is unsupported\n");
7
+        return AVERROR_PATCHWELCOME;
8
+    }
9
+
10
     ret = ff_bsf_get_packet(ctx, &in);
11
     if (ret < 0)
12
         return ret;
13
ffmpeg-3-3.4.12.tar.xz/libavcodec/pictordec.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/pictordec.c Changed
10
 
1
@@ -223,8 +223,6 @@
2
                         run = bytestream2_get_le16(&s->g);
3
                     val = bytestream2_get_byte(&s->g);
4
                 }
5
-                if (!bytestream2_get_bytes_left(&s->g))
6
-                    break;
7
 
8
                 if (bits_per_plane == 8) {
9
                     picmemset_8bpp(s, frame, val, run, &x, &y);
10
ffmpeg-3-3.4.12.tar.xz/libavcodec/pngdec.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/pngdec.c Changed
47
 
1
@@ -308,7 +308,7 @@
2
 static void deloco_ ## NAME(TYPE *dst, int size, int alpha) \
3
 { \
4
     int i; \
5
-    for (i = 0; i < size; i += 3 + alpha) { \
6
+    for (i = 0; i < size - 2; i += 3 + alpha) { \
7
         int g = dst i + 1; \
8
         dsti + 0 += g; \
9
         dsti + 2 += g; \
10
@@ -620,6 +620,8 @@
11
     int ret;
12
     size_t byte_depth = s->bit_depth > 8 ? 2 : 1;
13
 
14
+    if (!p)
15
+        return AVERROR_INVALIDDATA;
16
     if (!(s->hdr_state & PNG_IHDR)) {
17
         av_log(avctx, AV_LOG_ERROR, "IDAT without IHDR\n");
18
         return AVERROR_INVALIDDATA;
19
@@ -1292,6 +1294,8 @@
20
             break;
21
         }
22
         case MKTAG('i', 'C', 'C', 'P'): {
23
+            if (!p)
24
+                return AVERROR_INVALIDDATA;
25
             if ((ret = decode_iccp_chunk(s, length, p)) < 0)
26
                 goto fail;
27
             break;
28
@@ -1314,6 +1318,9 @@
29
     }
30
 exit_loop:
31
 
32
+    if (!p)
33
+        return AVERROR_INVALIDDATA;
34
+
35
     if (avctx->codec_id == AV_CODEC_ID_PNG &&
36
         avctx->skip_frame == AVDISCARD_ALL) {
37
         return 0;
38
@@ -1460,7 +1467,7 @@
39
         s->zstream.zfree  = ff_png_zfree;
40
 
41
         bytestream2_init(&s->gb, avctx->extradata, avctx->extradata_size);
42
-        if ((ret = decode_frame_common(avctx, s, p, avpkt)) < 0)
43
+        if ((ret = decode_frame_common(avctx, s, NULL, avpkt)) < 0)
44
             goto end;
45
     }
46
 
47
ffmpeg-3-3.4.12.tar.xz/libavcodec/scpr.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/scpr.c Changed
11
 
1
@@ -583,6 +583,9 @@
2
                 int run, r, g, b, z, bx = x * 16 + sx1, by = y * 16 + sy1;
3
                 unsigned clr, ptype = 0;
4
 
5
+                if (bx >= avctx->width)
6
+                    return AVERROR_INVALIDDATA;
7
+
8
                 for (; by < y * 16 + sy2 && by < avctx->height;) {
9
                     ret = decode_value(s, s->op_modelptype, 6, 1000, &ptype);
10
                     if (ret < 0)
11
ffmpeg-3-3.4.12.tar.xz/libavcodec/snowenc.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/snowenc.c Changed
28
 
1
@@ -1542,10 +1542,10 @@
2
     int level, orientation, x, y;
3
 
4
     for(level=0; level<s->spatial_decomposition_count; level++){
5
+        int64_t error=0;
6
         for(orientation=level ? 1 : 0; orientation<4; orientation++){
7
             SubBand *b= &p->bandlevelorientation;
8
             IDWTELEM *ibuf= b->ibuf;
9
-            int64_t error=0;
10
 
11
             memset(s->spatial_idwt_buffer, 0, sizeof(*s->spatial_idwt_buffer)*width*height);
12
             ibufb->width/2 + b->height/2*b->stride= 256*16;
13
@@ -1556,9 +1556,13 @@
14
                     error += d*d;
15
                 }
16
             }
17
-
18
+            if (orientation == 2)
19
+                error /= 2;
20
             b->qlog= (int)(QROOT * log2(352256.0/sqrt(error)) + 0.5);
21
+            if (orientation != 1)
22
+                error = 0;
23
         }
24
+        p->bandlevel1.qlog = p->bandlevel2.qlog;
25
     }
26
 }
27
 
28
ffmpeg-3-3.4.12.tar.xz/libavcodec/speedhq.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/speedhq.c Changed
10
 
1
@@ -426,6 +426,8 @@
2
 
3
     if (buf_size < 4 || avctx->width < 8 || avctx->width % 8 != 0)
4
         return AVERROR_INVALIDDATA;
5
+    if (buf_size < avctx->width*avctx->height / 64 / 4)
6
+        return AVERROR_INVALIDDATA;
7
 
8
     quality = buf0;
9
     if (quality >= 100) {
10
ffmpeg-3-3.4.12.tar.xz/libavcodec/sunrast.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/sunrast.c Changed
56
 
1
@@ -19,6 +19,7 @@
2
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3
  */
4
 
5
+#include "libavutil/avassert.h"
6
 #include "libavutil/common.h"
7
 #include "libavutil/intreadwrite.h"
8
 #include "libavutil/imgutils.h"
9
@@ -75,6 +76,12 @@
10
         return AVERROR_PATCHWELCOME;
11
     }
12
 
13
+    if (maplength > 768) {
14
+        av_log(avctx, AV_LOG_WARNING, "invalid colormap length\n");
15
+        return AVERROR_INVALIDDATA;
16
+    }
17
+
18
+    // This also checks depth to be valid
19
     switch (depth) {
20
         case 1:
21
             avctx->pix_fmt = maplength ? AV_PIX_FMT_PAL8 : AV_PIX_FMT_MONOWHITE;
22
@@ -96,15 +103,23 @@
23
             return AVERROR_INVALIDDATA;
24
     }
25
 
26
+    // This checks w and h to be valid in the sense that bytes of a padded bitmap are addressable with 32bit int
27
     ret = ff_set_dimensions(avctx, w, h);
28
     if (ret < 0)
29
         return ret;
30
 
31
+    // ensured by ff_set_dimensions()
32
+    av_assert0(w <= (INT32_MAX - 7) / depth);
33
+
34
     /* scanlines are aligned on 16 bit boundaries */
35
     len  = (depth * w + 7) >> 3;
36
     alen = len + (len & 1);
37
 
38
-    if (buf_end - buf < maplength + (len * h) * 3 / 256)
39
+    // ensured by ff_set_dimensions()
40
+    av_assert0(h  <= INT32_MAX / (3 * len));
41
+
42
+    // maplength is limited to 768 and the right term is limited to INT32_MAX / 256 so the add needs no check
43
+    if (buf_end - buf < (uint64_t)maplength + (len * h) * 3 / 256)
44
         return AVERROR_INVALIDDATA;
45
 
46
     if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
47
@@ -118,7 +133,7 @@
48
     } else if (maplength) {
49
         unsigned int len = maplength / 3;
50
 
51
-        if (maplength % 3 || maplength > 768) {
52
+        if (maplength % 3) {
53
             av_log(avctx, AV_LOG_WARNING, "invalid colormap length\n");
54
             return AVERROR_INVALIDDATA;
55
         }
56
ffmpeg-3-3.4.12.tar.xz/libavcodec/tak.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/tak.c Changed
11
 
1
@@ -154,6 +154,9 @@
2
     if (ti->flags & TAK_FRAME_FLAG_HAS_METADATA)
3
         return AVERROR_INVALIDDATA;
4
 
5
+    if (get_bits_left(gb) < 24)
6
+        return AVERROR_INVALIDDATA;
7
+
8
     skip_bits(gb, 24);
9
 
10
     return 0;
11
ffmpeg-3-3.4.12.tar.xz/libavcodec/tests/snowenc.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/tests/snowenc.c Changed
87
 
1
@@ -31,11 +31,13 @@
2
 #define width  256
3
 #define height 256
4
     int buffer2width*height;
5
+    short obufferwidth*height;
6
     SnowContext s;
7
     int i;
8
     AVLFG prng;
9
     s.spatial_decomposition_count=6;
10
     s.spatial_decomposition_type=1;
11
+    int ret = 0;
12
 
13
     s.temp_dwt_buffer  = av_mallocz_array(width, sizeof(DWTELEM));
14
     s.temp_idwt_buffer = av_mallocz_array(width, sizeof(IDWTELEM));
15
@@ -49,24 +51,34 @@
16
 
17
     printf("testing 5/3 DWT\n");
18
     for(i=0; i<width*height; i++)
19
-        buffer0i = buffer1i = av_lfg_get(&prng) % 54321 - 12345;
20
+        buffer0i = buffer1i = av_lfg_get(&prng) % 19000 - 9000;
21
 
22
     ff_spatial_dwt(buffer0, s.temp_dwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
23
-    ff_spatial_idwt((IDWTELEM*)buffer0, s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
24
+    for(i=0; i<width*height; i++)
25
+        obufferi = buffer0i;
26
+    ff_spatial_idwt(obuffer, s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
27
 
28
     for(i=0; i<width*height; i++)
29
-        if(buffer0i!= buffer1i) printf("fsck: %6d %12d %7d\n",i, buffer0i, buffer1i);
30
+        if(buffer1i!= obufferi) {
31
+            printf("fsck: %4dx%4dx %12d %7d\n",i%width, i/width, buffer1i, obufferi);
32
+            ret = 1;
33
+        }
34
 
35
     printf("testing 9/7 DWT\n");
36
     s.spatial_decomposition_type=0;
37
     for(i=0; i<width*height; i++)
38
-        buffer0i = buffer1i = av_lfg_get(&prng) % 54321 - 12345;
39
+        buffer0i = buffer1i = av_lfg_get(&prng) % 11000 - 5000;
40
 
41
     ff_spatial_dwt(buffer0, s.temp_dwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
42
-    ff_spatial_idwt((IDWTELEM*)buffer0, s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
43
+    for(i=0; i<width*height; i++)
44
+        obufferi = buffer0i;
45
+    ff_spatial_idwt(obuffer, s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
46
 
47
     for(i=0; i<width*height; i++)
48
-        if(FFABS(buffer0i - buffer1i)>20) printf("fsck: %6d %12d %7d\n",i, buffer0i, buffer1i);
49
+        if(FFABS(buffer1i - obufferi)>20) {
50
+            printf("fsck: %4dx%4d %12d %7d\n",i%width, i/width, buffer1i, obufferi);
51
+            ret = 1;
52
+        }
53
 
54
     {
55
     int level, orientation, x, y;
56
@@ -81,18 +93,18 @@
57
                 int w= width  >> (s.spatial_decomposition_count-level);
58
                 int h= height >> (s.spatial_decomposition_count-level);
59
                 int stride= width  << (s.spatial_decomposition_count-level);
60
-                DWTELEM *buf= buffer0;
61
+                IDWTELEM *buf= obuffer;
62
                 int64_t error=0;
63
 
64
                 if(orientation&1) buf+=w;
65
                 if(orientation>1) buf+=stride>>1;
66
 
67
-                memset(buffer0, 0, sizeof(int)*width*height);
68
-                bufw/2 + h/2*stride= 256*256;
69
-                ff_spatial_idwt((IDWTELEM*)buffer0, s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
70
+                memset(obuffer, 0, sizeof(short)*width*height);
71
+                bufw/2 + h/2*stride= 8*256;
72
+                ff_spatial_idwt(obuffer, s.temp_idwt_buffer, width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
73
                 for(y=0; y<height; y++){
74
                     for(x=0; x<width; x++){
75
-                        int64_t d= buffer0x + y*width;
76
+                        int64_t d= obufferx + y*width;
77
                         error += d*d;
78
                         if(FFABS(width/2-x)<9 && FFABS(height/2-y)<9 && level==2) printf("%8"PRId64" ", d);
79
                     }
80
@@ -143,5 +155,5 @@
81
         }
82
 
83
     }
84
-    return 0;
85
+    return ret;
86
 }
87
ffmpeg-3-3.4.12.tar.xz/libavcodec/utils.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/utils.c Changed
35
 
1
@@ -359,6 +359,8 @@
2
     case AV_PIX_FMT_GBRAP16BE:
3
         w_align = 16; //FIXME assume 16 pixel per macroblock
4
         h_align = 16 * 2; // interlaced needs 2 macroblocks height
5
+        if (s->codec_id == AV_CODEC_ID_BINKVIDEO)
6
+            w_align = 16*2;
7
         break;
8
     case AV_PIX_FMT_YUV411P:
9
     case AV_PIX_FMT_YUVJ411P:
10
@@ -424,12 +426,13 @@
11
     }
12
 
13
     if (s->codec_id == AV_CODEC_ID_IFF_ILBM) {
14
-        w_align = FFMAX(w_align, 8);
15
+        w_align = FFMAX(w_align, 16);
16
     }
17
 
18
     *width  = FFALIGN(*width, w_align);
19
     *height = FFALIGN(*height, h_align);
20
     if (s->codec_id == AV_CODEC_ID_H264 || s->lowres ||
21
+        s->codec_id == AV_CODEC_ID_VC1  || s->codec_id == AV_CODEC_ID_WMV3 ||
22
         s->codec_id == AV_CODEC_ID_VP5  || s->codec_id == AV_CODEC_ID_VP6 ||
23
         s->codec_id == AV_CODEC_ID_VP6F || s->codec_id == AV_CODEC_ID_VP6A
24
     ) {
25
@@ -443,6 +446,9 @@
26
         // the next rounded up width is 32
27
         *width = FFMAX(*width, 32);
28
     }
29
+    if (s->codec_id == AV_CODEC_ID_SVQ3) {
30
+        *width = FFMAX(*width, 32);
31
+    }
32
 
33
     for (i = 0; i < 4; i++)
34
         linesize_aligni = STRIDE_ALIGN;
35
ffmpeg-3-3.4.12.tar.xz/libavcodec/videodsp_template.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/videodsp_template.c Changed
19
 
1
@@ -60,7 +60,7 @@
2
     av_assert2(start_x < end_x && block_w);
3
 
4
     w    = end_x - start_x;
5
-    src += start_y * src_linesize + start_x * sizeof(pixel);
6
+    src += start_y * src_linesize + start_x * (ptrdiff_t)sizeof(pixel);
7
     buf += start_x * sizeof(pixel);
8
 
9
     // top
10
@@ -83,7 +83,7 @@
11
         buf += buf_linesize;
12
     }
13
 
14
-    buf -= block_h * buf_linesize + start_x * sizeof(pixel);
15
+    buf -= block_h * buf_linesize + start_x * (ptrdiff_t)sizeof(pixel);
16
     while (block_h--) {
17
         pixel *bufp = (pixel *) buf;
18
 
19
ffmpeg-3-3.4.12.tar.xz/libavcodec/vorbisdec.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/vorbisdec.c Changed
12
 
1
@@ -363,6 +363,10 @@
2
             unsigned codebook_value_bits = get_bits(gb, 4) + 1;
3
             unsigned codebook_sequence_p = get_bits1(gb);
4
 
5
+            if (!isfinite(codebook_minimum_value) || !isfinite(codebook_delta_value)) {
6
+                ret = AVERROR_INVALIDDATA;
7
+                goto error;
8
+            }
9
             ff_dlog(NULL, " We expect %d numbers for building the codevectors. \n",
10
                     codebook_lookup_values);
11
             ff_dlog(NULL, "  delta %f minmum %f \n",
12
ffmpeg-3-3.4.12.tar.xz/libavcodec/vp3.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/vp3.c Changed
45
 
1
@@ -1747,6 +1747,8 @@
2
     s->avctx  = avctx;
3
     s->width  = FFALIGN(avctx->coded_width, 16);
4
     s->height = FFALIGN(avctx->coded_height, 16);
5
+    if (s->width < 18)
6
+        return AVERROR_PATCHWELCOME;
7
     if (avctx->codec_id != AV_CODEC_ID_THEORA)
8
         avctx->pix_fmt = AV_PIX_FMT_YUV420P;
9
     avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
10
@@ -2099,8 +2101,13 @@
11
     if (ff_thread_get_buffer(avctx, &s->current_frame, AV_GET_BUFFER_FLAG_REF) < 0)
12
         goto error;
13
 
14
-    if (!s->edge_emu_buffer)
15
+    if (!s->edge_emu_buffer) {
16
         s->edge_emu_buffer = av_malloc(9 * FFABS(s->current_frame.f->linesize0));
17
+        if (!s->edge_emu_buffer) {
18
+            ret = AVERROR(ENOMEM);
19
+            goto error;
20
+        }
21
+    }
22
 
23
     if (s->keyframe) {
24
         if (!s->theora) {
25
@@ -2308,7 +2315,9 @@
26
     /* sanity check */
27
     if (av_image_check_size(visible_width, visible_height, 0, avctx) < 0 ||
28
         visible_width  + offset_x > s->width ||
29
-        visible_height + offset_y > s->height) {
30
+        visible_height + offset_y > s->height ||
31
+        visible_width < 18
32
+    ) {
33
         av_log(avctx, AV_LOG_ERROR,
34
                "Invalid frame dimensions - w:%d h:%d x:%d y:%d (%dx%d).\n",
35
                visible_width, visible_height, offset_x, offset_y,
36
@@ -2354,6 +2363,8 @@
37
     } else
38
         avctx->pix_fmt = AV_PIX_FMT_YUV420P;
39
 
40
+    if (s->width < 18)
41
+        return AVERROR_PATCHWELCOME;
42
     ret = ff_set_dimensions(avctx, s->width, s->height);
43
     if (ret < 0)
44
         return ret;
45
ffmpeg-3-3.4.12.tar.xz/libavcodec/wavpack.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/wavpack.c Changed
10
 
1
@@ -95,7 +95,7 @@
2
     e   = (1 << (p + 1)) - k - 1;
3
     res = get_bitsz(gb, p);
4
     if (res >= e)
5
-        res = (res << 1) - e + get_bits1(gb);
6
+        res = res * 2U - e + get_bits1(gb);
7
     return res;
8
 }
9
 
10
ffmpeg-3-3.4.12.tar.xz/libavcodec/xpmdec.c -> ffmpeg-3-3.4.13.tar.xz/libavcodec/xpmdec.c Changed
11
 
1
@@ -351,6 +351,9 @@
2
         return AVERROR_INVALIDDATA;
3
     }
4
 
5
+    if (size > SIZE_MAX / 4)
6
+        return AVERROR(ENOMEM);
7
+
8
     size *= 4;
9
 
10
     ptr += mod_strcspn(ptr, ",") + 1;
11
ffmpeg-3-3.4.12.tar.xz/libavformat/id3v2.c -> ffmpeg-3-3.4.13.tar.xz/libavformat/id3v2.c Changed
14
 
1
@@ -375,10 +375,10 @@
2
     lang3 = '\0';
3
     taglen -= 3;
4
 
5
-    if (decode_str(s, pb, encoding, &descriptor, &taglen) < 0)
6
+    if (decode_str(s, pb, encoding, &descriptor, &taglen) < 0 || taglen < 0)
7
         goto error;
8
 
9
-    if (decode_str(s, pb, encoding, &text, &taglen) < 0)
10
+    if (decode_str(s, pb, encoding, &text, &taglen) < 0 || taglen < 0)
11
         goto error;
12
 
13
     // FFmpeg does not support hierarchical metadata, so concatenate the keys.
14
ffmpeg-3-3.4.12.tar.xz/libavformat/mov.c -> ffmpeg-3-3.4.13.tar.xz/libavformat/mov.c Changed
15
 
1
@@ -3553,6 +3553,13 @@
2
                 if (keyframe)
3
                     distance = 0;
4
                 sample_size = sc->stsz_sample_size > 0 ? sc->stsz_sample_size : sc->sample_sizescurrent_sample;
5
+                if (current_offset > INT64_MAX - sample_size) {
6
+                    av_log(mov->fc, AV_LOG_ERROR, "Current offset %"PRId64" or sample size %u is too large\n",
7
+                           current_offset,
8
+                           sample_size);
9
+                    return;
10
+                }
11
+
12
                 if (sc->pseudo_stream_id == -1 ||
13
                    sc->stsc_datastsc_index.id - 1 == sc->pseudo_stream_id) {
14
                     AVIndexEntry *e;
15
ffmpeg-3-3.4.12.tar.xz/libavformat/replaygain.c -> ffmpeg-3-3.4.13.tar.xz/libavformat/replaygain.c Changed
10
 
1
@@ -61,7 +61,7 @@
2
         }
3
     }
4
 
5
-    if (abs(db) > (INT32_MAX - mb) / 100000)
6
+    if (llabs(db) > (INT32_MAX - mb) / 100000)
7
         return min;
8
 
9
     return db * 100000 + sign * mb;
10
ffmpeg-3-3.4.12.tar.xz/libavformat/wavdec.c -> ffmpeg-3-3.4.13.tar.xz/libavformat/wavdec.c Changed
12
 
1
@@ -647,6 +647,10 @@
2
                 goto smv_out;
3
             }
4
             size = avio_rl24(s->pb);
5
+            if (size > wav->smv_block_size) {
6
+                ret = AVERROR_EOF;
7
+                goto smv_out;
8
+            }
9
             ret  = av_get_packet(s->pb, pkt, size);
10
             if (ret < 0)
11
                 goto smv_out;
12
ffmpeg-3-3.4.12.tar.xz/libswscale/aarch64/yuv2rgb_neon.S -> ffmpeg-3-3.4.13.tar.xz/libswscale/aarch64/yuv2rgb_neon.S Changed
23
 
1
@@ -118,8 +118,8 @@
2
 .endm
3
 
4
 .macro increment_yuv422p
5
-    add                 x6,  x6,  w7, UXTW                              // srcU += incU
6
-    add                 x13, x13, w14, UXTW                             // srcV += incV
7
+    add                 x6,  x6,  w7, SXTW                              // srcU += incU
8
+    add                 x13, x13, w14, SXTW                             // srcV += incV
9
 .endm
10
 
11
 .macro compute_rgba r1 g1 b1 a1 r2 g2 b2 a2
12
@@ -188,8 +188,8 @@
13
     st4                 {v16.8B,v17.8B,v18.8B,v19.8B}, x2, #32
14
     subs                w8, w8, #16                                     // width -= 16
15
     b.gt                2b
16
-    add                 x2, x2, w3, UXTW                                // dst  += padding
17
-    add                 x4, x4, w5, UXTW                                // srcY += paddingY
18
+    add                 x2, x2, w3, SXTW                                // dst  += padding
19
+    add                 x4, x4, w5, SXTW                                // srcY += paddingY
20
     increment_\ifmt
21
     subs                w1, w1, #1                                      // height -= 1
22
     b.gt                1b
23
ffmpeg-3-3.4.12.tar.xz/libswscale/input.c -> ffmpeg-3-3.4.13.tar.xz/libswscale/input.c Changed
46
 
1
@@ -84,9 +84,9 @@
2
     int32_t rv = rgb2yuvRV_IDX, gv = rgb2yuvGV_IDX, bv = rgb2yuvBV_IDX;
3
     av_assert1(src1==src2);
4
     for (i = 0; i < width; i++) {
5
-        int r_b = (input_pixel(&src18 * i + 0) + input_pixel(&src18 * i + 4) + 1) >> 1;
6
-        int   g = (input_pixel(&src18 * i + 1) + input_pixel(&src18 * i + 5) + 1) >> 1;
7
-        int b_r = (input_pixel(&src18 * i + 2) + input_pixel(&src18 * i + 6) + 1) >> 1;
8
+        unsigned r_b = (input_pixel(&src18 * i + 0) + input_pixel(&src18 * i + 4) + 1) >> 1;
9
+        unsigned   g = (input_pixel(&src18 * i + 1) + input_pixel(&src18 * i + 5) + 1) >> 1;
10
+        unsigned b_r = (input_pixel(&src18 * i + 2) + input_pixel(&src18 * i + 6) + 1) >> 1;
11
 
12
         dstUi= (ru*r + gu*g + bu*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
13
         dstVi= (rv*r + gv*g + bv*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
14
@@ -156,9 +156,9 @@
15
     int32_t rv = rgb2yuvRV_IDX, gv = rgb2yuvGV_IDX, bv = rgb2yuvBV_IDX;
16
     av_assert1(src1 == src2);
17
     for (i = 0; i < width; i++) {
18
-        int r_b = input_pixel(&src1i * 3 + 0);
19
-        int g   = input_pixel(&src1i * 3 + 1);
20
-        int b_r = input_pixel(&src1i * 3 + 2);
21
+        unsigned r_b = input_pixel(&src1i * 3 + 0);
22
+        unsigned g   = input_pixel(&src1i * 3 + 1);
23
+        unsigned b_r = input_pixel(&src1i * 3 + 2);
24
 
25
         dstUi = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
26
         dstVi = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
27
@@ -178,12 +178,12 @@
28
     int32_t rv = rgb2yuvRV_IDX, gv = rgb2yuvGV_IDX, bv = rgb2yuvBV_IDX;
29
     av_assert1(src1 == src2);
30
     for (i = 0; i < width; i++) {
31
-        int r_b = (input_pixel(&src16 * i + 0) +
32
-                   input_pixel(&src16 * i + 3) + 1) >> 1;
33
-        int g   = (input_pixel(&src16 * i + 1) +
34
-                   input_pixel(&src16 * i + 4) + 1) >> 1;
35
-        int b_r = (input_pixel(&src16 * i + 2) +
36
-                   input_pixel(&src16 * i + 5) + 1) >> 1;
37
+        unsigned r_b = (input_pixel(&src16 * i + 0) +
38
+                        input_pixel(&src16 * i + 3) + 1) >> 1;
39
+        unsigned g   = (input_pixel(&src16 * i + 1) +
40
+                        input_pixel(&src16 * i + 4) + 1) >> 1;
41
+        unsigned b_r = (input_pixel(&src16 * i + 2) +
42
+                        input_pixel(&src16 * i + 5) + 1) >> 1;
43
 
44
         dstUi = (ru*r + gu*g + bu*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
45
         dstVi = (rv*r + gv*g + bv*b + (0x10001 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT;
46
ffmpeg-3-3.4.12.tar.xz/libswscale/output.c -> ffmpeg-3-3.4.13.tar.xz/libswscale/output.c Changed
201
 
1
@@ -827,8 +827,8 @@
2
         Y2 -= c->yuv2rgb_y_offset;
3
         Y1 *= c->yuv2rgb_y_coeff;
4
         Y2 *= c->yuv2rgb_y_coeff;
5
-        Y1 += 1 << 13; // 21
6
-        Y2 += 1 << 13;
7
+        Y1 += (1 << 13) - (1 << 29); // 21
8
+        Y2 += (1 << 13) - (1 << 29);
9
         // 8 bits: 17 + 13 bits = 30 bits, 16 bits: 17 + 13 bits = 30 bits
10
 
11
         R = V * c->yuv2rgb_v2r_coeff;
12
@@ -836,20 +836,20 @@
13
         B =                            U * c->yuv2rgb_u2b_coeff;
14
 
15
         // 8 bits: 30 - 22 = 8 bits, 16 bits: 30 bits - 14 = 16 bits
16
-        output_pixel(&dest0, av_clip_uintp2(R_B + Y1, 30) >> 14);
17
-        output_pixel(&dest1, av_clip_uintp2(  G + Y1, 30) >> 14);
18
-        output_pixel(&dest2, av_clip_uintp2(B_R + Y1, 30) >> 14);
19
+        output_pixel(&dest0, av_clip_uintp2(((R_B + Y1) >> 14) + (1<<15), 16));
20
+        output_pixel(&dest1, av_clip_uintp2(((  G + Y1) >> 14) + (1<<15), 16));
21
+        output_pixel(&dest2, av_clip_uintp2(((B_R + Y1) >> 14) + (1<<15), 16));
22
         if (eightbytes) {
23
             output_pixel(&dest3, av_clip_uintp2(A1      , 30) >> 14);
24
-            output_pixel(&dest4, av_clip_uintp2(R_B + Y2, 30) >> 14);
25
-            output_pixel(&dest5, av_clip_uintp2(  G + Y2, 30) >> 14);
26
-            output_pixel(&dest6, av_clip_uintp2(B_R + Y2, 30) >> 14);
27
+            output_pixel(&dest4, av_clip_uintp2(((R_B + Y2) >> 14) + (1<<15), 16));
28
+            output_pixel(&dest5, av_clip_uintp2(((  G + Y2) >> 14) + (1<<15), 16));
29
+            output_pixel(&dest6, av_clip_uintp2(((B_R + Y2) >> 14) + (1<<15), 16));
30
             output_pixel(&dest7, av_clip_uintp2(A2      , 30) >> 14);
31
             dest += 8;
32
         } else {
33
-            output_pixel(&dest3, av_clip_uintp2(R_B + Y2, 30) >> 14);
34
-            output_pixel(&dest4, av_clip_uintp2(  G + Y2, 30) >> 14);
35
-            output_pixel(&dest5, av_clip_uintp2(B_R + Y2, 30) >> 14);
36
+            output_pixel(&dest3, av_clip_uintp2(((R_B + Y2) >> 14) + (1<<15), 16));
37
+            output_pixel(&dest4, av_clip_uintp2(((  G + Y2) >> 14) + (1<<15), 16));
38
+            output_pixel(&dest5, av_clip_uintp2(((B_R + Y2) >> 14) + (1<<15), 16));
39
             dest += 6;
40
         }
41
     }
42
@@ -886,8 +886,8 @@
43
         Y2 -= c->yuv2rgb_y_offset;
44
         Y1 *= c->yuv2rgb_y_coeff;
45
         Y2 *= c->yuv2rgb_y_coeff;
46
-        Y1 += 1 << 13;
47
-        Y2 += 1 << 13;
48
+        Y1 += (1 << 13) - (1 << 29);
49
+        Y2 += (1 << 13) - (1 << 29);
50
 
51
         R = V * c->yuv2rgb_v2r_coeff;
52
         G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
53
@@ -901,20 +901,20 @@
54
             A2 += 1 << 13;
55
         }
56
 
57
-        output_pixel(&dest0, av_clip_uintp2(R_B + Y1, 30) >> 14);
58
-        output_pixel(&dest1, av_clip_uintp2(  G + Y1, 30) >> 14);
59
-        output_pixel(&dest2, av_clip_uintp2(B_R + Y1, 30) >> 14);
60
+        output_pixel(&dest0, av_clip_uintp2(((R_B + Y1) >> 14) + (1<<15), 16));
61
+        output_pixel(&dest1, av_clip_uintp2(((  G + Y1) >> 14) + (1<<15), 16));
62
+        output_pixel(&dest2, av_clip_uintp2(((B_R + Y1) >> 14) + (1<<15), 16));
63
         if (eightbytes) {
64
             output_pixel(&dest3, av_clip_uintp2(A1      , 30) >> 14);
65
-            output_pixel(&dest4, av_clip_uintp2(R_B + Y2, 30) >> 14);
66
-            output_pixel(&dest5, av_clip_uintp2(  G + Y2, 30) >> 14);
67
-            output_pixel(&dest6, av_clip_uintp2(B_R + Y2, 30) >> 14);
68
+            output_pixel(&dest4, av_clip_uintp2(((R_B + Y2) >> 14) + (1<<15), 16));
69
+            output_pixel(&dest5, av_clip_uintp2(((  G + Y2) >> 14) + (1<<15), 16));
70
+            output_pixel(&dest6, av_clip_uintp2(((B_R + Y2) >> 14) + (1<<15), 16));
71
             output_pixel(&dest7, av_clip_uintp2(A2      , 30) >> 14);
72
             dest += 8;
73
         } else {
74
-            output_pixel(&dest3, av_clip_uintp2(R_B + Y2, 30) >> 14);
75
-            output_pixel(&dest4, av_clip_uintp2(  G + Y2, 30) >> 14);
76
-            output_pixel(&dest5, av_clip_uintp2(B_R + Y2, 30) >> 14);
77
+            output_pixel(&dest3, av_clip_uintp2(((R_B + Y2) >> 14) + (1<<15), 16));
78
+            output_pixel(&dest4, av_clip_uintp2(((  G + Y2) >> 14) + (1<<15), 16));
79
+            output_pixel(&dest5, av_clip_uintp2(((B_R + Y2) >> 14) + (1<<15), 16));
80
             dest += 6;
81
         }
82
     }
83
@@ -942,8 +942,8 @@
84
             Y2 -= c->yuv2rgb_y_offset;
85
             Y1 *= c->yuv2rgb_y_coeff;
86
             Y2 *= c->yuv2rgb_y_coeff;
87
-            Y1 += 1 << 13;
88
-            Y2 += 1 << 13;
89
+            Y1 += (1 << 13) - (1 << 29);
90
+            Y2 += (1 << 13) - (1 << 29);
91
 
92
             if (hasAlpha) {
93
                 A1 = abuf0i * 2     << 11;
94
@@ -957,20 +957,20 @@
95
             G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
96
             B =                            U * c->yuv2rgb_u2b_coeff;
97
 
98
-            output_pixel(&dest0, av_clip_uintp2(R_B + Y1, 30) >> 14);
99
-            output_pixel(&dest1, av_clip_uintp2(  G + Y1, 30) >> 14);
100
-            output_pixel(&dest2, av_clip_uintp2(B_R + Y1, 30) >> 14);
101
+            output_pixel(&dest0, av_clip_uintp2(((R_B + Y1) >> 14) + (1<<15), 16));
102
+            output_pixel(&dest1, av_clip_uintp2(((  G + Y1) >> 14) + (1<<15), 16));
103
+            output_pixel(&dest2, av_clip_uintp2(((B_R + Y1) >> 14) + (1<<15), 16));
104
             if (eightbytes) {
105
                 output_pixel(&dest3, av_clip_uintp2(A1      , 30) >> 14);
106
-                output_pixel(&dest4, av_clip_uintp2(R_B + Y2, 30) >> 14);
107
-                output_pixel(&dest5, av_clip_uintp2(  G + Y2, 30) >> 14);
108
-                output_pixel(&dest6, av_clip_uintp2(B_R + Y2, 30) >> 14);
109
+                output_pixel(&dest4, av_clip_uintp2(((R_B + Y2) >> 14) + (1<<15), 16));
110
+                output_pixel(&dest5, av_clip_uintp2(((  G + Y2) >> 14) + (1<<15), 16));
111
+                output_pixel(&dest6, av_clip_uintp2(((B_R + Y2) >> 14) + (1<<15), 16));
112
                 output_pixel(&dest7, av_clip_uintp2(A2      , 30) >> 14);
113
                 dest += 8;
114
             } else {
115
-                output_pixel(&dest3, av_clip_uintp2(R_B + Y2, 30) >> 14);
116
-                output_pixel(&dest4, av_clip_uintp2(  G + Y2, 30) >> 14);
117
-                output_pixel(&dest5, av_clip_uintp2(B_R + Y2, 30) >> 14);
118
+                output_pixel(&dest3, av_clip_uintp2(((R_B + Y2) >> 14) + (1<<15), 16));
119
+                output_pixel(&dest4, av_clip_uintp2(((  G + Y2) >> 14) + (1<<15), 16));
120
+                output_pixel(&dest5, av_clip_uintp2(((B_R + Y2) >> 14) + (1<<15), 16));
121
                 dest += 6;
122
             }
123
         }
124
@@ -988,8 +988,8 @@
125
             Y2 -= c->yuv2rgb_y_offset;
126
             Y1 *= c->yuv2rgb_y_coeff;
127
             Y2 *= c->yuv2rgb_y_coeff;
128
-            Y1 += 1 << 13;
129
-            Y2 += 1 << 13;
130
+            Y1 += (1 << 13) - (1 << 29);
131
+            Y2 += (1 << 13) - (1 << 29);
132
 
133
             if (hasAlpha) {
134
                 A1 = abuf0i * 2     << 11;
135
@@ -1003,20 +1003,20 @@
136
             G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
137
             B =                            U * c->yuv2rgb_u2b_coeff;
138
 
139
-            output_pixel(&dest0, av_clip_uintp2(R_B + Y1, 30) >> 14);
140
-            output_pixel(&dest1, av_clip_uintp2(  G + Y1, 30) >> 14);
141
-            output_pixel(&dest2, av_clip_uintp2(B_R + Y1, 30) >> 14);
142
+            output_pixel(&dest0, av_clip_uintp2(((R_B + Y1) >> 14) + (1<<15), 16));
143
+            output_pixel(&dest1, av_clip_uintp2(((  G + Y1) >> 14) + (1<<15), 16));
144
+            output_pixel(&dest2, av_clip_uintp2(((B_R + Y1) >> 14) + (1<<15), 16));
145
             if (eightbytes) {
146
                 output_pixel(&dest3, av_clip_uintp2(A1      , 30) >> 14);
147
-                output_pixel(&dest4, av_clip_uintp2(R_B + Y2, 30) >> 14);
148
-                output_pixel(&dest5, av_clip_uintp2(  G + Y2, 30) >> 14);
149
-                output_pixel(&dest6, av_clip_uintp2(B_R + Y2, 30) >> 14);
150
+                output_pixel(&dest4, av_clip_uintp2(((R_B + Y2) >> 14) + (1<<15), 16));
151
+                output_pixel(&dest5, av_clip_uintp2(((  G + Y2) >> 14) + (1<<15), 16));
152
+                output_pixel(&dest6, av_clip_uintp2(((B_R + Y2) >> 14) + (1<<15), 16));
153
                 output_pixel(&dest7, av_clip_uintp2(A2      , 30) >> 14);
154
                 dest += 8;
155
             } else {
156
-                output_pixel(&dest3, av_clip_uintp2(R_B + Y2, 30) >> 14);
157
-                output_pixel(&dest4, av_clip_uintp2(  G + Y2, 30) >> 14);
158
-                output_pixel(&dest5, av_clip_uintp2(B_R + Y2, 30) >> 14);
159
+                output_pixel(&dest3, av_clip_uintp2(((R_B + Y2) >> 14) + (1<<15), 16));
160
+                output_pixel(&dest4, av_clip_uintp2(((  G + Y2) >> 14) + (1<<15), 16));
161
+                output_pixel(&dest5, av_clip_uintp2(((B_R + Y2) >> 14) + (1<<15), 16));
162
                 dest += 6;
163
             }
164
         }
165
@@ -1067,7 +1067,7 @@
166
         // 8bit: 27 -> 17bit, 16bit: 31 - 14 = 17bit
167
         Y -= c->yuv2rgb_y_offset;
168
         Y *= c->yuv2rgb_y_coeff;
169
-        Y += 1 << 13; // 21
170
+        Y += (1 << 13) - (1<<29); // 21
171
         // 8bit: 17 + 13bit = 30bit, 16bit: 17 + 13bit = 30bit
172
 
173
         R = V * c->yuv2rgb_v2r_coeff;
174
@@ -1075,9 +1075,9 @@
175
         B =                            U * c->yuv2rgb_u2b_coeff;
176
 
177
         // 8bit: 30 - 22 = 8bit, 16bit: 30bit - 14 = 16bit
178
-        output_pixel(&dest0, av_clip_uintp2(R_B + Y, 30) >> 14);
179
-        output_pixel(&dest1, av_clip_uintp2(  G + Y, 30) >> 14);
180
-        output_pixel(&dest2, av_clip_uintp2(B_R + Y, 30) >> 14);
181
+        output_pixel(&dest0, av_clip_uintp2(((R_B + Y)>>14) + (1<<15), 16));
182
+        output_pixel(&dest1, av_clip_uintp2(((  G + Y)>>14) + (1<<15), 16));
183
+        output_pixel(&dest2, av_clip_uintp2(((B_R + Y)>>14) + (1<<15), 16));
184
         if (eightbytes) {
185
             output_pixel(&dest3, av_clip_uintp2(A, 30) >> 14);
186
             dest += 4;
187
@@ -1115,7 +1115,7 @@
188
 
189
         Y -= c->yuv2rgb_y_offset;
190
         Y *= c->yuv2rgb_y_coeff;
191
-        Y += 1 << 13;
192
+        Y += (1 << 13) - (1 << 29);
193
 
194
         R = V * c->yuv2rgb_v2r_coeff;
195
         G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
196
@@ -1127,9 +1127,9 @@
197
             A += 1 << 13;
198
         }
199
 
200
-        output_pixel(&dest0, av_clip_uintp2(R_B + Y, 30) >> 14);
201
ffmpeg-3-3.4.12.tar.xz/tests/ref/seek/vsynth_lena-snow -> ffmpeg-3-3.4.13.tar.xz/tests/ref/seek/vsynth_lena-snow Changed
61
 
1
@@ -2,45 +2,45 @@
2
 ret: 0         st:-1 flags:0  ts:-1.000000
3
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5652 size:  3035
4
 ret: 0         st:-1 flags:1  ts: 1.894167
5
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos:  39806 size:  3640
6
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos:  39690 size:  3640
7
 ret: 0         st: 0 flags:0  ts: 0.800000
8
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  27442 size:  3494
9
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  27382 size:  3493
10
 ret:-1         st: 0 flags:1  ts:-0.320000
11
 ret:-1         st:-1 flags:0  ts: 2.576668
12
 ret: 0         st:-1 flags:1  ts: 1.470835
13
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos:  39806 size:  3640
14
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos:  39690 size:  3640
15
 ret: 0         st: 0 flags:0  ts: 0.360000
16
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  16134 size:  3244
17
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  16074 size:  3245
18
 ret:-1         st: 0 flags:1  ts:-0.760000
19
 ret:-1         st:-1 flags:0  ts: 2.153336
20
 ret: 0         st:-1 flags:1  ts: 1.047503
21
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  27442 size:  3494
22
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  27382 size:  3493
23
 ret: 0         st: 0 flags:0  ts:-0.040000
24
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5652 size:  3035
25
 ret: 0         st: 0 flags:1  ts: 2.840000
26
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos:  52608 size:  3582
27
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos:  52538 size:  3582
28
 ret: 0         st:-1 flags:0  ts: 1.730004
29
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos:  52608 size:  3582
30
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos:  52538 size:  3582
31
 ret: 0         st:-1 flags:1  ts: 0.624171
32
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  16134 size:  3244
33
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  16074 size:  3245
34
 ret: 0         st: 0 flags:0  ts:-0.480000
35
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5652 size:  3035
36
 ret: 0         st: 0 flags:1  ts: 2.400000
37
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos:  52608 size:  3582
38
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos:  52538 size:  3582
39
 ret: 0         st:-1 flags:0  ts: 1.306672
40
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos:  39806 size:  3640
41
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos:  39690 size:  3640
42
 ret: 0         st:-1 flags:1  ts: 0.200839
43
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5652 size:  3035
44
 ret: 0         st: 0 flags:0  ts:-0.920000
45
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   5652 size:  3035
46
 ret: 0         st: 0 flags:1  ts: 2.000000
47
-ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos:  52608 size:  3582
48
+ret: 0         st: 0 flags:1 dts: 1.920000 pts: 1.920000 pos:  52538 size:  3582
49
 ret: 0         st:-1 flags:0  ts: 0.883340
50
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  27442 size:  3494
51
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:  27382 size:  3493
52
 ret:-1         st:-1 flags:1  ts:-0.222493
53
 ret:-1         st: 0 flags:0  ts: 2.680000
54
 ret: 0         st: 0 flags:1  ts: 1.560000
55
-ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos:  39806 size:  3640
56
+ret: 0         st: 0 flags:1 dts: 1.440000 pts: 1.440000 pos:  39690 size:  3640
57
 ret: 0         st:-1 flags:0  ts: 0.460008
58
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  16134 size:  3244
59
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:  16074 size:  3245
60
 ret:-1         st:-1 flags:1  ts:-0.645825
61
ffmpeg-3-3.4.12.tar.xz/tests/ref/vsynth/vsynth1-snow -> ffmpeg-3-3.4.13.tar.xz/tests/ref/vsynth/vsynth1-snow Changed
10
 
1
@@ -1,4 +1,4 @@
2
-67c10f8d52fcd1103caa675a1408bf6e *tests/data/fate/vsynth1-snow.avi
3
-136088 tests/data/fate/vsynth1-snow.avi
4
-bfc0bcc4bc7b956933aa58acc587018d *tests/data/fate/vsynth1-snow.out.rawvideo
5
-stddev:   22.77 PSNR: 20.98 MAXDIFF:  175 bytes:  7603200/  7603200
6
+c4c77a6fb926b89fe6591c398f5cd4db *tests/data/fate/vsynth1-snow.avi
7
+136160 tests/data/fate/vsynth1-snow.avi
8
+dcf8b3f62d9c3ae2b2d0fbbacbf83e4e *tests/data/fate/vsynth1-snow.out.rawvideo
9
+stddev:   22.74 PSNR: 20.99 MAXDIFF:  173 bytes:  7603200/  7603200
10
ffmpeg-3-3.4.12.tar.xz/tests/ref/vsynth/vsynth1-snow-hpel -> ffmpeg-3-3.4.13.tar.xz/tests/ref/vsynth/vsynth1-snow-hpel Changed
10
 
1
@@ -1,4 +1,4 @@
2
-e62ae25d5040d04622a965bcb27fdb1e *tests/data/fate/vsynth1-snow-hpel.avi
3
-138446 tests/data/fate/vsynth1-snow-hpel.avi
4
-57c914cd150f8fc260b5989ce3e5884c *tests/data/fate/vsynth1-snow-hpel.out.rawvideo
5
-stddev:   22.74 PSNR: 20.99 MAXDIFF:  172 bytes:  7603200/  7603200
6
+5c9eb93646eb0e5570d37e9adc9625e4 *tests/data/fate/vsynth1-snow-hpel.avi
7
+138580 tests/data/fate/vsynth1-snow-hpel.avi
8
+3382bdde624d8bb4af206a5ac6614605 *tests/data/fate/vsynth1-snow-hpel.out.rawvideo
9
+stddev:   22.71 PSNR: 21.00 MAXDIFF:  171 bytes:  7603200/  7603200
10
ffmpeg-3-3.4.12.tar.xz/tests/ref/vsynth/vsynth2-snow -> ffmpeg-3-3.4.13.tar.xz/tests/ref/vsynth/vsynth2-snow Changed
10
 
1
@@ -1,4 +1,4 @@
2
-0a41e73ddd2f54936490655b46dad4a3 *tests/data/fate/vsynth2-snow.avi
3
-72868 tests/data/fate/vsynth2-snow.avi
4
-34a75f5cf8a71159f1a572d9cedcfef9 *tests/data/fate/vsynth2-snow.out.rawvideo
5
-stddev:   13.73 PSNR: 25.37 MAXDIFF:  162 bytes:  7603200/  7603200
6
+5e130d6a48b69348eee7f7c76c5869a3 *tests/data/fate/vsynth2-snow.avi
7
+72942 tests/data/fate/vsynth2-snow.avi
8
+9b6cee60e3ec0d1f312a8a25a7878fcc *tests/data/fate/vsynth2-snow.out.rawvideo
9
+stddev:   13.39 PSNR: 25.59 MAXDIFF:  154 bytes:  7603200/  7603200
10
ffmpeg-3-3.4.12.tar.xz/tests/ref/vsynth/vsynth2-snow-hpel -> ffmpeg-3-3.4.13.tar.xz/tests/ref/vsynth/vsynth2-snow-hpel Changed
10
 
1
@@ -1,4 +1,4 @@
2
-9bc409e4794ee50691a26c9c836d31a7 *tests/data/fate/vsynth2-snow-hpel.avi
3
-79728 tests/data/fate/vsynth2-snow-hpel.avi
4
-2cc64d8171175a1532fd7d3ed3011fbf *tests/data/fate/vsynth2-snow-hpel.out.rawvideo
5
-stddev:   13.70 PSNR: 25.39 MAXDIFF:  162 bytes:  7603200/  7603200
6
+8edcf0fd7f066972ff77d5b891ed6dde *tests/data/fate/vsynth2-snow-hpel.avi
7
+79798 tests/data/fate/vsynth2-snow-hpel.avi
8
+7e0f2a24feda6fb3e54b85511a28c45f *tests/data/fate/vsynth2-snow-hpel.out.rawvideo
9
+stddev:   13.35 PSNR: 25.62 MAXDIFF:  157 bytes:  7603200/  7603200
10
ffmpeg-3-3.4.12.tar.xz/tests/ref/vsynth/vsynth_lena-snow -> ffmpeg-3-3.4.13.tar.xz/tests/ref/vsynth/vsynth_lena-snow Changed
10
 
1
@@ -1,4 +1,4 @@
2
-8e96f337e8f4ccac7d72ef517e1d2208 *tests/data/fate/vsynth_lena-snow.avi
3
-57680 tests/data/fate/vsynth_lena-snow.avi
4
-90963cfd2359d460001c94d94256dc2b *tests/data/fate/vsynth_lena-snow.out.rawvideo
5
-stddev:   10.48 PSNR: 27.72 MAXDIFF:  119 bytes:  7603200/  7603200
6
+bf2cf9cacc1d98388798be98872049ee *tests/data/fate/vsynth_lena-snow.avi
7
+57604 tests/data/fate/vsynth_lena-snow.avi
8
+707a42eb20195913be55ba8dfadf72fb *tests/data/fate/vsynth_lena-snow.out.rawvideo
9
+stddev:   10.37 PSNR: 27.81 MAXDIFF:  120 bytes:  7603200/  7603200
10
ffmpeg-3-3.4.12.tar.xz/tests/ref/vsynth/vsynth_lena-snow-hpel -> ffmpeg-3-3.4.13.tar.xz/tests/ref/vsynth/vsynth_lena-snow-hpel Changed
10
 
1
@@ -1,4 +1,4 @@
2
-56b14cb1cbb637536233982e87f7ac3e *tests/data/fate/vsynth_lena-snow-hpel.avi
3
-61764 tests/data/fate/vsynth_lena-snow-hpel.avi
4
-244b0266127fa354d8485234b2c388e4 *tests/data/fate/vsynth_lena-snow-hpel.out.rawvideo
5
-stddev:   10.45 PSNR: 27.74 MAXDIFF:  119 bytes:  7603200/  7603200
6
+c6ec87a11415a99b1a781f9f5bacb722 *tests/data/fate/vsynth_lena-snow-hpel.avi
7
+61814 tests/data/fate/vsynth_lena-snow-hpel.avi
8
+40f330397b7acf6bdbb3ec6d908be451 *tests/data/fate/vsynth_lena-snow-hpel.out.rawvideo
9
+stddev:   10.34 PSNR: 27.83 MAXDIFF:  118 bytes:  7603200/  7603200
10