Previous 199869 Revisions Next

r20684 Saturday 2nd February, 2013 at 23:02:45 UTC by Phil Bennett
aviio.c - Fix bad frames occurring on 2GB RIFF splits [Phil Bennett]
[src/lib/util]aviio.c

trunk/src/lib/util/aviio.c
r20683r20684
5454#define FOUR_GB                 ((UINT64)1 << 32)
5555
5656#define MAX_SOUND_CHANNELS      2
57#define SOUND_BUFFER_MSEC       2000        /* microseconds of sond buffering */
57#define SOUND_BUFFER_MSEC       2000        /* milliseconds of sound buffering */
5858
5959#define CHUNKTYPE_RIFF          AVI_FOURCC('R','I','F','F')
6060#define CHUNKTYPE_LIST          AVI_FOURCC('L','I','S','T')
r20683r20684
541541
542542
543543/*-------------------------------------------------
544    avi_create - create a new QuickTime movie file
544    avi_create - create a new AVI movie file
545545-------------------------------------------------*/
546546
547547avi_error avi_create(const char *filename, const avi_movie_info *info, avi_file **file)
r20683r20684
648648
649649
650650/*-------------------------------------------------
651    avi_close - close a QuickTime movie file
651    avi_close - close an AVI movie file
652652-------------------------------------------------*/
653653
654654avi_error avi_close(avi_file *file)
r20683r20684
980980   if (avierr != AVIERR_NONE)
981981      return avierr;
982982
983   /* write the data */
984   avierr = chunk_write(file, get_chunkid_for_stream(file, stream), file->tempbuffer, maxlength);
985   if (avierr != AVIERR_NONE)
986      return avierr;
987
983988   /* set the info for this new chunk */
984   avierr = set_stream_chunk_info(stream, stream->chunks, file->writeoffs, maxlength + 8);
989   avierr = set_stream_chunk_info(stream, stream->chunks, file->writeoffs - maxlength - 8, maxlength + 8);
985990   if (avierr != AVIERR_NONE)
986991      return avierr;
992
987993   stream->samples = file->info.video_numsamples = stream->chunks;
988994
989   /* write the data */
990   return chunk_write(file, get_chunkid_for_stream(file, stream), file->tempbuffer, maxlength);
995   return AVIERR_NONE;
991996}
992997
993998
r20683r20684
10261031   if (avierr != AVIERR_NONE)
10271032      return avierr;
10281033
1034   /* write the data */
1035   avierr = chunk_write(file, get_chunkid_for_stream(file, stream), file->tempbuffer, maxlength);
1036   if (avierr != AVIERR_NONE)
1037      return avierr;
1038
10291039   /* set the info for this new chunk */
1030   avierr = set_stream_chunk_info(stream, stream->chunks, file->writeoffs, maxlength + 8);
1040   avierr = set_stream_chunk_info(stream, stream->chunks, file->writeoffs - maxlength - 8, maxlength + 8);
10311041   if (avierr != AVIERR_NONE)
10321042      return avierr;
1043
10331044   stream->samples = file->info.video_numsamples = stream->chunks;
10341045
1035   /* write the data */
1036   return chunk_write(file, get_chunkid_for_stream(file, stream), file->tempbuffer, maxlength);
1046   return AVIERR_NONE;
10371047}
10381048
10391049
r20683r20684
22102220{
22112221   avi_stream *stream = get_audio_stream(file, 0, NULL);
22122222   avi_error avierr;
2213   UINT32 chunknum;
22142223   UINT32 length;
22152224
22162225   /* skip if no audio stream */
r20683r20684
22242233      length = framenum_to_samplenum(file, framenum + 1 + file->soundbuf_frames) - framenum_to_samplenum(file, framenum + file->soundbuf_frames);
22252234   length *= stream->channels * sizeof(INT16);
22262235
2227   /* set the info for this new chunk */
2228   chunknum = stream->chunks;
2229   avierr = set_stream_chunk_info(stream, chunknum, file->writeoffs, length + 8);
2236   /* then do the initial write */
2237   avierr = chunk_write(file, get_chunkid_for_stream(file, stream), file->soundbuf, length);
22302238   if (avierr != AVIERR_NONE)
22312239      return avierr;
22322240
2233   /* then do the initial write */
2234   return chunk_overwrite(file, get_chunkid_for_stream(file, stream), file->soundbuf, length, &stream->chunk[chunknum].offset, TRUE);
2241   /* set the info for this new chunk */
2242   return set_stream_chunk_info(stream, stream->chunks, file->writeoffs - length - 8, length + 8);
22352243}
22362244
22372245

Previous 199869 Revisions Next


© 1997-2024 The MAME Team