[FFmpeg-cvslog] avcodec/utils: check the private context class

2014-12-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed Dec 17 
03:28:25 2014 +0100| [ddd7dac7ae0515ea6036396bb50d7bb5f702aeef] | committer: 
Michael Niedermayer

avcodec/utils: check the private context class

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ddd7dac7ae0515ea6036396bb50d7bb5f702aeef
---

 libavcodec/utils.c |4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index db79b67..74bf6d5 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1680,6 +1680,10 @@ int attribute_align_arg avcodec_open2(AVCodecContext 
*avctx, const AVCodec *code
 avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, 
(AVRational){avctx->ticks_per_frame, 1}));
 #endif
 }
+if (codec->priv_data_size > 0 && avctx->priv_data && codec->priv_class) {
+av_assert0(*(const AVClass **)avctx->priv_data == codec->priv_class);
+}
+
 end:
 ff_unlock_avcodec();
 if (options) {

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


[FFmpeg-cvslog] avcodec/indeo3: use signed variables to avoid underflow

2014-12-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed Dec 17 
03:14:21 2014 +0100| [3305acdc92fa37869f160a11a87741c8a0de0454] | committer: 
Michael Niedermayer

avcodec/indeo3: use signed variables to avoid underflow

Fixes out of array read
Fixes: signal_sigsegv_1b0a4da_1865_cov_2167818389_computer_anger.avi
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3305acdc92fa37869f160a11a87741c8a0de0454
---

 libavcodec/indeo3.c |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c
index d38765e..cafed51 100644
--- a/libavcodec/indeo3.c
+++ b/libavcodec/indeo3.c
@@ -94,7 +94,7 @@ typedef struct Indeo3DecodeContext {
 
 int16_t width, height;
 uint32_tframe_num;  ///< current frame number (zero-based)
-uint32_tdata_size;  ///< size of the frame data in bytes
+int data_size;  ///< size of the frame data in bytes
 uint16_tframe_flags;///< frame properties
 uint8_t cb_offset;  ///< needed for selecting VQ tables
 uint8_t buf_sel;///< active frame buffer: 0 - primary, 1 
-secondary
@@ -899,7 +899,8 @@ static int decode_frame_headers(Indeo3DecodeContext *ctx, 
AVCodecContext *avctx,
 GetByteContext gb;
 const uint8_t   *bs_hdr;
 uint32_tframe_num, word2, check_sum, data_size;
-uint32_ty_offset, u_offset, v_offset, starts[3], ends[3];
+int y_offset, u_offset, v_offset;
+uint32_tstarts[3], ends[3];
 uint16_theight, width;
 int i, j;
 

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


[FFmpeg-cvslog] avcodec/imc: dont read bits beyond the end

2014-12-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed Dec 17 
04:51:06 2014 +0100| [3ba105029279bf43e6338849f360f1ce9a2973a0] | committer: 
Michael Niedermayer

avcodec/imc: dont read bits beyond the end

Fixes use of uninitialized memory

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3ba105029279bf43e6338849f360f1ce9a2973a0
---

 libavcodec/imc.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/imc.c b/libavcodec/imc.c
index b367ccb..a3254f1 100644
--- a/libavcodec/imc.c
+++ b/libavcodec/imc.c
@@ -808,9 +808,8 @@ static void imc_get_coeffs(AVCodecContext *avctx,
 av_log(avctx, AV_LOG_WARNING,
 "Potential problem on band %i, coefficient %i"
 ": cw_len=%i\n", i, j, cw_len);
-}
-
-cw = get_bits(&q->gb, cw_len);
+} else
+cw = get_bits(&q->gb, cw_len);
 }
 
 chctx->codewords[j] = cw;

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


[FFmpeg-cvslog] flacenc: calculate lower sum levels in-place.

2014-12-16 Thread Reimar Döffinger
ffmpeg | branch: master | Reimar Döffinger  | Sat Nov 
22 20:05:08 2014 +0100| [254da44bf97e4d5d919a5363f476f936f3c06ccd] | committer: 
Reimar Döffinger

flacenc: calculate lower sum levels in-place.

Should improve cache usage and reduces stack usage.
Also reduces number of copies in case many levels
have the same number of bits.

Signed-off-by: Reimar Döffinger 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=254da44bf97e4d5d919a5363f476f936f3c06ccd
---

 libavcodec/flacenc.c |   34 +++---
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index e66ef3d..9786782 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -609,10 +609,10 @@ static uint64_t calc_optimal_rice_params(RiceContext *rc, 
int porder,
 }
 
 
-static void calc_sums(int pmin, int pmax, uint32_t *data, int n, int 
pred_order,
-  uint64_t sums[][MAX_PARTITIONS])
+static void calc_sum_top(int pmax, uint32_t *data, int n, int pred_order,
+ uint64_t sums[MAX_PARTITIONS])
 {
-int i, j;
+int i;
 int parts;
 uint32_t *res, *res_end;
 
@@ -624,17 +624,18 @@ static void calc_sums(int pmin, int pmax, uint32_t *data, 
int n, int pred_order,
 uint64_t sum = 0;
 while (res < res_end)
 sum += *(res++);
-sums[pmax][i] = sum;
+sums[i] = sum;
 res_end += n >> pmax;
 }
-/* sums for lower levels */
-for (i = pmax - 1; i >= pmin; i--) {
-parts = (1 << i);
-for (j = 0; j < parts; j++)
-sums[i][j] = sums[i+1][2*j] + sums[i+1][2*j+1];
-}
 }
 
+static void calc_sum_next(int level, uint64_t sums[MAX_PARTITIONS])
+{
+int i;
+int parts = (1 << level);
+for (i = 0; i < parts; i++)
+sums[i] = sums[2*i] + sums[2*i+1];
+}
 
 static uint64_t calc_rice_params(RiceContext *rc, int pmin, int pmax,
  int32_t *data, int n, int pred_order)
@@ -644,7 +645,7 @@ static uint64_t calc_rice_params(RiceContext *rc, int pmin, 
int pmax,
 int opt_porder;
 RiceContext tmp_rc;
 uint32_t *udata;
-uint64_t sums[MAX_PARTITION_ORDER+1][MAX_PARTITIONS];
+uint64_t sums[MAX_PARTITIONS];
 
 av_assert1(pmin >= 0 && pmin <= MAX_PARTITION_ORDER);
 av_assert1(pmax >= 0 && pmax <= MAX_PARTITION_ORDER);
@@ -656,16 +657,19 @@ static uint64_t calc_rice_params(RiceContext *rc, int 
pmin, int pmax,
 for (i = 0; i < n; i++)
 udata[i] = (2*data[i]) ^ (data[i]>>31);
 
-calc_sums(pmin, pmax, udata, n, pred_order, sums);
+calc_sum_top(pmax, udata, n, pred_order, sums);
 
 opt_porder = pmin;
 bits[pmin] = UINT32_MAX;
-for (i = pmin; i <= pmax; i++) {
-bits[i] = calc_optimal_rice_params(&tmp_rc, i, sums[i], n, pred_order);
-if (bits[i] <= bits[opt_porder]) {
+for (i = pmax; ; ) {
+bits[i] = calc_optimal_rice_params(&tmp_rc, i, sums, n, pred_order);
+if (bits[i] < bits[opt_porder]) {
 opt_porder = i;
 *rc = tmp_rc;
 }
+if (i == pmin)
+break;
+calc_sum_next(--i, sums);
 }
 
 av_freep(&udata);

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


[FFmpeg-cvslog] libavutil: cosmetic: inserted spaces wherever necessary

2014-12-16 Thread Supraja Meedinti
ffmpeg | branch: master | Supraja Meedinti  | Wed Dec 17 
02:19:42 2014 +0530| [abbcc68e5cefc09265d2665e507f69907cd5b8ca] | committer: 
Michael Niedermayer

libavutil: cosmetic: inserted spaces wherever necessary

Signed-off-by: Supraja Meedinti 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=abbcc68e5cefc09265d2665e507f69907cd5b8ca
---

 libavutil/cast5.c |  348 +++--
 libavutil/cast5.h |2 +-
 2 files changed, 181 insertions(+), 169 deletions(-)

diff --git a/libavutil/cast5.c b/libavutil/cast5.c
index c0d6d1e..14dd701 100644
--- a/libavutil/cast5.c
+++ b/libavutil/cast5.c
@@ -23,48 +23,48 @@
 #include "intreadwrite.h"
 #include "attributes.h"
 
-#define IA(x) ((x)>>24)
-#define IB(x) (((x)>>16) & 0xff)
-#define IC(x) (((x)>>8) & 0xff)
+#define IA(x) ((x) >> 24)
+#define IB(x) (((x) >> 16) & 0xff)
+#define IC(x) (((x) >> 8) & 0xff)
 #define ID(x) ((x) & 0xff)
 
-#define LR(x,c) (((x)<<(c))|((x)>>(32-(c
+#define LR(x, c) (((x) << (c)) | ((x) >> (32 - (c
 
-#define F3(l,r,i)   \
-do {\
-I=LR(cs->Km[i]-r,cs->Kr[i]);\
-f=((S1[IA(I)]+S2[IB(I)])^S3[IC(I)])-S4[ID(I)];  \
-l=f^l;  \
+#define F3(l, r, i)
  \
+do {   
  \
+I = LR(cs->Km[i] - r, cs->Kr[i]);  
  \
+f = ((S1[IA(I)] + S2[IB(I)]) ^ S3[IC(I)]) - S4[ID(I)]; 
  \
+l = f ^ l; 
  \
 } while (0)
 
-#define F2(l,r,i)   \
-do {\
-I=LR(cs->Km[i]^r,cs->Kr[i]);\
-f=((S1[IA(I)]-S2[IB(I)])+S3[IC(I)])^S4[ID(I)];  \
-l=f^l;  \
+#define F2(l, r, i)
  \
+do {   
  \
+I = LR(cs->Km[i] ^ r, cs->Kr[i]);  
  \
+f = ((S1[IA(I)] - S2[IB(I)]) + S3[IC(I)]) ^ S4[ID(I)]; 
  \
+l = f ^ l; 
  \
 } while (0)
 
-#define F1(l,r,i)   \
-do {\
-I=LR(cs->Km[i]+r,cs->Kr[i]);\
-f=((S1[IA(I)]^S2[IB(I)])-S3[IC(I)])+S4[ID(I)];  \
-l=f^l;  \
+#define F1(l, r, i)
  \
+do {   
  \
+I = LR(cs->Km[i] + r, cs->Kr[i]);  
  \
+f = ((S1[IA(I)] ^ S2[IB(I)]) - S3[IC(I)]) + S4[ID(I)]; 
  \
+l = f ^ l; 
  \
 } while (0)
 
-#define COMPUTE_Z  
\
-do {   
\
-
z[0]=x[0]^S5[IB(x[3])]^S6[ID(x[3])]^S7[IA(x[3])]^S8[IC(x[3])]^S7[IA(x[2])];\
-
z[1]=x[2]^S5[IA(z[0])]^S6[IC(z[0])]^S7[IB(z[0])]^S8[ID(z[0])]^S8[IC(x[2])];\
-
z[2]=x[3]^S5[ID(z[1])]^S6[IC(z[1])]^S7[IB(z[1])]^S8[IA(z[1])]^S5[IB(x[2])];\
-
z[3]=x[1]^S5[IC(z[2])]^S6[IB(z[2])]^S7[ID(z[2])]^S8[IA(z[2])]^S6[ID(x[2])];\
+#define COMPUTE_Z  
  \
+do {   
  \
+z[0] = x[0] ^ S5[IB(x[3])] ^ S6[ID(x[3])] ^ S7[IA(x[3])] ^ 
S8[IC(x[3])] ^ S7[IA(x[2])];  \
+z[1] = x[2] ^ S5[IA(z[0])] ^ S6[IC(z[0])] ^ S7[IB(z[0])] ^ 
S8[ID(z[0])] ^ S8[IC(x[2])];  \
+z[2] = x[3] ^ S5[ID(z[1])] ^ S6[IC(z[1])] ^ S7[IB(z[1])] ^ 
S8[IA(z[1])] ^ S5[IB(x[2])];  \
+z[3] = x[1] ^ S5[IC(z[2])] ^ S6[IB(z[2])] ^ S7[ID(z[2])] ^ 
S8[IA(z[2])] ^ S6[ID(x[2])];  \
 } while (0)
 
-#define COMPUTE_X  
\
-do {   
\
-
x[0]=z[2]^S5[IB

[FFmpeg-cvslog] avcodec/h264: make the first field of H264Context an AVClass

2014-12-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Wed Dec 17 
01:31:48 2014 +0100| [f3b5b139ad853b6f69c6a0b036815a60e7b3f261] | committer: 
Michael Niedermayer

avcodec/h264: make the first field of H264Context an AVClass

Fixes use of freed memory
Fixes: asan_heap-uaf_3660f67_757_cov_1257014655_Hi422FR1_SONY_A.jsv
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f3b5b139ad853b6f69c6a0b036815a60e7b3f261
---

 libavcodec/h264.h |1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 8af991b..74c1bbf 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -338,6 +338,7 @@ typedef struct H264Picture {
  * H264Context
  */
 typedef struct H264Context {
+AVClass *av_class;
 AVCodecContext *avctx;
 MECmpContext mecc;
 VideoDSPContext vdsp;

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


[FFmpeg-cvslog] swscale: increase yuv2rgb table headroom

2014-12-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue Dec 16 
22:21:21 2014 +0100| [2a983ff7fe076ae93926eb33cfb44ca49183dacc] | committer: 
Michael Niedermayer

swscale: increase yuv2rgb table headroom

Fixes out of array access
Fixes: case2_bad_read_yuv2rgbx32.mp4
Found-by: Michal Zalewski 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2a983ff7fe076ae93926eb33cfb44ca49183dacc
---

 libswscale/swscale_internal.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 63b4eca..37c2b37 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -39,7 +39,7 @@
 
 #define STR(s) AV_TOSTRING(s) // AV_STRINGIFY is too long
 
-#define YUVRGB_TABLE_HEADROOM 128
+#define YUVRGB_TABLE_HEADROOM 256
 
 #define MAX_FILTER_SIZE SWS_MAX_FILTER_SIZE
 

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


[FFmpeg-cvslog] avformat/mov: check atom nesting depth

2014-12-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue Dec 16 
21:14:40 2014 +0100| [caa7a3914f499f74b3ee346f26d598ebdc0ec210] | committer: 
Michael Niedermayer

avformat/mov: check atom nesting depth

Fixes call stack overflow
Fixes: case1_call_stack_overflow.mp4
Found-by: Michal Zalewski 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=caa7a3914f499f74b3ee346f26d598ebdc0ec210
---

 libavformat/isom.h |1 +
 libavformat/mov.c  |   13 -
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index f8e398b..b4f0202 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -190,6 +190,7 @@ typedef struct MOVContext {
 int has_looked_for_mfra;
 MOVFragmentIndex** fragment_index_data;
 unsigned fragment_index_count;
+int atom_depth;
 } MOVContext;
 
 int ff_mp4_read_descr_len(AVIOContext *pb);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 8bfe974..be2728c 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3412,6 +3412,12 @@ static int mov_read_default(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 MOVAtom a;
 int i;
 
+if (c->atom_depth > 10) {
+av_log(c->fc, AV_LOG_ERROR, "Atoms too deeply nested\n");
+return AVERROR_INVALIDDATA;
+}
+c->atom_depth ++;
+
 if (atom.size < 0)
 atom.size = INT64_MAX;
 while (total_size + 8 <= atom.size && !avio_feof(pb)) {
@@ -3441,6 +3447,7 @@ static int mov_read_default(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 {
 av_log(c->fc, AV_LOG_ERROR, "Broken file, trak/mdat not at 
top-level\n");
 avio_skip(pb, -8);
+c->atom_depth --;
 return 0;
 }
 }
@@ -3477,13 +3484,16 @@ static int mov_read_default(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 int64_t start_pos = avio_tell(pb);
 int64_t left;
 int err = parse(c, pb, a);
-if (err < 0)
+if (err < 0) {
+c->atom_depth --;
 return err;
+}
 if (c->found_moov && c->found_mdat &&
 ((!pb->seekable || c->fc->flags & AVFMT_FLAG_IGNIDX) ||
  start_pos + a.size == avio_size(pb))) {
 if (!pb->seekable || c->fc->flags & AVFMT_FLAG_IGNIDX)
 c->next_root_atom = start_pos + a.size;
+c->atom_depth --;
 return 0;
 }
 left = a.size - avio_tell(pb) + start_pos;
@@ -3503,6 +3513,7 @@ static int mov_read_default(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 if (total_size < atom.size && atom.size < 0x7)
 avio_skip(pb, atom.size - total_size);
 
+c->atom_depth --;
 return 0;
 }
 

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


[FFmpeg-cvslog] avformat/mov: fix integer overflow of size

2014-12-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue Dec 16 
21:29:27 2014 +0100| [be9ce6e10a8d53b8bc346c9337d75a5a30631a2a] | committer: 
Michael Niedermayer

avformat/mov: fix integer overflow of size

Fixes: case1_call_stack_overflow.mp4
Found-by: Michal Zalewski 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=be9ce6e10a8d53b8bc346c9337d75a5a30631a2a
---

 libavformat/mov.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index be2728c..0282ac4 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1574,7 +1574,7 @@ static void mov_parse_stsd_audio(MOVContext *c, 
AVIOContext *pb,
 
 static void mov_parse_stsd_subtitle(MOVContext *c, AVIOContext *pb,
 AVStream *st, MOVStreamContext *sc,
-int size)
+int64_t size)
 {
 // ttxt stsd contains display flags, justification, background
 // color, fonts, and default styles, so fake an atom to read it
@@ -1639,10 +1639,10 @@ static int mov_rewrite_dvd_sub_extradata(AVStream *st)
 
 static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,
 AVStream *st, MOVStreamContext *sc,
-int size)
+int64_t size)
 {
 if (st->codec->codec_tag == MKTAG('t','m','c','d')) {
-if (ff_get_extradata(st->codec, pb, size) < 0)
+if ((int)size != size || ff_get_extradata(st->codec, pb, size) < 0)
 return AVERROR(ENOMEM);
 if (size > 16) {
 MOVStreamContext *tmcd_ctx = st->priv_data;

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


[FFmpeg-cvslog] avcodec/utvideodec: Fix handling of slice_height=0

2014-12-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue Dec 16 
20:45:31 2014 +0100| [3881606240953b9275a247a1c98a567f3c44890f] | committer: 
Michael Niedermayer

avcodec/utvideodec: Fix handling of slice_height=0

Fixes out of array accesses
Fixes: asan_heap-oob_25bcd7e_3783_cov_3553517262_utvideo_rgba_median.avi
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3881606240953b9275a247a1c98a567f3c44890f
---

 libavcodec/utvideodec.c |4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/utvideodec.c b/libavcodec/utvideodec.c
index b565c10..3a3c46e 100644
--- a/libavcodec/utvideodec.c
+++ b/libavcodec/utvideodec.c
@@ -215,6 +215,8 @@ static void restore_median(uint8_t *src, int step, int 
stride,
 slice_height = slice + 1) * height) / slices) & cmask) -
slice_start;
 
+if (!slice_height)
+continue;
 bsrc = src + slice_start * stride;
 
 // first line - left neighbour prediction
@@ -270,6 +272,8 @@ static void restore_median_il(uint8_t *src, int step, int 
stride,
 slice_height   = slice + 1) * height) / slices) & cmask) -
  slice_start;
 slice_height >>= 1;
+if (!slice_height)
+continue;
 
 bsrc = src + slice_start * stride;
 

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


[FFmpeg-cvslog] doc/filters: fix typos and spelling errors

2014-12-16 Thread Lou Logan
ffmpeg | branch: master | Lou Logan  | Tue Dec 16 10:32:00 2014 
-0900| [a9a3c005b889fa44183d5a0118a34402c07b1cab] | committer: Lou Logan

doc/filters: fix typos and spelling errors

Prompted-by: Carl Oxwall <@oxwall>
Signed-off-by: Lou Logan 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a9a3c005b889fa44183d5a0118a34402c07b1cab
---

 doc/filters.texi |   30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 2f0e7fe..7fac8fb 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -922,7 +922,7 @@ It accepts the following option:
 @table @option
 @item length
 Short window length in seconds, used for peak and trough RMS measurement.
-Default is @code{0.05} (50 miliseconds). Allowed range is @code{[0.1 - 10]}.
+Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.1 - 10]}.
 @end table
 
 A description of each shown parameter follows:
@@ -1465,12 +1465,12 @@ Set base delay in milliseconds. Range from 0 to 30. 
Default value is 0.
 Set added swep delay in milliseconds. Range from 0 to 10. Default value is 2.
 
 @item regen
-Set percentage regeneneration (delayed signal feedback). Range from -95 to 95.
+Set percentage regeneration (delayed signal feedback). Range from -95 to 95.
 Default value is 0.
 
 @item width
 Set percentage of delayed signal mixed with original. Range from 0 to 100.
-Default valu is 71.
+Default value is 71.
 
 @item speed
 Set sweeps per second (Hz). Range from 0.1 to 10. Default value is 0.5.
@@ -1875,7 +1875,7 @@ or amplitude ratio. Default value is @code{0}.
 @item stop_periods
 Set the count for trimming silence from the end of audio.
 To remove silence from the middle of a file, specify a @var{stop_periods}
-that is negative. This value is then threated as a positive value and is
+that is negative. This value is then treated as a positive value and is
 used to indicate the effect should restart processing as specified by
 @var{start_periods}, making it suitable for removing periods of silence
 in the middle of the audio.
@@ -2169,7 +2169,7 @@ The sample rate of the incoming audio buffers.
 
 @item sample_fmt
 The sample format of the incoming audio buffers.
-Either a sample format name or its corresponging integer representation from
+Either a sample format name or its corresponding integer representation from
 the enum AVSampleFormat in @file{libavutil/samplefmt.h}
 
 @item channel_layout
@@ -2378,7 +2378,7 @@ Set the voice to use for the speech synthesis. Default 
value is
 
 @itemize
 @item
-Read from file @file{speech.txt}, and synthetize the text using the
+Read from file @file{speech.txt}, and synthesize the text using the
 standard flite voice:
 @example
 flite=textfile=speech.txt
@@ -3258,7 +3258,7 @@ crop=in_w:1/PHI*in_w
 @end example
 
 @item
-Appply trembling effect:
+Apply trembling effect:
 @example
 crop=in_w/2:in_h/2:(in_w-out_w)/2+((in_w-out_w)/2)*sin(n/10):(in_h-out_h)/2 
+((in_h-out_h)/2)*sin(n/7)
 @end example
@@ -5861,11 +5861,11 @@ The filter accepts the following options:
 @table @option
 @item cx
 Relative x-coordinate of the focal point of the image, and thereby the center 
of the
-distrortion. This value has a range [0,1] and is expressed as fractions of the 
image
+distortion. This value has a range [0,1] and is expressed as fractions of the 
image
 width.
 @item cy
 Relative y-coordinate of the focal point of the image, and thereby the center 
of the
-distrortion. This value has a range [0,1] and is expressed as fractions of the 
image
+distortion. This value has a range [0,1] and is expressed as fractions of the 
image
 height.
 @item k1
 Coefficient of the quadratic correction term. 0.5 means no correction.
@@ -6447,7 +6447,7 @@ libopencv function @code{cvSmooth}.
 Overlay one video on top of another.
 
 It takes two inputs and has one output. The first input is the "main"
-video on which the second input is overlayed.
+video on which the second input is overlaid.
 
 It accepts the following parameters:
 
@@ -6456,7 +6456,7 @@ A description of the accepted options follows.
 @table @option
 @item x
 @item y
-Set the expression for the x and y coordinates of the overlayed video
+Set the expression for the x and y coordinates of the overlaid video
 on the main video. Default value is "0" for both expressions. In case
 the expression is invalid, it is set to a huge value (meaning that the
 overlay will not be displayed within the output visible area).
@@ -7333,7 +7333,7 @@ it. Default value is 1.
 
 @item fillcolor, c
 Set the color used to fill the output area not covered by the rotated
-image. For the generalsyntax of this option, check the "Color" section in the
+image. For the general syntax of this option, check the "Color" section in the
 ffmpeg-utils manual. If the special value "none" is selected then no
 background is printed (useful for example if the background is never shown).
 
@@ -8558,7 +8558,7 @@ more advanced padding options (

[FFmpeg-cvslog] avcodec/vmdvideo: Check len before using it in method 3

2014-12-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue Dec 16 
16:24:55 2014 +0100| [3030fb7e0d41836f8add6399e9a7c7b740b48bfd] | committer: 
Michael Niedermayer

avcodec/vmdvideo: Check len before using it in method 3

Fixes out of array access
Fixes: asan_heap-oob_4d23ba_91_cov_3853393937_128.vmd

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3030fb7e0d41836f8add6399e9a7c7b740b48bfd
---

 libavcodec/vmdvideo.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/vmdvideo.c b/libavcodec/vmdvideo.c
index fa0fbe3..a2ba1c9 100644
--- a/libavcodec/vmdvideo.c
+++ b/libavcodec/vmdvideo.c
@@ -339,6 +339,9 @@ static int vmd_decode(VmdVideoContext *s, AVFrame *frame)
 ofs += slen;
 bytestream2_skip(&gb, len);
 } else {
+if (ofs + len > frame_width ||
+bytestream2_get_bytes_left(&gb) < len)
+return AVERROR_INVALIDDATA;
 bytestream2_get_buffer(&gb, &dp[ofs], len);
 ofs += len;
 }

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


[FFmpeg-cvslog] avcodec/xface: correct the XFACE_MAX_* values

2014-12-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue Dec 16 
18:57:54 2014 +0100| [93a5a16f136d095d23610f57bdad10ba88120fba] | committer: 
Michael Niedermayer

avcodec/xface: correct the XFACE_MAX_* values

Fixes out of array access

Fixes: asan_stack-oob_32c12e5_2536_cov_2442316831_lena.xface
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=93a5a16f136d095d23610f57bdad10ba88120fba
---

 libavcodec/xface.h |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/xface.h b/libavcodec/xface.h
index 63df5d3..0236d71 100644
--- a/libavcodec/xface.h
+++ b/libavcodec/xface.h
@@ -41,17 +41,17 @@
 /*
  * Image is encoded as a big integer, using characters from '~' to
  * '!', for a total of 94 symbols. In order to express
- * 48x48*2=8*XFACE_MAX_WORDS=4608
- * bits, we need a total of 704 digits, as given by:
- * ceil(lg_94(2^4608)) = 704
+ * 48x48 pixels with the worst case encoding 666 symbols should
+ * be sufficient.
  */
-#define XFACE_MAX_DIGITS 704
+#define XFACE_MAX_DIGITS 666
 
 #define XFACE_BITSPERWORD 8
 #define XFACE_WORDCARRY (1 << XFACE_BITSPERWORD)
 #define XFACE_WORDMASK (XFACE_WORDCARRY - 1)
 
-#define XFACE_MAX_WORDS ((XFACE_PIXELS * 2 + XFACE_BITSPERWORD - 1) / 
XFACE_BITSPERWORD)
+// This must be larger or equal to log256(94^XFACE_MAX_DIGITS)
+#define XFACE_MAX_WORDS 546
 
 /* Portable, very large unsigned integer arithmetic is needed.
  * Implementation uses arrays of WORDs. */

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


[FFmpeg-cvslog] avcodec/xface: Add asserts to limit nb_words from becoming too large

2014-12-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue Dec 16 
18:09:16 2014 +0100| [211200e0c0efa48b2815ce93fda10dab43526d1b] | committer: 
Michael Niedermayer

avcodec/xface: Add asserts to limit nb_words from becoming too large

Approved-by: Stefano Sabatini 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=211200e0c0efa48b2815ce93fda10dab43526d1b
---

 libavcodec/xface.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/xface.c b/libavcodec/xface.c
index 0ebf2f2..8c0cbfd 100644
--- a/libavcodec/xface.c
+++ b/libavcodec/xface.c
@@ -24,6 +24,8 @@
  * X-Face common data and utilities definition.
  */
 
+#include "libavutil/avassert.h"
+
 #include "xface.h"
 
 void ff_big_add(BigInt *b, uint8_t a)
@@ -43,6 +45,7 @@ void ff_big_add(BigInt *b, uint8_t a)
 c >>= XFACE_BITSPERWORD;
 }
 if (i == b->nb_words && c) {
+av_assert0(b->nb_words < XFACE_MAX_WORDS);
 b->nb_words++;
 *w = c & XFACE_WORDMASK;
 }
@@ -98,6 +101,7 @@ void ff_big_mul(BigInt *b, uint8_t a)
 return;
 if (a == 0) {
 /* treat this as a == WORDCARRY and just shift everything left a WORD 
*/
+av_assert0(b->nb_words < XFACE_MAX_WORDS);
 i = b->nb_words++;
 w = b->words + i;
 while (i--) {
@@ -116,6 +120,7 @@ void ff_big_mul(BigInt *b, uint8_t a)
 c >>= XFACE_BITSPERWORD;
 }
 if (c) {
+av_assert0(b->nb_words < XFACE_MAX_WORDS);
 b->nb_words++;
 *w = c & XFACE_WORDMASK;
 }

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


[FFmpeg-cvslog] avformat/hlsenc: Use av_freep() to avoid leaving stale pointers in memory

2014-12-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue Dec 16 
15:04:41 2014 +0100| [b8eb8b03104abb926616eb48fcb6d00127704bea] | committer: 
Michael Niedermayer

avformat/hlsenc: Use av_freep() to avoid leaving stale pointers in memory

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b8eb8b03104abb926616eb48fcb6d00127704bea
---

 libavformat/hlsenc.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 7645065..f46e8d4 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -396,7 +396,7 @@ fail:
 
 av_dict_free(&options);
 if (ret) {
-av_free(hls->basename);
+av_freep(&hls->basename);
 if (hls->avf)
 avformat_free_context(hls->avf);
 }
@@ -479,7 +479,7 @@ static int hls_write_trailer(struct AVFormatContext *s)
 avio_closep(&oc->pb);
 hls_append_segment(hls, hls->duration, hls->start_pos, hls->size);
 }
-av_free(hls->basename);
+av_freep(&hls->basename);
 avformat_free_context(oc);
 hls->avf = NULL;
 hls_window(s, 1);

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


[FFmpeg-cvslog] avformat/flvdec: Use av_freep() avoid leaving stale pointers in memory

2014-12-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue Dec 16 
15:03:32 2014 +0100| [91ea466551c148bd897706a1b6a168e783761a06] | committer: 
Michael Niedermayer

avformat/flvdec: Use av_freep() avoid leaving stale pointers in memory

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=91ea466551c148bd897706a1b6a168e783761a06
---

 libavformat/flvdec.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index c64b3a9..54f2f56 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -623,7 +623,7 @@ static int flv_read_close(AVFormatContext *s)
 
 static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
 {
-av_free(st->codec->extradata);
+av_freep(&st->codec->extradata);
 if (ff_get_extradata(st->codec, s->pb, size) < 0)
 return AVERROR(ENOMEM);
 return 0;

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


[FFmpeg-cvslog] avformat/hdsenc: Use av_freep() avoid leaving stale pointers in memory

2014-12-16 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue Dec 16 
15:01:05 2014 +0100| [16d763fa45b95783c6770edc559769d9a83d6a10] | committer: 
Michael Niedermayer

avformat/hdsenc: Use av_freep() avoid leaving stale pointers in memory

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=16d763fa45b95783c6770edc559769d9a83d6a10
---

 libavformat/hdsenc.c |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index 33d7c3a..a161b64 100644
--- a/libavformat/hdsenc.c
+++ b/libavformat/hdsenc.c
@@ -145,15 +145,15 @@ static void hds_free(AVFormatContext *s)
 if (os->ctx && os->ctx_inited)
 av_write_trailer(os->ctx);
 if (os->ctx && os->ctx->pb)
-av_free(os->ctx->pb);
+av_freep(&os->ctx->pb);
 if (os->ctx)
 avformat_free_context(os->ctx);
-av_free(os->metadata);
+av_freep(&os->metadata);
 for (j = 0; j < os->nb_extra_packets; j++)
-av_free(os->extra_packets[j]);
+av_freep(&os->extra_packets[j]);
 for (j = 0; j < os->nb_fragments; j++)
-av_free(os->fragments[j]);
-av_free(os->fragments);
+av_freep(&os->fragments[j]);
+av_freep(&os->fragments);
 }
 av_freep(&c->streams);
 }
@@ -499,7 +499,7 @@ static int hds_flush(AVFormatContext *s, OutputStream *os, 
int final,
 if (remove > 0) {
 for (i = 0; i < remove; i++) {
 unlink(os->fragments[i]->file);
-av_free(os->fragments[i]);
+av_freep(&os->fragments[i]);
 }
 os->nb_fragments -= remove;
 memmove(os->fragments, os->fragments + remove,

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


[FFmpeg-cvslog] lavfi: add colorlevels filter

2014-12-16 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat Dec  6 14:04:38 
2014 +| [5f90ef66119e100168552c027bb1d27df17a6d60] | committer: Paul B Mahol

lavfi: add colorlevels filter

Signed-off-by: Paul B Mahol 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5f90ef66119e100168552c027bb1d27df17a6d60
---

 Changelog|1 +
 doc/filters.texi |   69 
 libavfilter/Makefile |1 +
 libavfilter/allfilters.c |1 +
 libavfilter/version.h|4 +-
 libavfilter/vf_colorlevels.c |  254 ++
 6 files changed, 328 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index 47079f5..7097a12 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - nvenc encoder
 - 10bit spp filter
+- colorlevels filter
 
 
 version 2.5:
diff --git a/doc/filters.texi b/doc/filters.texi
index 7869d9c..2f0e7fe 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -2934,6 +2934,75 @@ colorbalance=rs=.3
 @end example
 @end itemize
 
+@section colorlevels
+
+Adjust video input frames using levels.
+
+The filter accepts the following options:
+
+@table @option
+@item rimin
+@item gimin
+@item bimin
+@item aimin
+Adjust red, green, blue and alpha input black point.
+Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{0}.
+
+@item rimax
+@item gimax
+@item bimax
+@item aimax
+Adjust red, green, blue and alpha input white point.
+Allowed ranges for options are @code{[-1.0, 1.0]}. Defaults are @code{1}.
+
+Input levels are used to lighten highlights (bright tones), darken shadows
+(dark tones), change the balance of bright and dark tones.
+
+@item romin
+@item gomin
+@item bomin
+@item aomin
+Adjust red, green, blue and alpha output black point.
+Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{0}.
+
+@item romax
+@item gomax
+@item bomax
+@item aomax
+Adjust red, green, blue and alpha output white point.
+Allowed ranges for options are @code{[0, 1.0]}. Defaults are @code{1}.
+
+Output levels allows manual selection of a constrained output level range.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Make video output darker:
+@example
+colorlevels=rimin=0.058:gimin=0.058:bimin=0.058
+@end example
+
+@item
+Increase contrast:
+@example
+colorlevels=rimin=0.039:gimin=0.039:bimin=0.039:rimax=0.96:gimax=0.96:bimax=0.96
+@end example
+
+@item
+Make video output lighter:
+@example
+colorlevels=rimax=0.902:gimax=0.902:bimax=0.902
+@end example
+
+@item
+Increase brightness:
+@example
+colorlevels=romin=0.5:gomin=0.5:bomin=0.5
+@end example
+@end itemize
+
 @section colorchannelmixer
 
 Adjust video input frames by re-mixing color channels.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 6b7291e..67a7e4b 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -100,6 +100,7 @@ OBJS-$(CONFIG_BOXBLUR_FILTER)+= vf_boxblur.o
 OBJS-$(CONFIG_CODECVIEW_FILTER)  += vf_codecview.o
 OBJS-$(CONFIG_COLORBALANCE_FILTER)   += vf_colorbalance.o
 OBJS-$(CONFIG_COLORCHANNELMIXER_FILTER)  += vf_colorchannelmixer.o
+OBJS-$(CONFIG_COLORLEVELS_FILTER)+= vf_colorlevels.o
 OBJS-$(CONFIG_COLORMATRIX_FILTER)+= vf_colormatrix.o
 OBJS-$(CONFIG_COPY_FILTER)   += vf_copy.o
 OBJS-$(CONFIG_CROP_FILTER)   += vf_crop.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index adb86be..066d9af 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -116,6 +116,7 @@ void avfilter_register_all(void)
 REGISTER_FILTER(CODECVIEW,  codecview,  vf);
 REGISTER_FILTER(COLORBALANCE,   colorbalance,   vf);
 REGISTER_FILTER(COLORCHANNELMIXER, colorchannelmixer, vf);
+REGISTER_FILTER(COLORLEVELS,colorlevels,vf);
 REGISTER_FILTER(COLORMATRIX,colormatrix,vf);
 REGISTER_FILTER(COPY,   copy,   vf);
 REGISTER_FILTER(CROP,   crop,   vf);
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 58a1c8b..8b6a09f 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,8 +30,8 @@
 #include "libavutil/version.h"
 
 #define LIBAVFILTER_VERSION_MAJOR  5
-#define LIBAVFILTER_VERSION_MINOR  3
-#define LIBAVFILTER_VERSION_MICRO 101
+#define LIBAVFILTER_VERSION_MINOR  4
+#define LIBAVFILTER_VERSION_MICRO 100
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
diff --git a/libavfilter/vf_colorlevels.c b/libavfilter/vf_colorlevels.c
new file mode 100644
index 000..4ceea66
--- /dev/null
+++ b/libavfilter/vf_colorlevels.c
@@ -0,0 +1,254 @@
+/*
+ * Copyright (c) 2013 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
+ *