Skip to content

Commit

Permalink
fix AIFC COMM chunk parsing error
Browse files Browse the repository at this point in the history
missing pack attribute on riff chunk structures

Ardour/ardour#805 (comment)
#5 (comment)
  • Loading branch information
agfline committed Jul 2, 2023
1 parent 455bfef commit db348e9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/AAFIface/AAFIAudioFiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,8 @@ int parse_audio_summary( AAF_Iface *aafi, aafiAudioEssence *audioEssence )
______________________________________________________________________
*/

// dump_hex( audioEssence->summary->val, audioEssence->summary->len );

rc = riff_parseAudioFile( &RIFFAudioFile, &embeddedAudioDataReaderCallback, audioEssence->summary->val, &audioEssence->summary->len );

if ( rc < 0 ) {
Expand Down
29 changes: 19 additions & 10 deletions src/AAFIface/RIFFParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
#define __RIFFParser__


#ifdef __GNUC__
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
#endif

#ifdef _MSC_VER
#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop))
#endif


struct RIFFAudioFile {
/* common to wave/aiff */
uint32_t sampleRate;
Expand All @@ -31,22 +40,22 @@ struct RIFFAudioFile {
};


struct riffHeaderChunk {
PACK(struct riffHeaderChunk {
char ckid[4];
uint32_t cksz;

char format[4];
unsigned char data[];
};
});

struct riffChunk {
PACK(struct riffChunk {
char ckid[4];
uint32_t cksz;

unsigned char data[];
};
});

struct wavFmtChunk {
PACK(struct wavFmtChunk {
char ckid[4]; //'fmt '
uint32_t cksz;

Expand All @@ -56,9 +65,9 @@ struct wavFmtChunk {
uint32_t avg_bytes_per_sec;
uint16_t block_align;
uint16_t bits_per_sample;
};
});

struct wavBextChunk {
PACK(struct wavBextChunk {
char ckid[4]; //'bext'
uint32_t cksz;

Expand Down Expand Up @@ -99,17 +108,17 @@ struct wavBextChunk {
of bext structure when parsing.
*/

};
});

struct aiffCOMMChunk {
PACK(struct aiffCOMMChunk {
char ckid[4]; //'COMM'
uint32_t cksz;

uint16_t numChannels;
uint32_t numSampleFrames;
uint16_t sampleSize;
unsigned char sampleRate[10]; // 80 bit IEEE Standard 754 floating point number
};
});



Expand Down

0 comments on commit db348e9

Please sign in to comment.