Force audio stream frames to always be keyframes.

This commit is contained in:
mjbudd77 2021-08-31 16:31:23 -04:00
parent 83633b11f3
commit 1c6a08e868
3 changed files with 16 additions and 11 deletions

View File

@ -152,9 +152,13 @@ gwavi_t::write_stream_header(FILE *fp, struct gwavi_stream_header_t *stream_head
goto write_int_failed;
if (write_int(fp, stream_header->sample_size) == -1)
goto write_int_failed;
if (write_int(fp, 0) == -1)
if (write_short(fp, 0) == -1)
goto write_int_failed;
if (write_int(fp, 0) == -1)
if (write_short(fp, 0) == -1)
goto write_int_failed;
if (write_short(fp, stream_header->image_width) == -1)
goto write_int_failed;
if (write_short(fp, stream_header->image_height) == -1)
goto write_int_failed;
if ((t = ftell(fp)) == -1) {
@ -464,7 +468,7 @@ gwavi_t::write_index(FILE *fp)
{
long marker, t;
unsigned int offset = 4;
unsigned int r;
unsigned int r, flags;
//char fourcc[8];
if (offsets.size() == 0 )
@ -486,6 +490,7 @@ gwavi_t::write_index(FILE *fp)
for (size_t i = 0; i < offsets.size(); i++)
{
//peak_chunk( fp, offset, fourcc, &r );
flags = 0;
if ( offsets[i].type == 0)
{
@ -499,14 +504,10 @@ gwavi_t::write_index(FILE *fp)
if ( offsets[i].keyFrame )
{
if (write_int(fp, 0x10) == -1)
goto write_int_failed;
}
else
{
if (write_int(fp, 0x00) == -1)
goto write_int_failed;
flags |= IF_KEYFRAME;
}
if (write_int(fp, flags) == -1)
goto write_int_failed;
if (write_int(fp, offset) == -1)
goto write_int_failed;
if (write_int(fp, offsets[i].len) == -1)

View File

@ -180,6 +180,8 @@ gwavi_t::open(const char *filename, unsigned int width, unsigned int height,
stream_header_v.data_rate = 1000000;
stream_header_v.buffer_size = size;
stream_header_v.data_length = 0;
stream_header_v.image_width = width;
stream_header_v.image_height = height;
/* set stream format */
stream_format_v.header_size = 40;
@ -370,7 +372,7 @@ gwavi_t::add_audio( unsigned char *buffer, size_t len)
idx.len = len;
idx.type = 1;
idx.keyFrame = 0;
idx.keyFrame = 1;
offsets.push_back( idx );

View File

@ -103,6 +103,8 @@ struct gwavi_stream_header_t
*/
int audio_quality;
unsigned int sample_size; /* dwSampleSize */
int image_width;
int image_height;
};
struct gwavi_stream_format_v_t