Bug 214644

Summary: cad/netgen: switch to multimedia/ffmpeg (2.0 API)
Product: Ports & Packages Reporter: Jan Beich <jbeich>
Component: Individual Port(s)Assignee: Stephen Montgomery-Smith <stephen>
Status: Closed FIXED    
Severity: Affects Only Me CC: stephen
Priority: --- Keywords: patch
Version: LatestFlags: jbeich: maintainer-feedback? (stephen)
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=207547
Bug Depends on: 214199    
Bug Blocks: 215036    
Attachments:
Description Flags
v1 jbeich: maintainer-approval? (stephen)

Description Jan Beich freebsd_committer freebsd_triage 2016-11-18 23:28:48 UTC
Building against ffmpeg 3.x requires fixing the following errors:

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,
    ^
Comment 1 Jan Beich freebsd_committer freebsd_triage 2016-11-18 23:36:06 UTC
Created attachment 177163 [details]
v1

avcodec_encode_video() was implemented on top of avcodec_encode_video2() [1]. My conversion maybe slightly error-prone but the rest are mechanical changes. If unsure check numerious examples scattered in the ports tree.

I'm not sure how to test runtime.

[1] https://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavcodec/utils.c;h=cc28732c01fb;hb=refs/heads/release/2.8#l2120
Comment 2 Stephen Montgomery-Smith freebsd_committer freebsd_triage 2016-11-20 15:27:35 UTC
Hi Jan,

Now I have time to look at it.  But there are now two different bug reports.  Could you send me one big patch that takes cad/netgen from where it is currently to where it should be?

Thanks, Stephen
Comment 3 Jan Beich freebsd_committer freebsd_triage 2016-11-20 15:36:30 UTC
combined diff: http://sprunge.us/XjgG
build log: http://sprunge.us/IWVA
Comment 4 Stephen Montgomery-Smith freebsd_committer freebsd_triage 2016-11-20 15:40:55 UTC
Also, can we close bug 214199, since this bug report supersedes it?
Comment 5 Jan Beich freebsd_committer freebsd_triage 2016-11-20 15:46:14 UTC
No, the issues are distinct. Bug 214199 unbreaks FFMPEG=on build in poudriere while this one divorces it from poorly maintained multimedia/ffmpeg0 and has higher risk of a regression.
Comment 6 commit-hook freebsd_committer freebsd_triage 2016-11-20 16:10:21 UTC
A commit references this bug:

Author: stephen
Date: Sun Nov 20 16:09:53 UTC 2016
New revision: 426602
URL: https://svnweb.freebsd.org/changeset/ports/426602

Log:
  - When FFMPEG=on, link to multimedia/ffmpeg.
  - Respect PREFIX.
  - Conversion for avcodec_encode_video().

  PR:		ports/214199
  PR:		ports/214644

Changes:
  head/cad/netgen/Makefile
  head/cad/netgen/files/patch-configure
  head/cad/netgen/files/patch-ng_ng.tcl
  head/cad/netgen/files/patch-ng_ngappinit.cpp
  head/cad/netgen/files/patch-ng_ngpkg.cpp
Comment 7 Stephen Montgomery-Smith freebsd_committer freebsd_triage 2016-11-20 16:13:18 UTC
Committed, thank you.  Please get back to me or re-open if there are further problems.  I don't actually use this software at present, so I don't know if your conversion produces run-time errors.