mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
jpeglib and FFmpeg updated
This commit is contained in:
parent
42e72d3bb6
commit
24ec58f024
18
configure.ac
18
configure.ac
@ -56,12 +56,28 @@ AC_ARG_ENABLE([parallel],
|
||||
[AC_SUBST([MPI_INCLUDES], "-I/opt/mpich/include -DPARALLEL -I/usr/share/metis/Lib -DMETIS")
|
||||
AC_SUBST([MPI_LIBS], "-lmetis -L/opt/mpich/ch-p4/lib -lmpich")
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# [AC_SUBST([MPI_INCLUDES], "-I/opt/mpich/include -DPARALLEL -I/home/joachim/download/metis-4.0/Lib -DMETIS")
|
||||
# AC_SUBST([MPI_LIBS], "-L/home/joachim/download/metis-4.0 -lmetis -L/opt/mpich/ch-p4/lib64 -lmpich")
|
||||
|
||||
|
||||
|
||||
AC_ARG_ENABLE([jpeglib],
|
||||
[ --enable-jpeglib enable snapshots using jpeglib],
|
||||
[AC_SUBST([JPEGLIB_INCLUDES], "-DJPEGLIB")
|
||||
AC_SUBST([JPEGLIB_LIBS], "-ljpeg")
|
||||
]
|
||||
)
|
||||
|
||||
AC_ARG_ENABLE([ffmpeg],
|
||||
[ --enable-ffmpeg enable video recording with FFmpeg, uses libavcodec],
|
||||
[AC_SUBST([FFMPEG_INCLUDES], "-DFFMPEG")
|
||||
AC_SUBST([FFMPEG_LIBS], "-lavutil -lavformat -lavcodec -lavutil -lswscale -lz -lbz2")
|
||||
]
|
||||
)
|
||||
|
||||
# AC_HEADER_STDC
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
include_HEADERS =
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include -I$(top_srcdir)/libsrc/interface -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(OCCFLAGS) $(TCL_INCLUDES) $(MPI_INCLUDES)
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include -I$(top_srcdir)/libsrc/interface -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(OCCFLAGS) $(TCL_INCLUDES) $(MPI_INCLUDES) $(FFMPEG_INCLUDES) $(JPEGLIB_INCLUDES)
|
||||
|
||||
bin_PROGRAMS = netgen
|
||||
netgen_SOURCES = demoview.cpp ngappinit.cpp ngpkg.cpp onetcl.cpp nginterface.cpp nginterface_v2.cpp parallelfunc.cpp parallelinterface.cpp demoview.hpp parallelfunc.hpp togl_1_7.h
|
||||
@ -16,7 +16,7 @@ netgen_LDADD = $(top_builddir)/libsrc/visualization/libvisual.a \
|
||||
$(top_builddir)/libsrc/gprim/libgprim.la \
|
||||
$(top_builddir)/libsrc/linalg/libla.la \
|
||||
$(top_builddir)/libsrc/general/libgeneral.la \
|
||||
$(OCCLIBS) -L$(TK_BIN_DIR)/Togl1.7 $(TOGLLIBDIR) -lTogl1.7 $(LIBGLU) $(TK_LIB_SPEC) $(TCL_LIB_SPEC) $(MPI_LIBS) $(PKG_LIBS)
|
||||
$(OCCLIBS) -L$(TK_BIN_DIR)/Togl1.7 $(TOGLLIBDIR) -lTogl1.7 $(LIBGLU) $(TK_LIB_SPEC) $(TCL_LIB_SPEC) $(MPI_LIBS) $(FFMPEG_LIBS) $(JPEGLIB_LIBS) $(PKG_LIBS)
|
||||
|
||||
|
||||
#
|
||||
|
48
ng/ngpkg.cpp
48
ng/ngpkg.cpp
@ -57,10 +57,15 @@ namespace netgen
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VIDEOCLIP
|
||||
#ifdef JPEGLIB
|
||||
#include <jpeglib.h>
|
||||
#endif
|
||||
|
||||
#ifdef FFMPEG
|
||||
extern "C" {
|
||||
#include <ffmpeg/avcodec.h>
|
||||
#include <ffmpeg/avformat.h>
|
||||
#include <ffmpeg/swscale.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3335,7 +3340,7 @@ namespace netgen
|
||||
|
||||
#if TOGL_MAJOR_VERSION==1
|
||||
|
||||
#ifndef VIDEOCLIP
|
||||
#ifndef JPEGLIB
|
||||
static int Ng_SnapShot (struct Togl * togl,
|
||||
int argc, tcl_const char *argv[])
|
||||
{
|
||||
@ -3459,12 +3464,16 @@ namespace netgen
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef VIDEOCLIP
|
||||
// VIDEO CLIP:
|
||||
|
||||
#define INBUF_SIZE 4096
|
||||
|
||||
|
||||
#ifdef FFMPEG
|
||||
|
||||
#define STATE_READY 0
|
||||
#define STATE_STARTED 1
|
||||
|
||||
|
||||
#define INBUF_SIZE 4096
|
||||
#define DEFAULT_B_FRAMES 3
|
||||
// #define DEFAULT_B_FRAMES 0
|
||||
#define DEFAULT_GOP_SIZE 200
|
||||
@ -3474,7 +3483,6 @@ namespace netgen
|
||||
// #define DEFAULT_MPG_BUFSIZE 500000
|
||||
#define DEFAULT_MPG_BUFSIZE 500000
|
||||
|
||||
|
||||
typedef struct buffer_s {
|
||||
uint8_t *MPG;
|
||||
uint8_t *YUV;
|
||||
@ -3504,6 +3512,8 @@ namespace netgen
|
||||
cout << " size=" << bytes << " PSNR(Y)=" << Ypsnr << " dB q=" << (float)quality << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int Ng_VideoClip (struct Togl * togl,
|
||||
int argc, tcl_const char *argv[])
|
||||
{
|
||||
@ -3523,6 +3533,7 @@ namespace netgen
|
||||
static CodecID codec_id = CODEC_ID_MPEG1VIDEO;
|
||||
static FILE *MPGfile;
|
||||
static buffer_t buff;
|
||||
static struct SwsContext *img_convert_ctx;
|
||||
|
||||
|
||||
if (strcmp (argv[2], "init") == 0)
|
||||
@ -3534,6 +3545,8 @@ namespace netgen
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Open output file:
|
||||
//-------------------
|
||||
const char * filename = argv[3];
|
||||
@ -3560,8 +3573,7 @@ namespace netgen
|
||||
// Initialize libavcodec:
|
||||
//-----------------------
|
||||
if( !initialized ) {
|
||||
avcodec_init();
|
||||
avcodec_register_all();
|
||||
av_register_all();
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
@ -3622,6 +3634,8 @@ namespace netgen
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
else if (strcmp (argv[2], "addframe") == 0)
|
||||
{
|
||||
// Can't compress if status != started:
|
||||
@ -3647,8 +3661,19 @@ namespace netgen
|
||||
|
||||
// Convert to YUV:
|
||||
//----------------
|
||||
img_convert( (AVPicture*)YUVpicture, PIX_FMT_YUV420P,
|
||||
(AVPicture*)RGBpicture, PIX_FMT_RGB24, nx, ny );
|
||||
if( img_convert_ctx == NULL )
|
||||
img_convert_ctx = sws_getContext( nx, ny, PIX_FMT_RGB24,
|
||||
nx, ny, PIX_FMT_YUV420P,
|
||||
SWS_BICUBIC, NULL, NULL, NULL );
|
||||
|
||||
if( img_convert_ctx == NULL ) {
|
||||
cout << "can't initialize scaler context" << endl;
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
sws_scale( img_convert_ctx, RGBpicture->data, RGBpicture->linesize,
|
||||
0, ny, YUVpicture->data, YUVpicture->linesize );
|
||||
|
||||
|
||||
// Encode frame:
|
||||
//--------------
|
||||
@ -3662,6 +3687,7 @@ namespace netgen
|
||||
}
|
||||
|
||||
|
||||
|
||||
else if (strcmp (argv[2], "finalize") == 0)
|
||||
{
|
||||
// Can't stop if status != started:
|
||||
@ -3703,11 +3729,11 @@ namespace netgen
|
||||
cout << "finalized" << endl;
|
||||
|
||||
return TCL_OK;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#else
|
||||
static int Ng_VideoClip (struct Togl * togl,
|
||||
int argc, tcl_const char *argv[])
|
||||
|
Loading…
Reference in New Issue
Block a user