From e7c42afe4e60f57c42886de9feeb330d9d763641 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Fri, 4 Nov 2016 16:30:06 +0000 Subject: emulators/visualboyadvance-m: unbreak build with ffmpeg 3.x In file included from src/common/ffmpeg.cpp:62: src/common/ffmpeg.h:70:5: error: unknown type name 'PixelFormat'; did you mean 'AVPixelFormat'? priv_PixelFormat pixfmt; ^~~~~~~~~~~~~~~~ AVPixelFormat src/common/ffmpeg.cpp:61:26: note: expanded from macro 'priv_PixelFormat' ^ /usr/local/include/libavutil/pixfmt.h:60:6: note: 'AVPixelFormat' declared here enum AVPixelFormat { ^ src/common/ffmpeg.cpp:81:11: error: use of undeclared identifier 'avcodec_alloc_frame' pic = avcodec_alloc_frame(); ^ src/common/ffmpeg.cpp:92:28: error: use of undeclared identifier 'CODEC_ID_NONE'; did you mean 'AV_CODEC_ID_NONE'? if(fmt->audio_codec == CODEC_ID_NONE) ^~~~~~~~~~~~~ AV_CODEC_ID_NONE /usr/local/include/libavcodec/avcodec.h:192:5: note: 'AV_CODEC_ID_NONE' declared here AV_CODEC_ID_NONE, ^ src/common/ffmpeg.cpp:163:11: error: use of undeclared identifier 'PIX_FMT_RGB24'; did you mean 'AV_PIX_FMT_RGB24'? 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... ^ src/common/ffmpeg.cpp:416:13: error: use of undeclared identifier 'avcodec_encode_video'; did you mean 'avcodec_encode_video2'? pkt.size = avcodec_encode_video(ctx, video_buf, VIDEO_BUF_LEN, f); ^~~~~~~~~~~~~~~~~~~~ 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, ^ src/common/ffmpeg.cpp:468:13: error: use of undeclared identifier 'avcodec_encode_audio'; did you mean 'avcodec_encode_audio2'? pkt.size = avcodec_encode_audio(ctx, audio_buf, frame_len, ^~~~~~~~~~~~~~~~~~~~ avcodec_encode_audio2 /usr/local/include/libavcodec/avcodec.h:5283:5: note: 'avcodec_encode_audio2' declared here int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, ^ PR: 214190 Approved by: Nicole Reid (maintainer) --- emulators/visualboyadvance-m/Makefile | 1 + .../files/patch-src_common_ffmpeg.cpp | 122 +++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 emulators/visualboyadvance-m/files/patch-src_common_ffmpeg.cpp diff --git a/emulators/visualboyadvance-m/Makefile b/emulators/visualboyadvance-m/Makefile index 2cf9571..dbacec3 100644 --- a/emulators/visualboyadvance-m/Makefile +++ b/emulators/visualboyadvance-m/Makefile @@ -3,6 +3,7 @@ PORTNAME= visualboyadvance-m PORTVERSION= 2.0.0b2 +PORTREVISION= 1 CATEGORIES= emulators MAINTAINER= root@cooltrainer.org diff --git a/emulators/visualboyadvance-m/files/patch-src_common_ffmpeg.cpp b/emulators/visualboyadvance-m/files/patch-src_common_ffmpeg.cpp new file mode 100644 index 0000000..c360156 --- /dev/null +++ b/emulators/visualboyadvance-m/files/patch-src_common_ffmpeg.cpp @@ -0,0 +1,122 @@ +--- src/common/ffmpeg.cpp.orig 2016-11-04 16:28:22 UTC ++++ src/common/ffmpeg.cpp +@@ -58,7 +58,7 @@ static void avformat_free_context(AVForm + #define priv_AVOutputFormat AVOutputFormat + #define priv_AVFrame AVFrame + #define priv_SwsContext SwsContext +-#define priv_PixelFormat PixelFormat ++#define priv_PixelFormat AVPixelFormat + #include "ffmpeg.h" + + // I have no idea what size to make these buffers +@@ -78,7 +78,7 @@ MediaRecorder::MediaRecorder() : oc(0), + did_init = true; + av_register_all(); + } +- pic = avcodec_alloc_frame(); ++ pic = av_frame_alloc(); + } + + MediaRet MediaRecorder::setup_sound_stream(const char *fname, AVOutputFormat *fmt) +@@ -89,7 +89,7 @@ MediaRet MediaRecorder::setup_sound_stre + oc->oformat = fmt; + strncpy(oc->filename, fname, sizeof(oc->filename) - 1); + oc->filename[sizeof(oc->filename) - 1] = 0; +- if(fmt->audio_codec == CODEC_ID_NONE) ++ if(fmt->audio_codec == AV_CODEC_ID_NONE) + return MRET_OK; + + AVCodecContext *ctx; +@@ -157,14 +157,14 @@ MediaRet MediaRecorder::setup_video_stre + switch(d) { + case 16: + // FIXME: test & make endian-neutral +- pixfmt = PIX_FMT_RGB565LE; ++ pixfmt = AV_PIX_FMT_RGB565LE; + break; + case 24: +- pixfmt = PIX_FMT_RGB24; ++ pixfmt = AV_PIX_FMT_RGB24; + break; + case 32: + default: // should never be anything else +- pixfmt = PIX_FMT_RGBA; ++ pixfmt = AV_PIX_FMT_RGBA; + break; + } + ctx->pix_fmt = pixfmt; +@@ -177,7 +177,7 @@ MediaRet MediaRecorder::setup_video_stre + AVCodec *codec = avcodec_find_encoder(oc->oformat->video_codec); + // make sure RGB is supported (mostly not) + if(codec->pix_fmts) { +- const enum PixelFormat *p; ++ const enum AVPixelFormat *p; + #if LIBAVCODEC_VERSION_MAJOR < 55 + int64_t mask = 0; + #endif +@@ -205,7 +205,7 @@ MediaRet MediaRecorder::setup_video_stre + #endif + if(dp == -1) + dp = codec->pix_fmts[0]; +- if(!(convpic = avcodec_alloc_frame()) || ++ if(!(convpic = av_frame_alloc()) || + avpicture_alloc((AVPicture *)convpic, dp, w, h) < 0) { + avformat_free_context(oc); + oc = NULL; +@@ -254,10 +254,10 @@ MediaRet MediaRecorder::finish_setup(con + frame_len = aud_st->codec->frame_size * 4; + sample_len = soundGetSampleRate() * 4 / 60; + switch(aud_st->codec->codec_id) { +- case CODEC_ID_PCM_S16LE: +- case CODEC_ID_PCM_S16BE: +- case CODEC_ID_PCM_U16LE: +- case CODEC_ID_PCM_U16BE: ++ case AV_CODEC_ID_PCM_S16LE: ++ case AV_CODEC_ID_PCM_S16BE: ++ case AV_CODEC_ID_PCM_U16LE: ++ case AV_CODEC_ID_PCM_U16BE: + frame_len = sample_len; + } + audio_buf = (u8 *)malloc(AUDIO_BUF_LEN); +@@ -307,7 +307,7 @@ MediaRet MediaRecorder::Record(const cha + AVOutputFormat *fmt = av_guess_format(NULL, fname, NULL); + if(!fmt) + fmt = av_guess_format("avi", NULL, NULL); +- if(!fmt || fmt->video_codec == CODEC_ID_NONE) ++ if(!fmt || fmt->video_codec == AV_CODEC_ID_NONE) + return MRET_ERR_FMTGUESS; + MediaRet ret; + if((ret = setup_sound_stream(fname, fmt)) == MRET_OK && +@@ -324,7 +324,7 @@ MediaRet MediaRecorder::Record(const cha + AVOutputFormat *fmt = av_guess_format(NULL, fname, NULL); + if(!fmt) + fmt = av_guess_format("wav", NULL, NULL); +- if(!fmt || fmt->audio_codec == CODEC_ID_NONE) ++ if(!fmt || fmt->audio_codec == AV_CODEC_ID_NONE) + return MRET_ERR_FMTGUESS; + MediaRet ret; + if((ret = setup_sound_stream(fname, fmt)) == MRET_OK) +@@ -392,7 +392,7 @@ MediaRet MediaRecorder::AddFrame(const u + tbord = 1; rbord = 1; break; + } + avpicture_fill((AVPicture *)pic, (uint8_t *)vid + tbord * (linesize + pixsize * rbord), +- (PixelFormat)pixfmt, ctx->width + rbord, ctx->height); ++ (AVPixelFormat)pixfmt, ctx->width + rbord, ctx->height); + // satisfy stupid sws_scale()'s integrity check + pic->data[1] = pic->data[2] = pic->data[3] = pic->data[0]; + pic->linesize[1] = pic->linesize[2] = pic->linesize[3] = pic->linesize[0]; +@@ -413,8 +413,12 @@ MediaRet MediaRecorder::AddFrame(const u + pkt.data = f->data[0]; + pkt.size = linesize * ctx->height; + } else { +- pkt.size = avcodec_encode_video(ctx, video_buf, VIDEO_BUF_LEN, f); +- if(!pkt.size) ++ pkt.data = video_buf; ++ pkt.size = VIDEO_BUF_LEN; ++ ++ int ret, got_packet = 0; ++ ret = avcodec_encode_video2(ctx, &pkt, f, &got_packet); ++ if(ret < 0 || !got_packet || pkt.size <= 0) + return MRET_OK; + if(ctx->coded_frame && ctx->coded_frame->pts != AV_NOPTS_VALUE) + pkt.pts = av_rescale_q(ctx->coded_frame->pts, ctx->time_base, vid_st->time_base);