Bug 214178

Summary: multimedia/pHash: fails to build with ffmpeg 3.x
Product: Ports & Packages Reporter: Jan Beich <jbeich>
Component: Individual Port(s)Assignee: Jan Beich <jbeich>
Status: Closed FIXED    
Severity: Affects Only Me CC: cyberbotx
Priority: --- Flags: cyberbotx: maintainer-feedback+
Version: Latest   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 207547    
Attachments:
Description Flags
fix, v1 cyberbotx: maintainer-approval+

Description Jan Beich freebsd_committer freebsd_triage 2016-11-04 01:40:05 UTC
configure fails early but the rest are as trivial.

  configure:16037: c++ -o conftest -O2 -pipe -fstack-protector  -ffast-math -O3 -D_THREAD_SAFE -I/usr/local/include -fstack-protector -L/usr/local/lib conftest.cpp -lavcodec  -lpthread  >&5
  /tmp/conftest-07ad8e.o: In function `main':
  conftest.cpp:(.text+0x5): undefined reference to `avcodec_alloc_frame'
  c++: error: linker command failed with exit code 1 (use -v to see invocation)
  configure:16037: $? = 1


  cimgffmpeg.cpp:42:2: error: unknown type name 'PixelFormat'; did you mean 'AVPixelFormat'?
	  PixelFormat ffmpeg_pixfmt;
	  ^~~~~~~~~~~
	  AVPixelFormat
  /usr/local/include/libavutil/pixfmt.h:60:6: note: 'AVPixelFormat' declared here
  enum AVPixelFormat {
       ^
  cimgffmpeg.cpp:44:22: error: use of undeclared identifier 'PIX_FMT_GRAY8'; did you mean
	'AV_PIX_FMT_GRAY8'?
	      ffmpeg_pixfmt = PIX_FMT_GRAY8;
			      ^~~~~~~~~~~~~
			      AV_PIX_FMT_GRAY8
  /usr/local/include/libavutil/pixfmt.h:70:5: note: 'AV_PIX_FMT_GRAY8' declared here
      AV_PIX_FMT_GRAY8,     ///<        Y        ,  8bpp
      ^
  cimgffmpeg.cpp:46:22: error: use of undeclared identifier 'PIX_FMT_RGB24'; did you mean
	'AV_PIX_FMT_RGB24'?
	      ffmpeg_pixfmt = 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...
      ^
  cimgffmpeg.cpp:70:39: warning: 'codec' is deprecated [-Wdeprecated-declarations]
		  if(st_info->pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO)
						      ^
  /usr/local/include/./libavformat/avformat.h:893:21: note: 'codec' has been explicitly marked
	deprecated here
      AVCodecContext *codec;
		      ^
  cimgffmpeg.cpp:81:79: warning: 'codec' is deprecated [-Wdeprecated-declarations]
	      st_info->pCodecCtx = st_info->pFormatCtx->streams[st_info->videoStream]->codec;
										       ^
  /usr/local/include/./libavformat/avformat.h:893:21: note: 'codec' has been explicitly marked
	deprecated here
      AVCodecContext *codec;
		      ^
  cimgffmpeg.cpp:103:9: error: use of undeclared identifier 'avcodec_alloc_frame'
	  pFrame=avcodec_alloc_frame();
		 ^
  cimgffmpeg.cpp:108:29: error: use of undeclared identifier 'avcodec_alloc_frame'
	  AVFrame *pConvertedFrame = avcodec_alloc_frame();
				     ^
  cimgffmpeg.cpp:115:11: warning: 'avpicture_get_size' is deprecated [-Wdeprecated-declarations]
	  numBytes=avpicture_get_size(ffmpeg_pixfmt, st_info->width,st_info->height);
		   ^
  /usr/local/include/./libavcodec/avcodec.h:5467:5: note: 'avpicture_get_size' has been explicitly
	marked deprecated here
  int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
      ^
  cimgffmpeg.cpp:120:2: warning: 'avpicture_fill' is deprecated [-Wdeprecated-declarations]
	  avpicture_fill((AVPicture *)pConvertedFrame,buffer,ffmpeg_pixfmt,st_info->width,st_in...
	  ^
  /usr/local/include/./libavcodec/avcodec.h:5452:5: note: 'avpicture_fill' has been explicitly marked
	deprecated here
  int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
      ^
  cimgffmpeg.cpp:126:41: error: use of undeclared identifier 'PIX_FMT_GRAY8'; did you mean
	'AV_PIX_FMT_GRAY8'?
	  int channels = ffmpeg_pixfmt == PIX_FMT_GRAY8 ? 1 : 3;
					  ^~~~~~~~~~~~~
					  AV_PIX_FMT_GRAY8
  /usr/local/include/libavutil/pixfmt.h:70:5: note: 'AV_PIX_FMT_GRAY8' declared here
      AV_PIX_FMT_GRAY8,     ///<        Y        ,  8bpp
      ^
  cimgffmpeg.cpp:147:4: warning: 'avcodec_decode_video2' is deprecated [-Wdeprecated-declarations]
		  avcodec_decode_video2(st_info->pCodecCtx, pFrame, &frameFinished,&avpkt);
		  ^
  /usr/local/include/./libavcodec/avcodec.h:4811:5: note: 'avcodec_decode_video2' has been explicitly
	marked deprecated here
  int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
      ^
  cimgffmpeg.cpp:163:8: warning: 'av_free_packet' is deprecated [-Wdeprecated-declarations]
		av_free_packet(&packet);
		^
  /usr/local/include/./libavcodec/avcodec.h:4472:6: note: 'av_free_packet' has been explicitly marked
	deprecated here
  void av_free_packet(AVPacket *pkt);
       ^
  cimgffmpeg.cpp:192:9: error: unknown type name 'PixelFormat'; did you mean 'AVPixelFormat'?
	  PixelFormat ffmpeg_pixfmt;
	  ^~~~~~~~~~~
	  AVPixelFormat
  /usr/local/include/libavutil/pixfmt.h:60:6: note: 'AVPixelFormat' declared here
  enum AVPixelFormat {
       ^
  cimgffmpeg.cpp:194:22: error: use of undeclared identifier 'PIX_FMT_GRAY8'; did you mean
	'AV_PIX_FMT_GRAY8'?
	      ffmpeg_pixfmt = PIX_FMT_GRAY8;
			      ^~~~~~~~~~~~~
			      AV_PIX_FMT_GRAY8
  /usr/local/include/libavutil/pixfmt.h:70:5: note: 'AV_PIX_FMT_GRAY8' declared here
      AV_PIX_FMT_GRAY8,     ///<        Y        ,  8bpp
      ^
  cimgffmpeg.cpp:196:22: error: use of undeclared identifier 'PIX_FMT_RGB24'; did you mean
	'AV_PIX_FMT_RGB24'?
	      ffmpeg_pixfmt = 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...
      ^
  cimgffmpeg.cpp:224:40: warning: 'codec' is deprecated [-Wdeprecated-declarations]
			  if(st_info->pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO)
							      ^
  /usr/local/include/./libavformat/avformat.h:893:21: note: 'codec' has been explicitly marked
	deprecated here
      AVCodecContext *codec;
		      ^
  cimgffmpeg.cpp:236:76: warning: 'codec' is deprecated [-Wdeprecated-declarations]
		  st_info->pCodecCtx = st_info->pFormatCtx->streams[st_info->videoStream]->codec;
											   ^
  /usr/local/include/./libavformat/avformat.h:893:21: note: 'codec' has been explicitly marked
	deprecated here
      AVCodecContext *codec;
		      ^
  cimgffmpeg.cpp:257:9: error: use of undeclared identifier 'avcodec_alloc_frame'
	  pFrame=avcodec_alloc_frame();
		 ^
  cimgffmpeg.cpp:260:29: error: use of undeclared identifier 'avcodec_alloc_frame'
	  AVFrame *pConvertedFrame = avcodec_alloc_frame();
				     ^
  cimgffmpeg.cpp:268:11: warning: 'avpicture_get_size' is deprecated [-Wdeprecated-declarations]
	  numBytes=avpicture_get_size(ffmpeg_pixfmt, st_info->width,st_info->height);
		   ^
  /usr/local/include/./libavcodec/avcodec.h:5467:5: note: 'avpicture_get_size' has been explicitly
	marked deprecated here
  int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height);
      ^
  cimgffmpeg.cpp:274:2: warning: 'avpicture_fill' is deprecated [-Wdeprecated-declarations]
	  avpicture_fill((AVPicture *)pConvertedFrame,buffer,ffmpeg_pixfmt,st_info->width,st_in...
	  ^
  /usr/local/include/./libavcodec/avcodec.h:5452:5: note: 'avpicture_fill' has been explicitly marked
	deprecated here
  int avpicture_fill(AVPicture *picture, const uint8_t *ptr,
      ^
  cimgffmpeg.cpp:290:35: error: use of undeclared identifier 'PIX_FMT_GRAY8'; did you mean
	'AV_PIX_FMT_GRAY8'?
		  int channels = ffmpeg_pixfmt == PIX_FMT_GRAY8 ? 1 : 3;
						  ^~~~~~~~~~~~~
						  AV_PIX_FMT_GRAY8
  /usr/local/include/libavutil/pixfmt.h:70:5: note: 'AV_PIX_FMT_GRAY8' declared here
      AV_PIX_FMT_GRAY8,     ///<        Y        ,  8bpp
      ^
  cimgffmpeg.cpp:300:17: warning: 'avcodec_decode_video2' is deprecated [-Wdeprecated-declarations]
		  avcodec_decode_video2(st_info->pCodecCtx, pFrame, &frameFinished,&avpkt);
		  ^
  /usr/local/include/./libavcodec/avcodec.h:4811:5: note: 'avcodec_decode_video2' has been explicitly
	marked deprecated here
  int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
      ^
  cimgffmpeg.cpp:321:14: warning: 'av_free_packet' is deprecated [-Wdeprecated-declarations]
		  av_free_packet(&packet);
		  ^
  /usr/local/include/./libavcodec/avcodec.h:4472:6: note: 'av_free_packet' has been explicitly marked
	deprecated here
  void av_free_packet(AVPacket *pkt);
       ^
  cimgffmpeg.cpp:380:34: warning: 'codec' is deprecated [-Wdeprecated-declarations]
	       if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO)
					  ^
  /usr/local/include/./libavformat/avformat.h:893:21: note: 'codec' has been explicitly marked
	deprecated here
      AVCodecContext *codec;
		      ^
  cimgffmpeg.cpp:425:35: warning: 'codec' is deprecated [-Wdeprecated-declarations]
		       if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO)
						  ^
  /usr/local/include/./libavformat/avformat.h:893:21: note: 'codec' has been explicitly marked
	deprecated here
      AVCodecContext *codec;
		      ^
  14 warnings and 12 errors generated.

http://package23.nyi.freebsd.org/data/103i386-default-PR207547/2016-10-04_18h24m30s/logs/errors/pHash-0.9.6.log
Comment 1 Jan Beich freebsd_committer freebsd_triage 2016-11-04 01:57:10 UTC
Hmm, I can't find upstream development repository.
Comment 2 Naram Qashat 2016-11-04 03:03:26 UTC
The only public repository I've been able to find is https://github.com/clearscene/pHash but it says it isn't official, only based on the official one, and an older version at that. The one on the official website is version 0.9.6 but the one they have on GitHub is 0.9.4.

As for the build failure, I can look into it next week in a bit more detail, I'm busy this weekend.
Comment 3 Jan Beich freebsd_committer freebsd_triage 2016-11-04 04:19:56 UTC
Created attachment 176607 [details]
fix, v1

Mechanical change. Only build tested against ffmpeg 2.8/3.2 by adding -Wl,-z,defs to LDFLAGS.

10.1 i386 log: http://sprunge.us/ZOVU
Comment 4 Naram Qashat 2016-11-04 04:25:31 UTC
Comment on attachment 176607 [details]
fix, v1

Patch looks good to me.
Comment 5 commit-hook freebsd_committer freebsd_triage 2016-11-04 04:48:31 UTC
A commit references this bug:

Author: jbeich
Date: Fri Nov  4 04:48:12 UTC 2016
New revision: 425287
URL: https://svnweb.freebsd.org/changeset/ports/425287

Log:
  multimedia/pHash: unbreak build with ffmpeg 3.x

    =======================<phase: configure      >============================
    [...]
    *** Configuring video Hash ***

    checking whether FFmpeg is present... checking for avcodec_alloc_frame in -lavcodec... no
    configure: error:

    *** libavcodec not found.

  PR:		214178
  Approved by:	Naram Qashat <cyberbotx@cyberbotx.com> (maintainer)
  MFH:		2016Q4

Changes:
  head/multimedia/pHash/Makefile
  head/multimedia/pHash/files/patch-ffmpeg30
Comment 6 commit-hook freebsd_committer freebsd_triage 2016-11-04 05:39:36 UTC
A commit references this bug:

Author: jbeich
Date: Fri Nov  4 05:38:40 UTC 2016
New revision: 425288
URL: https://svnweb.freebsd.org/changeset/ports/425288

Log:
  MFH: r425287

  multimedia/pHash: unbreak build with ffmpeg 3.x

    =======================<phase: configure      >============================
    [...]
    *** Configuring video Hash ***

    checking whether FFmpeg is present... checking for avcodec_alloc_frame in -lavcodec... no
    configure: error:

    *** libavcodec not found.

  PR:		214178
  Approved by:	Naram Qashat <cyberbotx@cyberbotx.com> (maintainer)
  Approved by:	ports-secteam (delphij)

Changes:
_U  branches/2016Q4/
  branches/2016Q4/multimedia/pHash/Makefile
  branches/2016Q4/multimedia/pHash/files/patch-ffmpeg30