[FFmpeg-cvslog] avfilter/af_dynaudnorm: fix possible null pointer dereference

2016-01-14 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Thu Jan 14 14:27:01 
2016 +0100| [70df51112ccc8d281cdb96141f20b3fd8a5b11f8] | committer: Paul B Mahol

avfilter/af_dynaudnorm: fix possible null pointer dereference

Signed-off-by: Paul B Mahol 

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

 libavfilter/af_dynaudnorm.c |   12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavfilter/af_dynaudnorm.c b/libavfilter/af_dynaudnorm.c
index 1a5fc48..d0bb51d 100644
--- a/libavfilter/af_dynaudnorm.c
+++ b/libavfilter/af_dynaudnorm.c
@@ -173,7 +173,8 @@ static cqueue *cqueue_create(int size)
 
 static void cqueue_free(cqueue *q)
 {
-av_free(q->elements);
+if (q)
+av_free(q->elements);
 av_free(q);
 }
 
@@ -684,9 +685,12 @@ static av_cold void uninit(AVFilterContext *ctx)
 av_freep(&s->fade_factors[1]);
 
 for (c = 0; c < s->channels; c++) {
-cqueue_free(s->gain_history_original[c]);
-cqueue_free(s->gain_history_minimum[c]);
-cqueue_free(s->gain_history_smoothed[c]);
+if (s->gain_history_original)
+cqueue_free(s->gain_history_original[c]);
+if (s->gain_history_minimum)
+cqueue_free(s->gain_history_minimum[c]);
+if (s->gain_history_smoothed)
+cqueue_free(s->gain_history_smoothed[c]);
 }
 
 av_freep(&s->gain_history_original);

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


[FFmpeg-cvslog] swscale/yuv2rgb: Factor YUVRGB_TABLE_LUMA_HEADROOM out

2016-01-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Jan 14 12:36:41 2016 +0100| [5e5f82a28737fba4402259617500911cc37e3674] | 
committer: Michael Niedermayer

swscale/yuv2rgb: Factor YUVRGB_TABLE_LUMA_HEADROOM out

Signed-off-by: Michael Niedermayer 

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

 libswscale/swscale_internal.h |1 +
 libswscale/yuv2rgb.c  |   89 +
 2 files changed, 46 insertions(+), 44 deletions(-)

diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index a53fdc4..5ac7eec 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -40,6 +40,7 @@
 #define STR(s) AV_TOSTRING(s) // AV_STRINGIFY is too long
 
 #define YUVRGB_TABLE_HEADROOM 256
+#define YUVRGB_TABLE_LUMA_HEADROOM 0
 
 #define MAX_FILTER_SIZE SWS_MAX_FILTER_SIZE
 
diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c
index 1d682ba..e81f3f6 100644
--- a/libswscale/yuv2rgb.c
+++ b/libswscale/yuv2rgb.c
@@ -776,7 +776,8 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const 
int inv_table[4],
 uint16_t *y_table16;
 uint32_t *y_table32;
 int i, base, rbase, gbase, bbase, av_uninit(abase), needAlpha;
-const int yoffs = fullRange ? 384 : 326;
+const int yoffs = (fullRange ? 384 : 326) + YUVRGB_TABLE_LUMA_HEADROOM;
+const int table_plane_size = 1024 + 2*YUVRGB_TABLE_LUMA_HEADROOM;
 
 int64_t crv =  inv_table[0];
 int64_t cbu =  inv_table[1];
@@ -833,10 +834,10 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const 
int inv_table[4],
 return AVERROR(ENOMEM);
 switch (bpp) {
 case 1:
-ALLOC_YUV_TABLE(1024);
+ALLOC_YUV_TABLE(table_plane_size);
 y_table = c->yuvTable;
-yb = -(384 << 16) - oy;
-for (i = 0; i < 1024 - 110; i++) {
+yb = -(384 << 16) - YUVRGB_TABLE_LUMA_HEADROOM*cy - oy;
+for (i = 0; i < table_plane_size - 110; i++) {
 y_table[i + 110]  = av_clip_uint8((yb + 0x8000) >> 16) >> 7;
 yb   += cy;
 }
@@ -848,60 +849,60 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const 
int inv_table[4],
 rbase   = isRgb ? 3 : 0;
 gbase   = 1;
 bbase   = isRgb ? 0 : 3;
-ALLOC_YUV_TABLE(1024 * 3);
+ALLOC_YUV_TABLE(table_plane_size * 3);
 y_table = c->yuvTable;
-yb = -(384 << 16) - oy;
-for (i = 0; i < 1024 - 110; i++) {
+yb = -(384 << 16) - YUVRGB_TABLE_LUMA_HEADROOM*cy - oy;
+for (i = 0; i < table_plane_size - 110; i++) {
 int yval= av_clip_uint8((yb + 0x8000) >> 16);
 y_table[i + 110]= (yval >> 7)<< rbase;
-y_table[i +  37 + 1024] = ((yval + 43) / 85) << gbase;
-y_table[i + 110 + 2048] = (yval >> 7)<< bbase;
+y_table[i +  37 +   table_plane_size] = ((yval + 43) / 85) << 
gbase;
+y_table[i + 110 + 2*table_plane_size] = (yval >> 7)<< 
bbase;
 yb += cy;
 }
 fill_table(c->table_rV, 1, crv, y_table + yoffs);
-fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
-fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
+fill_table(c->table_gU, 1, cgu, y_table + yoffs +   table_plane_size);
+fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2*table_plane_size);
 fill_gv_table(c->table_gV, 1, cgv);
 break;
 case 8:
 rbase   = isRgb ? 5 : 0;
 gbase   = isRgb ? 2 : 3;
 bbase   = isRgb ? 0 : 6;
-ALLOC_YUV_TABLE(1024 * 3);
+ALLOC_YUV_TABLE(table_plane_size * 3);
 y_table = c->yuvTable;
-yb = -(384 << 16) - oy;
-for (i = 0; i < 1024 - 38; i++) {
+yb = -(384 << 16) - YUVRGB_TABLE_LUMA_HEADROOM*cy - oy;
+for (i = 0; i < table_plane_size - 38; i++) {
 int yval   = av_clip_uint8((yb + 0x8000) >> 16);
 y_table[i + 16]= ((yval + 18) / 36) << rbase;
-y_table[i + 16 + 1024] = ((yval + 18) / 36) << gbase;
-y_table[i + 37 + 2048] = ((yval + 43) / 85) << bbase;
+y_table[i + 16 +   table_plane_size] = ((yval + 18) / 36) << gbase;
+y_table[i + 37 + 2*table_plane_size] = ((yval + 43) / 85) << bbase;
 yb += cy;
 }
 fill_table(c->table_rV, 1, crv, y_table + yoffs);
-fill_table(c->table_gU, 1, cgu, y_table + yoffs + 1024);
-fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2048);
+fill_table(c->table_gU, 1, cgu, y_table + yoffs +   table_plane_size);
+fill_table(c->table_bU, 1, cbu, y_table + yoffs + 2*table_plane_size);
 fill_gv_table(c->table_gV, 1, cgv);
 break;
 case 12:
 rbase   = isRgb ? 8 : 0;
 gbase   = 4;
 bbase   = isRgb ? 0 : 8;
-ALLOC

[FFmpeg-cvslog] swscale/utils: Detect and skip unneeded sws_setColorspaceDetails() calls

2016-01-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Jan 14 15:11:48 2016 +0100| [cc538e9dbd14b61d1ac8c9fa687d83289673fe90] | 
committer: Michael Niedermayer

swscale/utils: Detect and skip unneeded sws_setColorspaceDetails() calls

This avoids running various table inits unnecessarily

Signed-off-by: Michael Niedermayer 

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

 libswscale/utils.c |   22 ++
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/libswscale/utils.c b/libswscale/utils.c
index 1875a54..74f0bd3 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -832,8 +832,6 @@ int sws_setColorspaceDetails(struct SwsContext *c, const 
int inv_table[4],
 const AVPixFmtDescriptor *desc_dst;
 const AVPixFmtDescriptor *desc_src;
 int need_reinit = 0;
-memmove(c->srcColorspaceTable, inv_table, sizeof(int) * 4);
-memmove(c->dstColorspaceTable, table, sizeof(int) * 4);
 
 handle_formats(c);
 desc_dst = av_pix_fmt_desc_get(c->dstFormat);
@@ -844,11 +842,24 @@ int sws_setColorspaceDetails(struct SwsContext *c, const 
int inv_table[4],
 if(!isYUV(c->srcFormat) && !isGray(c->srcFormat))
 srcRange = 0;
 
+if (c->srcRange != srcRange ||
+c->dstRange != dstRange ||
+c->brightness != brightness ||
+c->contrast   != contrast ||
+c->saturation != saturation ||
+memcmp(c->srcColorspaceTable, inv_table, sizeof(int) * 4) ||
+memcmp(c->dstColorspaceTable, table, sizeof(int) * 4)
+)
+need_reinit = 1;
+
+memmove(c->srcColorspaceTable, inv_table, sizeof(int) * 4);
+memmove(c->dstColorspaceTable, table, sizeof(int) * 4);
+
+
+
 c->brightness = brightness;
 c->contrast   = contrast;
 c->saturation = saturation;
-if (c->srcRange != srcRange || c->dstRange != dstRange)
-need_reinit = 1;
 c->srcRange   = srcRange;
 c->dstRange   = dstRange;
 
@@ -863,6 +874,9 @@ int sws_setColorspaceDetails(struct SwsContext *c, const 
int inv_table[4],
 if (c->cascaded_context[c->cascaded_mainindex])
 return 
sws_setColorspaceDetails(c->cascaded_context[c->cascaded_mainindex],inv_table, 
srcRange,table, dstRange, brightness,  contrast, saturation);
 
+if (!need_reinit)
+return 0;
+
 if ((isYUV(c->dstFormat) || isGray(c->dstFormat)) && (isYUV(c->srcFormat) 
|| isGray(c->srcFormat))) {
 if (!c->cascaded_context[0] &&
 memcmp(c->dstColorspaceTable, c->srcColorspaceTable, sizeof(int) * 
4) &&

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


[FFmpeg-cvslog] swscale/yuv2rgb: Increase YUV2RGB table headroom

2016-01-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Jan 14 03:05:11 2016 +0100| [8f3a9a8c278acf886f70a1d743bc07b6f9c7b51a] | 
committer: Michael Niedermayer

swscale/yuv2rgb: Increase YUV2RGB table headroom

This makes SWS more robust
Fixes: 
07650a772d98aa63b0fed6370dc89037/asan_heap-oob_27ddeaf_2657_2c81ff264dee5d9712cb3251fb9c3bbb.264
Fixes: out of array read

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

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

 libswscale/swscale_internal.h |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 5ac7eec..b28a233 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -39,8 +39,8 @@
 
 #define STR(s) AV_TOSTRING(s) // AV_STRINGIFY is too long
 
-#define YUVRGB_TABLE_HEADROOM 256
-#define YUVRGB_TABLE_LUMA_HEADROOM 0
+#define YUVRGB_TABLE_HEADROOM 512
+#define YUVRGB_TABLE_LUMA_HEADROOM 512
 
 #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] avfilter: add spectrumsynth filter

2016-01-14 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sun Jan 10 14:48:12 
2016 +0100| [653f9d84ae83188bc1dbef0546b7187841040dc8] | committer: Paul B Mahol

avfilter: add spectrumsynth filter

Signed-off-by: Paul B Mahol 

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

 Changelog   |1 +
 configure   |3 +
 doc/filters.texi|   63 +
 libavfilter/Makefile|1 +
 libavfilter/allfilters.c|1 +
 libavfilter/vaf_spectrumsynth.c |  533 +++
 libavfilter/version.h   |2 +-
 7 files changed, 603 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 7b19557..df2a30a 100644
--- a/Changelog
+++ b/Changelog
@@ -52,6 +52,7 @@ version :
 - automatic bitstream filtering
 - showspectrumpic filter
 - libstagefright support removed
+- spectrumsynth filter
 
 
 version 2.8:
diff --git a/configure b/configure
index 28ec5bf..7cef6f5 100755
--- a/configure
+++ b/configure
@@ -2903,6 +2903,8 @@ showspectrumpic_filter_deps="avcodec"
 showspectrumpic_filter_select="fft"
 sofalizer_filter_deps="netcdf avcodec"
 sofalizer_filter_select="fft"
+spectrumsynth_filter_deps="avcodec"
+spectrumsynth_filter_select="fft"
 spp_filter_deps="gpl avcodec"
 spp_filter_select="fft idctdsp fdctdsp me_cmp pixblockdsp"
 stereo3d_filter_deps="gpl"
@@ -6081,6 +6083,7 @@ enabled sofalizer_filter&& prepend avfilter_deps 
"avcodec"
 enabled showfreqs_filter&& prepend avfilter_deps "avcodec"
 enabled showspectrum_filter && prepend avfilter_deps "avcodec"
 enabled smartblur_filter&& prepend avfilter_deps "swscale"
+enabled spectrumsynth_filter && prepend avfilter_deps "avcodec"
 enabled subtitles_filter&& prepend avfilter_deps "avformat avcodec"
 enabled uspp_filter && prepend avfilter_deps "avcodec"
 
diff --git a/doc/filters.texi b/doc/filters.texi
index 45d22f4..9b3acc9 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -14578,6 +14578,7 @@ Default is @code{combined}.
 
 @end table
 
+@anchor{showspectrum}
 @section showspectrum
 
 Convert input audio to a video output, representing the audio frequency
@@ -15003,6 +15004,68 @@ ffmpeg -i audio.mp3 -filter_complex 
"showwavespic,colorchannelmixer=rr=66/255:gg
 @end example
 @end itemize
 
+@section spectrumsynth
+
+Sythesize audio from 2 input video spectrums, first input stream represents
+magnitude across time and second represents phase across time.
+The filter will transform from frequency domain as displayed in videos back
+to time domain as presented in audio output.
+
+This filter is primarly created for reversing processed @ref{showspectrum}
+filter outputs, but can synthesize sound from other spectrograms too.
+But in such case results are going to be poor if the phase data is not
+available, because in such cases phase data need to be recreated, usually
+its just recreated from random noise.
+For best results use gray only output (@code{channel} color mode in
+@ref{showspectrum} filter) and @code{log} scale for magnitude video and
+@code{lin} scale for phase video. To produce phase, for 2nd video, use
+@code{data} option. Inputs videos should generally use @code{fullframe}
+slide mode as that saves resources needed for decoding video.
+
+The filter accepts the following options:
+
+@table @option
+@item sample_rate
+Specify sample rate of output audio, the sample rate of audio from which
+spectrum was generated may differ.
+
+@item channels
+Set number of channels represented in input video spectrums.
+
+@item scale
+Set scale which was used when generating magnitude input spectrum.
+Can be @code{lin} or @code{log}. Default is @code{log}.
+
+@item slide
+Set slide which was used when generating inputs spectrums.
+Can be @code{replace}, @code{scroll}, @code{fullframe} or @code{rscroll}.
+Default is @code{fullframe}.
+
+@item win_func
+Set window function used for resynthesis.
+
+@item overlap
+Set window overlap. In range @code{[0, 1]}. Default is @code{1},
+which means optimal overlap for selected window function will be picked.
+
+@item orientation
+Set orientation of input videos. Can be @code{vertical} or @code{horizontal}.
+Default is @code{vertical}.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+First create magnitude and phase videos from audio, assuming audio is stereo 
with 44100 sample rate,
+then resynthesize videos back to audio with spectrumsynth:
+@example
+ffmpeg -i input.flac -lavfi 
showspectrum=mode=separate:scale=log:overlap=0.875:color=channel:slide=fullframe:data=magnitude
 -an -c:v rawvideo magnitude.nut
+ffmpeg -i input.flac -lavfi 
showspectrum=mode=separate:scale=lin:overlap=0.875:color=channel:slide=fullframe:data=phase
 -an -c:v rawvideo phase.nut
+ffmpeg -i magnitude.nut -i phase.nut -lavfi 
spectrumsynth=channels=2:sample_rate=44100:win_fun=hann:overlap=0.875:slide=fullframe
 output.flac
+@end example
+@end itemize
+
 @section split, 

[FFmpeg-cvslog] swscale/vscale: Add fixme comment to "ugly" code

2016-01-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Jan 14 18:11:22 2016 +0100| [fe6372bb614db1a8d73514d045c7c7b0b059289a] | 
committer: Michael Niedermayer

swscale/vscale: Add fixme comment to "ugly" code

Signed-off-by: Michael Niedermayer 

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

 libswscale/vscale.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libswscale/vscale.c b/libswscale/vscale.c
index f4b0b67..ff1988f 100644
--- a/libswscale/vscale.c
+++ b/libswscale/vscale.c
@@ -239,7 +239,7 @@ void ff_init_vscale_pfn(SwsContext *c,
 {
 VScalerContext *lumCtx = NULL;
 VScalerContext *chrCtx = NULL;
-int idx = c->numDesc - (c->is_internal_gamma ? 2 : 1);
+int idx = c->numDesc - (c->is_internal_gamma ? 2 : 1); //FIXME avoid 
hardcoding indexes
 
 if (isPlanarYUV(c->dstFormat) || (isGray(c->dstFormat) && 
!isALPHA(c->dstFormat))) {
 if (!isGray(c->dstFormat)) {

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


[FFmpeg-cvslog] swscale/slice: Fix doc typo

2016-01-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Jan 14 17:13:13 2016 +0100| [8feeffc1d7ca1c7708e7788e44bdeb25ce3de5a5] | 
committer: Michael Niedermayer

swscale/slice: Fix doc typo

Signed-off-by: Michael Niedermayer 

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

 libswscale/slice.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libswscale/slice.c b/libswscale/slice.c
index 38e12e3..2299eac 100644
--- a/libswscale/slice.c
+++ b/libswscale/slice.c
@@ -39,7 +39,7 @@ static void free_lines(SwsSlice *s)
 }
 
 /*
- slice lines contains extra bytes for vetorial code thus @size
+ slice lines contains extra bytes for vectorial code thus @size
  is the allocated memory size and @width is the number of pixels
 */
 static int alloc_lines(SwsSlice *s, int size, int width)

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


[FFmpeg-cvslog] swscale/vscale: Check that 2 tap filters are bilinear before using bilinear code

2016-01-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Jan 14 21:33:53 2016 +0100| [eb7802afefb7af4da50bc56818cdab9da07de7d0] | 
committer: Michael Niedermayer

swscale/vscale: Check that 2 tap filters are bilinear before using bilinear code

Fixes: out of array reads
Fixes: 
07e8b9c5d348ccdf7add0f37de20cf6c/asan_heap-oob_27e8df7_6849_e56653f768070ec8cb52f587048444c2.mov

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

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

 libswscale/swscale_internal.h |1 +
 libswscale/vscale.c   |   32 +---
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index fa288bd..1e29ec3 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -398,6 +398,7 @@ typedef struct SwsContext {
 uint8_t *chrMmxextFilterCode; ///< Runtime-generated MMXEXT horizontal 
fast bilinear scaler code for chroma planes.
 
 int canMMXEXTBeUsed;
+int warned_unuseable_bilinear;
 
 int dstY; ///< Last destination vertical line output 
from last slice.
 int flags;///< Flags passed by the user to select 
scaler algorithm, optimizations, subsampling, etc...
diff --git a/libswscale/vscale.c b/libswscale/vscale.c
index ff1988f..308a080 100644
--- a/libswscale/vscale.c
+++ b/libswscale/vscale.c
@@ -26,6 +26,7 @@ typedef struct VScalerContext
 int filter_size;
 int isMMX;
 void *pfn;
+yuv2packedX_fn yuv2packedX;
 } VScalerContext;
 
 
@@ -123,10 +124,21 @@ static int packed_vscale(SwsContext *c, 
SwsFilterDescriptor *desc, int sliceY, i
 uint8_t **dst = desc->dst->plane[0].line + dp;
 
 
-if (c->yuv2packed1 && lum_fsize == 1 && chr_fsize <= 2) { // unscaled RGB
-int chrAlpha = chr_fsize == 1 ? 0 : chr_filter[2 * sliceY + 1];
-((yuv2packed1_fn)inst->pfn)(c, (const int16_t*)*src0, (const 
int16_t**)src1, (const int16_t**)src2, (const int16_t*)(desc->alpha ? *src3 : 
NULL),  *dst, dstW, chrAlpha, sliceY);
-} else if (c->yuv2packed2 && lum_fsize == 2 && chr_fsize == 2) { // 
bilinear upscale RGB
+if (c->yuv2packed1 && lum_fsize == 1 && chr_fsize == 1) { // unscaled RGB
+((yuv2packed1_fn)inst->pfn)(c, (const int16_t*)*src0, (const 
int16_t**)src1, (const int16_t**)src2,
+(const int16_t*)(desc->alpha ? *src3 : 
NULL),  *dst, dstW, 0, sliceY);
+} else if (c->yuv2packed1 && lum_fsize == 1 && chr_fsize == 2 &&
+   chr_filter[2 * sliceY + 1] + chr_filter[2 * chrSliceY] == 4096 
&&
+   chr_filter[2 * sliceY + 1] <= 4096U) { // unscaled RGB
+int chrAlpha = chr_filter[2 * sliceY + 1];
+((yuv2packed1_fn)inst->pfn)(c, (const int16_t*)*src0, (const 
int16_t**)src1, (const int16_t**)src2,
+(const int16_t*)(desc->alpha ? *src3 : 
NULL),  *dst, dstW, chrAlpha, sliceY);
+} else if (c->yuv2packed2 && lum_fsize == 2 && chr_fsize == 2 &&
+   lum_filter[2 * sliceY + 1] + lum_filter[2 * sliceY] == 4096 &&
+   lum_filter[2 * sliceY + 1] <= 4096U &&
+   chr_filter[2 * chrSliceY + 1] + chr_filter[2 * chrSliceY] == 
4096 &&
+   chr_filter[2 * chrSliceY + 1] <= 4096U
+) { // bilinear upscale RGB
 int lumAlpha = lum_filter[2 * sliceY + 1];
 int chrAlpha = chr_filter[2 * sliceY + 1];
 c->lumMmxFilter[2] =
@@ -136,7 +148,14 @@ static int packed_vscale(SwsContext *c, 
SwsFilterDescriptor *desc, int sliceY, i
 ((yuv2packed2_fn)inst->pfn)(c, (const int16_t**)src0, (const 
int16_t**)src1, (const int16_t**)src2, (const int16_t**)src3,
 *dst, dstW, lumAlpha, chrAlpha, sliceY);
 } else { // general RGB
-((yuv2packedX_fn)inst->pfn)(c, lum_filter + sliceY * lum_fsize,
+if ((c->yuv2packed1 && lum_fsize == 1 && chr_fsize == 2) ||
+(c->yuv2packed2 && lum_fsize == 2 && chr_fsize == 2)) {
+if (!c->warned_unuseable_bilinear)
+av_log(c, AV_LOG_INFO, "Optimized 2 tap filter code cannot be 
used\n");
+c->warned_unuseable_bilinear = 1;
+}
+
+inst->yuv2packedX(c, lum_filter + sliceY * lum_fsize,
 (const int16_t**)src0, lum_fsize, chr_filter + sliceY * 
chr_fsize,
 (const int16_t**)src1, (const int16_t**)src2, chr_fsize, 
(const int16_t**)src3, *dst, dstW, sliceY);
 }
@@ -287,8 +306,7 @@ void ff_init_vscale_pfn(SwsContext *c,
 lumCtx->pfn = yuv2packed1;
 else if (c->yuv2packed2 && c->vLumFilterSize == 2 && 
c->vChrFilterSize == 2)
 lumCtx->pfn = yuv2packed2;
-else
-lumCtx->pfn = yuv2packedX;
+lumCtx->yuv2packedX = yuv2packedX;
 } else
 lumCtx->pfn = yuv2anyX;

[FFmpeg-cvslog] swscale: Move VScalerContext into vscale.c

2016-01-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Jan 14 16:49:33 2016 +0100| [7b6e6895f2cbfa90a39874d03e2fac392bcbd33b] | 
committer: Michael Niedermayer

swscale: Move VScalerContext into vscale.c

Signed-off-by: Michael Niedermayer 

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

 libswscale/swscale_internal.h |9 -
 libswscale/vscale.c   |   10 ++
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index b28a233..80c1dc2 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -1004,15 +1004,6 @@ typedef struct FilterContext
 int xInc;
 } FilterContext;
 
-typedef struct VScalerContext
-{
-uint16_t *filter[2];
-int32_t  *filter_pos;
-int filter_size;
-int isMMX;
-void *pfn;
-} VScalerContext;
-
 // warp input lines in the form (src + width*i + j) to slice format 
(line[i][j])
 // relative=true means first line src[x][0] otherwise first line is 
src[x][lum/crh Y]
 int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], int stride[4], int 
srcW, int lumY, int lumH, int chrY, int chrH, int relative);
diff --git a/libswscale/vscale.c b/libswscale/vscale.c
index 3d6e81a..f4b0b67 100644
--- a/libswscale/vscale.c
+++ b/libswscale/vscale.c
@@ -19,6 +19,16 @@
  */
 #include "swscale_internal.h"
 
+typedef struct VScalerContext
+{
+uint16_t *filter[2];
+int32_t  *filter_pos;
+int filter_size;
+int isMMX;
+void *pfn;
+} VScalerContext;
+
+
 static int lum_planar_vscale(SwsContext *c, SwsFilterDescriptor *desc, int 
sliceY, int sliceH)
 {
 VScalerContext *inst = desc->instance;

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


[FFmpeg-cvslog] swscale/slice: Fix indention

2016-01-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Jan 14 17:18:41 2016 +0100| [705a2f70ee148fac26ce642b46850f30f32d3d90] | 
committer: Michael Niedermayer

swscale/slice: Fix indention

Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libswscale/slice.c b/libswscale/slice.c
index 2299eac..66fe413 100644
--- a/libswscale/slice.c
+++ b/libswscale/slice.c
@@ -149,9 +149,9 @@ int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], 
int stride[4], int src
 int i = 0;
 
 const int start[4] = {lumY,
-chrY,
-chrY,
-lumY};
+  chrY,
+  chrY,
+  lumY};
 
 const int end[4] = {lumY +lumH,
 chrY + chrH,
@@ -159,9 +159,9 @@ int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], 
int stride[4], int src
 lumY + lumH};
 
 const uint8_t *src_[4] = {src[0] + (relative ? 0 : start[0]) * stride[0],
- src[1] + (relative ? 0 : start[1]) * stride[0],
- src[2] + (relative ? 0 : start[2]) * stride[0],
- src[3] + (relative ? 0 : start[3]) * stride[0]};
+  src[1] + (relative ? 0 : start[1]) * stride[0],
+  src[2] + (relative ? 0 : start[2]) * stride[0],
+  src[3] + (relative ? 0 : start[3]) * stride[0]};
 
 s->width = srcW;
 

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


[FFmpeg-cvslog] swscale: Move Contexts used only in hscale.c into it

2016-01-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Jan 14 16:51:34 2016 +0100| [e06403331cecae4686a1590793eb5a2c064b2478] | 
committer: Michael Niedermayer

swscale: Move Contexts used only in hscale.c into it

Signed-off-by: Michael Niedermayer 

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

 libswscale/hscale.c   |   15 +++
 libswscale/swscale_internal.h |   15 ---
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/libswscale/hscale.c b/libswscale/hscale.c
index ca09576..9f9d35b 100644
--- a/libswscale/hscale.c
+++ b/libswscale/hscale.c
@@ -20,6 +20,21 @@
 
 #include "swscale_internal.h"
 
+/// Scaler instance data
+typedef struct FilterContext
+{
+uint16_t *filter;
+int *filter_pos;
+int filter_size;
+int xInc;
+} FilterContext;
+
+/// Color conversion instance data
+typedef struct ColorContext
+{
+uint32_t *pal;
+} ColorContext;
+
 static int lum_h_scale(SwsContext *c, SwsFilterDescriptor *desc, int sliceY, 
int sliceH)
 {
 FilterContext *instance = desc->instance;
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 80c1dc2..fa288bd 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -989,21 +989,6 @@ typedef struct SwsFilterDescriptor
 int (*process)(SwsContext *c, struct SwsFilterDescriptor *desc, int 
sliceY, int sliceH);
 } SwsFilterDescriptor;
 
-/// Color conversion instance data
-typedef struct ColorContext
-{
-uint32_t *pal;
-} ColorContext;
-
-/// Scaler instance data
-typedef struct FilterContext
-{
-uint16_t *filter;
-int *filter_pos;
-int filter_size;
-int xInc;
-} FilterContext;
-
 // warp input lines in the form (src + width*i + j) to slice format 
(line[i][j])
 // relative=true means first line src[x][0] otherwise first line is 
src[x][lum/crh Y]
 int ff_init_slice_from_src(SwsSlice * s, uint8_t *src[4], int stride[4], int 
srcW, int lumY, int lumH, int chrY, int chrH, int relative);

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


[FFmpeg-cvslog] swscale/output: Assert that yalpha and uvalpha are within their expected range

2016-01-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Jan 14 18:36:02 2016 +0100| [b99f4987167946872bd7987164445b4d20f35c33] | 
committer: Michael Niedermayer

swscale/output: Assert that yalpha and uvalpha are within their expected range

Signed-off-by: Michael Niedermayer 

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

 libswscale/output.c |   16 
 1 file changed, 16 insertions(+)

diff --git a/libswscale/output.c b/libswscale/output.c
index 4b70626..5811814 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -385,6 +385,7 @@ yuv2mono_2_c_template(SwsContext *c, const int16_t *buf[2],
 const uint8_t * const d128 = ff_dither_8x8_220[y & 7];
 int  yalpha1 = 4096 - yalpha;
 int i;
+av_assert2(yalpha  <= 4096U);
 
 if (c->dither == SWS_DITHER_ED) {
 int err = 0;
@@ -590,6 +591,8 @@ yuv2422_2_c_template(SwsContext *c, const int16_t *buf[2],
 int  yalpha1 = 4096 - yalpha;
 int uvalpha1 = 4096 - uvalpha;
 int i;
+av_assert2(yalpha  <= 4096U);
+av_assert2(uvalpha <= 4096U);
 
 for (i = 0; i < ((dstW + 1) >> 1); i++) {
 int Y1 = (buf0[i * 2] * yalpha1  + buf1[i * 2] * yalpha)  >> 
19;
@@ -777,6 +780,9 @@ yuv2rgba64_2_c_template(SwsContext *c, const int32_t 
*buf[2],
 int i;
 int A1 = 0x<<14, A2 = 0x<<14;
 
+av_assert2(yalpha  <= 4096U);
+av_assert2(uvalpha <= 4096U);
+
 for (i = 0; i < ((dstW + 1) >> 1); i++) {
 int Y1 = (buf0[i * 2] * yalpha1  + buf1[i * 2] * yalpha) >> 14;
 int Y2 = (buf0[i * 2 + 1] * yalpha1  + buf1[i * 2 + 1] * yalpha) >> 14;
@@ -1006,6 +1012,9 @@ yuv2rgba64_full_2_c_template(SwsContext *c, const int32_t 
*buf[2],
 int i;
 int A = 0x<<14;
 
+av_assert2(yalpha  <= 4096U);
+av_assert2(uvalpha <= 4096U);
+
 for (i = 0; i < dstW; i++) {
 int Y  = (buf0[i] * yalpha1  + buf1[i] * yalpha) >> 14;
 int U  = (ubuf0[i]   * uvalpha1 + ubuf1[i] * uvalpha - (128 << 
23)) >> 14;
@@ -1387,6 +1396,8 @@ yuv2rgb_2_c_template(SwsContext *c, const int16_t *buf[2],
 int  yalpha1 = 4096 - yalpha;
 int uvalpha1 = 4096 - uvalpha;
 int i;
+av_assert2(yalpha  <= 4096U);
+av_assert2(uvalpha <= 4096U);
 
 for (i = 0; i < ((dstW + 1) >> 1); i++) {
 int Y1 = (buf0[i * 2] * yalpha1  + buf1[i * 2] * yalpha)  >> 
19;
@@ -1729,6 +1740,9 @@ yuv2rgb_full_2_c_template(SwsContext *c, const int16_t 
*buf[2],
 int err[4] = {0};
 int A = 0; // init to silcene warning
 
+av_assert2(yalpha  <= 4096U);
+av_assert2(uvalpha <= 4096U);
+
 if(   target == AV_PIX_FMT_BGR4_BYTE || target == AV_PIX_FMT_RGB4_BYTE
|| target == AV_PIX_FMT_BGR8  || target == AV_PIX_FMT_RGB8)
 step = 1;
@@ -1956,6 +1970,8 @@ yuv2ya8_2_c(SwsContext *c, const int16_t *buf[2],
 int  yalpha1 = 4096 - yalpha;
 int i;
 
+av_assert2(yalpha  <= 4096U);
+
 for (i = 0; i < dstW; i++) {
 int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 19;
 int A;

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


[FFmpeg-cvslog] lavc/ccaption_dec: flush context on seek

2016-01-14 Thread Aman Gupta
ffmpeg | branch: master | Aman Gupta  | Tue Jan  5 21:46:27 2016 
-0800| [260e3687173b24f20566da1cec4a3b4541d77fca] | committer: Clément Bœsch

lavc/ccaption_dec: flush context on seek

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

 libavcodec/ccaption_dec.c |   19 +++
 1 file changed, 19 insertions(+)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index ca497e5..6cb826c 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -173,6 +173,24 @@ static av_cold int close_decoder(AVCodecContext *avctx)
 return 0;
 }
 
+static void flush_decoder(AVCodecContext *avctx)
+{
+CCaptionSubContext *ctx = avctx->priv_data;
+ctx->screen[0].row_used = 0;
+ctx->screen[1].row_used = 0;
+ctx->prev_cmd[0] = 0;
+ctx->prev_cmd[1] = 0;
+ctx->mode = CCMODE_ROLLUP;
+ctx->rollup = 2;
+ctx->cursor_row = 0;
+ctx->cursor_column = 0;
+ctx->cursor_font = 0;
+ctx->cursor_color = 0;
+ctx->active_screen = 0;
+ctx->buffer_changed = 0;
+av_bprint_clear(&ctx->buffer);
+}
+
 /**
  * @param ctx closed caption context just to print log
  */
@@ -578,6 +596,7 @@ AVCodec ff_ccaption_decoder = {
 .priv_data_size = sizeof(CCaptionSubContext),
 .init   = init_decoder,
 .close  = close_decoder,
+.flush  = flush_decoder,
 .decode = decode,
 .priv_class = &ccaption_dec_class,
 };

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


[FFmpeg-cvslog] avfilter/vf_fftfilt: this is video filter so use pixels instead of samples

2016-01-14 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Thu Jan 14 22:20:25 
2016 +0100| [d6f1abe9ce08279e6e3f90a80724fcef7a2ab673] | committer: Paul B Mahol

avfilter/vf_fftfilt: this is video filter so use pixels instead of samples

Signed-off-by: Paul B Mahol 

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

 libavfilter/vf_fftfilt.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c
index bc493e3..8cbfa35 100644
--- a/libavfilter/vf_fftfilt.c
+++ b/libavfilter/vf_fftfilt.c
@@ -335,7 +335,7 @@ static const AVFilterPad fftfilt_outputs[] = {
 
 AVFilter ff_vf_fftfilt = {
 .name= "fftfilt",
-.description = NULL_IF_CONFIG_SMALL("Apply arbitrary expressions to 
samples in frequency domain."),
+.description = NULL_IF_CONFIG_SMALL("Apply arbitrary expressions to 
pixels in frequency domain."),
 .priv_size   = sizeof(FFTFILTContext),
 .priv_class  = &fftfilt_class,
 .inputs  = fftfilt_inputs,

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


[FFmpeg-cvslog] avfilter/vf_fftfilt: use the name 's' for the pointer to the private context

2016-01-14 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Thu Jan 14 22:19:52 
2016 +0100| [2bbc7e9625f2cceb0adad95f8d8b9bbf15881dd4] | committer: Paul B Mahol

avfilter/vf_fftfilt: use the name 's' for the pointer to the private context

Signed-off-by: Paul B Mahol 

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

 libavfilter/vf_fftfilt.c |  144 +++---
 1 file changed, 72 insertions(+), 72 deletions(-)

diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c
index 915de02..bc493e3 100644
--- a/libavfilter/vf_fftfilt.c
+++ b/libavfilter/vf_fftfilt.c
@@ -73,8 +73,8 @@ AVFILTER_DEFINE_CLASS(fftfilt);
 
 static inline double lum(void *priv, double x, double y, int plane)
 {
-FFTFILTContext *fftfilt = priv;
-return fftfilt->rdft_vdata[plane][(int)x * fftfilt->rdft_vlen[plane] + 
(int)y];
+FFTFILTContext *s = priv;
+return s->rdft_vdata[plane][(int)x * s->rdft_vlen[plane] + (int)y];
 }
 
 static double weight_Y(void *priv, double x, double y) { return lum(priv, x, 
y, Y); }
@@ -93,95 +93,95 @@ static void copy_rev (FFTSample *dest, int w, int w2)
 }
 
 /*Horizontal pass - RDFT*/
-static void rdft_horizontal(FFTFILTContext *fftfilt, AVFrame *in, int w, int 
h, int plane)
+static void rdft_horizontal(FFTFILTContext *s, AVFrame *in, int w, int h, int 
plane)
 {
 int i, j;
-fftfilt->rdft = av_rdft_init(fftfilt->rdft_hbits[plane], DFT_R2C);
+s->rdft = av_rdft_init(s->rdft_hbits[plane], DFT_R2C);
 
 for (i = 0; i < h; i++) {
 for (j = 0; j < w; j++)
-fftfilt->rdft_hdata[plane][i * fftfilt->rdft_hlen[plane] + j] = 
*(in->data[plane] + in->linesize[plane] * i + j);
+s->rdft_hdata[plane][i * s->rdft_hlen[plane] + j] = 
*(in->data[plane] + in->linesize[plane] * i + j);
 
-copy_rev(fftfilt->rdft_hdata[plane] + i * fftfilt->rdft_hlen[plane], 
w, fftfilt->rdft_hlen[plane]);
+copy_rev(s->rdft_hdata[plane] + i * s->rdft_hlen[plane], w, 
s->rdft_hlen[plane]);
 }
 
 for (i = 0; i < h; i++)
-av_rdft_calc(fftfilt->rdft, fftfilt->rdft_hdata[plane] + i * 
fftfilt->rdft_hlen[plane]);
+av_rdft_calc(s->rdft, s->rdft_hdata[plane] + i * s->rdft_hlen[plane]);
 
-av_rdft_end(fftfilt->rdft);
+av_rdft_end(s->rdft);
 }
 
 /*Vertical pass - RDFT*/
-static void rdft_vertical(FFTFILTContext *fftfilt, int h, int plane)
+static void rdft_vertical(FFTFILTContext *s, int h, int plane)
 {
 int i, j;
-fftfilt->rdft = av_rdft_init(fftfilt->rdft_vbits[plane], DFT_R2C);
+s->rdft = av_rdft_init(s->rdft_vbits[plane], DFT_R2C);
 
-for (i = 0; i < fftfilt->rdft_hlen[plane]; i++) {
+for (i = 0; i < s->rdft_hlen[plane]; i++) {
 for (j = 0; j < h; j++)
-fftfilt->rdft_vdata[plane][i * fftfilt->rdft_vlen[plane] + j] =
-fftfilt->rdft_hdata[plane][j * fftfilt->rdft_hlen[plane] + i];
-copy_rev(fftfilt->rdft_vdata[plane] + i * fftfilt->rdft_vlen[plane], 
h, fftfilt->rdft_vlen[plane]);
+s->rdft_vdata[plane][i * s->rdft_vlen[plane] + j] =
+s->rdft_hdata[plane][j * s->rdft_hlen[plane] + i];
+copy_rev(s->rdft_vdata[plane] + i * s->rdft_vlen[plane], h, 
s->rdft_vlen[plane]);
 }
 
-for (i = 0; i < fftfilt->rdft_hlen[plane]; i++)
-av_rdft_calc(fftfilt->rdft, fftfilt->rdft_vdata[plane] + i * 
fftfilt->rdft_vlen[plane]);
+for (i = 0; i < s->rdft_hlen[plane]; i++)
+av_rdft_calc(s->rdft, s->rdft_vdata[plane] + i * s->rdft_vlen[plane]);
 
-av_rdft_end(fftfilt->rdft);
+av_rdft_end(s->rdft);
 }
 /*Vertical pass - IRDFT*/
-static void irdft_vertical(FFTFILTContext *fftfilt, int h, int plane)
+static void irdft_vertical(FFTFILTContext *s, int h, int plane)
 {
 int i, j;
-fftfilt->rdft = av_rdft_init(fftfilt->rdft_vbits[plane], IDFT_C2R);
-for (i = 0; i < fftfilt->rdft_hlen[plane]; i++)
-av_rdft_calc(fftfilt->rdft, fftfilt->rdft_vdata[plane] + i * 
fftfilt->rdft_vlen[plane]);
+s->rdft = av_rdft_init(s->rdft_vbits[plane], IDFT_C2R);
+for (i = 0; i < s->rdft_hlen[plane]; i++)
+av_rdft_calc(s->rdft, s->rdft_vdata[plane] + i * s->rdft_vlen[plane]);
 
-for (i = 0; i < fftfilt->rdft_hlen[plane]; i++)
+for (i = 0; i < s->rdft_hlen[plane]; i++)
 for (j = 0; j < h; j++)
-fftfilt->rdft_hdata[plane][j * fftfilt->rdft_hlen[plane] + i] =
-fftfilt->rdft_vdata[plane][i * fftfilt->rdft_vlen[plane] + j];
+s->rdft_hdata[plane][j * s->rdft_hlen[plane] + i] =
+s->rdft_vdata[plane][i * s->rdft_vlen[plane] + j];
 
-av_rdft_end(fftfilt->rdft);
+av_rdft_end(s->rdft);
 }
 
 /*Horizontal pass - IRDFT*/
-static void irdft_horizontal(FFTFILTContext *fftfilt, AVFrame *out, int w, int 
h, int plane)
+static void irdft_horizontal(FFTFILTContext *s, AVFrame *out, int w, int h, 
int plane)
 {
 int i, j;
-fftfilt->rdft = av_rdft_init(fftfilt->rdft_hbits[plane], IDFT_C2R);
+   

[FFmpeg-cvslog] lavc/ccaption_dec: implement real_time option

2016-01-14 Thread Aman Gupta
ffmpeg | branch: master | Aman Gupta  | Fri Jan  8 19:01:22 2016 
-0800| [5c041e21e09321f0be729364eb70411b6ce1] | committer: Clément Bœsch

lavc/ccaption_dec: implement real_time option

This new mode is useful for realtime decoding of closed captions so they
can be display along with mpeg2 frames.

Closed caption streams contain two major types of captions:

- POPON captions, which are buffered off-screen and displayed
  only after EOC (end of caption, aka display buffer)

- PAINTON/ROLLUP captions, which are written to the display as soon as
  they arrive.

In a typical real-time eia608 decoder, commands like EOC (end of
caption; display buffer), EDM (erase display memory) and EBM (erase
buffered memory) perform their expected functions as soon as the
commands are processed. This is implemented in the real_time branches
added in this commit.

Before this commit, and in the !real_time branches after this commit,
the decoder cleverly implements its own version of the decoder which is
specifically geared towards buffered decoding. It does so by actively
ignoring commands like EBM (erase buffered memory), and then re-using
the non-display buffer to hold the previous caption while the new one is
received. This is the opposite of the real-time decoder, which uses the
non-display buffer to hold the new caption while the display buffer is
still showing the current caption.

In addition to ignoring EBM, the buffered decoder also has custom
implementations for EDM and EOC. An EDM (erase display memory) command
flushes the existing contents before clearing the screen, and EOC
similarly always flushes the active buffer (the previous subtitle)
before flipping buffers.

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

 libavcodec/ccaption_dec.c |   82 -
 1 file changed, 74 insertions(+), 8 deletions(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index 6cb826c..ca08d48 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -116,6 +116,7 @@ struct Screen {
 
 typedef struct CCaptionSubContext {
 AVClass *class;
+int real_time;
 struct Screen screen[2];
 int active_screen;
 uint8_t cursor_row;
@@ -130,6 +131,8 @@ typedef struct CCaptionSubContext {
 /* visible screen time */
 int64_t startv_time;
 int64_t end_time;
+int screen_touched;
+int64_t last_real_time;
 char prev_cmd[2];
 /* buffer to store pkt data */
 AVBufferRef *pktbuf;
@@ -187,6 +190,8 @@ static void flush_decoder(AVCodecContext *avctx)
 ctx->cursor_font = 0;
 ctx->cursor_color = 0;
 ctx->active_screen = 0;
+ctx->last_real_time = 0;
+ctx->screen_touched = 0;
 ctx->buffer_changed = 0;
 av_bprint_clear(&ctx->buffer);
 }
@@ -426,15 +431,33 @@ static void handle_edm(CCaptionSubContext *ctx, int64_t 
pts)
 {
 struct Screen *screen = ctx->screen + ctx->active_screen;
 
-reap_screen(ctx, pts);
+// In buffered mode, keep writing to screen until it is wiped.
+// Before wiping the display, capture contents to emit subtitle.
+if (!ctx->real_time)
+reap_screen(ctx, pts);
+
 screen->row_used = 0;
+
+// In realtime mode, emit an empty caption so the last one doesn't
+// stay on the screen.
+if (ctx->real_time)
+reap_screen(ctx, pts);
 }
 
 static void handle_eoc(CCaptionSubContext *ctx, int64_t pts)
 {
-handle_edm(ctx,pts);
+// In buffered mode, we wait til the *next* EOC and
+// reap what was already on the screen since the last EOC.
+if (!ctx->real_time)
+handle_edm(ctx,pts);
+
 ctx->active_screen = !ctx->active_screen;
 ctx->cursor_column = 0;
+
+// In realtime mode, we display the buffered contents (after
+// flipping the buffer to active above) as soon as EOC arrives.
+if (ctx->real_time)
+reap_screen(ctx, pts);
 }
 
 static void handle_delete_end_of_row(CCaptionSubContext *ctx, char hi, char lo)
@@ -456,6 +479,9 @@ static void handle_char(CCaptionSubContext *ctx, char hi, 
char lo, int64_t pts)
 }
 write_char(ctx, screen, 0);
 
+if (ctx->mode != CCMODE_POPON)
+ctx->screen_touched = 1;
+
 /* reset prev command since character can repeat */
 ctx->prev_cmd[0] = 0;
 ctx->prev_cmd[1] = 0;
@@ -505,10 +531,20 @@ static void process_cc608(CCaptionSubContext *ctx, 
int64_t pts, uint8_t hi, uint
 case 0x2d:
 /* carriage return */
 ff_dlog(ctx, "carriage return\n");
-reap_screen(ctx, pts);
+if (!ctx->real_time)
+reap_screen(ctx, pts);
 roll_up(ctx);
 ctx->cursor_column = 0;
 break;
+case 0x2e:
+/* erase buffered (non displayed) memory */
+// Only in realtime mode. In buffered mode, we re-use the inactive 
screen
+// for our own buffering.
+if (ctx->real_time)

[FFmpeg-cvslog] fate: add test for realtime ccaption decoder

2016-01-14 Thread Aman Gupta
ffmpeg | branch: master | Aman Gupta  | Tue Jan 12 17:22:30 2016 
-0800| [fdbe5cd5c5234772f1b7624a790439924a91ced2] | committer: Clément Bœsch

fate: add test for realtime ccaption decoder

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

 tests/fate/subtitles.mak   |3 +++
 tests/ref/fate/sub-cc-realtime |   42 
 2 files changed, 45 insertions(+)

diff --git a/tests/fate/subtitles.mak b/tests/fate/subtitles.mak
index d273f2e..8aa0279 100644
--- a/tests/fate/subtitles.mak
+++ b/tests/fate/subtitles.mak
@@ -4,6 +4,9 @@ fate-sub-aqtitle: CMD = fmtstdout ass -sub_charenc windows-1250 
-i $(TARGET_SAMP
 FATE_SUBTITLES_ASS-$(call ALLYES, AVDEVICE LAVFI_INDEV CCAPTION_DECODER 
MOVIE_FILTER MPEGTS_DEMUXER) += fate-sub-cc
 fate-sub-cc: CMD = fmtstdout ass -f lavfi -i 
"movie=$(TARGET_SAMPLES)/sub/Closedcaption_rollup.m2v[out0+subcc]"
 
+FATE_SUBTITLES_ASS-$(call ALLYES, AVDEVICE LAVFI_INDEV CCAPTION_DECODER 
MOVIE_FILTER MPEGTS_DEMUXER) += fate-sub-cc-realtime
+fate-sub-cc-realtime: CMD = fmtstdout ass -real_time 1 -f lavfi -i 
"movie=$(TARGET_SAMPLES)/sub/Closedcaption_rollup.m2v[out0+subcc]"
+
 FATE_SUBTITLES_ASS-$(call DEMDEC, ASS, ASS) += fate-sub-ass-to-ass-transcode
 fate-sub-ass-to-ass-transcode: CMD = fmtstdout ass -i 
$(TARGET_SAMPLES)/sub/1ededcbd7b.ass
 
diff --git a/tests/ref/fate/sub-cc-realtime b/tests/ref/fate/sub-cc-realtime
new file mode 100644
index 000..c9e6b6c
--- /dev/null
+++ b/tests/ref/fate/sub-cc-realtime
@@ -0,0 +1,42 @@
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, 
OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, 
Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, 
MarginV, Encoding
+Style: 
Default,Monospace,16,&Hff,&Hff,&H0,&H0,0,0,0,0,100,100,0,0,3,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:00:14.14,9:59:59.99,Default,,0,0,0,,(
+Dialogue: 0,0:00:15.47,9:59:59.99,Default,,0,0,0,,({\i1} in
+Dialogue: 0,0:00:15.92,9:59:59.99,Default,,0,0,0,,({\i1} inau
+Dialogue: 0,0:00:16.36,9:59:59.99,Default,,0,0,0,,({\i1} inaudi
+Dialogue: 0,0:00:16.81,9:59:59.99,Default,,0,0,0,,({\i1} inaudibl
+Dialogue: 0,0:00:17.25,9:59:59.99,Default,,0,0,0,,({\i1} inaudible 
+Dialogue: 0,0:00:17.70,9:59:59.99,Default,,0,0,0,,({\i1} inaudible ra
+Dialogue: 0,0:00:18.14,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radi
+Dialogue: 0,0:00:18.59,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
+Dialogue: 0,0:00:19.03,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio ch
+Dialogue: 0,0:00:19.48,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio chat
+Dialogue: 0,0:00:19.92,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio chatte
+Dialogue: 0,0:00:20.36,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter
+Dialogue: 0,0:00:21.70,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )
+Dialogue: 0,0:00:42.61,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>>
+Dialogue: 0,0:00:43.05,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> S
+Dialogue: 0,0:00:43.50,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Saf
+Dialogue: 0,0:00:43.94,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safet
+Dialogue: 0,0:00:44.39,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety 
+Dialogue: 0,0:00:44.83,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety re
+Dialogue: 0,0:00:45.28,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety rema
+Dialogue: 0,0:00:45.72,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remain
+Dialogue: 0,0:00:46.17,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains 
+Dialogue: 0,0:00:46.61,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains ou
+Dialogue: 0,0:00:47.06,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our 
+Dialogue: 0,0:00:47.50,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our nu
+Dialogue: 0,0:00:47.95,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our numb
+Dialogue: 0,0:00:48.39,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our number
+Dialogue: 0,0:00:48.84,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our number o
+Dialogue: 0,0:00:49.28,9:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our number one

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

[FFmpeg-cvslog] lavc/ccaption_dec: clean up whitespace

2016-01-14 Thread Aman Gupta
ffmpeg | branch: master | Aman Gupta  | Thu Jan 14 13:55:07 2016 
-0800| [9027806e3cf6b8d2693f74c57abfd88c8c2a9008] | committer: Clément Bœsch

lavc/ccaption_dec: clean up whitespace

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

 libavcodec/ccaption_dec.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index ca08d48..3e33580 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -297,7 +297,6 @@ static void roll_up(CCaptionSubContext *ctx)
 for (i = 0; i < ctx->cursor_row - keep_lines; i++)
 UNSET_FLAG(screen->row_used, i);
 
-
 for (i = 0; i < keep_lines && screen->row_used; i++) {
 const int i_row = ctx->cursor_row - keep_lines + i + 1;
 
@@ -306,8 +305,8 @@ static void roll_up(CCaptionSubContext *ctx)
 memcpy(screen->fonts[i_row], screen->fonts[i_row+1], SCREEN_COLUMNS);
 if (CHECK_FLAG(screen->row_used, i_row + 1))
 SET_FLAG(screen->row_used, i_row);
-
 }
+
 UNSET_FLAG(screen->row_used, ctx->cursor_row);
 }
 

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


[FFmpeg-cvslog] lavc/ccaption_dec: clear all unused rows during rollup

2016-01-14 Thread Aman Gupta
ffmpeg | branch: master | Aman Gupta  | Tue Jan 12 17:27:06 2016 
-0800| [3a0e5cfcee5bcbf60e3830da0d03041de3f1e5f5] | committer: Clément Bœsch

lavc/ccaption_dec: clear all unused rows during rollup

Sometimes rollup captions can move around the screen. This fixes "ghost"
captions from below the current rollup area from continuing to be
captured when a rollup moves higher up on the screen.

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

 libavcodec/ccaption_dec.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index 3e33580..330ea6a 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -294,8 +294,11 @@ static void roll_up(CCaptionSubContext *ctx)
  */
 keep_lines = FFMIN(ctx->cursor_row + 1, ctx->rollup);
 
-for (i = 0; i < ctx->cursor_row - keep_lines; i++)
+for (i = 0; i < SCREEN_ROWS; i++) {
+if (i > ctx->cursor_row - keep_lines && i <= ctx->cursor_row)
+continue;
 UNSET_FLAG(screen->row_used, i);
+}
 
 for (i = 0; i < keep_lines && screen->row_used; i++) {
 const int i_row = ctx->cursor_row - keep_lines + i + 1;

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


[FFmpeg-cvslog] swscale/vscale: Use matching sliceY/chrSliceY for luma/chroma

2016-01-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Jan 14 22:10:08 2016 +0100| [fc2588a1d6cbb17f15e05f585c92a3be734bcc5a] | 
committer: Michael Niedermayer

swscale/vscale: Use matching sliceY/chrSliceY for luma/chroma

No case known where that makes a difference

Signed-off-by: Michael Niedermayer 

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

 libswscale/vscale.c |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libswscale/vscale.c b/libswscale/vscale.c
index 308a080..39e1eec 100644
--- a/libswscale/vscale.c
+++ b/libswscale/vscale.c
@@ -109,7 +109,7 @@ static int packed_vscale(SwsContext *c, SwsFilterDescriptor 
*desc, int sliceY, i
 uint16_t *lum_filter = inst[0].filter[0];
 uint16_t *chr_filter = inst[1].filter[0];
 
-int firstLum = FFMAX(1-lum_fsize, inst[0].filter_pos[chrSliceY]);
+int firstLum = FFMAX(1-lum_fsize, inst[0].filter_pos[   sliceY]);
 int firstChr = FFMAX(1-chr_fsize, inst[1].filter_pos[chrSliceY]);
 
 int sp0 = firstLum - desc->src->plane[0].sliceY;
@@ -128,9 +128,9 @@ static int packed_vscale(SwsContext *c, SwsFilterDescriptor 
*desc, int sliceY, i
 ((yuv2packed1_fn)inst->pfn)(c, (const int16_t*)*src0, (const 
int16_t**)src1, (const int16_t**)src2,
 (const int16_t*)(desc->alpha ? *src3 : 
NULL),  *dst, dstW, 0, sliceY);
 } else if (c->yuv2packed1 && lum_fsize == 1 && chr_fsize == 2 &&
-   chr_filter[2 * sliceY + 1] + chr_filter[2 * chrSliceY] == 4096 
&&
-   chr_filter[2 * sliceY + 1] <= 4096U) { // unscaled RGB
-int chrAlpha = chr_filter[2 * sliceY + 1];
+   chr_filter[2 * chrSliceY + 1] + chr_filter[2 * chrSliceY] == 
4096 &&
+   chr_filter[2 * chrSliceY + 1] <= 4096U) { // unscaled RGB
+int chrAlpha = chr_filter[2 * chrSliceY + 1];
 ((yuv2packed1_fn)inst->pfn)(c, (const int16_t*)*src0, (const 
int16_t**)src1, (const int16_t**)src2,
 (const int16_t*)(desc->alpha ? *src3 : 
NULL),  *dst, dstW, chrAlpha, sliceY);
 } else if (c->yuv2packed2 && lum_fsize == 2 && chr_fsize == 2 &&
@@ -140,7 +140,7 @@ static int packed_vscale(SwsContext *c, SwsFilterDescriptor 
*desc, int sliceY, i
chr_filter[2 * chrSliceY + 1] <= 4096U
 ) { // bilinear upscale RGB
 int lumAlpha = lum_filter[2 * sliceY + 1];
-int chrAlpha = chr_filter[2 * sliceY + 1];
+int chrAlpha = chr_filter[2 * chrSliceY + 1];
 c->lumMmxFilter[2] =
 c->lumMmxFilter[3] = lum_filter[2 * sliceY]* 0x10001;
 c->chrMmxFilter[2] =
@@ -156,7 +156,7 @@ static int packed_vscale(SwsContext *c, SwsFilterDescriptor 
*desc, int sliceY, i
 }
 
 inst->yuv2packedX(c, lum_filter + sliceY * lum_fsize,
-(const int16_t**)src0, lum_fsize, chr_filter + sliceY * 
chr_fsize,
+(const int16_t**)src0, lum_fsize, chr_filter + chrSliceY * 
chr_fsize,
 (const int16_t**)src1, (const int16_t**)src2, chr_fsize, 
(const int16_t**)src3, *dst, dstW, sliceY);
 }
 return 1;
@@ -173,7 +173,7 @@ static int any_vscale(SwsContext *c, SwsFilterDescriptor 
*desc, int sliceY, int
 uint16_t *lum_filter = inst[0].filter[0];
 uint16_t *chr_filter = inst[1].filter[0];
 
-int firstLum = FFMAX(1-lum_fsize, inst[0].filter_pos[chrSliceY]);
+int firstLum = FFMAX(1-lum_fsize, inst[0].filter_pos[   sliceY]);
 int firstChr = FFMAX(1-chr_fsize, inst[1].filter_pos[chrSliceY]);
 
 int sp0 = firstLum - desc->src->plane[0].sliceY;

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


[FFmpeg-cvslog] avformat/rmdec: Check size in ivr_read_packet() before use

2016-01-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Jan 14 23:20:58 2016 +0100| [80fd348bb7d9ee55c3100da87795f3a5bcbdfb32] | 
committer: Michael Niedermayer

avformat/rmdec: Check size in ivr_read_packet() before use

Fixes out of array access
Fixes: asan_heap-oob_445b39_1741_d00eb645ab48eb2203b4a04a5b997103.ivr

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

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

 libavformat/rmdec.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index 4e46a3d..ad919e8 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -1357,6 +1357,11 @@ static int ivr_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 size = avio_rb32(pb);
 avio_skip(pb, 4);
 
+if (size < 1 || size > INT_MAX/4) {
+av_log(s, AV_LOG_ERROR, "size %d is invalid\n");
+return AVERROR_INVALIDDATA;
+}
+
 st = s->streams[index];
 ret = ff_rm_parse_packet(s, pb, st, st->priv_data, size, pkt,
  &seq, 0, pts);

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


[FFmpeg-cvslog] avformat/rmdec: Fix Packet memleak at close()

2016-01-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Jan 14 23:32:13 2016 +0100| [c3a24006d552d02a23f8adbbc475c0f09318a378] | 
committer: Michael Niedermayer

avformat/rmdec: Fix Packet memleak at close()

Fixes: asan_heap-oob_445b39_1741_d00eb645ab48eb2203b4a04a5b997103.ivr

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

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

 libavformat/rmdec.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index ad919e8..0867485 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -1399,5 +1399,6 @@ AVInputFormat ff_ivr_demuxer = {
 .read_probe = ivr_probe,
 .read_header= ivr_read_header,
 .read_packet= ivr_read_packet,
+.read_close = rm_read_close,
 .extensions = "ivr",
 };

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


[FFmpeg-cvslog] lavc/aacenc: use isfinite to simplify isnan/isinf logic

2016-01-14 Thread Ganesh Ajjanagadde
ffmpeg | branch: master | Ganesh Ajjanagadde  | Thu Jan 
14 17:55:56 2016 -0500| [2e4fd16f5b9084b86e6872fddc365d0528383259] | committer: 
Ganesh Ajjanagadde

lavc/aacenc: use isfinite to simplify isnan/isinf logic

Reviewed-by: Claudio Freire 
Signed-off-by: Ganesh Ajjanagadde 

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

 libavcodec/aacenc.c |   17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 9a7d3a8..2e0db7d 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -29,6 +29,7 @@
  * add sane pulse detection
  ***/
 
+#include "libavutil/libm.h"
 #include "libavutil/thread.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/opt.h"
@@ -606,14 +607,14 @@ static int aac_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 s->mdct1024.mdct_calc(&s->mdct1024, sce->lcoeffs, 
sce->ret_buf);
 }
 
-if (isnan(cpe->ch->coeffs[0]) || isinf(cpe->ch->coeffs[0]) 
||
-isnan(cpe->ch->coeffs[  128]) || isinf(cpe->ch->coeffs[  128]) 
||
-isnan(cpe->ch->coeffs[2*128]) || isinf(cpe->ch->coeffs[2*128]) 
||
-isnan(cpe->ch->coeffs[3*128]) || isinf(cpe->ch->coeffs[3*128]) 
||
-isnan(cpe->ch->coeffs[4*128]) || isinf(cpe->ch->coeffs[4*128]) 
||
-isnan(cpe->ch->coeffs[5*128]) || isinf(cpe->ch->coeffs[5*128]) 
||
-isnan(cpe->ch->coeffs[6*128]) || isinf(cpe->ch->coeffs[6*128]) 
||
-isnan(cpe->ch->coeffs[7*128]) || isinf(cpe->ch->coeffs[7*128])
+if (!(isfinite(cpe->ch->coeffs[0]) &&
+  isfinite(cpe->ch->coeffs[  128]) &&
+  isfinite(cpe->ch->coeffs[2*128]) &&
+  isfinite(cpe->ch->coeffs[3*128]) &&
+  isfinite(cpe->ch->coeffs[4*128]) &&
+  isfinite(cpe->ch->coeffs[5*128]) &&
+  isfinite(cpe->ch->coeffs[6*128]) &&
+  isfinite(cpe->ch->coeffs[7*128]))
 ) {
 av_log(avctx, AV_LOG_ERROR, "Input contains NaN/+-Inf\n");
 return AVERROR(EINVAL);

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


[FFmpeg-cvslog] lavu: prevent overflow in av_clip_intp2_c

2016-01-14 Thread Andreas Cadhalpun
ffmpeg | branch: master | Andreas Cadhalpun  
| Thu Jan 14 01:15:22 2016 +0100| [f8bc0137bdf8da8806ef75d30bb749fcc301bb35] | 
committer: Andreas Cadhalpun

lavu: prevent overflow in av_clip_intp2_c

This fixes ubsan runtime error: signed integer overflow: 8388608 +
2140274688 cannot be represented in type 'int'

Reviewed-by: Michael Niedermayer 
Signed-off-by: Andreas Cadhalpun 

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

 libavutil/common.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/common.h b/libavutil/common.h
index f9766ad..7b7bcbe 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -211,7 +211,7 @@ static av_always_inline av_const int32_t 
av_clipl_int32_c(int64_t a)
  */
 static av_always_inline av_const int av_clip_intp2_c(int a, int p)
 {
-if ((a + (1 << p)) & ~((2 << p) - 1))
+if (((unsigned)a + (1 << p)) & ~((2 << p) - 1))
 return (a >> 31) ^ ((1 << p) - 1);
 else
 return a;

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


[FFmpeg-cvslog] asfdec_o: break if EOF is reached after asf_read_packet_header

2016-01-14 Thread Andreas Cadhalpun
ffmpeg | branch: master | Andreas Cadhalpun  
| Wed Jan  6 18:44:33 2016 +0100| [0e32153e9c296366e004352ecb3f9fcea74dc17d] | 
committer: Andreas Cadhalpun

asfdec_o: break if EOF is reached after asf_read_packet_header

asf_read_payload can unset eof_reached, so check it also before calling
that function.

This fixes infinite loops.

Reviewed-by: Alexandra Hájková 
Signed-off-by: Andreas Cadhalpun 

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

 libavformat/asfdec_o.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c
index 4a3c815..ca4a066 100644
--- a/libavformat/asfdec_o.c
+++ b/libavformat/asfdec_o.c
@@ -1434,6 +1434,8 @@ static int asf_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 while (!pb->eof_reached) {
 if (asf->state == PARSE_PACKET_HEADER) {
 asf_read_packet_header(s);
+if (pb->eof_reached)
+break;
 if (!asf->nb_mult_left)
 asf->state = READ_SINGLE;
 else

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


[FFmpeg-cvslog] asfdec_o: make sure packet_size is non-zero before seeking

2016-01-14 Thread Andreas Cadhalpun
ffmpeg | branch: master | Andreas Cadhalpun  
| Wed Jan  6 19:03:17 2016 +0100| [3776a72962b0622af17c4aef89a831da2cbaceca] | 
committer: Andreas Cadhalpun

asfdec_o: make sure packet_size is non-zero before seeking

This fixes infinite loops due to seeking back.

Reviewed-by: Alexandra Hájková 
Signed-off-by: Andreas Cadhalpun 

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

 libavformat/asfdec_o.c |4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c
index b81519f..4a3c815 100644
--- a/libavformat/asfdec_o.c
+++ b/libavformat/asfdec_o.c
@@ -1287,6 +1287,10 @@ static int asf_read_payload(AVFormatContext *s, AVPacket 
*pkt)
 }
 if (!asf_pkt) {
 if (asf->packet_offset + asf->packet_size <= asf->data_offset + 
asf->data_size) {
+if (!asf->packet_size) {
+av_log(s, AV_LOG_ERROR, "Invalid packet size 0.\n");
+return AVERROR_INVALIDDATA;
+}
 avio_seek(pb, asf->packet_offset + asf->packet_size, SEEK_SET);
 av_log(s, AV_LOG_WARNING, "Skipping the stream with the 
invalid stream index %d.\n",
asf->stream_index);

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


[FFmpeg-cvslog] asfdec_o: check for too small size in asf_read_unknown

2016-01-14 Thread Andreas Cadhalpun
ffmpeg | branch: master | Andreas Cadhalpun  
| Wed Jan  6 19:21:49 2016 +0100| [c29e87ad55a2be29cc8ac5c0e047512c1f5d34d4] | 
committer: Andreas Cadhalpun

asfdec_o: check for too small size in asf_read_unknown

This fixes infinite loops due to seeking back.

Reviewed-by: Alexandra Hájková 
Signed-off-by: Andreas Cadhalpun 

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

 libavformat/asfdec_o.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c
index ca4a066..bc79f10 100644
--- a/libavformat/asfdec_o.c
+++ b/libavformat/asfdec_o.c
@@ -190,8 +190,13 @@ static int asf_read_unknown(AVFormatContext *s, const 
GUIDParseTable *g)
 if ((ret = detect_unknown_subobject(s, asf->unknown_offset,
 asf->unknown_size)) < 0)
 return ret;
-} else
+} else {
+if (size < 24) {
+av_log(s, AV_LOG_ERROR, "Too small size %"PRIu64" (< 24).\n", 
size);
+return AVERROR_INVALIDDATA;
+}
 avio_skip(pb, size - 24);
+}
 
 return 0;
 }

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


[FFmpeg-cvslog] asfdec_o: check avio_skip in asf_read_simple_index

2016-01-14 Thread Andreas Cadhalpun
ffmpeg | branch: master | Andreas Cadhalpun  
| Wed Jan  6 13:54:59 2016 +0100| [0002d845e873af4fd00f0519e0248b07d65bef5f] | 
committer: Andreas Cadhalpun

asfdec_o: check avio_skip in asf_read_simple_index

The loop can be very long, even though the file is very short.

Reviewed-by: Alexandra Hájková 
Signed-off-by: Andreas Cadhalpun 

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

 libavformat/asfdec_o.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c
index 02809bb..bc168d3 100644
--- a/libavformat/asfdec_o.c
+++ b/libavformat/asfdec_o.c
@@ -970,7 +970,7 @@ static int asf_read_simple_index(AVFormatContext *s, const 
GUIDParseTable *g)
 uint64_t interval; // index entry time interval in 100 ns units, usually 
it's 1s
 uint32_t pkt_num, nb_entries;
 int32_t prev_pkt_num = -1;
-int i;
+int i, ret;
 uint64_t size = avio_rl64(pb);
 
 // simple index objects should be ordered by stream number, this loop 
tries to find
@@ -992,7 +992,11 @@ static int asf_read_simple_index(AVFormatContext *s, const 
GUIDParseTable *g)
 nb_entries = avio_rl32(pb);
 for (i = 0; i < nb_entries; i++) {
 pkt_num = avio_rl32(pb);
-avio_skip(pb, 2);
+ret = avio_skip(pb, 2);
+if (ret < 0) {
+av_log(s, AV_LOG_ERROR, "Skipping failed in 
asf_read_simple_index.\n");
+return ret;
+}
 if (prev_pkt_num != pkt_num) {
 av_add_index_entry(st, asf->first_packet_offset + asf->packet_size 
*
pkt_num, av_rescale(interval, i, 1),

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


[FFmpeg-cvslog] asfdec_o: only set asf_pkt->data_size after sanity checks

2016-01-14 Thread Andreas Cadhalpun
ffmpeg | branch: master | Andreas Cadhalpun  
| Tue Jan  5 13:06:51 2016 +0100| [763c572801a3db1cc7a2f07a52fee9d2e35ec95a] | 
committer: Andreas Cadhalpun

asfdec_o: only set asf_pkt->data_size after sanity checks

Otherwise invalid values are used unchecked in the next run.
This can cause NULL pointer dereferencing.

Reviewed-by: Alexandra Hájková 
Signed-off-by: Andreas Cadhalpun 

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

 libavformat/asfdec_o.c |   18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c
index 38751d7..79b9ee4 100644
--- a/libavformat/asfdec_o.c
+++ b/libavformat/asfdec_o.c
@@ -1136,14 +1136,15 @@ static int asf_read_replicated_data(AVFormatContext *s, 
ASFPacket *asf_pkt)
 {
 ASFContext *asf = s->priv_data;
 AVIOContext *pb = s->pb;
-int ret;
+int ret, data_size;
 
 if (!asf_pkt->data_size) {
-asf_pkt->data_size = asf_pkt->size_left = avio_rl32(pb); // read media 
object size
-if (asf_pkt->data_size <= 0)
+data_size = avio_rl32(pb); // read media object size
+if (data_size <= 0)
 return AVERROR_INVALIDDATA;
-if ((ret = av_new_packet(&asf_pkt->avpkt, asf_pkt->data_size)) < 0)
+if ((ret = av_new_packet(&asf_pkt->avpkt, data_size)) < 0)
 return ret;
+asf_pkt->data_size = asf_pkt->size_left = data_size;
 } else
 avio_skip(pb, 4); // reading of media object size is already done
 asf_pkt->dts = avio_rl32(pb); // read presentation time
@@ -1212,14 +1213,15 @@ static int asf_read_single_payload(AVFormatContext *s, 
AVPacket *pkt,
 int64_t  offset;
 uint64_t size;
 unsigned char *p;
-int ret;
+int ret, data_size;
 
 if (!asf_pkt->data_size) {
-asf_pkt->data_size = asf_pkt->size_left = avio_rl32(pb); // read media 
object size
-if (asf_pkt->data_size <= 0)
+data_size = avio_rl32(pb); // read media object size
+if (data_size <= 0)
 return AVERROR_EOF;
-if ((ret = av_new_packet(&asf_pkt->avpkt, asf_pkt->data_size)) < 0)
+if ((ret = av_new_packet(&asf_pkt->avpkt, data_size)) < 0)
 return ret;
+asf_pkt->data_size = asf_pkt->size_left = data_size;
 } else
 avio_skip(pb, 4); // skip media object size
 asf_pkt->dts = avio_rl32(pb); // read presentation time

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


[FFmpeg-cvslog] asfdec_o: reject size > INT64_MAX in asf_read_unknown

2016-01-14 Thread Andreas Cadhalpun
ffmpeg | branch: master | Andreas Cadhalpun  
| Tue Jan  5 13:20:11 2016 +0100| [aa180169961b46cf0d2bcc23cb686f93c079b256] | 
committer: Andreas Cadhalpun

asfdec_o: reject size > INT64_MAX in asf_read_unknown

Both avio_skip and detect_unknown_subobject use int64_t for the size
parameter.

This fixes a segmentation fault due to infinite recursion.

Reviewed-by: Alexandra Hájková 
Signed-off-by: Andreas Cadhalpun 

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

 libavformat/asfdec_o.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c
index 79b9ee4..02809bb 100644
--- a/libavformat/asfdec_o.c
+++ b/libavformat/asfdec_o.c
@@ -178,6 +178,9 @@ static int asf_read_unknown(AVFormatContext *s, const 
GUIDParseTable *g)
 uint64_t size   = avio_rl64(pb);
 int ret;
 
+if (size > INT64_MAX)
+return AVERROR_INVALIDDATA;
+
 if (asf->is_header)
 asf->unknown_size = size;
 asf->is_header = 0;

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


[FFmpeg-cvslog] asfdec_o: prevent overflow causing seekback

2016-01-14 Thread Andreas Cadhalpun
ffmpeg | branch: master | Andreas Cadhalpun  
| Wed Jan  6 14:09:22 2016 +0100| [74474750f1ac522730dae271a5ea5003caa8b73c] | 
committer: Andreas Cadhalpun

asfdec_o: prevent overflow causing seekback

This fixes infinite loops.

Reviewed-by: Alexandra Hájková 
Signed-off-by: Andreas Cadhalpun 

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

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

diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c
index bc168d3..b81519f 100644
--- a/libavformat/asfdec_o.c
+++ b/libavformat/asfdec_o.c
@@ -167,7 +167,7 @@ static void swap_guid(ff_asf_guid guid)
 
 static void align_position(AVIOContext *pb,  int64_t offset, uint64_t size)
 {
-if (avio_tell(pb) != offset + size)
+if (size < INT64_MAX - offset && avio_tell(pb) != offset + size)
 avio_seek(pb, offset + size, SEEK_SET);
 }
 

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


[FFmpeg-cvslog] lavf/mov: Confine 0x00000000 to raw/ twos fourcc mapping to version 0 sample descriptions

2016-01-14 Thread Mats Peterson
ffmpeg | branch: master | Mats Peterson  | 
Wed Jan 13 00:32:20 2016 +0100| [b58cfa616c169c90166938608e7135cdab5820e0] | 
committer: Michael Niedermayer

lavf/mov: Confine 0x to raw/twos fourcc mapping to version 0 sample 
descriptions

Confine the 0x to 'raw '/'twos' fourcc mapping to old version 0
sound sample descriptions, since they are the only valid sample
descriptions for this type of mapping.

Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 98c2f51..4cc5ff2 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1863,7 +1863,7 @@ static void mov_parse_stsd_audio(MOVContext *c, 
AVIOContext *pb,
 }
 }
 
-if (sc->format == 0) {
+if (version == 0 && sc->format == 0) {
 if (st->codec->bits_per_coded_sample == 8)
 st->codec->codec_id = mov_codec_id(st, MKTAG('r','a','w',' '));
 else if (st->codec->bits_per_coded_sample == 16)

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


[FFmpeg-cvslog] avcodec/pngenc: Fix mixed up linesizes

2016-01-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Jan 15 00:57:00 2016 +0100| [8f4c3e4b92212d98f5b9ca2dee13e076effe9589] | 
committer: Michael Niedermayer

avcodec/pngenc: Fix mixed up linesizes

Fixes out of array accesses
Fixes: 
0cf176e6d3ab9fe924f39738e513f547/asan_generic_4a54aa_3431_aaa28be1cb32e307a9890cad06f84fba.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=8f4c3e4b92212d98f5b9ca2dee13e076effe9589
---

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

diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index 52968fb..a623307 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -770,7 +770,7 @@ static int apng_encode_frame(AVCodecContext *avctx, const 
AVFrame *pict,
 
 if (last_fctl_chunk.dispose_op == APNG_DISPOSE_OP_BACKGROUND) {
 for (y = last_fctl_chunk.y_offset; y < 
last_fctl_chunk.y_offset + last_fctl_chunk.height; ++y) {
-size_t row_start = s->last_frame->linesize[0] * y + 
bpp * last_fctl_chunk.x_offset;
+size_t row_start = diffFrame->linesize[0] * y + bpp * 
last_fctl_chunk.x_offset;
 memset(diffFrame->data[0] + row_start, 0, bpp * 
last_fctl_chunk.width);
 }
 }
@@ -948,7 +948,7 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt,
 uint32_t y;
 uint8_t bpp = (s->bits_per_pixel + 7) >> 3;
 for (y = s->last_frame_fctl.y_offset; y < 
s->last_frame_fctl.y_offset + s->last_frame_fctl.height; ++y) {
-size_t row_start = s->last_frame->linesize[0] * y + bpp * 
s->last_frame_fctl.x_offset;
+size_t row_start = s->prev_frame->linesize[0] * y + bpp * 
s->last_frame_fctl.x_offset;
 memset(s->prev_frame->data[0] + row_start, 0, bpp * 
s->last_frame_fctl.width);
 }
 }

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


[FFmpeg-cvslog] avcodec/pngenc: Replace memcpy by av_image_copy()

2016-01-14 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Jan 15 00:35:57 2016 +0100| [7ec9c5ce8a753175244da971fed9f1e25aef7971] | 
committer: Michael Niedermayer

avcodec/pngenc: Replace memcpy by av_image_copy()

Fixes out of array access
Fixes: 
0cf176e6d3ab9fe924f39738e513f547/asan_generic_4a54aa_3431_aaa28be1cb32e307a9890cad06f84fba.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=7ec9c5ce8a753175244da971fed9f1e25aef7971
---

 libavcodec/pngenc.c |9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index bc61f8f..52968fb 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -766,8 +766,7 @@ static int apng_encode_frame(AVCodecContext *avctx, const 
AVFrame *pict,
 
 // Do disposal
 if (last_fctl_chunk.dispose_op != APNG_DISPOSE_OP_PREVIOUS) {
-memcpy(diffFrame->data[0], s->last_frame->data[0],
-   s->last_frame->linesize[0] * s->last_frame->height);
+av_frame_copy(diffFrame, s->last_frame);
 
 if (last_fctl_chunk.dispose_op == APNG_DISPOSE_OP_BACKGROUND) {
 for (y = last_fctl_chunk.y_offset; y < 
last_fctl_chunk.y_offset + last_fctl_chunk.height; ++y) {
@@ -779,8 +778,7 @@ static int apng_encode_frame(AVCodecContext *avctx, const 
AVFrame *pict,
 if (!s->prev_frame)
 continue;
 
-memcpy(diffFrame->data[0], s->prev_frame->data[0],
-   s->prev_frame->linesize[0] * s->prev_frame->height);
+av_frame_copy(diffFrame, s->prev_frame);
 }
 
 // Do inverse blending
@@ -945,8 +943,7 @@ static int encode_apng(AVCodecContext *avctx, AVPacket *pkt,
 }
 
 // Do disposal, but not blending
-memcpy(s->prev_frame->data[0], s->last_frame->data[0],
-   s->last_frame->linesize[0] * s->last_frame->height);
+av_frame_copy(s->prev_frame, s->last_frame);
 if (s->last_frame_fctl.dispose_op == APNG_DISPOSE_OP_BACKGROUND) {
 uint32_t y;
 uint8_t bpp = (s->bits_per_pixel + 7) >> 3;

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


[FFmpeg-cvslog] avcodec/rmdec: add missing av_log argument

2016-01-14 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri Jan 15 02:26:36 
2016 -0300| [e3c188e72c02f30d10906ae06516563f58a58a1b] | committer: James Almer

avcodec/rmdec: add missing av_log argument

Also change the format specifier to expect an unsigned int

Signed-off-by: James Almer 

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

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

diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index 0867485..1a61b10 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -1358,7 +1358,7 @@ static int ivr_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 avio_skip(pb, 4);
 
 if (size < 1 || size > INT_MAX/4) {
-av_log(s, AV_LOG_ERROR, "size %d is invalid\n");
+av_log(s, AV_LOG_ERROR, "size %u is invalid\n", size);
 return AVERROR_INVALIDDATA;
 }
 

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