diff options
author | Jan Beich <jbeich@FreeBSD.org> | 2016-11-18 22:00:57 +0000 |
---|---|---|
committer | Jan Beich <jbeich@FreeBSD.org> | 2016-11-18 22:00:57 +0000 |
commit | 7f3933d17c12d730a5e223c7acae72c8b15d2a0c (patch) | |
tree | 6f5a6df5e0a92ec88f72dcdd5069b46f04acdfa0 /emulators/visualboyadvance-m | |
parent | 70f518b2a2a408cac93f112d69cbd8aa871e42b3 (diff) | |
download | ports-7f3933d17c12d730a5e223c7acae72c8b15d2a0c.tar.gz ports-7f3933d17c12d730a5e223c7acae72c8b15d2a0c.zip |
Notes
Diffstat (limited to 'emulators/visualboyadvance-m')
-rw-r--r-- | emulators/visualboyadvance-m/Makefile | 1 | ||||
-rw-r--r-- | emulators/visualboyadvance-m/files/patch-src_common_ffmpeg.cpp | 173 |
2 files changed, 174 insertions, 0 deletions
diff --git a/emulators/visualboyadvance-m/Makefile b/emulators/visualboyadvance-m/Makefile index e40765eae5b9..06e8c78ac587 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 000000000000..dba2218fabd0 --- /dev/null +++ b/emulators/visualboyadvance-m/files/patch-src_common_ffmpeg.cpp @@ -0,0 +1,173 @@ +https://github.com/visualboyadvance-m/visualboyadvance-m/commit/502de18 +https://github.com/visualboyadvance-m/visualboyadvance-m/commit/a3a07d2 +https://github.com/visualboyadvance-m/visualboyadvance-m/commit/029a5fc +https://github.com/visualboyadvance-m/visualboyadvance-m/commit/3f3c385 + +--- src/common/ffmpeg.cpp.orig 2015-09-19 15:58:26 UTC ++++ src/common/ffmpeg.cpp +@@ -53,6 +53,26 @@ static void avformat_free_context(AVFormatContext *ctx) + #endif + } + ++// For compatibility with 3.0+ ffmpeg ++#include <libavutil/version.h> ++#ifndef PixelFormat ++#define PixelFormat AVPixelFormat ++#endif ++#if LIBAVCODEC_VERSION_MAJOR > 56 ++#define CODEC_ID_NONE AV_CODEC_ID_NONE ++#define CODEC_ID_PCM_S16LE AV_CODEC_ID_PCM_S16LE ++#define CODEC_ID_PCM_S16BE AV_CODEC_ID_PCM_S16BE ++#define CODEC_ID_PCM_U16LE AV_CODEC_ID_PCM_U16LE ++#define CODEC_ID_PCM_U16BE AV_CODEC_ID_PCM_U16BE ++#define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER ++#endif ++#if LIBAVUTIL_VERSION_MAJOR > 54 ++#define avcodec_alloc_frame av_frame_alloc ++#define PIX_FMT_RGB565LE AV_PIX_FMT_RGB565LE ++#define PIX_FMT_RGB24 AV_PIX_FMT_RGB24 ++#define PIX_FMT_RGBA AV_PIX_FMT_RGBA ++#endif ++ + #define priv_AVFormatContext AVFormatContext + #define priv_AVStream AVStream + #define priv_AVOutputFormat AVOutputFormat +@@ -103,10 +123,16 @@ MediaRet MediaRecorder::setup_sound_stream(const char *fname, AVOutputFormat *fm + oc = NULL; + return MRET_ERR_NOMEM; + } ++ ++ AVCodec *codec = avcodec_find_encoder(fmt->audio_codec); ++ + ctx = aud_st->codec; + ctx->codec_id = fmt->audio_codec; + ctx->codec_type = AVMEDIA_TYPE_AUDIO; +- ctx->sample_fmt = AV_SAMPLE_FMT_S16; ++ // Some encoders don't like s16 (SAMPLE_FMT_S16) ++ ctx->sample_fmt = codec->sample_fmts[0]; ++ // This was changed in the initial ffmpeg 3.0 update, ++ // but shouldn't (as far as I'm aware) cause problems with older versions + ctx->bit_rate = 128000; // arbitrary; in case we're generating mp3 + ctx->sample_rate = soundGetSampleRate(); + ctx->channels = 2; +@@ -115,7 +141,6 @@ MediaRet MediaRecorder::setup_sound_stream(const char *fname, AVOutputFormat *fm + if(fmt->flags & AVFMT_GLOBALHEADER) + ctx->flags |= CODEC_FLAG_GLOBAL_HEADER; + +- AVCodec *codec = avcodec_find_encoder(fmt->audio_codec); + #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53,6,0) + if(!codec || avcodec_open(ctx, codec)) { + #else +@@ -369,6 +394,7 @@ MediaRecorder::~MediaRecorder() + Stop(); + } + ++// Still needs updating for avcodec_encode_video2 + MediaRet MediaRecorder::AddFrame(const u8 *vid) + { + if(!oc || !vid_st) +@@ -376,6 +402,9 @@ MediaRet MediaRecorder::AddFrame(const u8 *vid) + + AVCodecContext *ctx = vid_st->codec; + AVPacket pkt; ++#if LIBAVCODEC_VERSION_MAJOR > 56 ++ int ret, got_packet = 0; ++#endif + + // strip borders. inconsistent between depths for some reason + // but fortunately consistent between gb/gba. +@@ -413,7 +442,20 @@ MediaRet MediaRecorder::AddFrame(const u8 *vid) + pkt.data = f->data[0]; + pkt.size = linesize * ctx->height; + } else { ++#if LIBAVCODEC_VERSION_MAJOR > 56 ++ pkt.data = video_buf; ++ pkt.size = VIDEO_BUF_LEN; ++ f->format = ctx->pix_fmt; ++ f->width = ctx->width; ++ f->height = ctx->height; ++ ret = avcodec_encode_video2(ctx, &pkt, f, &got_packet); ++ if(!ret && got_packet && ctx->coded_frame) { ++ ctx->coded_frame->pts = pkt.pts; ++ ctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY); ++ } ++#else + pkt.size = avcodec_encode_video(ctx, video_buf, VIDEO_BUF_LEN, f); ++#endif + if(!pkt.size) + return MRET_OK; + if(ctx->coded_frame && ctx->coded_frame->pts != AV_NOPTS_VALUE) +@@ -438,6 +480,53 @@ MediaRet MediaRecorder::AddFrame(const u8 *vid) + return MRET_OK; + } + ++#if LIBAVCODEC_VERSION_MAJOR > 56 ++/* FFmpeg depricated avcodec_encode_audio. ++ * It was removed completely in 3.0. ++ * This will at least get audio recording *working* ++ */ ++static inline int MediaRecorderEncodeAudio(AVCodecContext *ctx, ++ AVPacket *pkt, ++ uint8_t *buf, int buf_size, ++ const short *samples) ++{ ++ AVFrame *frame; ++ av_init_packet(pkt); ++ int ret, samples_size, got_packet = 0; ++ ++ pkt->data = buf; ++ pkt->size = buf_size; ++ if (samples) { ++ frame = frame = av_frame_alloc(); ++ if (ctx->frame_size) { ++ frame->nb_samples = ctx->frame_size; ++ } else { ++ frame->nb_samples = (int64_t)buf_size * 8 / ++ (av_get_bits_per_sample(ctx->codec_id) * ++ ctx->channels); ++ } ++ frame->format = ctx->sample_fmt; ++ frame->channel_layout = ctx->channel_layout; ++ samples_size = av_samples_get_buffer_size(NULL, ctx->channels, ++ frame->nb_samples, ctx->sample_fmt, 1); ++ avcodec_fill_audio_frame(frame, ctx->channels, ctx->sample_fmt, ++ (const uint8_t *)samples, samples_size, 1); ++ //frame->pts = AV_NOPTS_VALUE; ++ } else { ++ frame = NULL; ++ } ++ ret = avcodec_encode_audio2(ctx, pkt, frame, &got_packet); ++ if (!ret && got_packet && ctx->coded_frame) { ++ ctx->coded_frame->pts = pkt->pts; ++ ctx->coded_frame->key_frame = !!(pkt->flags & AV_PKT_FLAG_KEY); ++ } ++ if (frame && frame->extended_data != frame->data) ++ av_freep(&frame->extended_data); ++ return ret; ++ ++} ++#endif ++ + MediaRet MediaRecorder::AddFrame(const u16 *aud) + { + if(!oc || !aud_st) +@@ -465,13 +554,19 @@ MediaRet MediaRecorder::AddFrame(const u16 *aud) + } + while(len + in_audio_buf2 >= frame_len) { + av_init_packet(&pkt); ++ #if LIBAVCODEC_VERSION_MAJOR > 56 ++ MediaRecorderEncodeAudio(ctx, &pkt, audio_buf, frame_len, ++ #else + pkt.size = avcodec_encode_audio(ctx, audio_buf, frame_len, ++ #endif + (const short *)(in_audio_buf2 ? audio_buf2 : aud)); + if(ctx->coded_frame && ctx->coded_frame->pts != AV_NOPTS_VALUE) + pkt.pts = av_rescale_q(ctx->coded_frame->pts, ctx->time_base, aud_st->time_base); + pkt.flags |= AV_PKT_FLAG_KEY; + pkt.stream_index = aud_st->index; ++ #if LIBAVCODEC_VERSION_MAJOR < 57 + pkt.data = audio_buf; ++ #endif + if(av_interleaved_write_frame(oc, &pkt) < 0) { + avformat_free_context(oc); + oc = NULL; |