From 6cb22835284b2328ca2c2eb8e5d083308a772dbf Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Fri, 18 Nov 2016 23:17:38 +0000 Subject: cad/netgen: switch to ffmpeg 2.x API ngpkg.cpp:2269:12: error: unknown type name 'CodecID'; did you mean 'AVCodecID'? static CodecID codec_id = CODEC_ID_MPEG1VIDEO; ^~~~~~~ AVCodecID /usr/local/include/libavcodec/avcodec.h:191:6: note: 'AVCodecID' declared here enum AVCodecID { ^ ngpkg.cpp:2269:31: error: use of undeclared identifier 'CODEC_ID_MPEG1VIDEO'; did you mean 'AV_CODEC_ID_MPEG1VIDEO'? static CodecID codec_id = CODEC_ID_MPEG1VIDEO; ^~~~~~~~~~~~~~~~~~~ AV_CODEC_ID_MPEG1VIDEO /usr/local/include/libavcodec/avcodec.h:195:5: note: 'AV_CODEC_ID_MPEG1VIDEO' declared here AV_CODEC_ID_MPEG1VIDEO, ^ ngpkg.cpp:2341:28: error: use of undeclared identifier 'PIX_FMT_YUV420P'; did you mean 'AV_PIX_FMT_YUV420P'? context->pix_fmt = PIX_FMT_YUV420P; ^~~~~~~~~~~~~~~ AV_PIX_FMT_YUV420P /usr/local/include/libavutil/pixfmt.h:62:5: note: 'AV_PIX_FMT_YUV420P' declared here AV_PIX_FMT_YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) ^ ngpkg.cpp:2354:22: error: use of undeclared identifier 'avcodec_alloc_frame' YUVpicture = avcodec_alloc_frame(); ^ ngpkg.cpp:2363:22: error: use of undeclared identifier 'avcodec_alloc_frame' RGBpicture = avcodec_alloc_frame(); ^ ngpkg.cpp:2408:53: error: use of undeclared identifier 'PIX_FMT_RGB24'; did you mean 'AV_PIX_FMT_RGB24'? img_convert_ctx = sws_getContext( nx, ny, PIX_FMT_RGB24, ^~~~~~~~~~~~~ AV_PIX_FMT_RGB24 /usr/local/include/libavutil/pixfmt.h:64:5: note: 'AV_PIX_FMT_RGB24' declared here AV_PIX_FMT_RGB24, ///< packed RGB 8:8:8, 24bpp, RGBRGB... ^ ngpkg.cpp:2409:53: error: use of undeclared identifier 'PIX_FMT_YUV420P'; did you mean 'AV_PIX_FMT_YUV420P'? nx, ny, PIX_FMT_YUV420P, ^~~~~~~~~~~~~~~ AV_PIX_FMT_YUV420P /usr/local/include/libavutil/pixfmt.h:62:5: note: 'AV_PIX_FMT_YUV420P' declared here AV_PIX_FMT_YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) ^ ngpkg.cpp:2423:17: error: use of undeclared identifier 'avcodec_encode_video'; did you mean 'avcodec_encode_video2'? bytes = avcodec_encode_video( context, buff.MPG, ^~~~~~~~~~~~~~~~~~~~ avcodec_encode_video2 /usr/local/include/libavcodec/avcodec.h:5322:5: note: 'avcodec_encode_video2' declared here int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, ^ ngpkg.cpp:2423:48: error: cannot initialize a parameter of type 'AVPacket *' with an lvalue of type 'uint8_t *' (aka 'unsigned char *') bytes = avcodec_encode_video( context, buff.MPG, ^~~~~~~~ /usr/local/include/libavcodec/avcodec.h:5322:60: note: passing argument to parameter 'avpkt' here int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, ^ ngpkg.cpp:2446:19: error: use of undeclared identifier 'avcodec_encode_video'; did you mean 'avcodec_encode_video2'? bytes = avcodec_encode_video( context, buff.MPG, MPGbufsize, NULL ); ^~~~~~~~~~~~~~~~~~~~ avcodec_encode_video2 /usr/local/include/libavcodec/avcodec.h:5322:5: note: 'avcodec_encode_video2' declared here int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, ^ ngpkg.cpp:2446:50: error: cannot initialize a parameter of type 'AVPacket *' with an lvalue of type 'uint8_t *' (aka 'unsigned char *') bytes = avcodec_encode_video( context, buff.MPG, MPGbufsize, NULL ); ^~~~~~~~ /usr/local/include/libavcodec/avcodec.h:5322:60: note: passing argument to parameter 'avpkt' here int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, ^ ngpkg.cpp:2454:25: error: use of undeclared identifier 'CODEC_ID_MPEG1VIDEO'; did you mean 'AV_CODEC_ID_MPEG1VIDEO'? if( codec_id == CODEC_ID_MPEG1VIDEO ) { ^~~~~~~~~~~~~~~~~~~ AV_CODEC_ID_MPEG1VIDEO /usr/local/include/libavcodec/avcodec.h:195:5: note: 'AV_CODEC_ID_MPEG1VIDEO' declared here AV_CODEC_ID_MPEG1VIDEO, ^ PR: ??? Approved by: stephen (maintainer) --- cad/netgen/Makefile | 4 +- cad/netgen/files/patch-configure | 12 ----- cad/netgen/files/patch-ng_ngpkg.cpp | 93 +++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 15 deletions(-) create mode 100644 cad/netgen/files/patch-ng_ngpkg.cpp diff --git a/cad/netgen/Makefile b/cad/netgen/Makefile index 9d61138..e028b03 100644 --- a/cad/netgen/Makefile +++ b/cad/netgen/Makefile @@ -36,10 +36,8 @@ OCC_LIB_DEPENDS= libTKernel.so:cad/opencascade OCC_CXXFLAGS= -DOCCGEOMETRY -DHAVE_CONFIG_H -D${ARCH} -I${LOCALBASE}/include/OpenCASCADE OCC_CONFIGURE_ON= --enable-occ -FFMPEG_LIB_DEPENDS= libavcodec0.so:multimedia/ffmpeg0 +FFMPEG_LIB_DEPENDS= libavcodec.so:multimedia/ffmpeg FFMPEG_CONFIGURE_ON= --enable-ffmpeg -FFMPEG_CPPFLAGS= -isystem ${LOCALBASE}/include/ffmpeg0 -FFMPEG_LIBS= -L${LOCALBASE}/lib/ffmpeg0 MACHINE= ${OPSYS:tu} diff --git a/cad/netgen/files/patch-configure b/cad/netgen/files/patch-configure index 687b512..9d86a92 100644 --- a/cad/netgen/files/patch-configure +++ b/cad/netgen/files/patch-configure @@ -153,15 +153,3 @@ need_version=no need_lib_prefix=no ;; -@@ -15534,9 +15534,9 @@ fi - ffmpegon=false - # Check whether --enable-ffmpeg was given. - if test "${enable_ffmpeg+set}" = set; then : -- enableval=$enable_ffmpeg; FFMPEG_INCLUDES="-DFFMPEG -D__STDC_CONSTANT_MACROS" -+ enableval=$enable_ffmpeg; FFMPEG_INCLUDES="-DFFMPEG -D__STDC_CONSTANT_MACROS" - -- FFMPEG_LIBS="-lavutil -lavformat -lavcodec -lavutil -lswscale -lz -lbz2" -+ FFMPEG_LIBS="-lavutil0 -lavformat0 -lavcodec0 -lavutil0 -lswscale0 -lz -lbz2" - - if test "$enableval" = yes; then ffmpegon=true; else ffmpegon=false; fi - diff --git a/cad/netgen/files/patch-ng_ngpkg.cpp b/cad/netgen/files/patch-ng_ngpkg.cpp new file mode 100644 index 0000000..81ee1c7 --- /dev/null +++ b/cad/netgen/files/patch-ng_ngpkg.cpp @@ -0,0 +1,93 @@ +--- ng/ngpkg.cpp.orig 2014-08-29 09:54:01 UTC ++++ ng/ngpkg.cpp +@@ -2266,7 +2266,7 @@ namespace netgen + static int gopsize = DEFAULT_GOP_SIZE; + static int bframes = DEFAULT_B_FRAMES; + static int MPGbufsize = DEFAULT_MPG_BUFSIZE; +- static CodecID codec_id = CODEC_ID_MPEG1VIDEO; ++ static AVCodecID codec_id = AV_CODEC_ID_MPEG1VIDEO; + static FILE *MPGfile; + static buffer_t buff; + static struct SwsContext *img_convert_ctx; +@@ -2338,7 +2338,7 @@ namespace netgen + context->time_base = s; + context->gop_size = gopsize; + context->max_b_frames = bframes; +- context->pix_fmt = PIX_FMT_YUV420P; ++ context->pix_fmt = AV_PIX_FMT_YUV420P; + context->flags |= CODEC_FLAG_PSNR; + + // if( avcodec_open( context, codec ) < 0 ) { +@@ -2351,7 +2351,7 @@ namespace netgen + return TCL_ERROR; + } + +- YUVpicture = avcodec_alloc_frame(); ++ YUVpicture = av_frame_alloc(); + + YUVpicture->data[0] = buff.YUV; + YUVpicture->data[1] = buff.YUV + PIXsize; +@@ -2360,7 +2360,7 @@ namespace netgen + YUVpicture->linesize[1] = nx / 2; + YUVpicture->linesize[2] = nx / 2; + +- RGBpicture = avcodec_alloc_frame(); ++ RGBpicture = av_frame_alloc(); + + RGBpicture->data[0] = buff.RGB; + RGBpicture->data[1] = buff.RGB; +@@ -2405,8 +2405,8 @@ namespace netgen + // Convert to YUV: + //---------------- + if( img_convert_ctx == NULL ) +- img_convert_ctx = sws_getContext( nx, ny, PIX_FMT_RGB24, +- nx, ny, PIX_FMT_YUV420P, ++ img_convert_ctx = sws_getContext( nx, ny, AV_PIX_FMT_RGB24, ++ nx, ny, AV_PIX_FMT_YUV420P, + SWS_BICUBIC, NULL, NULL, NULL ); + + if( img_convert_ctx == NULL ) { +@@ -2420,8 +2420,15 @@ namespace netgen + + // Encode frame: + //-------------- +- bytes = avcodec_encode_video( context, buff.MPG, +- MPGbufsize, YUVpicture ); ++ AVPacket pkt; ++ av_init_packet( &pkt ); ++ pkt.data = buff.MPG; ++ pkt.size = MPGbufsize; ++ ++ int got_packet = 0; ++ int ret = avcodec_encode_video2( context, &pkt, YUVpicture, ++ &got_packet ); ++ bytes = ret ? ret : pkt.size; + count_frames++; + print_info( count_frames, context, bytes ); + fwrite( buff.MPG, 1, bytes, MPGfile ); +@@ -2442,8 +2449,15 @@ namespace netgen + + // Get the delayed frames, if any: + //-------------------------------- ++ AVPacket pkt; ++ av_init_packet( &pkt ); ++ pkt.data = buff.MPG; ++ pkt.size = MPGbufsize; ++ ++ int got_packet = 0; + for( ; bytes; ) { +- bytes = avcodec_encode_video( context, buff.MPG, MPGbufsize, NULL ); ++ int ret = avcodec_encode_video2( context, &pkt, NULL, &got_packet ); ++ bytes = ret ? ret : pkt.size; + count_frames++; + print_info( count_frames, context, bytes ); + fwrite( buff.MPG, 1, bytes, MPGfile ); +@@ -2451,7 +2465,7 @@ namespace netgen + + // Add sequence end code: + //----------------------- +- if( codec_id == CODEC_ID_MPEG1VIDEO ) { ++ if( codec_id == AV_CODEC_ID_MPEG1VIDEO ) { + buff.MPG[0] = 0x00; + buff.MPG[1] = 0x00; + buff.MPG[2] = 0x01;