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 1 commit
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/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
5 changes: 5 additions & 0 deletions external/hap/hap.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#define kHapFormatRGBADXT5 0xE
#define kHapFormatYCoCgDXT5 0xF
#define kHapFormatARGTC1 0x1
#define kHapFormatRGBABC7 0xC

/*
Packed byte values for Hap
Expand Down Expand Up @@ -212,6 +213,8 @@ static unsigned int hap_texture_format_constant_for_format_identifier(unsigned i
return HapTextureFormat_YCoCg_DXT5;
case kHapFormatARGTC1:
return HapTextureFormat_A_RGTC1;
case kHapFormatRGBABC7:
return HapTextureFormat_RGBA_BC7;
default:
return 0;

Expand All @@ -231,6 +234,8 @@ static unsigned int hap_texture_format_identifier_for_format_constant(unsigned i
return kHapFormatYCoCgDXT5;
case HapTextureFormat_A_RGTC1:
return kHapFormatARGTC1;
case HapTextureFormat_RGBA_BC7:
return kHapFormatRGBABC7;
default:
return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion external/hap/hap.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ enum HapTextureFormat {
HapTextureFormat_RGB_DXT1 = 0x83F0,
HapTextureFormat_RGBA_DXT5 = 0x83F3,
HapTextureFormat_YCoCg_DXT5 = 0x01,
HapTextureFormat_A_RGTC1 = 0x8DBB
HapTextureFormat_A_RGTC1 = 0x8DBB,
HapTextureFormat_RGBA_BC7 = 0x8E8C,
};

enum HapCompressor {
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