Added avi metadata encoding to libav for Qt GUI.

This commit is contained in:
mjbudd77 2021-10-04 22:18:09 -04:00
parent 899dd03ac9
commit 6f0f4177f2
3 changed files with 70 additions and 1 deletions

View File

@ -32,12 +32,16 @@
#include <vfw.h>
#endif
#include <QDate>
#include <QLocale>
#include <QObject>
#include <QHeaderView>
#include <QMessageBox>
#include <QInputDialog>
#include "fceu.h"
#include "driver.h"
#include "version.h"
#include "common/os_utils.h"
#ifdef _USE_X264
@ -86,6 +90,7 @@ static int aviDriver = 0;
static int videoFormat = AVI_RGB24;
static int audioSampleRate = 48000;
static FILE *avLogFp = NULL;
//**************************************************************************************
static void convertRgb_32_to_24( const unsigned char *src, unsigned char *dest, int w, int h, int nPix, bool verticalFlip )
@ -1581,6 +1586,7 @@ static int setCodecFromConfig(void)
static int initMedia( const char *filename )
{
//AVDictionaryEntry *dictEntry = NULL;
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT( 59, 0, 0 )
const AVOutputFormat *fmt;
@ -1649,6 +1655,16 @@ static int initMedia( const char *filename )
}
}
for ( auto it = avi_info.kvmap.begin(); it != avi_info.kvmap.end(); it++)
{
av_dict_set( &oc->metadata, it->first.c_str(), it->second.c_str(), 0 );
}
//while ( dictEntry = av_dict_get( oc->metadata, "", dictEntry, AV_DICT_IGNORE_SUFFIX ) )
//{
// printf("Entry: %s = %s \n", dictEntry->key, dictEntry->value );
//}
/* Write the stream header, if any. */
if ( avformat_write_header(oc, NULL) )
{
@ -2012,10 +2028,14 @@ int aviRecordLogOpen(void)
//**************************************************************************************
int aviRecordOpenFile( const char *filepath )
{
QDate date;
QLocale locale;
char fourcc[8];
gwavi_audio_t audioConfig;
double fps;
char fileName[1024];
char txt[512];
const char *romFile;
if ( aviRecordLogOpen() )
{
@ -2030,7 +2050,6 @@ int aviRecordOpenFile( const char *filepath )
}
else
{
const char *romFile;
romFile = getRomFile();
@ -2090,6 +2109,33 @@ int aviRecordOpenFile( const char *filepath )
}
}
date = QDate::currentDate();
avi_info.add_pair( "ICRD", date.toString(Qt::ISODate).toStdString().c_str() );
avi_info.add_pair( "ILNG", QLocale::languageToString( locale.language() ).toStdString().c_str() );
avi_info.add_pair( "IARL", QLocale::countryToString( locale.country() ).toStdString().c_str() );
sprintf( txt, "FCEUX %s", FCEU_VERSION_STRING );
avi_info.add_pair( "ITCH", txt );
romFile = getRomFile();
if ( romFile )
{
getFileBaseName( romFile, txt );
if ( txt[0] != 0 )
{
avi_info.add_pair( "ISRC", txt );
}
if ( GameInfo )
{
avi_info.add_pair( "ISRF", md5_asciistr(GameInfo->MD5) );
}
}
g_config->getOption("SDL.AviVideoFormat", &videoFormat);
#ifdef WIN32

View File

@ -64,6 +64,7 @@
* @return Structure containing required information in order to create the AVI
* file. If an error occured, NULL is returned.
*/
gwavi_info_list_t avi_info;
gwavi_t::gwavi_t(void)
{

View File

@ -36,6 +36,8 @@
#include <stdint.h> /* for size_t */
#include <stddef.h> /* for size_t */
#include <vector>
#include <string>
#include <map>
#pragma pack( push, 2 )
@ -185,6 +187,26 @@ class gwavi_dataBuffer
size_t size;
};
class gwavi_info_list_t
{
public:
void add_pair( const char *key, const char *value )
{
std::string k = key, v = value;
kvmap[k] = v;
}
void clear(void)
{
kvmap.clear();
}
std::map <std::string, std::string> kvmap;
};
extern gwavi_info_list_t avi_info;
class gwavi_t
{
public: