You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-07-11 14:30:22 +02:00
RFC 2 stage: First feedback from review comments
- License is GPL, simplify the license header to make it clear - Add myself to license header, clarify who did what - Use 64 bit PTS - Move mouse bitmaps to the mouse cursor painting function. Make them const again - Properly detach X11 from the shared memory segment on close - Destroy X11 image on close (patch by Edouard Gomez) Originally committed as revision 7305 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:

committed by
Guillaume Poirier
parent
65a1c656d7
commit
ef84bf0404
@ -1,46 +1,32 @@
|
|||||||
/*
|
/*
|
||||||
* X11 video grab interface
|
* X11 video grab interface
|
||||||
* Copyright (C) 2006 Clemens Fruhwirth
|
|
||||||
*
|
*
|
||||||
* A quick note on licensing. This file is a mixture of LGPL code
|
* This file is part of FFmpeg.
|
||||||
* (ffmpeg) and GPL code (xvidcap). The result is a file that must
|
*
|
||||||
* abid both licenses. As they are compatible and GPL is more
|
* FFmpeg integration:
|
||||||
* strict, this code has an "effective" GPL license.
|
* Copyright (C) 2006 Clemens Fruhwirth <clemens@endorphin.org>
|
||||||
*
|
* Edouard Gomez <ed.gomez@free.fr>
|
||||||
|
*
|
||||||
* This file contains code from grab.c:
|
* This file contains code from grab.c:
|
||||||
* Copyright (c) 2000, 2001 Fabrice Bellard
|
* Copyright (c) 2000-2001 Fabrice Bellard
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*
|
*
|
||||||
* This file contains code from the xvidcap project:
|
* This file contains code from the xvidcap project:
|
||||||
* Copyright (C) 1997-98 Rasca, Berlin
|
* Copyright (C) 1997-1998 Rasca, Berlin
|
||||||
* Copyright (C) 2003,04 Karl H. Beckers, Frankfurt
|
* 2003-2004 Karl H. Beckers, Frankfurt
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* FFmpeg is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* FFmpeg is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* along with this program; if not, write to the Free Software
|
* License along with FFmpeg; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
@ -55,6 +41,7 @@
|
|||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xlibint.h>
|
#include <X11/Xlibint.h>
|
||||||
#include <X11/Xproto.h>
|
#include <X11/Xproto.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
#include <X11/extensions/XShm.h>
|
#include <X11/extensions/XShm.h>
|
||||||
@ -113,7 +100,7 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
|||||||
if (!st) {
|
if (!st) {
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
av_set_pts_info(st, 48, 1, 1000000); /* 48 bits pts in us */
|
av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
|
||||||
|
|
||||||
use_shm = XShmQueryExtension(dpy);
|
use_shm = XShmQueryExtension(dpy);
|
||||||
av_log(s1, AV_LOG_INFO, "shared memory extension %s\n", use_shm ? "found" : "not found");
|
av_log(s1, AV_LOG_INFO, "shared memory extension %s\n", use_shm ? "found" : "not found");
|
||||||
@ -121,8 +108,8 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
|||||||
if(use_shm) {
|
if(use_shm) {
|
||||||
int scr = XDefaultScreen(dpy);
|
int scr = XDefaultScreen(dpy);
|
||||||
image = XShmCreateImage(dpy,
|
image = XShmCreateImage(dpy,
|
||||||
DefaultVisual(dpy,scr),
|
DefaultVisual(dpy, scr),
|
||||||
DefaultDepth(dpy,scr),
|
DefaultDepth(dpy, scr),
|
||||||
ZPixmap,
|
ZPixmap,
|
||||||
NULL,
|
NULL,
|
||||||
&x11grab->shminfo,
|
&x11grab->shminfo,
|
||||||
@ -236,18 +223,6 @@ fail:
|
|||||||
return AVERROR_IO;
|
return AVERROR_IO;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t mousePointerBlack[] =
|
|
||||||
{
|
|
||||||
0, 49152, 40960, 36864, 34816, 33792, 33280, 33024, 32896, 32832,
|
|
||||||
33728, 37376, 43264, 51456, 1152, 1152, 576, 576, 448, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint16_t mousePointerWhite[] =
|
|
||||||
{
|
|
||||||
0, 0, 16384, 24576, 28672, 30720, 31744, 32256, 32512, 32640, 31744,
|
|
||||||
27648, 17920, 1536, 768, 768, 384, 384, 0, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
getCurrentPointer(AVFormatContext *s1, X11Grab *s, int *x, int *y)
|
getCurrentPointer(AVFormatContext *s1, X11Grab *s, int *x, int *y)
|
||||||
{
|
{
|
||||||
@ -299,6 +274,22 @@ for (line = 0; line < min(20, (y_off + height) - *y); line++ ) { \
|
|||||||
static void
|
static void
|
||||||
paintMousePointer(AVFormatContext *s1, X11Grab *s, int *x, int *y, XImage *image)
|
paintMousePointer(AVFormatContext *s1, X11Grab *s, int *x, int *y, XImage *image)
|
||||||
{
|
{
|
||||||
|
static const uint16_t const mousePointerBlack[] =
|
||||||
|
{
|
||||||
|
0, 49152, 40960, 36864, 34816,
|
||||||
|
33792, 33280, 33024, 32896, 32832,
|
||||||
|
33728, 37376, 43264, 51456, 1152,
|
||||||
|
1152, 576, 576, 448, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
static const uint16_t const mousePointerWhite[] =
|
||||||
|
{
|
||||||
|
0, 0, 16384, 24576, 28672,
|
||||||
|
30720, 31744, 32256, 32512, 32640,
|
||||||
|
31744, 27648, 17920, 1536, 768,
|
||||||
|
768, 384, 384, 0, 0
|
||||||
|
};
|
||||||
|
|
||||||
int x_off = s->x_off;
|
int x_off = s->x_off;
|
||||||
int y_off = s->y_off;
|
int y_off = s->y_off;
|
||||||
int width = s->width;
|
int width = s->width;
|
||||||
@ -429,12 +420,19 @@ static int x11grab_read_close(AVFormatContext *s1)
|
|||||||
{
|
{
|
||||||
X11Grab *x11grab = s1->priv_data;
|
X11Grab *x11grab = s1->priv_data;
|
||||||
|
|
||||||
/* Free shared mem if necessary */
|
/* Detach cleanly from shared mem */
|
||||||
if (x11grab->use_shm) {
|
if (x11grab->use_shm) {
|
||||||
|
XShmDetach(x11grab->dpy, &x11grab->shminfo);
|
||||||
shmdt(x11grab->shminfo.shmaddr);
|
shmdt(x11grab->shminfo.shmaddr);
|
||||||
shmctl(x11grab->shminfo.shmid, IPC_RMID, NULL);
|
shmctl(x11grab->shminfo.shmid, IPC_RMID, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Destroy X11 image */
|
||||||
|
if (x11grab->image) {
|
||||||
|
XDestroyImage(x11grab->image);
|
||||||
|
x11grab->image = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Free X11 display */
|
/* Free X11 display */
|
||||||
XCloseDisplay(x11grab->dpy);
|
XCloseDisplay(x11grab->dpy);
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user