Skip to content
Permalink
Browse files

Updated encoded format constant for AVIF

Summary:
@public
`LibAvifTranscodingPlugin` used the constant "ivfav1" to represent the AVIF encoded image format. This updates this constant to "avif", and adds android and iOS bindings.

Reviewed By: diegosanchezr

Differential Revision: D16827020

fbshipit-source-id: 17d3c21add6e9ed5b94b6e9546e116040cd93868
  • Loading branch information...
Aurelien Fredouelle authored and facebook-github-bot committed Aug 15, 2019
1 parent 31337b5 commit 89b87bee831d3c7aabd0ad327fb118ce699df55d
@@ -33,6 +33,9 @@
/** A HEIF encoded image, see https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format */
public static final EncodedImageFormat HEIF = new EncodedImageFormat("heif");

/** An AVIF encoded image, see https://en.wikipedia.org/wiki/AV1#AV1_Image_File_Format_(AVIF) */
public static final EncodedImageFormat AVIF = new EncodedImageFormat("avif");

@DoNotStrip
public EncodedImageFormat(final String identifier) {
super(identifier);
@@ -170,7 +170,7 @@ void IvfAv1Decompressor::_ensureHeaderIsRead() {

_imageSpecification = image::Specification{
.size = image::Size{fileHeader.frameWidth, fileHeader.frameHeight},
.format = formats::IvfAv1,
.format = formats::Avif,
.pixelSpecification = image::pixel::specifications::RGB};
}

@@ -23,7 +23,7 @@ namespace {
constexpr auto IvfPrefix = folly::StringPiece{"DKIF"};
constexpr auto Av1FourCC = folly::StringPiece{"AV01"};

folly::Optional<image::EncodedFormat> ivfEncodedImageFormatDetectorHandler(
folly::Optional<image::EncodedFormat> avifEncodedImageFormatDetectorHandler(
io::IImageSource& source) {
constexpr auto len = sizeof(fb::ivf::IvfFileHeader);

@@ -44,25 +44,25 @@ folly::Optional<image::EncodedFormat> ivfEncodedImageFormatDetectorHandler(
Av1FourCC.begin(),
reinterpret_cast<const char*>(ivfHeader.fourcc),
Av1FourCC.size()) == 0) {
return formats::IvfAv1; // fourcc indicating AV1
return formats::Avif; // fourcc indicating AV1
}

return folly::none;
}

inline codecs::DecompressorProvider::Factory makeIvfAv1DecompressorFactory() {
inline codecs::DecompressorProvider::Factory makeAvifDecompressorFactory() {
return [](io::IImageSource& source,
const folly::Optional<image::Ratio>& /* unused */,
const Configuration& /* unused */) {
return std::make_unique<IvfAv1Decompressor>(source);
};
}

codecs::DecompressorProvider makeIvfAv1DecompressorProvider() {
codecs::DecompressorProvider makeAvifDecompressorProvider() {
return {
.format = formats::IvfAv1,
.format = formats::Avif,
.supportedSamplingRatios = {},
.decompressorFactory = makeIvfAv1DecompressorFactory(),
.decompressorFactory = makeAvifDecompressorFactory(),
};
}

@@ -71,8 +71,8 @@ codecs::DecompressorProvider makeIvfAv1DecompressorProvider() {
Plugin makeTranscodingPlugin() {
auto plugin = Plugin{};
plugin.encodedImageFormatDetectorHandlers.push_back(
&ivfEncodedImageFormatDetectorHandler);
plugin.decompressorProviders.push_back(makeIvfAv1DecompressorProvider());
&avifEncodedImageFormatDetectorHandler);
plugin.decompressorProviders.push_back(makeAvifDecompressorProvider());
return plugin;
}

@@ -17,7 +17,7 @@ namespace formats {
/**
* An IVF formatted file with AV1 payload as generated e.g. using libaom.
*/
static constexpr image::EncodedFormat IvfAv1{"ivfav1"};
static constexpr image::EncodedFormat Avif{"avif"};
} // namespace formats

Plugin makeTranscodingPlugin();
@@ -35,7 +35,7 @@ TEST(
auto decompressor = IvfAv1Decompressor{source};

const auto specifications = decompressor.sourceImageSpecification();
ASSERT_EQ(avif::formats::IvfAv1, specifications.format);
ASSERT_EQ(avif::formats::Avif, specifications.format);
ASSERT_EQ((image::Size{256, 170}), specifications.size);
}

@@ -64,7 +64,7 @@ TEST(plugins_avif_EncodedImageFormatHandler, whenCorrectFourCC_thenIvfAv1) {
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" // frame nom, dem, cnt
"\x00\x00\x00\x00", // unused
32);
ASSERT_EQ(formats::IvfAv1, runEncodedImageFormatHandler(input));
ASSERT_EQ(formats::Avif, runEncodedImageFormatHandler(input));
}

} // namespace test
@@ -52,6 +52,9 @@ NS_SWIFT_NAME(EncodedImageFormat)
/** A HEIF encoded image, see https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format */
@property (class, nonatomic, readonly) FSPEncodedImageFormat *heif;

/** An AVIF encoded image, see https://en.wikipedia.org/wiki/AV1#AV1_Image_File_Format_(AVIF) */
@property (class, nonatomic, readonly) FSPEncodedImageFormat *avif;

@end

NS_ASSUME_NONNULL_END
@@ -108,6 +108,11 @@ + (FSPEncodedImageFormat *)heif
return [self imageFormatWithIdentifier:FSPStringFromInternalFixedString(image::formats::Heif.identifier())];
}

+ (FSPEncodedImageFormat *)avif
{
return [self imageFormatWithIdentifier:FSPStringFromInternalFixedString(image::formats::Avif.identifier())];
}

#pragma mark - Internal

- (image::EncodedFormat)makeInternalFormat

0 comments on commit 89b87be

Please sign in to comment.
You can’t perform that action at this time.