separate sps/pps data

This commit is contained in:
itsmattkc committed 2024-08-21 09:31:07 -07:00
1 parent ef1a06af27
commit d80bb9c6f4
7 files changed
+27 -33

No files matched your search

+5 -1
View File
@@ -10,5 +10,9 @@ SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
add_subdirectory(lib)
add_subdirectory(pipe)
if (NOT ANDROID)
add_subdirectory(pipe)
endif()
add_subdirectory(app)
+4 -3
View File
@@ -171,6 +171,7 @@ void VideoDecoder::startRecording()
m_recordingFilename = QDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation)).filePath("vanilla-recording-%0.mp4").arg(QDateTime::currentSecsSinceEpoch());
QByteArray filenameUtf8 = m_recordingFilename.toUtf8();
size_t sps_pps_size;
int r = avformat_alloc_output_context2(&m_recordingCtx, nullptr, nullptr, filenameUtf8.constData());
if (r < 0) {
@@ -192,11 +193,11 @@ void VideoDecoder::startRecording()
m_videoStream->time_base = {1, 60};
m_videoStream->codecpar->codec_id = AV_CODEC_ID_H264;
size_t sps_pps_size;
vanilla_retrieve_sps_pps_data(nullptr, &sps_pps_size);
sps_pps_size = sizeof(VANILLA_SPS_PARAMS) + sizeof(VANILLA_PPS_PARAMS);
m_videoStream->codecpar->extradata_size = sps_pps_size;
m_videoStream->codecpar->extradata = (uint8_t *) av_malloc(sps_pps_size);
vanilla_retrieve_sps_pps_data(m_videoStream->codecpar->extradata, &sps_pps_size);
memcpy(m_videoStream->codecpar->extradata, VANILLA_SPS_PARAMS, sizeof(VANILLA_SPS_PARAMS));
memcpy(m_videoStream->codecpar->extradata + sizeof(VANILLA_SPS_PARAMS), VANILLA_PPS_PARAMS, sizeof(VANILLA_PPS_PARAMS));
m_audioStream = avformat_new_stream(m_recordingCtx, nullptr);
if (!m_audioStream) {
+6 -4
View File
@@ -1,4 +1,4 @@
add_library(vanilla SHARED
add_library(vanilla STATIC
gamepad/audio.c
gamepad/command.c
gamepad/gamepad.c
@@ -13,8 +13,10 @@ target_include_directories(vanilla PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(vanilla PRIVATE
pthread
)
if (NOT ANDROID)
target_link_libraries(vanilla PRIVATE
pthread
)
endif()
install(TARGETS vanilla)
+4 -2
View File
@@ -146,8 +146,10 @@ void handle_video_packet(vanilla_event_handler_t event_handler, void *context, u
frame_decode_num++;
if (is_idr) {
memcpy(nals_current, sps_pps_params, sizeof(sps_pps_params));
nals_current += sizeof(sps_pps_params);
memcpy(nals_current, VANILLA_SPS_PARAMS, sizeof(VANILLA_SPS_PARAMS));
nals_current += sizeof(VANILLA_SPS_PARAMS);
memcpy(nals_current, VANILLA_PPS_PARAMS, sizeof(VANILLA_PPS_PARAMS));
nals_current += sizeof(VANILLA_PPS_PARAMS);
}
// begin slice nalu
-7
View File
@@ -6,11 +6,4 @@
void *listen_video(void *x);
void request_idr();
static const uint8_t sps_pps_params[] = {
// sps
0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x20, 0xac, 0x2b, 0x40, 0x6c, 0x1e, 0xf3, 0x68,
// pps
0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x06, 0x0c, 0xe8
};
#endif // GAMEPAD_VIDEO_H
-8
View File
@@ -103,14 +103,6 @@ void vanilla_request_idr()
request_idr();
}
void vanilla_retrieve_sps_pps_data(void *data, size_t *size)
{
if (data != NULL) {
memcpy(data, sps_pps_params, MIN(*size, sizeof(sps_pps_params)));
}
*size = sizeof(sps_pps_params);
}
void vanilla_set_region(int region)
{
set_region(region);
+8 -8
View File
@@ -85,6 +85,14 @@ enum VanillaBatteryStatus {
VANILLA_BATTERY_STATUS_FULL = 6
};
static const uint8_t VANILLA_SPS_PARAMS[] = {
0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x20, 0xac, 0x2b, 0x40, 0x6c, 0x1e, 0xf3, 0x68,
};
static const uint8_t VANILLA_PPS_PARAMS[] = {
0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x06, 0x0c, 0xe8
};
/**
* Event handler used by caller to receive events
*/
@@ -142,14 +150,6 @@ void vanilla_install_logger(void (*logger)(const char *, va_list args));
*/
void vanilla_request_idr();
/**
* Retrieve SPS/PPS data for H.264 encoding
*
* If `data` is null, `*size` will be set to the number of bytes required.
* If `data` is not null, bytes will be copied up to `*size` or the total number of bytes.
*/
void vanilla_retrieve_sps_pps_data(void *data, size_t *size);
/**
* Sets the region Vanilla should present itself to the console
*