[FFmpeg-cvslog] avcodec/hevc_ps: Check default display window bitstream and skip if invalid

2014-10-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Oct 27 
14:03:09 2014 +0100| [852aaead1fc294bcb63a1f9e384e781f6e51ded6] | committer: 
Michael Niedermayer

avcodec/hevc_ps: Check default display window bitstream and skip if invalid

Fixes Ticket4035

Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index c17ca04..4e1c561 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -525,7 +525,11 @@ static void decode_vui(HEVCContext *s, HEVCSPS *sps)
 vui->field_seq_flag= get_bits1(gb);
 vui->frame_field_info_present_flag = get_bits1(gb);
 
-vui->default_display_window_flag = get_bits1(gb);
+if (get_bits_left(gb) >= 68 && show_bits_long(gb, 21) == 0x10) {
+vui->default_display_window_flag = 0;
+av_log(s->avctx, AV_LOG_WARNING, "Invalid default display window\n");
+} else
+vui->default_display_window_flag = get_bits1(gb);
 // Backup context in case an alternate header is detected
 memcpy(&backup, gb, sizeof(backup));
 

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


[FFmpeg-cvslog] lavd/avfoundation: Fix compilation for non MAC OS devices by conditional compilation of screen capture capabilities.

2014-10-27 Thread Thilo Borgmann
ffmpeg | branch: master | Thilo Borgmann  | Mon Oct 27 
15:20:27 2014 +0100| [ed2e97ce6a7a3dbd55174cf390ea8f010094b366] | committer: 
Michael Niedermayer

lavd/avfoundation: Fix compilation for non MAC OS devices by conditional 
compilation of screen capture capabilities.

Signed-off-by: Michael Niedermayer 

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

 libavdevice/avfoundation.m |8 
 1 file changed, 8 insertions(+)

diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index 75c62ed..5e5f70b 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -535,7 +535,9 @@ static int avf_read_header(AVFormatContext *s)
 pthread_mutex_init(&ctx->frame_lock, NULL);
 pthread_cond_init(&ctx->frame_wait_cond, NULL);
 
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
 CGGetActiveDisplayList(0, NULL, &num_screens);
+#endif
 
 // List devices if requested
 if (ctx->list_devices) {
@@ -548,6 +550,7 @@ static int avf_read_header(AVFormatContext *s)
 av_log(ctx, AV_LOG_INFO, "[%d] %s\n", index, name);
 index++;
 }
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
 if (num_screens > 0) {
 CGDirectDisplayID screens[num_screens];
 CGGetActiveDisplayList(num_screens, screens, &num_screens);
@@ -555,6 +558,7 @@ static int avf_read_header(AVFormatContext *s)
 av_log(ctx, AV_LOG_INFO, "[%d] Capture screen %d\n", index + 
i, i);
 }
 }
+#endif
 
 av_log(ctx, AV_LOG_INFO, "AVFoundation audio devices:\n");
 devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeAudio];
@@ -588,10 +592,12 @@ static int avf_read_header(AVFormatContext *s)
 if (ctx->video_device_index < ctx->num_video_devices) {
 video_device = [video_devices 
objectAtIndex:ctx->video_device_index];
 } else if (ctx->video_device_index < ctx->num_video_devices + 
num_screens) {
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
 CGDirectDisplayID screens[num_screens];
 CGGetActiveDisplayList(num_screens, screens, &num_screens);
 AVCaptureScreenInput* capture_screen_input = 
[[[AVCaptureScreenInput alloc] 
initWithDisplayID:screens[ctx->video_device_index - ctx->num_video_devices]] 
autorelease];
 video_device = (AVCaptureDevice*) capture_screen_input;
+#endif
  } else {
 av_log(ctx, AV_LOG_ERROR, "Invalid device index\n");
 goto fail;
@@ -606,6 +612,7 @@ static int avf_read_header(AVFormatContext *s)
 }
 }
 
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
 // looking for screen inputs
 if (!video_device) {
 int idx;
@@ -617,6 +624,7 @@ static int avf_read_header(AVFormatContext *s)
 ctx->video_device_index = ctx->num_video_devices + idx;
 }
 }
+#endif
 
 if (!video_device) {
 av_log(ctx, AV_LOG_ERROR, "Video device not found\n");

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


[FFmpeg-cvslog] avcodec/sgidec: fix count check

2014-10-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Oct 27 
20:48:58 2014 +0100| [a050cf0c451bdf1c1bd512c4fce6b6f8a5e85102] | committer: 
Michael Niedermayer

avcodec/sgidec: fix count check

Fixes: asan_heap-oob_22b30d4_39_038.sgi
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

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

 libavcodec/sgidec.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c
index 8338863..3ddbf77 100644
--- a/libavcodec/sgidec.c
+++ b/libavcodec/sgidec.c
@@ -98,7 +98,7 @@ static int expand_rle_row16(SgiState *s, uint16_t *out_buf,
 break;
 
 /* Check for buffer overflow. */
-if (pixelstride * (count - 1) >= len) {
+if (out_end - out_buf <= pixelstride * (count - 1)) {
 av_log(s->avctx, AV_LOG_ERROR, "Invalid pixel count.\n");
 return AVERROR_INVALIDDATA;
 }

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


[FFmpeg-cvslog] avcodec/sgidec: fix linesize for 16bit

2014-10-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Oct 27 
20:48:58 2014 +0100| [3b20ed85489a14cb5028c873d06960dbc5eef88a] | committer: 
Michael Niedermayer

avcodec/sgidec: fix linesize for 16bit

Fixes: asan_heap-oob_22b30d4_39_038.sgi
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

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

 libavcodec/sgidec.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c
index 6f51ec3..8338863 100644
--- a/libavcodec/sgidec.c
+++ b/libavcodec/sgidec.c
@@ -145,7 +145,7 @@ static int read_rle_sgi(uint8_t *out_buf, SgiState *s)
 for (z = 0; z < s->depth; z++) {
 dest_row = out_buf;
 for (y = 0; y < s->height; y++) {
-linesize = s->width * s->depth * s->bytes_per_channel;
+linesize = s->width * s->depth;
 dest_row -= s->linesize;
 start_offset = bytestream2_get_be32(&g_table);
 bytestream2_seek(&s->g, start_offset, SEEK_SET);

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


[FFmpeg-cvslog] xcbgrab: XCB-based screen capture

2014-10-27 Thread Luca Barbato
ffmpeg | branch: master | Luca Barbato  | Sun Aug 24 
14:18:22 2014 +0200| [a6674d2e7771dbf7a4a5556f5e126be83cadac96] | committer: 
Luca Barbato

xcbgrab: XCB-based screen capture

Matches the x11grab screen capture by features.

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

 Changelog|1 +
 configure|   39 ++-
 libavdevice/Makefile |3 +-
 libavdevice/alldevices.c |1 +
 libavdevice/version.h|2 +-
 libavdevice/xcbgrab.c|  655 ++
 6 files changed, 693 insertions(+), 8 deletions(-)

diff --git a/Changelog b/Changelog
index 27770e5..c51fa8f 100644
--- a/Changelog
+++ b/Changelog
@@ -5,6 +5,7 @@ version :
 - aliases and defaults for Ogg subtypes (opus, spx)
 - HEVC/H.265 RTP payload format (draft v6) packetizer and depacketizer
 - avplay now exits by default at the end of playback
+- XCB-based screen-grabber
 
 
 version 11:
diff --git a/configure b/configure
index f53332d..184d00c 100755
--- a/configure
+++ b/configure
@@ -210,10 +210,13 @@ External library support:
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
   --enable-libxavs enable AVS encoding via xavs [no]
+  --enable-libxcb  enable X11 grabbing using XCB [no]
+  --enable-libxcb-shm  enable X11 grabbing shm communication [auto]
+  --enable-libxcb-xfixes   enable X11 grabbing mouse rendering [auto]
   --enable-libxvid enable Xvid encoding via xvidcore,
native MPEG-4/Xvid encoder exists [no]
   --enable-openssl enable openssl [no]
-  --enable-x11grab enable X11 grabbing [no]
+  --enable-x11grab enable X11 grabbing (legacy) [no]
   --enable-zlibenable zlib [autodetect]
 
 Toolchain options:
@@ -1170,6 +1173,9 @@ EXTERNAL_LIBRARY_LIST="
 libx264
 libx265
 libxavs
+libxcb
+libxcb_shm
+libxcb_xfixes
 libxvid
 openssl
 x11grab
@@ -2102,7 +2108,8 @@ sndio_outdev_deps="sndio_h"
 v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
 vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
 vfwcap_indev_extralibs="-lavicap32"
-x11grab_indev_deps="x11grab XShmCreateImage"
+x11grab_indev_deps="x11grab"
+x11grab_xcb_indev_deps="libxcb"
 
 # protocols
 ffrtmpcrypt_protocol_deps="!librtmp_protocol"
@@ -4273,10 +4280,30 @@ fi
 
 check_lib X11/Xlib.h XOpenDisplay -lX11 && enable xlib
 
-enabled x11grab   &&
-require Xext X11/extensions/XShm.h XShmCreateImage -lXext &&
-require Xfixes X11/extensions/Xfixes.h XFixesGetCursorImage -lXfixes &&
-{ enabled xlib || die "ERROR: Xlib not found"; }
+if enabled libxcb || enabled x11grab && ! disabled libxcb; then
+check_pkg_config xcb-event xcb/xcb.h xcb_connect || {
+enabled libxcb && die "ERROR: libxcb not found";
+} && disable x11grab && enable libxcb
+
+disabled libxcb_shm ||
+check_pkg_config xcb-shm xcb/shm.h xcb_shm_attach || {
+enabled libxcb_shm && die "ERROR: libxcb_shm not found";
+} && check_header sys/shm.h && enable libxcb_shm
+
+disabled libxcb_xfixes ||
+check_pkg_config xcb-xfixes xcb/xfixes.h xcb_xfixes_get_cursor_image 
|| {
+enabled libxcb_xfixes && die "ERROR: libxcb_xfixes not found";
+} && enable libxcb_xfixes
+
+add_cflags "$xcb_event_cflags $xcb_shm_cflags $xcb_xfixes_cflags"
+add_extralibs "$xcb_event_libs $xcb_shm_libs $xcb_xfixes_libs"
+fi
+
+if enabled x11grab; then
+enabled xlib || die "ERROR: Xlib not found"
+require Xext X11/extensions/XShm.h XShmCreateImage -lXext
+require Xfixes X11/extensions/Xfixes.h XFixesGetCursorImage -lXfixes
+fi
 
 enabled vdpau &&
 check_cpp_condition vdpau/vdpau.h "defined 
VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index 25e126c..1f113dd 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -22,7 +22,8 @@ OBJS-$(CONFIG_SNDIO_INDEV)   += sndio_common.o 
sndio_dec.o
 OBJS-$(CONFIG_SNDIO_OUTDEV)  += sndio_common.o sndio_enc.o
 OBJS-$(CONFIG_V4L2_INDEV)+= v4l2.o
 OBJS-$(CONFIG_VFWCAP_INDEV)  += vfwcap.o
-OBJS-$(CONFIG_X11GRAB_INDEV) += x11grab.o
+OBJS-$(CONFIG_X11GRAB_XLIB_INDEV)+= x11grab.o
+OBJS-$(CONFIG_X11GRAB_XCB_INDEV) += xcbgrab.o
 
 # external libraries
 OBJS-$(CONFIG_LIBCDIO_INDEV) += libcdio.o
diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index 155f7a8..5dbe277 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -58,6 +58,7 @@ void avdevice_register_all(void)
 REGISTER_INDEV   (V4L2, v4l2);
 REGISTER_INDEV   (VFWCAP,   vfwcap);
 REGISTER_INDEV   (X11GRAB,  x11grab);
+REGISTER_INDEV   (X11GRAB_XCB,  x11grab_xcb);
 

[FFmpeg-cvslog] Merge commit 'a6674d2e7771dbf7a4a5556f5e126be83cadac96'

2014-10-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Oct 27 
21:26:51 2014 +0100| [a38a1d516fe68542523c772af27e41f28ae9852c] | committer: 
Michael Niedermayer

Merge commit 'a6674d2e7771dbf7a4a5556f5e126be83cadac96'

* commit 'a6674d2e7771dbf7a4a5556f5e126be83cadac96':
  xcbgrab: XCB-based screen capture

Conflicts:
Changelog
configure
libavdevice/Makefile
libavdevice/alldevices.c
libavdevice/version.h

Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] matroskaenc: write correct Display{Width, Height} in stereo encoding

2014-10-27 Thread Vittorio Giovara
ffmpeg | branch: master | Vittorio Giovara  | Wed 
Oct 22 14:36:32 2014 +0100| [090c67d586e3916f9acc49e010b6389d07f97153] | 
committer: Vittorio Giovara

matroskaenc: write correct Display{Width, Height} in stereo encoding

should be the raw amount of pixels (for example 3840x1080 for full HD side by
side) and the DisplayWidth/Height in pixels should be the amount of pixels for
one plane (1920x1080 for that full HD stream)."

So, move the aspect ratio check in the mkv_write_stereo_mode() function
and always write the embl when stereo format and/or aspect ration is set.
Also add a few comments to that function.

CC: libav-sta...@libav.org
Found-by: Asan Usipov 

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

 libavformat/matroskaenc.c |   30 --
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index ed68170..4ec474d 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -629,6 +629,9 @@ static int mkv_write_stereo_mode(AVFormatContext *s, 
AVIOContext *pb,
  AVStream *st, int mode)
 {
 int i;
+int display_width, display_height;
+int h_width = 1, h_height = 1;
+AVCodecContext *codec = st->codec;
 AVDictionaryEntry *tag;
 MatroskaVideoStereoModeType format = MATROSKA_VIDEO_STEREOMODE_TYPE_NB;
 
@@ -643,6 +646,7 @@ static int mkv_write_stereo_mode(AVFormatContext *s, 
AVIOContext *pb,
 }
 }
 
+// iterate to find the stereo3d side data
 for (i = 0; i < st->nb_side_data; i++) {
 AVPacketSideData sd = st->side_data[i];
 if (sd.type == AV_PKT_DATA_STEREO3D) {
@@ -656,11 +660,13 @@ static int mkv_write_stereo_mode(AVFormatContext *s, 
AVIOContext *pb,
 format = (stereo->flags & AV_STEREO3D_FLAG_INVERT)
 ? MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT
 : MATROSKA_VIDEO_STEREOMODE_TYPE_LEFT_RIGHT;
+h_width = 2;
 break;
 case AV_STEREO3D_TOPBOTTOM:
 format = MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM;
 if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
 format--;
+h_height = 2;
 break;
 case AV_STEREO3D_CHECKERBOARD:
 format = MATROSKA_VIDEO_STEREOMODE_TYPE_CHECKERBOARD_LR;
@@ -671,11 +677,13 @@ static int mkv_write_stereo_mode(AVFormatContext *s, 
AVIOContext *pb,
 format = MATROSKA_VIDEO_STEREOMODE_TYPE_ROW_INTERLEAVED_LR;
 if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
 format--;
+h_height = 2;
 break;
 case AV_STEREO3D_COLUMNS:
 format = MATROSKA_VIDEO_STEREOMODE_TYPE_COL_INTERLEAVED_LR;
 if (stereo->flags & AV_STEREO3D_FLAG_INVERT)
 format--;
+h_width = 2;
 break;
 case AV_STEREO3D_FRAMESEQUENCE:
 format = MATROSKA_VIDEO_STEREOMODE_TYPE_BOTH_EYES_BLOCK_LR;
@@ -688,14 +696,30 @@ static int mkv_write_stereo_mode(AVFormatContext *s, 
AVIOContext *pb,
 }
 }
 
+// if webm, do not write unsupported modes
 if (mode == MODE_WEBM &&
 (format > MATROSKA_VIDEO_STEREOMODE_TYPE_TOP_BOTTOM &&
  format != MATROSKA_VIDEO_STEREOMODE_TYPE_RIGHT_LEFT))
 format = MATROSKA_VIDEO_STEREOMODE_TYPE_NB;
 
+// write StereoMode if format is valid
 if (format < MATROSKA_VIDEO_STEREOMODE_TYPE_NB)
 put_ebml_uint(pb, MATROSKA_ID_VIDEOSTEREOMODE, format);
 
+// write DisplayWidth and DisplayHeight, they contain the size of
+// a single source view and/or the display aspect ratio
+display_width  = codec->width  / h_width;
+display_height = codec->height / h_height;
+if (st->sample_aspect_ratio.num) {
+display_width *= av_q2d(st->sample_aspect_ratio);
+put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYUNIT, 3); // DAR
+}
+if (st->sample_aspect_ratio.num ||
+format < MATROSKA_VIDEO_STEREOMODE_TYPE_NB) {
+put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH,  display_width);
+put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, display_height);
+}
+
 return 0;
 }
 
@@ -805,12 +829,6 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 if (ret < 0)
 return ret;
 
-if (st->sample_aspect_ratio.num) {
-int d_width = codec->width*av_q2d(st->sample_aspect_ratio);
-put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , d_width);
-put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, codec->height);
-put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYUNIT, 3);
-}
 end_ebml_master(pb, subinfo);
 break;
 

___
ffmpeg-cvslog mailing li

[FFmpeg-cvslog] Merge commit '090c67d586e3916f9acc49e010b6389d07f97153'

2014-10-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Oct 27 
22:18:03 2014 +0100| [f769671f86ed84a886a4360998ddd7f1fb0bc55d] | committer: 
Michael Niedermayer

Merge commit '090c67d586e3916f9acc49e010b6389d07f97153'

* commit '090c67d586e3916f9acc49e010b6389d07f97153':
  matroskaenc: write correct Display{Width, Height} in stereo encoding

Conflicts:
libavformat/matroskaenc.c

See: 6103faaa51d2f46d6ccecaad9a089b4b42ff66ee
Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] Merge commit 'b46b233baffc2076a1a17a264ba9553ae0d4878f'

2014-10-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Oct 27 
22:25:37 2014 +0100| [76b9043e903c96a0bb9793e8809337857c66abff] | committer: 
Michael Niedermayer

Merge commit 'b46b233baffc2076a1a17a264ba9553ae0d4878f'

* commit 'b46b233baffc2076a1a17a264ba9553ae0d4878f':
  filmstripdec: avoid integer overflow

Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] filmstripdec: avoid integer overflow

2014-10-27 Thread Vittorio Giovara
ffmpeg | branch: master | Vittorio Giovara  | Fri 
Oct 24 13:15:39 2014 +0100| [b46b233baffc2076a1a17a264ba9553ae0d4878f] | 
committer: Vittorio Giovara

filmstripdec: avoid integer overflow

CC: libav-sta...@libav.org
Bug-Id: CID 732246

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

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

diff --git a/libavformat/filmstripdec.c b/libavformat/filmstripdec.c
index 3fa6842..e4dee11 100644
--- a/libavformat/filmstripdec.c
+++ b/libavformat/filmstripdec.c
@@ -84,7 +84,7 @@ static int read_packet(AVFormatContext *s,
 return AVERROR(EIO);
 pkt->dts = avio_tell(s->pb) / (st->codec->width * (st->codec->height + 
film->leading) * 4);
 pkt->size = av_get_packet(s->pb, pkt, st->codec->width * st->codec->height 
* 4);
-avio_skip(s->pb, st->codec->width * film->leading * 4);
+avio_skip(s->pb, st->codec->width * (int64_t) film->leading * 4);
 if (pkt->size < 0)
 return pkt->size;
 pkt->flags |= AV_PKT_FLAG_KEY;

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


[FFmpeg-cvslog] avformat/filmstripdec: Fix several integer overflows

2014-10-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Oct 27 
22:56:04 2014 +0100| [9612dcd6b24f21b28940ef95f31335ab436b255d] | committer: 
Michael Niedermayer

avformat/filmstripdec: Fix several integer overflows

Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/filmstripdec.c b/libavformat/filmstripdec.c
index 155ded2..b76d4b7 100644
--- a/libavformat/filmstripdec.c
+++ b/libavformat/filmstripdec.c
@@ -67,6 +67,12 @@ static int read_header(AVFormatContext *s)
 st->codec->width  = avio_rb16(pb);
 st->codec->height = avio_rb16(pb);
 film->leading = avio_rb16(pb);
+
+if (st->codec->width * 4LL * st->codec->height >= INT_MAX) {
+av_log(s, AV_LOG_ERROR, "dimensions too large\n");
+return AVERROR_PATCHWELCOME;
+}
+
 avpriv_set_pts_info(st, 64, 1, avio_rb16(pb));
 
 avio_seek(pb, 0, SEEK_SET);
@@ -82,7 +88,7 @@ static int read_packet(AVFormatContext *s,
 
 if (avio_feof(s->pb))
 return AVERROR(EIO);
-pkt->dts = avio_tell(s->pb) / (st->codec->width * (st->codec->height + 
film->leading) * 4);
+pkt->dts = avio_tell(s->pb) / (st->codec->width * 
(int64_t)(st->codec->height + film->leading) * 4);
 pkt->size = av_get_packet(s->pb, pkt, st->codec->width * st->codec->height 
* 4);
 avio_skip(s->pb, st->codec->width * (int64_t) film->leading * 4);
 if (pkt->size < 0)

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


[FFmpeg-cvslog] Merge commit 'e6c66f1e4ea19a3aa6ed999c5cb92e1b682c7600'

2014-10-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Oct 27 
23:08:50 2014 +0100| [5ee6527c4386c76a0aae1b07842d6676ee1e91d1] | committer: 
Michael Niedermayer

Merge commit 'e6c66f1e4ea19a3aa6ed999c5cb92e1b682c7600'

* commit 'e6c66f1e4ea19a3aa6ed999c5cb92e1b682c7600':
  bethsoftvid: check return value and clean memory

Conflicts:
libavformat/bethsoftvid.c

See: 3632f35c8e163f6aa6d63c317e3e1fca6a4a5fab
Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] avformat/bethsoftvid: print error in case the side date failed to be allocated

2014-10-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Oct 27 
23:20:21 2014 +0100| [0894b9405c0cdb7cbf1cd80092a4d9f3766b4e66] | committer: 
Michael Niedermayer

avformat/bethsoftvid: print error in case the side date failed to be allocated

Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/bethsoftvid.c b/libavformat/bethsoftvid.c
index c98ff14..05f5c4f 100644
--- a/libavformat/bethsoftvid.c
+++ b/libavformat/bethsoftvid.c
@@ -194,6 +194,9 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext 
*pb, AVPacket *pkt,
  BVID_PALETTE_SIZE);
 if (pdata)
 memcpy(pdata, vid->palette, BVID_PALETTE_SIZE);
+else
+av_log(s, AV_LOG_ERROR, "Failed to allocate palette side data\n");
+
 av_freep(&vid->palette);
 }
 

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


[FFmpeg-cvslog] bethsoftvid: check return value and clean memory

2014-10-27 Thread Vittorio Giovara
ffmpeg | branch: master | Vittorio Giovara  | Fri 
Oct 24 13:15:34 2014 +0100| [e6c66f1e4ea19a3aa6ed999c5cb92e1b682c7600] | 
committer: Vittorio Giovara

bethsoftvid: check return value and clean memory

CC: libav-sta...@libav.org
Bug-Id: CID 733777

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

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

diff --git a/libavformat/bethsoftvid.c b/libavformat/bethsoftvid.c
index 120e145..85abf25 100644
--- a/libavformat/bethsoftvid.c
+++ b/libavformat/bethsoftvid.c
@@ -189,6 +189,10 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext 
*pb, AVPacket *pkt,
 if (vid->palette) {
 uint8_t *pdata = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,
  BVID_PALETTE_SIZE);
+if (!pdata) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
 memcpy(pdata, vid->palette, BVID_PALETTE_SIZE);
 av_freep(&vid->palette);
 }

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


[FFmpeg-cvslog] Merge commit '11467ecf519788f2e2f49c63a17eb600e618489e'

2014-10-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon Oct 27 
23:33:39 2014 +0100| [d4e8cc35b3d9bf32e713d198b9a55d86f080aa19] | committer: 
Michael Niedermayer

Merge commit '11467ecf519788f2e2f49c63a17eb600e618489e'

* commit '11467ecf519788f2e2f49c63a17eb600e618489e':
  mxfdec: reduce loop bound in mxf_read_pixel_layout()

See: 187630b2449f1eae1096f81f31bab7d81bed3cf1
Merged-by: Michael Niedermayer 

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



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


[FFmpeg-cvslog] mxfdec: reduce loop bound in mxf_read_pixel_layout()

2014-10-27 Thread Tomas Härdin
ffmpeg | branch: master | Tomas Härdin  | Mon Oct 27 
13:59:48 2014 +0100| [11467ecf519788f2e2f49c63a17eb600e618489e] | committer: 
Vittorio Giovara

mxfdec: reduce loop bound in mxf_read_pixel_layout()

Makes coverity less confused and code more readable.

Bug-Id: CID 732262

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

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

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index ff88f91..b71c80f 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -816,7 +816,7 @@ static void mxf_read_pixel_layout(AVIOContext *pb, 
MXFDescriptor *descriptor)
 value = avio_r8(pb);
 av_dlog(NULL, "pixel layout: code %#x\n", code);
 
-if (ofs < 16) {
+if (ofs <= 14) {
 layout[ofs++] = code;
 layout[ofs++] = value;
 }

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


Re: [FFmpeg-cvslog] xcbgrab: XCB-based screen capture

2014-10-27 Thread compn
On Mon, 27 Oct 2014 21:44:59 +0100 (CET)
g...@videolan.org (Luca Barbato) wrote:

> ffmpeg | branch: master | Luca Barbato  | Sun Aug
> 24 14:18:22 2014 +0200| [a6674d2e7771dbf7a4a5556f5e126be83cadac96] |
> committer: Luca Barbato
> 
> xcbgrab: XCB-based screen capture
> 
> Matches the x11grab screen capture by features.

> 100644 --- a/libavdevice/Makefile
> -OBJS-$(CONFIG_X11GRAB_INDEV) += x11grab.o
> +OBJS-$(CONFIG_X11GRAB_XLIB_INDEV)+= x11grab.o
> +OBJS-$(CONFIG_X11GRAB_XCB_INDEV) += xcbgrab.o 

so its name is changed in the makefile, but not the device name?

> diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
>  REGISTER_INDEV   (X11GRAB,  x11grab);
> +REGISTER_INDEV   (X11GRAB_XCB,  x11grab_xcb);

> a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c new file mode 100644
> index 000..5055fde
> --- /dev/null
> +++ b/libavdevice/xcbgrab.c
> @@ -0,0 +1,655 @@
> +/*
> + * XCB input grabber
> + * Copyright (C) 2014 Luca Barbato 
> + *
> + * This file is part of Libav.

> +static const AVOption options[] = {
> +{ "draw_mouse", "Draw the mouse pointer.", OFFSET(draw_mouse),
> AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, D },
> +{ "follow_mouse", "Move the grabbing region when the mouse
> pointer reaches within specified amount of pixels to the edge of
> region.",
> +  OFFSET(follow_mouse), AV_OPT_TYPE_INT, { .i64 = 0 },
> FOLLOW_CENTER, INT_MAX, D, "follow_mouse" },
> +{ "centered", "Keep the mouse pointer at the center of grabbing
> region when following.", 0, AV_OPT_TYPE_CONST, { .i64 = -1 },
> INT_MIN, INT_MAX, D, "follow_mouse" },
> +{ "show_region", "Show the grabbing region.",
> OFFSET(show_region), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, D },
> +{ "region_border", "Set the region border thickness.",
> OFFSET(region_border), AV_OPT_TYPE_INT, { .i64 = 3 }, 1, 128, D },
> +{ NULL },

from x11grab.c:

static const AVOption options[] = {
{ "draw_mouse", "draw the mouse pointer", OFFSET(draw_mouse), 
AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, DEC },
{ "follow_mouse", "move the grabbing region when the mouse pointer reaches 
within specified amount of pixels to the edge of region",
  OFFSET(follow_mouse), AV_OPT_TYPE_INT, {.i64 = 0}, -1, INT_MAX, DEC, 
"follow_mouse" },
{ "centered", "keep the mouse pointer at the center of grabbing region 
when following",
  0, AV_OPT_TYPE_CONST, {.i64 = -1}, INT_MIN, INT_MAX, DEC, "follow_mouse" 
},




> +static void wait_frame(AVFormatContext *s, AVPacket *pkt)
> +{
> +XCBGrabContext *c = s->priv_data;
> +int64_t curtime, delay;
> +int64_t frame_time = av_rescale_q(1, c->time_base,
> AV_TIME_BASE_Q); +
> +c->time_frame += frame_time;
> +
> +for (;;) {
> +curtime = av_gettime();
> +delay   = c->time_frame - curtime;
> +if (delay <= 0)
> +break;
> +av_usleep(delay);
> +}
> +
> +pkt->pts = curtime;

is this file based on x11grab.c ? if so , copyrights need to be
modified.

from x11grab.c:
int64_t curtime, delay;
...
/* wait based on the frame rate */
for (;;) {
curtime = av_gettime();
delay   = s->time_frame * av_q2d(s->time_base) - curtime;
if (delay <= 0) {
if (delay < INT64_C(-100) * av_q2d(s->time_base))
s->time_frame += INT64_C(100);
break;
}
...
pkt->pts  = curtime;



> +AVInputFormat ff_x11grab_xcb_demuxer = {
> +.name   = "x11grab",
> +.long_name  = NULL_IF_CONFIG_SMALL("X11 screen capture,
> using XCB"),

i've confused myself with x11grab x11grab_xlib and x11grab_xcb , is the name of 
this demuxer correct?

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


[FFmpeg-cvslog] avcodec/dirac_arith: fix integer overflow

2014-10-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue Oct 28 
02:14:41 2014 +0100| [39680caceebfc6abf09b17032048752c014e57a8] | committer: 
Michael Niedermayer

avcodec/dirac_arith: fix integer overflow

Fixes: asan_heap-oob_1078676_9_008.drc
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

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

 libavcodec/dirac_arith.h |4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/dirac_arith.h b/libavcodec/dirac_arith.h
index 089c71a..a1fa96b 100644
--- a/libavcodec/dirac_arith.h
+++ b/libavcodec/dirac_arith.h
@@ -171,6 +171,10 @@ static inline int dirac_get_arith_uint(DiracArith *c, int 
follow_ctx, int data_c
 {
 int ret = 1;
 while (!dirac_get_arith_bit(c, follow_ctx)) {
+if (ret >= 0x4000) {
+av_log(NULL, AV_LOG_ERROR, "dirac_get_arith_uint overflow\n");
+return -1;
+}
 ret <<= 1;
 ret += dirac_get_arith_bit(c, data_ctx);
 follow_ctx = ff_dirac_next_ctx[follow_ctx];

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


[FFmpeg-cvslog] avcodec/diracdec: Tighter checks on CODEBLOCKS_X/Y

2014-10-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue Oct 28 
01:23:40 2014 +0100| [5145d22b88b9835db81c4d286b931a78e08ab76a] | committer: 
Michael Niedermayer

avcodec/diracdec: Tighter checks on CODEBLOCKS_X/Y

Fixes very long but finite loop
Fixes: asan_heap-oob_107866c_42_041.drc
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index 0511f1c..aa8e2b0 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -1004,8 +1004,8 @@ static int dirac_unpack_idwt_params(DiracContext *s)
 /* Codeblock parameters (core syntax only) */
 if (get_bits1(gb)) {
 for (i = 0; i <= s->wavelet_depth; i++) {
-CHECKEDREAD(s->codeblock[i].width , tmp < 1, "codeblock width 
invalid\n")
-CHECKEDREAD(s->codeblock[i].height, tmp < 1, "codeblock height 
invalid\n")
+CHECKEDREAD(s->codeblock[i].width , tmp < 1 || tmp > 
(s->avctx->width >>s->wavelet_depth-i), "codeblock width invalid\n")
+CHECKEDREAD(s->codeblock[i].height, tmp < 1 || tmp > 
(s->avctx->height>>s->wavelet_depth-i), "codeblock height invalid\n")
 }
 
 CHECKEDREAD(s->codeblock_mode, tmp > 1, "unknown codeblock mode\n")

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


[FFmpeg-cvslog] avcodec/diracdec: Use 64bit in calculation of codeblock coordinates

2014-10-27 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue Oct 28 
01:23:40 2014 +0100| [526886e6069636a918c8c04db17e864e3d8151c1] | committer: 
Michael Niedermayer

avcodec/diracdec: Use 64bit in calculation of codeblock coordinates

Fixes integer overflow
Fixes out of array read
Fixes: asan_heap-oob_107866c_42_041.drc
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index c03f45c..0511f1c 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -612,10 +612,10 @@ static av_always_inline void 
decode_subband_internal(DiracContext *s, SubBand *b
 
 top = 0;
 for (cb_y = 0; cb_y < cb_height; cb_y++) {
-bottom = (b->height * (cb_y+1)) / cb_height;
+bottom = (b->height * (cb_y+1LL)) / cb_height;
 left = 0;
 for (cb_x = 0; cb_x < cb_width; cb_x++) {
-right = (b->width * (cb_x+1)) / cb_width;
+right = (b->width * (cb_x+1LL)) / cb_width;
 codeblock(s, b, &gb, &c, left, right, top, bottom, blockcnt_one, 
is_arith);
 left = right;
 }

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