From 4cea83fd1b9a3212df20a0bbc7d8724b473af990 Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Sat, 23 Oct 2021 05:55:17 -0400 Subject: [PATCH 1/4] Changed command line lua script fullpath resolution logic to use cross platform QFileInfo instead of unix realpath. --- src/drivers/Qt/fceuWrapper.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/drivers/Qt/fceuWrapper.cpp b/src/drivers/Qt/fceuWrapper.cpp index 8705490b..8084cad2 100644 --- a/src/drivers/Qt/fceuWrapper.cpp +++ b/src/drivers/Qt/fceuWrapper.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include "Qt/main.h" #include "Qt/throttle.h" @@ -961,18 +962,27 @@ int fceuWrapperInit( int argc, char *argv[] ) // load lua script if option passed g_config->getOption("SDL.LuaScript", &s); g_config->setOption("SDL.LuaScript", ""); - if (s != "") + if (s.size() > 0) { -#if defined(__linux__) || defined(__APPLE__) || defined(__unix__) + QFileInfo fi( s.c_str() ); // Resolve absolute path to file - char fullpath[2048]; - if ( realpath( s.c_str(), fullpath ) != NULL ) + if ( fi.exists() ) { - //printf("Fullpath: '%s'\n", fullpath ); - s.assign( fullpath ); + //printf("FI: '%s'\n", fi.absoluteFilePath().toStdString().c_str() ); + //printf("FI: '%s'\n", fi.canonicalFilePath().toStdString().c_str() ); + s = fi.canonicalFilePath().toStdString(); } -#endif +//#if defined(__linux__) || defined(__APPLE__) || defined(__unix__) +// +// // Resolve absolute path to file +// char fullpath[2048]; +// if ( realpath( s.c_str(), fullpath ) != NULL ) +// { +// printf("Fullpath: '%s'\n", fullpath ); +// s.assign( fullpath ); +// } +//#endif FCEU_LoadLuaCode(s.c_str()); } #endif From 860a182233acd29b79a2b89c62c83a94e3d0c169 Mon Sep 17 00:00:00 2001 From: Dan Church Date: Mon, 25 Oct 2021 16:05:59 -0500 Subject: [PATCH 2/4] Use GNUInstallDirs for man page install paths --- src/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a630b14c..41b27e60 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,4 @@ +include(GNUInstallDirs) set( APP_NAME fceux) set(CMAKE_AUTOMOC ON) @@ -631,7 +632,7 @@ install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/auxlib.lua DESTINA install( DIRECTORY ${CMAKE_SOURCE_DIR}/output/. DESTINATION share/fceux ) install( FILES ${CMAKE_SOURCE_DIR}/fceux1.png DESTINATION share/pixmaps ) install( FILES ${CMAKE_SOURCE_DIR}/fceux.desktop DESTINATION share/applications ) -install( FILES ${CMAKE_SOURCE_DIR}/documentation/fceux.6 DESTINATION share/man/man6 ) -install( FILES ${CMAKE_SOURCE_DIR}/documentation/fceux-net-server.6 DESTINATION share/man/man6 ) +install( FILES ${CMAKE_SOURCE_DIR}/documentation/fceux.6 DESTINATION ${CMAKE_INSTALL_MANDIR}/man6 ) +install( FILES ${CMAKE_SOURCE_DIR}/documentation/fceux-net-server.6 DESTINATION ${CMAKE_INSTALL_MANDIR}/man6 ) endif(APPLE) From b6ece28e766e72fc677b55dc66fe1517910e622d Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Tue, 26 Oct 2021 20:45:45 -0400 Subject: [PATCH 3/4] Preparing for the removal of av_init_packet. It is depricated in the latest release of ffmpeg. --- src/drivers/Qt/AviRecord.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/drivers/Qt/AviRecord.cpp b/src/drivers/Qt/AviRecord.cpp index 798eace1..bc192478 100644 --- a/src/drivers/Qt/AviRecord.cpp +++ b/src/drivers/Qt/AviRecord.cpp @@ -1723,7 +1723,9 @@ static int write_audio_frame( AVFrame *frame ) while (ret >= 0) { AVPacket pkt = { 0 }; // data and size must be 0; +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 59, 0, 0 ) av_init_packet(&pkt); +#endif ret = avcodec_receive_packet(ost->enc, &pkt); if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) { @@ -1918,7 +1920,9 @@ static int encode_video_frame( unsigned char *inBuf ) { AVPacket pkt = { 0 }; +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 59, 0, 0 ) av_init_packet(&pkt); +#endif ret = avcodec_receive_packet(c, &pkt); From 03341dd83445b314722d018c6eaa834573cc0144 Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Wed, 27 Oct 2021 07:02:44 -0400 Subject: [PATCH 4/4] Further fixing av_init_packet deprecation. In the future AVPacket will not be able to be allocated on the stack. Instead using av_packet_alloc/av_packet_free. --- src/drivers/Qt/AviRecord.cpp | 57 +++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/src/drivers/Qt/AviRecord.cpp b/src/drivers/Qt/AviRecord.cpp index bc192478..c0b2de81 100644 --- a/src/drivers/Qt/AviRecord.cpp +++ b/src/drivers/Qt/AviRecord.cpp @@ -756,6 +756,7 @@ struct OutputStream AVCodecContext *enc; AVFrame *frame; AVFrame *tmp_frame; + AVPacket *pkt; struct SwsContext *sws_ctx; struct SwrContext *swr_ctx; int64_t next_pts; @@ -774,6 +775,7 @@ struct OutputStream st = NULL; enc = NULL; frame = tmp_frame = NULL; + pkt = NULL; sws_ctx = NULL; swr_ctx = NULL; bytesPerSample = 0; @@ -800,6 +802,10 @@ struct OutputStream { avcodec_free_context(&enc); enc = NULL; } + if ( pkt != NULL ) + { + av_packet_free(&pkt); pkt = NULL; + } if ( frame != NULL ) { av_frame_free(&frame); frame = NULL; @@ -1223,6 +1229,14 @@ static int initVideoStream( const char *codec_name, OutputStream *ost ) return -1; } + /* packet for holding encoded output */ + ost->pkt = av_packet_alloc(); + if (ost->pkt == NULL) + { + fprintf( avLogFp, "Could not allocate the video packet\n"); + return -1; + } + /* Allocate the encoded raw picture. */ ost->frame = alloc_picture(c->pix_fmt, c->width, c->height); @@ -1456,6 +1470,14 @@ static int initAudioStream( const char *codec_name, OutputStream *ost ) return -1; } + /* packet for holding encoded output */ + ost->pkt = av_packet_alloc(); + if (ost->pkt == NULL) + { + fprintf( avLogFp, "Could not allocate the audio packet\n"); + return -1; + } + if (c->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE) { nb_samples = audioSampleRate / 4; @@ -1722,11 +1744,11 @@ static int write_audio_frame( AVFrame *frame ) } while (ret >= 0) { - AVPacket pkt = { 0 }; // data and size must be 0; -#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 59, 0, 0 ) - av_init_packet(&pkt); -#endif - ret = avcodec_receive_packet(ost->enc, &pkt); + //AVPacket pkt = { 0 }; // data and size must be 0; +//#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 59, 0, 0 ) +// av_init_packet(&pkt); +//#endif + ret = avcodec_receive_packet(ost->enc, ost->pkt); if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) { fprintf( avLogFp, "Error encoding audio frame\n"); @@ -1735,16 +1757,17 @@ static int write_audio_frame( AVFrame *frame ) } else if (ret >= 0) { - av_packet_rescale_ts(&pkt, ost->enc->time_base, ost->st->time_base); - pkt.stream_index = ost->st->index; + av_packet_rescale_ts(ost->pkt, ost->enc->time_base, ost->st->time_base); + ost->pkt->stream_index = ost->st->index; /* Write the compressed frame to the media file. */ - ret = av_interleaved_write_frame(oc, &pkt); + ret = av_interleaved_write_frame(oc, ost->pkt); if (ret < 0) { fprintf( avLogFp, "Error while writing audio frame\n"); ost->writeError = true; return -1; } + av_packet_unref(ost->pkt); } } return 0; @@ -1918,13 +1941,12 @@ static int encode_video_frame( unsigned char *inBuf ) while (ret >= 0) { - AVPacket pkt = { 0 }; + //AVPacket pkt = { 0 }; -#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 59, 0, 0 ) - av_init_packet(&pkt); -#endif - - ret = avcodec_receive_packet(c, &pkt); +//#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT( 59, 0, 0 ) +// av_init_packet(&pkt); +//#endif + ret = avcodec_receive_packet(c, ost->pkt); if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) { @@ -1934,16 +1956,17 @@ static int encode_video_frame( unsigned char *inBuf ) } else if (ret >= 0) { - av_packet_rescale_ts(&pkt, c->time_base, video_st.st->time_base); - pkt.stream_index = video_st.st->index; + av_packet_rescale_ts(ost->pkt, c->time_base, video_st.st->time_base); + ost->pkt->stream_index = video_st.st->index; /* Write the compressed frame to the media file. */ - ret = av_interleaved_write_frame(oc, &pkt); + ret = av_interleaved_write_frame(oc, ost->pkt); if (ret < 0) { fprintf( avLogFp, "Error while writing video frame\n"); ost->writeError = true; return -1; } + av_packet_unref(ost->pkt); } }