Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Hap7 decoding. #35

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions HapInAVFoundation/AVAssetAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ - (BOOL) isHapTrack {
case kHapYCoCgCodecSubType:
case kHapYCoCgACodecSubType:
case kHapAOnlyCodecSubType:
case kHap7CodecSubType:
returnMe = YES;
break;
default:
Expand Down
1 change: 1 addition & 0 deletions HapInAVFoundation/AVPlayerItemAdditions.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ - (AVAssetTrack *) hapTrack {
case 'HapY':
case 'HapM':
case 'HapA':
case 'Hap7':
hapTrack = trackPtr;
break;
default:
Expand Down
6 changes: 6 additions & 0 deletions HapInAVFoundation/HapDecoderFrame.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ - (id) initEmptyWithHapSampleBuffer:(CMSampleBufferRef)sb {
dxtPixelFormats[1] = 0;
dxtMinDataSizes[1] = 0;
break;
case kHap7CodecSubType:
dxtPlaneCount = 1;
dxtPixelFormats[0] = kHapCVPixelFormat_RGBA_BC7;
dxtPixelFormats[1] = 0;
dxtMinDataSizes[1] = 0;
break;
}
rgbMinDataSize = 32 * imgSize.width * imgSize.height / 8;
}
Expand Down
283 changes: 185 additions & 98 deletions external/hap/hap.c

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions external/hap/hap.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ extern "C" {
#endif

/*
These match the constants defined by GL_EXT_texture_compression_s3tc and
GL_ARB_texture_compression_rgtc
These match the constants defined by GL_EXT_texture_compression_s3tc,
GL_ARB_texture_compression_rgtc and GL_ARB_texture_compression_bptc
*/

enum HapTextureFormat {
HapTextureFormat_RGB_DXT1 = 0x83F0,
HapTextureFormat_RGBA_DXT5 = 0x83F3,
HapTextureFormat_YCoCg_DXT5 = 0x01,
HapTextureFormat_A_RGTC1 = 0x8DBB
HapTextureFormat_A_RGTC1 = 0x8DBB,
HapTextureFormat_RGBA_BPTC_UNORM = 0x8E8C
};

enum HapCompressor {
Expand Down Expand Up @@ -143,6 +144,11 @@ unsigned int HapGetFrameTextureCount(const void *inputBuffer, unsigned long inpu
*/
unsigned int HapGetFrameTextureFormat(const void *inputBuffer, unsigned long inputBufferBytes, unsigned int index, unsigned int *outputBufferTextureFormat);

/*
On return sets chunk_count to the chunk count value of the texture at index in the frame.
*/
unsigned int HapGetFrameTextureChunkCount(const void *inputBuffer, unsigned long inputBufferBytes, unsigned int index, int *chunk_count);

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions source/HapCodecSubTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
#define kHapYCoCgCodecSubType 'HapY'
#define kHapYCoCgACodecSubType 'HapM'
#define kHapAOnlyCodecSubType 'HapA'
#define kHap7CodecSubType 'Hap7'

#endif
1 change: 1 addition & 0 deletions source/PixelFormats.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ void HapCodecRegisterPixelFormats(void)
HapCodecRegisterDXTPixelFormat(kHapCVPixelFormat_YCoCg_DXT5, 8, 0x83F3, false);
HapCodecRegisterYCoCgPixelFormat();
HapCodecRegisterYCoCgDXTARGTC1PixelFormat();
HapCodecRegisterDXTPixelFormat(kHapCVPixelFormat_RGBA_BC7, 8, 0x8E8C, true);
registered = true;
}
}
5 changes: 5 additions & 0 deletions source/PixelFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
*/
#define kHapCVPixelFormat_A_RGTC1 'RGA1'

/*
RGBA BC7
*/
#define kHapCVPixelFormat_RGBA_BC7 'BC7 '

/* CoreVideo requires us to "register" the DXT pixel format- if this isn't done, the various CV-related resources won't recognize it as a valid pixel format and stuff won't work. this function only needs to be called once, before you do anything with hap. the framework does this automatically in the +initialize methods of AVPlayerItemHapDXTOutput and AVAssetWriterHapInput. */
void HapCodecRegisterDXTPixelFormat(OSType fmt, short bits_per_pixel, SInt32 open_gl_internal_format, Boolean has_alpha);
void HapCodecRegisterYCoCgPixelFormat(void);
Expand Down