Merge branch 'master' into TasEditor

This commit is contained in:
mjbudd77 2021-10-28 20:18:27 -04:00
commit 306923afd9
3 changed files with 60 additions and 22 deletions

View File

@ -1,3 +1,4 @@
include(GNUInstallDirs)
set( APP_NAME fceux)
set(CMAKE_AUTOMOC ON)
@ -649,7 +650,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)

View File

@ -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,9 +1744,11 @@ static int write_audio_frame( AVFrame *frame )
}
while (ret >= 0)
{
AVPacket pkt = { 0 }; // data and size must be 0;
av_init_packet(&pkt);
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");
@ -1733,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;
@ -1916,11 +1941,12 @@ static int encode_video_frame( unsigned char *inBuf )
while (ret >= 0)
{
AVPacket pkt = { 0 };
//AVPacket pkt = { 0 };
av_init_packet(&pkt);
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)
{
@ -1930,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);
}
}

View File

@ -25,6 +25,7 @@
#include <limits.h>
#include <unzip.h>
#include <QFileInfo>
#include <QStyleFactory>
#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