Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.

Commit

Permalink
Added a boolean for indicating whether the container is well framed. …
Browse files Browse the repository at this point in the history
…Apparently, some AVI files are framed well for the first sound frame, but not thereafter. This breaks AC3 passthrough of some files on the ATV.
  • Loading branch information
gbooker committed Dec 14, 2008
1 parent c36db2e commit a55142f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion MatroskaImportPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ void MatroskaTrack::ParseFirstBlock(KaxInternalBlock &block)
if (desc) {
switch ((*desc)->dataFormat) {
case kAudioFormatAC3:
replaceSoundDesc = parse_ac3_bitstream(&asbd, &acl, block.GetBuffer(0).Buffer(), block.GetFrameSize(0));
replaceSoundDesc = parse_ac3_bitstream(&asbd, &acl, block.GetBuffer(0).Buffer(), block.GetFrameSize(0), true);
break;
}
}
Expand Down
5 changes: 3 additions & 2 deletions bitstream_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ static int ac3_synchronize(uint8_t *buf, int buf_size)
* @param acl Pointer to the AudioChannelLayout to fill
* @param buffer Pointer to the buffer data to scan
* @param buff_size Size of the buffer
* @param wellFramed YES if the container is well frame, NO otherwise. AVI is NO!
* @return 1 if successfull, 0 otherwise
*/

int parse_ac3_bitstream(AudioStreamBasicDescription *asbd, AudioChannelLayout *acl, uint8_t *buffer, int buff_size)
int parse_ac3_bitstream(AudioStreamBasicDescription *asbd, AudioChannelLayout *acl, uint8_t *buffer, int buff_size, bool wellFramed)
{
int offset = ac3_synchronize(buffer, buff_size);
if(offset == -1)
Expand Down Expand Up @@ -140,7 +141,7 @@ int parse_ac3_bitstream(AudioStreamBasicDescription *asbd, AudioChannelLayout *a
/* Setup the AudioStreamBasicDescription and AudioChannelLayout */
memset(asbd, 0, sizeof(AudioStreamBasicDescription));
asbd->mSampleRate = sample_rate >> shift;
if(offset == 0 && buff_size == framesize)
if(wellFramed && offset == 0 && buff_size == framesize)
asbd->mFormatID = kAudioFormatAC3;
else
asbd->mFormatID = kAudioFormatAC3MS;
Expand Down
2 changes: 1 addition & 1 deletion bitstream_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
extern "C" {
#endif

int parse_ac3_bitstream(AudioStreamBasicDescription *asbd, AudioChannelLayout *acl, uint8_t *buffer, int buff_size);
int parse_ac3_bitstream(AudioStreamBasicDescription *asbd, AudioChannelLayout *acl, uint8_t *buffer, int buff_size, bool wellFramed);

typedef struct FFusionParserContext
{
Expand Down
4 changes: 2 additions & 2 deletions ff_private.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ OSStatus initialize_audio_map(NCStream *map, Track targetTrack, Handle dataRef,
error = QTMetaDataAddItem(trackMetaData, kQTMetaDataStorageFormatUserData, kQTMetaDataKeyFormatUserData, (UInt8 *)&key, sizeof(key), (UInt8 *)prop, strlen(prop), kQTMetaDataTypeUTF8, NULL);
QTMetaDataRelease(trackMetaData);
}
if(parse_ac3_bitstream(&asbd, &acl, firstFrame->data, firstFrame->size))
if(parse_ac3_bitstream(&asbd, &acl, firstFrame->data, firstFrame->size, false))
{
useDefault = 0;
aclSize = sizeof(AudioChannelLayout);
Expand Down Expand Up @@ -850,11 +850,11 @@ int import_using_index(ff_global_ptr storage, int *hadIndex, TimeValue *addedDur
{
/* Add all of the samples to the media */
AddMediaSampleReferences64(ncstr->media, ncstr->sampleHdl, sampleNum, ncstr->sampleTable, NULL);
free(ncstr->sampleTable);

/* The index is both present and not empty */
*hadIndex = 1;
}
free(ncstr->sampleTable);
}

if(*hadIndex == 0)
Expand Down

0 comments on commit a55142f

Please sign in to comment.