Add support for AVIF album artwork
Import libavif and libaom, specifically built only for decoding, not encoding. Signed-off-by: Christopher Snowhill <kode54@gmail.com>CQTexperiment
parent
8c945b53de
commit
b8057b7c29
|
@ -119,6 +119,9 @@
|
|||
835A8FD327957310005B3C39 /* json.c in Sources */ = {isa = PBXBuildFile; fileRef = 835A8FC627957310005B3C39 /* json.c */; };
|
||||
835EDD8A27A000E8001EDCCE /* gsx.wv in Resources */ = {isa = PBXBuildFile; fileRef = 835EDD8027A000E8001EDCCE /* gsx.wv */; };
|
||||
835F00BB279BD1CD00055FCF /* SecondsFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 835F00B8279BD1CD00055FCF /* SecondsFormatter.m */; };
|
||||
835FAC7927BCDF2A00BA8562 /* AVIFDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 835FAC7527BCDF2A00BA8562 /* AVIFDecoder.m */; };
|
||||
835FAC7E27BCDF5B00BA8562 /* libaom.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 835FAC7C27BCDF5B00BA8562 /* libaom.a */; };
|
||||
835FAC7F27BCDF5B00BA8562 /* libavif.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 835FAC7D27BCDF5B00BA8562 /* libavif.a */; };
|
||||
8360EF6D17F92E56005208A4 /* HighlyComplete.bundle in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8360EF0517F92B24005208A4 /* HighlyComplete.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
836D28A818086386005B7299 /* MiniModeMenuTitleTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 836D28A718086386005B7299 /* MiniModeMenuTitleTransformer.m */; };
|
||||
836EF0C827BB91E600BF35B2 /* libogg.0.dylib in CopyFiles */ = {isa = PBXBuildFile; fileRef = 836EF0C427BB919300BF35B2 /* libogg.0.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
|
@ -906,6 +909,21 @@
|
|||
835EDD8027A000E8001EDCCE /* gsx.wv */ = {isa = PBXFileReference; lastKnownFileType = file; path = gsx.wv; sourceTree = "<group>"; };
|
||||
835F00B4279BD1CD00055FCF /* SecondsFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecondsFormatter.h; sourceTree = "<group>"; };
|
||||
835F00B8279BD1CD00055FCF /* SecondsFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SecondsFormatter.m; sourceTree = "<group>"; };
|
||||
835FAC6727BCDF2A00BA8562 /* aomdx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aomdx.h; sourceTree = "<group>"; };
|
||||
835FAC6827BCDF2A00BA8562 /* aom_frame_buffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aom_frame_buffer.h; sourceTree = "<group>"; };
|
||||
835FAC6927BCDF2A00BA8562 /* aom_encoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aom_encoder.h; sourceTree = "<group>"; };
|
||||
835FAC6A27BCDF2A00BA8562 /* aom_integer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aom_integer.h; sourceTree = "<group>"; };
|
||||
835FAC6B27BCDF2A00BA8562 /* aom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aom.h; sourceTree = "<group>"; };
|
||||
835FAC6C27BCDF2A00BA8562 /* aom_external_partition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aom_external_partition.h; sourceTree = "<group>"; };
|
||||
835FAC6D27BCDF2A00BA8562 /* aom_image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aom_image.h; sourceTree = "<group>"; };
|
||||
835FAC6E27BCDF2A00BA8562 /* aom_codec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aom_codec.h; sourceTree = "<group>"; };
|
||||
835FAC6F27BCDF2A00BA8562 /* aom_decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aom_decoder.h; sourceTree = "<group>"; };
|
||||
835FAC7027BCDF2A00BA8562 /* aomcx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aomcx.h; sourceTree = "<group>"; };
|
||||
835FAC7227BCDF2A00BA8562 /* avif.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = avif.h; sourceTree = "<group>"; };
|
||||
835FAC7427BCDF2A00BA8562 /* AVIFDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVIFDecoder.h; sourceTree = "<group>"; };
|
||||
835FAC7527BCDF2A00BA8562 /* AVIFDecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AVIFDecoder.m; sourceTree = "<group>"; };
|
||||
835FAC7C27BCDF5B00BA8562 /* libaom.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libaom.a; path = ThirdParty/avif/lib/libaom.a; sourceTree = "<group>"; };
|
||||
835FAC7D27BCDF5B00BA8562 /* libavif.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libavif.a; path = ThirdParty/avif/lib/libavif.a; sourceTree = "<group>"; };
|
||||
8360EF0017F92B23005208A4 /* HighlyComplete.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = HighlyComplete.xcodeproj; path = Plugins/HighlyComplete/HighlyComplete.xcodeproj; sourceTree = "<group>"; };
|
||||
836D28A618086386005B7299 /* MiniModeMenuTitleTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MiniModeMenuTitleTransformer.h; path = Window/MiniModeMenuTitleTransformer.h; sourceTree = "<group>"; };
|
||||
836D28A718086386005B7299 /* MiniModeMenuTitleTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MiniModeMenuTitleTransformer.m; path = Window/MiniModeMenuTitleTransformer.m; sourceTree = "<group>"; };
|
||||
|
@ -1029,6 +1047,8 @@
|
|||
8355D6B8180613FB00D05687 /* Security.framework in Frameworks */,
|
||||
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
|
||||
17BB5CED0B8A86010009ACB1 /* AudioToolbox.framework in Frameworks */,
|
||||
835FAC7F27BCDF5B00BA8562 /* libavif.a in Frameworks */,
|
||||
835FAC7E27BCDF5B00BA8562 /* libaom.a in Frameworks */,
|
||||
17BB5CF90B8A86350009ACB1 /* AudioUnit.framework in Frameworks */,
|
||||
17BB5CFA0B8A86350009ACB1 /* CoreAudio.framework in Frameworks */,
|
||||
838F851E256B4E5E00C3E614 /* Sparkle.framework in Frameworks */,
|
||||
|
@ -1085,6 +1105,8 @@
|
|||
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
835FAC7C27BCDF5B00BA8562 /* libaom.a */,
|
||||
835FAC7D27BCDF5B00BA8562 /* libavif.a */,
|
||||
836EF0CD27BB94F100BF35B2 /* libopusfile.0.dylib */,
|
||||
836EF0CC27BB94E100BF35B2 /* libopus.0.dylib */,
|
||||
836EF0C727BB91BC00BF35B2 /* libFLAC.8.dylib */,
|
||||
|
@ -1139,6 +1161,7 @@
|
|||
177EBF770B8BC2A70000BC8C /* ThirdParty */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
835FAC6427BCDF2900BA8562 /* avif */,
|
||||
835A8FC527957310005B3C39 /* json */,
|
||||
177EBF850B8BC2A70000BC8C /* ImageTextCell */,
|
||||
179790DD0C087AB7001D6996 /* OpenURLPanel */,
|
||||
|
@ -1664,6 +1687,58 @@
|
|||
path = Formatters;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
835FAC6427BCDF2900BA8562 /* avif */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
835FAC6527BCDF2900BA8562 /* include */,
|
||||
835FAC7327BCDF2A00BA8562 /* source */,
|
||||
);
|
||||
path = avif;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
835FAC6527BCDF2900BA8562 /* include */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
835FAC6627BCDF2900BA8562 /* aom */,
|
||||
835FAC7127BCDF2A00BA8562 /* avif */,
|
||||
);
|
||||
path = include;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
835FAC6627BCDF2900BA8562 /* aom */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
835FAC6727BCDF2A00BA8562 /* aomdx.h */,
|
||||
835FAC6827BCDF2A00BA8562 /* aom_frame_buffer.h */,
|
||||
835FAC6927BCDF2A00BA8562 /* aom_encoder.h */,
|
||||
835FAC6A27BCDF2A00BA8562 /* aom_integer.h */,
|
||||
835FAC6B27BCDF2A00BA8562 /* aom.h */,
|
||||
835FAC6C27BCDF2A00BA8562 /* aom_external_partition.h */,
|
||||
835FAC6D27BCDF2A00BA8562 /* aom_image.h */,
|
||||
835FAC6E27BCDF2A00BA8562 /* aom_codec.h */,
|
||||
835FAC6F27BCDF2A00BA8562 /* aom_decoder.h */,
|
||||
835FAC7027BCDF2A00BA8562 /* aomcx.h */,
|
||||
);
|
||||
path = aom;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
835FAC7127BCDF2A00BA8562 /* avif */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
835FAC7227BCDF2A00BA8562 /* avif.h */,
|
||||
);
|
||||
path = avif;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
835FAC7327BCDF2A00BA8562 /* source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
835FAC7427BCDF2A00BA8562 /* AVIFDecoder.h */,
|
||||
835FAC7527BCDF2A00BA8562 /* AVIFDecoder.m */,
|
||||
);
|
||||
path = source;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
8360EF0117F92B23005208A4 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
@ -2415,6 +2490,7 @@
|
|||
1755E1F90BA0D2B600CA3560 /* PlaylistLoader.m in Sources */,
|
||||
8E9A30160BA792DC0091081B /* NSFileHandle+CreateFile.m in Sources */,
|
||||
179790E10C087AB7001D6996 /* OpenURLPanel.m in Sources */,
|
||||
835FAC7927BCDF2A00BA8562 /* AVIFDecoder.m in Sources */,
|
||||
EDAAA41F25A665C000731773 /* PositionSliderToolbarItem.swift in Sources */,
|
||||
1791FF900CB43A2C0070BC5C /* MediaKeysApplication.m in Sources */,
|
||||
5604D45B0D60349B004F5C5D /* SpotlightWindowController.m in Sources */,
|
||||
|
@ -2743,10 +2819,14 @@
|
|||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
HEADER_SEARCH_PATHS = ThirdParty/avif/include;
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
INSTALL_PATH = "$(HOME)/Applications";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/ThirdParty/avif/lib",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.12;
|
||||
OTHER_CFLAGS = (
|
||||
"-D__MACOSX__",
|
||||
|
@ -2787,10 +2867,14 @@
|
|||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/ThirdParty/Frameworks";
|
||||
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
|
||||
HEADER_SEARCH_PATHS = ThirdParty/avif/include;
|
||||
INFOPLIST_FILE = Info.plist;
|
||||
INSTALL_PATH = "$(HOME)/Applications";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/ThirdParty/avif/lib",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.12;
|
||||
OTHER_CFLAGS = (
|
||||
"-D__MACOSX__",
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
//
|
||||
|
||||
#import "PlaylistEntry.h"
|
||||
#import "AVIFDecoder.h"
|
||||
#import "SecondsFormatter.h"
|
||||
|
||||
@implementation PlaylistEntry
|
||||
|
@ -29,6 +30,7 @@
|
|||
@synthesize errorMessage;
|
||||
|
||||
@synthesize URL;
|
||||
@synthesize trashURL;
|
||||
|
||||
@synthesize artist;
|
||||
@synthesize albumartist;
|
||||
|
@ -378,7 +380,15 @@
|
|||
NSImage *image = [NSImage imageNamed:imageCacheTag];
|
||||
|
||||
if(image == nil) {
|
||||
image = [[NSImage alloc] initWithData:albumArtInternal];
|
||||
if([AVIFDecoder isAVIFFormatForData:albumArtInternal]) {
|
||||
CGImageRef imageRef = [AVIFDecoder createAVIFImageWithData:albumArtInternal];
|
||||
if(imageRef) {
|
||||
image = [[NSImage alloc] initWithCGImage:imageRef size:NSZeroSize];
|
||||
CFRelease(imageRef);
|
||||
}
|
||||
} else {
|
||||
image = [[NSImage alloc] initWithData:albumArtInternal];
|
||||
}
|
||||
[image setName:imageCacheTag];
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
These were built from libavif and libaom, from the following repositories:
|
||||
|
||||
https://github.com/link-u/libaom - at revision: v2.0.0-586-gdee179da7
|
||||
https://github.com/AOMediaCodec/libavif - at revision: v0.9.3-43-g380d91a
|
||||
|
||||
libaom was built to two separate targets, with the following options:
|
||||
|
||||
```
|
||||
arch -x86_64 /usr/local/bin/cmake .. -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.12" -DCONFIG_AV1_ENCODER=0 -DCONFIG_WEBM_IO=0
|
||||
make -j8
|
||||
```
|
||||
|
||||
```
|
||||
cmake .. -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_OSX_DEPLOYMENT_TARGET="11.0" -DCONFIG_AV1_ENCODER=0 -DCONFIG_WEBM_IO=0 -DCONFIG_RUNTIME_CPU_DETECT=0
|
||||
make -j8
|
||||
```
|
||||
|
||||
And then they were merged using lipo.
|
||||
|
||||
libavif was built with the following:
|
||||
|
||||
```
|
||||
arch -x86_64 /usr/local/bin/cmake .. -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.12" -DAVIF_CODEC_AOM=ON -DBUILD_SHARED_LIBS=OFF
|
||||
make -j8
|
||||
```
|
||||
|
||||
```
|
||||
cmake .. -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_OSX_DEPLOYMENT_TARGET="11.0" -DAVIF_CODEC_AOM=ON -DBUILD_SHARED_LIBS=OFF
|
||||
make -j8
|
||||
```
|
||||
|
||||
And then they were merged with lipo.
|
||||
|
||||
The AVIF decoder contained in the source directory was based on code from
|
||||
the following repository:
|
||||
|
||||
https://github.com/dreampiggy/AVIFQuickLook
|
||||
|
||||
|
||||
I updated the code to work with newer libavif.
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
/*!\defgroup aom AOM
|
||||
* \ingroup codecs
|
||||
* AOM is aom's newest video compression algorithm that uses motion
|
||||
* compensated prediction, Discrete Cosine Transform (DCT) coding of the
|
||||
* prediction error signal and context dependent entropy coding techniques
|
||||
* based on arithmetic principles. It features:
|
||||
* - YUV 4:2:0 image format
|
||||
* - Macro-block based coding (16x16 luma plus two 8x8 chroma)
|
||||
* - 1/4 (1/8) pixel accuracy motion compensated prediction
|
||||
* - 4x4 DCT transform
|
||||
* - 128 level linear quantizer
|
||||
* - In loop deblocking filter
|
||||
* - Context-based entropy coding
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*!\file
|
||||
* \brief Provides controls common to both the AOM encoder and decoder.
|
||||
*/
|
||||
#ifndef AOM_AOM_AOM_H_
|
||||
#define AOM_AOM_AOM_H_
|
||||
|
||||
#include "aom/aom_codec.h"
|
||||
#include "aom/aom_image.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!\brief Control functions
|
||||
*
|
||||
* The set of macros define the control functions of AOM interface
|
||||
*/
|
||||
enum aom_com_control_id {
|
||||
/* TODO(https://crbug.com/aomedia/2671): The encoder overlaps the range of
|
||||
* these values for its control ids, see the NOTEs in aom/aomcx.h. These
|
||||
* should be migrated to something like the AOM_DECODER_CTRL_ID_START range
|
||||
* next time we're ready to break the ABI.
|
||||
*/
|
||||
AV1_GET_REFERENCE = 128, /**< get a pointer to a reference frame,
|
||||
av1_ref_frame_t* parameter */
|
||||
AV1_SET_REFERENCE = 129, /**< write a frame into a reference buffer,
|
||||
av1_ref_frame_t* parameter */
|
||||
AV1_COPY_REFERENCE = 130, /**< get a copy of reference frame from the decoderm
|
||||
av1_ref_frame_t* parameter */
|
||||
AOM_COMMON_CTRL_ID_MAX,
|
||||
|
||||
AV1_GET_NEW_FRAME_IMAGE =
|
||||
192, /**< get a pointer to the new frame, aom_image_t* parameter */
|
||||
AV1_COPY_NEW_FRAME_IMAGE = 193, /**< copy the new frame to an external buffer,
|
||||
aom_image_t* parameter */
|
||||
|
||||
AOM_DECODER_CTRL_ID_START = 256
|
||||
};
|
||||
|
||||
/*!\brief AV1 specific reference frame data struct
|
||||
*
|
||||
* Define the data struct to access av1 reference frames.
|
||||
*/
|
||||
typedef struct av1_ref_frame {
|
||||
int idx; /**< frame index to get (input) */
|
||||
int use_external_ref; /**< Directly use external ref buffer(decoder only) */
|
||||
aom_image_t img; /**< img structure to populate (output) */
|
||||
} av1_ref_frame_t;
|
||||
|
||||
/*!\cond */
|
||||
/*!\brief aom decoder control function parameter type
|
||||
*
|
||||
* Defines the data type for each of AOM decoder control function requires.
|
||||
*
|
||||
* \note For each control ID "X", a macro-define of
|
||||
* AOM_CTRL_X is provided. It is used at compile time to determine
|
||||
* if the control ID is supported by the libaom library available,
|
||||
* when the libaom version cannot be controlled.
|
||||
*/
|
||||
AOM_CTRL_USE_TYPE(AV1_GET_REFERENCE, av1_ref_frame_t *)
|
||||
#define AOM_CTRL_AV1_GET_REFERENCE
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1_SET_REFERENCE, av1_ref_frame_t *)
|
||||
#define AOM_CTRL_AV1_SET_REFERENCE
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1_COPY_REFERENCE, av1_ref_frame_t *)
|
||||
#define AOM_CTRL_AV1_COPY_REFERENCE
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1_GET_NEW_FRAME_IMAGE, aom_image_t *)
|
||||
#define AOM_CTRL_AV1_GET_NEW_FRAME_IMAGE
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1_COPY_NEW_FRAME_IMAGE, aom_image_t *)
|
||||
#define AOM_CTRL_AV1_COPY_NEW_FRAME_IMAGE
|
||||
|
||||
/*!\endcond */
|
||||
/*! @} - end defgroup aom */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AOM_AOM_AOM_H_
|
|
@ -0,0 +1,552 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Internal implementation details
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// There are two levels of interfaces used to access the AOM codec: the
|
||||
// the aom_codec_iface and the aom_codec_ctx.
|
||||
//
|
||||
// 1. aom_codec_iface_t
|
||||
// (Related files: aom/aom_codec.h, aom/src/aom_codec.c,
|
||||
// aom/internal/aom_codec_internal.h, av1/av1_cx_iface.c,
|
||||
// av1/av1_dx_iface.c)
|
||||
//
|
||||
// Used to initialize the codec context, which contains the configuration for
|
||||
// for modifying the encoder/decoder during run-time. See the other
|
||||
// documentation in this header file for more details. For the most part,
|
||||
// users will call helper functions, such as aom_codec_iface_name,
|
||||
// aom_codec_get_caps, etc., to interact with it.
|
||||
//
|
||||
// The main purpose of the aom_codec_iface_t is to provide a way to generate
|
||||
// a default codec config, find out what capabilities the implementation has,
|
||||
// and create an aom_codec_ctx_t (which is actually used to interact with the
|
||||
// codec).
|
||||
//
|
||||
// Note that the implementations for the AV1 algorithm are located in
|
||||
// av1/av1_cx_iface.c and av1/av1_dx_iface.c
|
||||
//
|
||||
//
|
||||
// 2. aom_codec_ctx_t
|
||||
// (Related files: aom/aom_codec.h, av1/av1_cx_iface.c, av1/av1_dx_iface.c,
|
||||
// aom/aomcx.h, aom/aomdx.h, aom/src/aom_encoder.c, aom/src/aom_decoder.c)
|
||||
//
|
||||
// The actual interface between user code and the codec. It stores the name
|
||||
// of the codec, a pointer back to the aom_codec_iface_t that initialized it,
|
||||
// initialization flags, a config for either encoder or the decoder, and a
|
||||
// pointer to internal data.
|
||||
//
|
||||
// The codec is configured / queried through calls to aom_codec_control,
|
||||
// which takes a control ID (listed in aomcx.h and aomdx.h) and a parameter.
|
||||
// In the case of "getter" control IDs, the parameter is modified to have
|
||||
// the requested value; in the case of "setter" control IDs, the codec's
|
||||
// configuration is changed based on the parameter. Note that a aom_codec_err_t
|
||||
// is returned, which indicates if the operation was successful or not.
|
||||
//
|
||||
// Note that for the encoder, the aom_codec_alg_priv_t points to the
|
||||
// the aom_codec_alg_priv structure in av1/av1_cx_iface.c, and for the decoder,
|
||||
// the struct in av1/av1_dx_iface.c. Variables such as AV1_COMP cpi are stored
|
||||
// here and also used in the core algorithm.
|
||||
//
|
||||
// At the end, aom_codec_destroy should be called for each initialized
|
||||
// aom_codec_ctx_t.
|
||||
|
||||
/*!\defgroup codec Common Algorithm Interface
|
||||
* This abstraction allows applications to easily support multiple video
|
||||
* formats with minimal code duplication. This section describes the interface
|
||||
* common to all codecs (both encoders and decoders).
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the codec algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video codec algorithm.
|
||||
*
|
||||
* An application instantiates a specific codec instance by using
|
||||
* aom_codec_dec_init() or aom_codec_enc_init() and a pointer to the
|
||||
* algorithm's interface structure:
|
||||
* <pre>
|
||||
* my_app.c:
|
||||
* extern aom_codec_iface_t my_codec;
|
||||
* {
|
||||
* aom_codec_ctx_t algo;
|
||||
* int threads = 4;
|
||||
* aom_codec_dec_cfg_t cfg = { threads, 0, 0, 1 };
|
||||
* res = aom_codec_dec_init(&algo, &my_codec, &cfg, 0);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Once initialized, the instance is managed using other functions from
|
||||
* the aom_codec_* family.
|
||||
*/
|
||||
#ifndef AOM_AOM_AOM_CODEC_H_
|
||||
#define AOM_AOM_AOM_CODEC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "aom/aom_image.h"
|
||||
#include "aom/aom_integer.h"
|
||||
|
||||
/*!\brief Decorator indicating a function is deprecated */
|
||||
#ifndef AOM_DEPRECATED
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
#define AOM_DEPRECATED __attribute__((deprecated))
|
||||
#elif defined(_MSC_VER)
|
||||
#define AOM_DEPRECATED
|
||||
#else
|
||||
#define AOM_DEPRECATED
|
||||
#endif
|
||||
#endif /* AOM_DEPRECATED */
|
||||
|
||||
#ifndef AOM_DECLSPEC_DEPRECATED
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
#define AOM_DECLSPEC_DEPRECATED /**< \copydoc #AOM_DEPRECATED */
|
||||
#elif defined(_MSC_VER)
|
||||
/*!\brief \copydoc #AOM_DEPRECATED */
|
||||
#define AOM_DECLSPEC_DEPRECATED __declspec(deprecated)
|
||||
#else
|
||||
#define AOM_DECLSPEC_DEPRECATED /**< \copydoc #AOM_DEPRECATED */
|
||||
#endif
|
||||
#endif /* AOM_DECLSPEC_DEPRECATED */
|
||||
|
||||
/*!\brief Decorator indicating a function is potentially unused */
|
||||
#ifdef AOM_UNUSED
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#define AOM_UNUSED __attribute__((unused))
|
||||
#else
|
||||
#define AOM_UNUSED
|
||||
#endif
|
||||
|
||||
/*!\brief Decorator indicating that given struct/union/enum is packed */
|
||||
#ifndef ATTRIBUTE_PACKED
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
#define ATTRIBUTE_PACKED __attribute__((packed))
|
||||
#elif defined(_MSC_VER)
|
||||
#define ATTRIBUTE_PACKED
|
||||
#else
|
||||
#define ATTRIBUTE_PACKED
|
||||
#endif
|
||||
#endif /* ATTRIBUTE_PACKED */
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define AOM_CODEC_ABI_VERSION (5 + AOM_IMAGE_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*!\brief Algorithm return codes */
|
||||
typedef enum {
|
||||
/*!\brief Operation completed without error */
|
||||
AOM_CODEC_OK,
|
||||
|
||||
/*!\brief Unspecified error */
|
||||
AOM_CODEC_ERROR,
|
||||
|
||||
/*!\brief Memory operation failed */
|
||||
AOM_CODEC_MEM_ERROR,
|
||||
|
||||
/*!\brief ABI version mismatch */
|
||||
AOM_CODEC_ABI_MISMATCH,
|
||||
|
||||
/*!\brief Algorithm does not have required capability */
|
||||
AOM_CODEC_INCAPABLE,
|
||||
|
||||
/*!\brief The given bitstream is not supported.
|
||||
*
|
||||
* The bitstream was unable to be parsed at the highest level. The decoder
|
||||
* is unable to proceed. This error \ref SHOULD be treated as fatal to the
|
||||
* stream. */
|
||||
AOM_CODEC_UNSUP_BITSTREAM,
|
||||
|
||||
/*!\brief Encoded bitstream uses an unsupported feature
|
||||
*
|
||||
* The decoder does not implement a feature required by the encoder. This
|
||||
* return code should only be used for features that prevent future
|
||||
* pictures from being properly decoded. This error \ref MAY be treated as
|
||||
* fatal to the stream or \ref MAY be treated as fatal to the current GOP.
|
||||
*/
|
||||
AOM_CODEC_UNSUP_FEATURE,
|
||||
|
||||
/*!\brief The coded data for this stream is corrupt or incomplete
|
||||
*
|
||||
* There was a problem decoding the current frame. This return code
|
||||
* should only be used for failures that prevent future pictures from
|
||||
* being properly decoded. This error \ref MAY be treated as fatal to the
|
||||
* stream or \ref MAY be treated as fatal to the current GOP. If decoding
|
||||
* is continued for the current GOP, artifacts may be present.
|
||||
*/
|
||||
AOM_CODEC_CORRUPT_FRAME,
|
||||
|
||||
/*!\brief An application-supplied parameter is not valid.
|
||||
*
|
||||
*/
|
||||
AOM_CODEC_INVALID_PARAM,
|
||||
|
||||
/*!\brief An iterator reached the end of list.
|
||||
*
|
||||
*/
|
||||
AOM_CODEC_LIST_END
|
||||
|
||||
} aom_codec_err_t;
|
||||
|
||||
/*! \brief Codec capabilities bitfield
|
||||
*
|
||||
* Each codec advertises the capabilities it supports as part of its
|
||||
* ::aom_codec_iface_t interface structure. Capabilities are extra interfaces
|
||||
* or functionality, and are not required to be supported.
|
||||
*
|
||||
* The available flags are specified by AOM_CODEC_CAP_* defines.
|
||||
*/
|
||||
typedef long aom_codec_caps_t;
|
||||
#define AOM_CODEC_CAP_DECODER 0x1 /**< Is a decoder */
|
||||
#define AOM_CODEC_CAP_ENCODER 0x2 /**< Is an encoder */
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow for
|
||||
* proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by AOM_CODEC_USE_* defines.
|
||||
*/
|
||||
typedef long aom_codec_flags_t;
|
||||
|
||||
/*!\brief Time Stamp Type
|
||||
*
|
||||
* An integer, which when multiplied by the stream's time base, provides
|
||||
* the absolute time of a sample.
|
||||
*/
|
||||
typedef int64_t aom_codec_pts_t;
|
||||
|
||||
/*!\brief Codec interface structure.
|
||||
*
|
||||
* Contains function pointers and other data private to the codec
|
||||
* implementation. This structure is opaque to the application. Common
|
||||
* functions used with this structure:
|
||||
* - aom_codec_iface_name(aom_codec_iface_t *iface): get the
|
||||
* name of the codec
|
||||
* - aom_codec_get_caps(aom_codec_iface_t *iface): returns
|
||||
* the capabilities of the codec
|
||||
* - aom_codec_enc_config_default: generate the default config for
|
||||
* initializing the encoder (see documention in aom_encoder.h)
|
||||
* - aom_codec_dec_init, aom_codec_enc_init: initialize the codec context
|
||||
* structure (see documentation on aom_codec_ctx).
|
||||
*
|
||||
* To get access to the AV1 encoder and decoder, use aom_codec_av1_cx() and
|
||||
* aom_codec_av1_dx().
|
||||
*/
|
||||
typedef const struct aom_codec_iface aom_codec_iface_t;
|
||||
|
||||
/*!\brief Codec private data structure.
|
||||
*
|
||||
* Contains data private to the codec implementation. This structure is opaque
|
||||
* to the application.
|
||||
*/
|
||||
typedef struct aom_codec_priv aom_codec_priv_t;
|
||||
|
||||
/*!\brief Compressed Frame Flags
|
||||
*
|
||||
* This type represents a bitfield containing information about a compressed
|
||||
* frame that may be useful to an application. The most significant 16 bits
|
||||
* can be used by an algorithm to provide additional detail, for example to
|
||||
* support frame types that are codec specific (MPEG-1 D-frames for example)
|
||||
*/
|
||||
typedef uint32_t aom_codec_frame_flags_t;
|
||||
#define AOM_FRAME_IS_KEY 0x1 /**< frame is the start of a GOP */
|
||||
/*!\brief frame can be dropped without affecting the stream (no future frame
|
||||
* depends on this one) */
|
||||
#define AOM_FRAME_IS_DROPPABLE 0x2
|
||||
/*!\brief this is an INTRA_ONLY frame */
|
||||
#define AOM_FRAME_IS_INTRAONLY 0x10
|
||||
/*!\brief this is an S-frame */
|
||||
#define AOM_FRAME_IS_SWITCH 0x20
|
||||
/*!\brief this is an error-resilient frame */
|
||||
#define AOM_FRAME_IS_ERROR_RESILIENT 0x40
|
||||
/*!\brief this is a key-frame dependent recovery-point frame */
|
||||
#define AOM_FRAME_IS_DELAYED_RANDOM_ACCESS_POINT 0x80
|
||||
|
||||
/*!\brief Iterator
|
||||
*
|
||||
* Opaque storage used for iterating over lists.
|
||||
*/
|
||||
typedef const void *aom_codec_iter_t;
|
||||
|
||||
/*!\brief Codec context structure
|
||||
*
|
||||
* All codecs \ref MUST support this context structure fully. In general,
|
||||
* this data should be considered private to the codec algorithm, and
|
||||
* not be manipulated or examined by the calling application. Applications
|
||||
* may reference the 'name' member to get a printable description of the
|
||||
* algorithm.
|
||||
*/
|
||||
typedef struct aom_codec_ctx {
|
||||
const char *name; /**< Printable interface name */
|
||||
aom_codec_iface_t *iface; /**< Interface pointers */
|
||||
aom_codec_err_t err; /**< Last returned error */
|
||||
const char *err_detail; /**< Detailed info, if available */
|
||||
aom_codec_flags_t init_flags; /**< Flags passed at init time */
|
||||
union {
|
||||
/**< Decoder Configuration Pointer */
|
||||
const struct aom_codec_dec_cfg *dec;
|
||||
/**< Encoder Configuration Pointer */
|
||||
const struct aom_codec_enc_cfg *enc;
|
||||
const void *raw;
|
||||
} config; /**< Configuration pointer aliasing union */
|
||||
aom_codec_priv_t *priv; /**< Algorithm private storage */
|
||||
} aom_codec_ctx_t;
|
||||
|
||||
/*!\brief Bit depth for codec
|
||||
* *
|
||||
* This enumeration determines the bit depth of the codec.
|
||||
*/
|
||||
typedef enum aom_bit_depth {
|
||||
AOM_BITS_8 = 8, /**< 8 bits */
|
||||
AOM_BITS_10 = 10, /**< 10 bits */
|
||||
AOM_BITS_12 = 12, /**< 12 bits */
|
||||
} aom_bit_depth_t;
|
||||
|
||||
/*!\brief Superblock size selection.
|
||||
*
|
||||
* Defines the superblock size used for encoding. The superblock size can
|
||||
* either be fixed at 64x64 or 128x128 pixels, or it can be dynamically
|
||||
* selected by the encoder for each frame.
|
||||
*/
|
||||
typedef enum aom_superblock_size {
|
||||
AOM_SUPERBLOCK_SIZE_64X64, /**< Always use 64x64 superblocks. */
|
||||
AOM_SUPERBLOCK_SIZE_128X128, /**< Always use 128x128 superblocks. */
|
||||
AOM_SUPERBLOCK_SIZE_DYNAMIC /**< Select superblock size dynamically. */
|
||||
} aom_superblock_size_t;
|
||||
|
||||
/*
|
||||
* Library Version Number Interface
|
||||
*
|
||||
* For example, see the following sample return values:
|
||||
* aom_codec_version() (1<<16 | 2<<8 | 3)
|
||||
* aom_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
|
||||
* aom_codec_version_extra_str() "rc1-16-gec6a1ba"
|
||||
*/
|
||||
|
||||
/*!\brief Return the version information (as an integer)
|
||||
*
|
||||
* Returns a packed encoding of the library version number. This will only
|
||||
* include the major.minor.patch component of the version number. Note that this
|
||||
* encoded value should be accessed through the macros provided, as the encoding
|
||||
* may change in the future.
|
||||
*
|
||||
*/
|
||||
int aom_codec_version(void);
|
||||
|
||||
/*!\brief Return the major version number */
|
||||
#define aom_codec_version_major() ((aom_codec_version() >> 16) & 0xff)
|
||||
|
||||
/*!\brief Return the minor version number */
|
||||
#define aom_codec_version_minor() ((aom_codec_version() >> 8) & 0xff)
|
||||
|
||||
/*!\brief Return the patch version number */
|
||||
#define aom_codec_version_patch() ((aom_codec_version() >> 0) & 0xff)
|
||||
|
||||
/*!\brief Return the version information (as a string)
|
||||
*
|
||||
* Returns a printable string containing the full library version number. This
|
||||
* may contain additional text following the three digit version number, as to
|
||||
* indicate release candidates, prerelease versions, etc.
|
||||
*
|
||||
*/
|
||||
const char *aom_codec_version_str(void);
|
||||
|
||||
/*!\brief Return the version information (as a string)
|
||||
*
|
||||
* Returns a printable "extra string". This is the component of the string
|
||||
* returned by aom_codec_version_str() following the three digit version number.
|
||||
*
|
||||
*/
|
||||
const char *aom_codec_version_extra_str(void);
|
||||
|
||||
/*!\brief Return the build configuration
|
||||
*
|
||||
* Returns a printable string containing an encoded version of the build
|
||||
* configuration. This may be useful to aom support.
|
||||
*
|
||||
*/
|
||||
const char *aom_codec_build_config(void);
|
||||
|
||||
/*!\brief Return the name for a given interface
|
||||
*
|
||||
* Returns a human readable string for name of the given codec interface.
|
||||
*
|
||||
* \param[in] iface Interface pointer
|
||||
*
|
||||
*/
|
||||
const char *aom_codec_iface_name(aom_codec_iface_t *iface);
|
||||
|
||||
/*!\brief Convert error number to printable string
|
||||
*
|
||||
* Returns a human readable string for the last error returned by the
|
||||
* algorithm. The returned error will be one line and will not contain
|
||||
* any newline characters.
|
||||
*
|
||||
*
|
||||
* \param[in] err Error number.
|
||||
*
|
||||
*/
|
||||
const char *aom_codec_err_to_string(aom_codec_err_t err);
|
||||
|
||||
/*!\brief Retrieve error synopsis for codec context
|
||||
*
|
||||
* Returns a human readable string for the last error returned by the
|
||||
* algorithm. The returned error will be one line and will not contain
|
||||
* any newline characters.
|
||||
*
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
*
|
||||
*/
|
||||
const char *aom_codec_error(aom_codec_ctx_t *ctx);
|
||||
|
||||
/*!\brief Retrieve detailed error information for codec context
|
||||
*
|
||||
* Returns a human readable string providing detailed information about
|
||||
* the last error.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
*
|
||||
* \retval NULL
|
||||
* No detailed information is available.
|
||||
*/
|
||||
const char *aom_codec_error_detail(aom_codec_ctx_t *ctx);
|
||||
|
||||
/* REQUIRED FUNCTIONS
|
||||
*
|
||||
* The following functions are required to be implemented for all codecs.
|
||||
* They represent the base case functionality expected of all codecs.
|
||||
*/
|
||||
|
||||
/*!\brief Destroy a codec instance
|
||||
*
|
||||
* Destroys a codec context, freeing any associated memory buffers.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
*
|
||||
* \retval #AOM_CODEC_OK
|
||||
* The codec algorithm initialized.
|
||||
* \retval #AOM_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
aom_codec_err_t aom_codec_destroy(aom_codec_ctx_t *ctx);
|
||||
|
||||
/*!\brief Get the capabilities of an algorithm.
|
||||
*
|
||||
* Retrieves the capabilities bitfield from the algorithm's interface.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface
|
||||
*
|
||||
*/
|
||||
aom_codec_caps_t aom_codec_get_caps(aom_codec_iface_t *iface);
|
||||
|
||||
/*!\name Codec Control
|
||||
*
|
||||
* The aom_codec_control function exchanges algorithm specific data with the
|
||||
* codec instance. Additionally, the macro AOM_CODEC_CONTROL_TYPECHECKED is
|
||||
* provided, which will type-check the parameter against the control ID before
|
||||
* calling aom_codec_control - note that this macro requires the control ID
|
||||
* to be directly encoded in it, e.g.,
|
||||
* AOM_CODEC_CONTROL_TYPECHECKED(&ctx, AOME_SET_CPUUSED, 8).
|
||||
*
|
||||
* The codec control IDs can be found in aom.h, aomcx.h, and aomdx.h
|
||||
* (defined as aom_com_control_id, aome_enc_control_id, and aom_dec_control_id).
|
||||
* @{
|
||||
*/
|
||||
/*!\brief Algorithm Control
|
||||
*
|
||||
* aom_codec_control takes a context, a control ID, and a third parameter
|
||||
* (with varying type). If the context is non-null and an error occurs,
|
||||
* ctx->err will be set to the same value as the return value.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] ctrl_id Algorithm specific control identifier
|
||||
*
|
||||
* \retval #AOM_CODEC_OK
|
||||
* The control request was processed.
|
||||
* \retval #AOM_CODEC_ERROR
|
||||
* The control request was not processed.
|
||||
* \retval #AOM_CODEC_INVALID_PARAM
|
||||
* The data was not valid.
|
||||
*/
|
||||
aom_codec_err_t aom_codec_control(aom_codec_ctx_t *ctx, int ctrl_id, ...);
|
||||
|
||||
/*!\brief aom_codec_control wrapper macro (adds type-checking, less flexible)
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to aom_codec_control(). However, it requires the explicit control ID
|
||||
* be passed in (it cannot be passed in via a variable) -- otherwise a compiler
|
||||
* error will occur. After the type checking, it calls aom_codec_control.
|
||||
*/
|
||||
#define AOM_CODEC_CONTROL_TYPECHECKED(ctx, id, data) \
|
||||
aom_codec_control_typechecked_##id(ctx, id, data) /**<\hideinitializer*/
|
||||
|
||||
/*!\brief Creates typechecking mechanisms for aom_codec_control
|
||||
*
|
||||
* It defines a static function with the correctly typed arguments as a wrapper
|
||||
* to the type-unsafe aom_codec_control function. It also creates a typedef
|
||||
* for each type.
|
||||
*/
|
||||
#define AOM_CTRL_USE_TYPE(id, typ) \
|
||||
static aom_codec_err_t aom_codec_control_typechecked_##id( \
|
||||
aom_codec_ctx_t *, int, typ) AOM_UNUSED; \
|
||||
static aom_codec_err_t aom_codec_control_typechecked_##id( \
|
||||
aom_codec_ctx_t *ctx, int ctrl, typ data) { \
|
||||
return aom_codec_control(ctx, ctrl, data); \
|
||||
} /**<\hideinitializer*/ \
|
||||
typedef typ aom_codec_control_type_##id;
|
||||
/*!@} end Codec Control group */
|
||||
|
||||
/*!\brief OBU types. */
|
||||
typedef enum ATTRIBUTE_PACKED {
|
||||
OBU_SEQUENCE_HEADER = 1,
|
||||
OBU_TEMPORAL_DELIMITER = 2,
|
||||
OBU_FRAME_HEADER = 3,
|
||||
OBU_TILE_GROUP = 4,
|
||||
OBU_METADATA = 5,
|
||||
OBU_FRAME = 6,
|
||||
OBU_REDUNDANT_FRAME_HEADER = 7,
|
||||
OBU_TILE_LIST = 8,
|
||||
OBU_PADDING = 15,
|
||||
} OBU_TYPE;
|
||||
|
||||
/*!\brief OBU metadata types. */
|
||||
typedef enum {
|
||||
OBU_METADATA_TYPE_AOM_RESERVED_0 = 0,
|
||||
OBU_METADATA_TYPE_HDR_CLL = 1,
|
||||
OBU_METADATA_TYPE_HDR_MDCV = 2,
|
||||
OBU_METADATA_TYPE_SCALABILITY = 3,
|
||||
OBU_METADATA_TYPE_ITUT_T35 = 4,
|
||||
OBU_METADATA_TYPE_TIMECODE = 5,
|
||||
} OBU_METADATA_TYPE;
|
||||
|
||||
/*!\brief Returns string representation of OBU_TYPE.
|
||||
*
|
||||
* \param[in] type The OBU_TYPE to convert to string.
|
||||
*/
|
||||
const char *aom_obu_type_to_string(OBU_TYPE type);
|
||||
|
||||
/*!@} - end defgroup codec*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // AOM_AOM_AOM_CODEC_H_
|
|
@ -0,0 +1,257 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
#ifndef AOM_AOM_AOM_DECODER_H_
|
||||
#define AOM_AOM_AOM_DECODER_H_
|
||||
|
||||
/*!\defgroup decoder Decoder Algorithm Interface
|
||||
* \ingroup codec
|
||||
* This abstraction allows applications using this decoder to easily support
|
||||
* multiple video formats with minimal code duplication. This section describes
|
||||
* the interface common to all decoders.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the decoder algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video decoder algorithm.
|
||||
*
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "aom/aom_codec.h"
|
||||
#include "aom/aom_frame_buffer.h"
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define AOM_DECODER_ABI_VERSION \
|
||||
(6 + AOM_CODEC_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*! \brief Decoder capabilities bitfield
|
||||
*
|
||||
* Each decoder advertises the capabilities it supports as part of its
|
||||
* ::aom_codec_iface_t interface structure. Capabilities are extra interfaces
|
||||
* or functionality, and are not required to be supported by a decoder.
|
||||
*
|
||||
* The available flags are specified by AOM_CODEC_CAP_* defines.
|
||||
*/
|
||||
/*!brief Can support external frame buffers */
|
||||
#define AOM_CODEC_CAP_EXTERNAL_FRAME_BUFFER 0x200000
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow for
|
||||
* proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by AOM_CODEC_USE_* defines.
|
||||
*/
|
||||
|
||||
/*!\brief Stream properties
|
||||
*
|
||||
* This structure is used to query or set properties of the decoded
|
||||
* stream.
|
||||
*/
|
||||
typedef struct aom_codec_stream_info {
|
||||
unsigned int w; /**< Width (or 0 for unknown/default) */
|
||||
unsigned int h; /**< Height (or 0 for unknown/default) */
|
||||
unsigned int is_kf; /**< Current frame is a keyframe */
|
||||
unsigned int number_spatial_layers; /**< Number of spatial layers */
|
||||
unsigned int number_temporal_layers; /**< Number of temporal layers */
|
||||
unsigned int is_annexb; /**< Is Bitstream in Annex-B format */
|
||||
} aom_codec_stream_info_t;
|
||||
|
||||
/* REQUIRED FUNCTIONS
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders.
|
||||
* They represent the base case functionality expected of all decoders.
|
||||
*/
|
||||
|
||||
/*!\brief Initialization Configurations
|
||||
*
|
||||
* This structure is used to pass init time configuration options to the
|
||||
* decoder.
|
||||
*/
|
||||
typedef struct aom_codec_dec_cfg {
|
||||
unsigned int threads; /**< Maximum number of threads to use, default 1 */
|
||||
unsigned int w; /**< Width */
|
||||
unsigned int h; /**< Height */
|
||||
unsigned int allow_lowbitdepth; /**< Allow use of low-bitdepth coding path */
|
||||
} aom_codec_dec_cfg_t; /**< alias for struct aom_codec_dec_cfg */
|
||||
|
||||
/*!\brief Initialize a decoder instance
|
||||
*
|
||||
* Initializes a decoder context using the given interface. Applications
|
||||
* should call the aom_codec_dec_init convenience macro instead of this
|
||||
* function directly, to ensure that the ABI version number parameter
|
||||
* is properly initialized.
|
||||
*
|
||||
* If the library was configured with cmake -DCONFIG_MULTITHREAD=0, this
|
||||
* call is not thread safe and should be guarded with a lock if being used
|
||||
* in a multithreaded context.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[in] cfg Configuration to use, if known. May be NULL.
|
||||
* \param[in] flags Bitfield of AOM_CODEC_USE_* flags
|
||||
* \param[in] ver ABI version number. Must be set to
|
||||
* AOM_DECODER_ABI_VERSION
|
||||
* \retval #AOM_CODEC_OK
|
||||
* The decoder algorithm initialized.
|
||||
* \retval #AOM_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
aom_codec_err_t aom_codec_dec_init_ver(aom_codec_ctx_t *ctx,
|
||||
aom_codec_iface_t *iface,
|
||||
const aom_codec_dec_cfg_t *cfg,
|
||||
aom_codec_flags_t flags, int ver);
|
||||
|
||||
/*!\brief Convenience macro for aom_codec_dec_init_ver()
|
||||
*
|
||||
* Ensures the ABI version parameter is properly set.
|
||||
*/
|
||||
#define aom_codec_dec_init(ctx, iface, cfg, flags) \
|
||||
aom_codec_dec_init_ver(ctx, iface, cfg, flags, AOM_DECODER_ABI_VERSION)
|
||||
|
||||
/*!\brief Parse stream info from a buffer
|
||||
*
|
||||
* Performs high level parsing of the bitstream. Construction of a decoder
|
||||
* context is not necessary. Can be used to determine if the bitstream is
|
||||
* of the proper format, and to extract information from the stream.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface
|
||||
* \param[in] data Pointer to a block of data to parse
|
||||
* \param[in] data_sz Size of the data buffer
|
||||
* \param[in,out] si Pointer to stream info to update. The is_annexb
|
||||
* member \ref MUST be properly initialized. This
|
||||
* function sets the rest of the members.
|
||||
*
|
||||
* \retval #AOM_CODEC_OK
|
||||
* Bitstream is parsable and stream information updated.
|
||||
* \retval #AOM_CODEC_INVALID_PARAM
|
||||
* One of the arguments is invalid, for example a NULL pointer.
|
||||
* \retval #AOM_CODEC_UNSUP_BITSTREAM
|
||||
* The decoder didn't recognize the coded data, or the
|
||||
* buffer was too short.
|
||||
*/
|
||||
aom_codec_err_t aom_codec_peek_stream_info(aom_codec_iface_t *iface,
|
||||
const uint8_t *data, size_t data_sz,
|
||||
aom_codec_stream_info_t *si);
|
||||
|
||||
/*!\brief Return information about the current stream.
|
||||
*
|
||||
* Returns information about the stream that has been parsed during decoding.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] si Pointer to stream info to update.
|
||||
*
|
||||
* \retval #AOM_CODEC_OK
|
||||
* Bitstream is parsable and stream information updated.
|
||||
* \retval #AOM_CODEC_INVALID_PARAM
|
||||
* One of the arguments is invalid, for example a NULL pointer.
|
||||
* \retval #AOM_CODEC_UNSUP_BITSTREAM
|
||||
* The decoder couldn't parse the submitted data.
|
||||
*/
|
||||
aom_codec_err_t aom_codec_get_stream_info(aom_codec_ctx_t *ctx,
|
||||
aom_codec_stream_info_t *si);
|
||||
|
||||
/*!\brief Decode data
|
||||
*
|
||||
* Processes a buffer of coded data. Encoded data \ref MUST be passed in DTS
|
||||
* (decode time stamp) order. Frames produced will always be in PTS
|
||||
* (presentation time stamp) order.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] data Pointer to this block of new coded data.
|
||||
* \param[in] data_sz Size of the coded data, in bytes.
|
||||
* \param[in] user_priv Application specific data to associate with
|
||||
* this frame.
|
||||
*
|
||||
* \return Returns #AOM_CODEC_OK if the coded data was processed completely
|
||||
* and future pictures can be decoded without error. Otherwise,
|
||||
* see the descriptions of the other error codes in ::aom_codec_err_t
|
||||
* for recoverability capabilities.
|
||||
*/
|
||||
aom_codec_err_t aom_codec_decode(aom_codec_ctx_t *ctx, const uint8_t *data,
|
||||
size_t data_sz, void *user_priv);
|
||||
|
||||
/*!\brief Decoded frames iterator
|
||||
*
|
||||
* Iterates over a list of the frames available for display. The iterator
|
||||
* storage should be initialized to NULL to start the iteration. Iteration is
|
||||
* complete when this function returns NULL.
|
||||
*
|
||||
* The list of available frames becomes valid upon completion of the
|
||||
* aom_codec_decode call, and remains valid until the next call to
|
||||
* aom_codec_decode.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] iter Iterator storage, initialized to NULL
|
||||
*
|
||||
* \return Returns a pointer to an image, if one is ready for display. Frames
|
||||
* produced will always be in PTS (presentation time stamp) order.
|
||||
*/
|
||||
aom_image_t *aom_codec_get_frame(aom_codec_ctx_t *ctx, aom_codec_iter_t *iter);
|
||||
|
||||
/*!\defgroup cap_external_frame_buffer External Frame Buffer Functions
|
||||
*
|
||||
* The following function is required to be implemented for all decoders
|
||||
* that advertise the AOM_CODEC_CAP_EXTERNAL_FRAME_BUFFER capability.
|
||||
* Calling this function for codecs that don't advertise this capability
|
||||
* will result in an error code being returned, usually AOM_CODEC_INCAPABLE.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief Pass in external frame buffers for the decoder to use.
|
||||
*
|
||||
* Registers functions to be called when libaom needs a frame buffer
|
||||
* to decode the current frame and a function to be called when libaom does
|
||||
* not internally reference the frame buffer. This set function must
|
||||
* be called before the first call to decode or libaom will assume the
|
||||
* default behavior of allocating frame buffers internally.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb_get Pointer to the get callback function
|
||||
* \param[in] cb_release Pointer to the release callback function
|
||||
* \param[in] cb_priv Callback's private data
|
||||
*
|
||||
* \retval #AOM_CODEC_OK
|
||||
* External frame buffers will be used by libaom.
|
||||
* \retval #AOM_CODEC_INVALID_PARAM
|
||||
* One or more of the callbacks were NULL.
|
||||
* \retval #AOM_CODEC_ERROR
|
||||
* Decoder context not initialized.
|
||||
* \retval #AOM_CODEC_INCAPABLE
|
||||
* Algorithm not capable of using external frame buffers.
|
||||
*
|
||||
* \note
|
||||
* When decoding AV1, the application may be required to pass in at least
|
||||
* #AOM_MAXIMUM_WORK_BUFFERS external frame buffers.
|
||||
*/
|
||||
aom_codec_err_t aom_codec_set_frame_buffer_functions(
|
||||
aom_codec_ctx_t *ctx, aom_get_frame_buffer_cb_fn_t cb_get,
|
||||
aom_release_frame_buffer_cb_fn_t cb_release, void *cb_priv);
|
||||
|
||||
/*!@} - end defgroup cap_external_frame_buffer */
|
||||
|
||||
/*!@} - end defgroup decoder*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // AOM_AOM_AOM_DECODER_H_
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,404 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
#ifndef AOM_AOM_AOM_EXTERNAL_PARTITION_H_
|
||||
#define AOM_AOM_AOM_EXTERNAL_PARTITION_H_
|
||||
|
||||
/*!\defgroup aom_encoder AOMedia AOM/AV1 Encoder
|
||||
* \ingroup aom
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#include <stdint.h>
|
||||
|
||||
/*!\file
|
||||
* \brief Provides function pointer definitions for the external partition.
|
||||
*/
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures.
|
||||
*/
|
||||
#define AOM_EXT_PART_ABI_VERSION 3
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!\brief Abstract external partition model handler
|
||||
*/
|
||||
typedef void *aom_ext_part_model_t;
|
||||
|
||||
/*!\brief Number of features to determine whether to skip partition none and
|
||||
* do partition split directly. The same as "FEATURE_SIZE_SMS_SPLIT".
|
||||
*/
|
||||
#define AOM_EXT_PART_SIZE_DIRECT_SPLIT 17
|
||||
|
||||
/*!\brief Number of features to use simple motion search to prune out
|
||||
* rectangular partition in some direction. The same as
|
||||
* "FEATURE_SIZE_SMS_PRUNE_PART".
|
||||
*/
|
||||
#define AOM_EXT_PART_SIZE_PRUNE_PART 25
|
||||
|
||||
/*!\brief Number of features to prune split and rectangular partition
|
||||
* after PARTITION_NONE.
|
||||
*/
|
||||
#define AOM_EXT_PART_SIZE_PRUNE_NONE 4
|
||||
|
||||
/*!\brief Number of features to terminates partition after partition none using
|
||||
* simple_motion_search features and the rate, distortion, and rdcost of
|
||||
* PARTITION_NONE. The same as "FEATURE_SIZE_SMS_TERM_NONE".
|
||||
*/
|
||||
#define AOM_EXT_PART_SIZE_TERM_NONE 28
|
||||
|
||||
/*!\brief Number of features to terminates partition after partition split.
|
||||
*/
|
||||
#define AOM_EXT_PART_SIZE_TERM_SPLIT 31
|
||||
|
||||
/*!\brief Number of features to prune rectangular partition using stats
|
||||
* collected after partition split.
|
||||
*/
|
||||
#define AOM_EXT_PART_SIZE_PRUNE_RECT 9
|
||||
|
||||
/*!\brief Number of features to prune AB partition using stats
|
||||
* collected after rectangular partition..
|
||||
*/
|
||||
#define AOM_EXT_PART_SIZE_PRUNE_AB 10
|
||||
|
||||
/*!\brief Number of features to prune 4-way partition using stats
|
||||
* collected after AB partition.
|
||||
*/
|
||||
#define AOM_EXT_PART_SIZE_PRUNE_4_WAY 18
|
||||
|
||||
/*!\brief Decision mode of the external partition model.
|
||||
* AOM_EXT_PART_WHOLE_TREE: the external partition model should provide the
|
||||
* whole partition tree for the superblock.
|
||||
*
|
||||
* AOM_EXT_PART_RECURSIVE: the external partition model provides the partition
|
||||
* decision of the current block only. The decision process starts from
|
||||
* the superblock size, down to the smallest block size (4x4) recursively.
|
||||
*/
|
||||
typedef enum aom_ext_part_decision_mode {
|
||||
AOM_EXT_PART_WHOLE_TREE = 0,
|
||||
AOM_EXT_PART_RECURSIVE = 1,
|
||||
} aom_ext_part_decision_mode_t;
|
||||
|
||||
/*!\brief Config information sent to the external partition model.
|
||||
*
|
||||
* For example, the maximum superblock size determined by the sequence header.
|
||||
*/
|
||||
typedef struct aom_ext_part_config {
|
||||
int superblock_size; ///< super block size (either 64x64 or 128x128)
|
||||
} aom_ext_part_config_t;
|
||||
|
||||
/*!\brief Features pass to the external model to make partition decisions.
|
||||
* Specifically, features collected before NONE partition.
|
||||
* Features "f" are used to determine:
|
||||
* partition_none_allowed, partition_horz_allowed, partition_vert_allowed,
|
||||
* do_rectangular_split, do_square_split
|
||||
* Features "f_part2" are used to determine:
|
||||
* prune_horz, prune_vert.
|
||||
*/
|
||||
typedef struct aom_partition_features_before_none {
|
||||
/*! features to determine whether skip partition none and do split directly */
|
||||
float f[AOM_EXT_PART_SIZE_DIRECT_SPLIT];
|
||||
/*! features to determine whether to prune rectangular partition */
|
||||
float f_part2[AOM_EXT_PART_SIZE_PRUNE_PART];
|
||||
} aom_partition_features_before_none_t;
|
||||
|
||||
/*!\brief Features pass to the external model to make partition decisions.
|
||||
* Specifically, features collected after NONE partition.
|
||||
*/
|
||||
typedef struct aom_partition_features_none {
|
||||
/*! features to prune split and rectangular partition */
|
||||
float f[AOM_EXT_PART_SIZE_PRUNE_NONE];
|
||||
/*! features to determine termination of partition */
|
||||
float f_terminate[AOM_EXT_PART_SIZE_TERM_NONE];
|
||||
} aom_partition_features_none_t;
|
||||
|
||||
/*!\brief Features pass to the external model to make partition decisions.
|
||||
* Specifically, features collected after SPLIT partition.
|
||||
*/
|
||||
typedef struct aom_partition_features_split {
|
||||
/*! features to determine termination of partition */
|
||||
float f_terminate[AOM_EXT_PART_SIZE_TERM_SPLIT];
|
||||
/*! features to determine pruning rect partition */
|
||||
float f_prune_rect[AOM_EXT_PART_SIZE_PRUNE_RECT];
|
||||
} aom_partition_features_split_t;
|
||||
|
||||
/*!\brief Features pass to the external model to make partition decisions.
|
||||
* Specifically, features collected after RECTANGULAR partition.
|
||||
*/
|
||||
typedef struct aom_partition_features_rect {
|
||||
/*! features to determine pruning AB partition */
|
||||
float f[AOM_EXT_PART_SIZE_PRUNE_AB];
|
||||
} aom_partition_features_rect_t;
|
||||
|
||||
/*!\brief Features pass to the external model to make partition decisions.
|
||||
* Specifically, features collected after AB partition: HORZ_A, HORZ_B, VERT_A,
|
||||
* VERT_B.
|
||||
*/
|
||||
typedef struct aom_partition_features_ab {
|
||||
/*! features to determine pruning 4-way partition */
|
||||
float f[AOM_EXT_PART_SIZE_PRUNE_4_WAY];
|
||||
} aom_partition_features_ab_t;
|
||||
|
||||
/*!\brief Feature id to tell the external model the current stage in partition
|
||||
* pruning and what features to use to make decisions accordingly.
|
||||
*/
|
||||
typedef enum {
|
||||
AOM_EXT_PART_FEATURE_BEFORE_NONE,
|
||||
AOM_EXT_PART_FEATURE_BEFORE_NONE_PART2,
|
||||
AOM_EXT_PART_FEATURE_AFTER_NONE,
|
||||
AOM_EXT_PART_FEATURE_AFTER_NONE_PART2,
|
||||
AOM_EXT_PART_FEATURE_AFTER_SPLIT,
|
||||
AOM_EXT_PART_FEATURE_AFTER_SPLIT_PART2,
|
||||
AOM_EXT_PART_FEATURE_AFTER_RECT,
|
||||
AOM_EXT_PART_FEATURE_AFTER_AB
|
||||
} AOM_EXT_PART_FEATURE_ID;
|
||||
|
||||
/*!\brief Features collected from the tpl process.
|
||||
*
|
||||
* The tpl process collects information that help measure the inter-frame
|
||||
* dependency.
|
||||
* The tpl process is computed in the unit of tpl_bsize_1d (16x16).
|
||||
* Therefore, the max number of units inside a superblock is
|
||||
* 128x128 / (16x16) = 64. Change it if the tpl process changes.
|
||||
*/
|
||||
typedef struct aom_sb_tpl_features {
|
||||
int available; ///< If tpl stats are available
|
||||
int tpl_unit_length; ///< The block length of tpl process
|
||||
int num_units; ///< The number of units inside the current superblock
|
||||
int64_t intra_cost[64]; ///< The intra cost of each unit
|
||||
int64_t inter_cost[64]; ///< The inter cost of each unit
|
||||
int64_t mc_dep_cost[64]; ///< The motion compensated dependency cost
|
||||
} aom_sb_tpl_features_t;
|
||||
|
||||
/*!\brief Features collected from the simple motion process.
|
||||
*
|
||||
* The simple motion process collects information by applying motion compensated
|
||||
* prediction on each block.
|
||||
* The block size is 16x16, which could be changed. If it is changed, update
|
||||
* comments and the array size here.
|
||||
*/
|
||||
typedef struct aom_sb_simple_motion_features {
|
||||
int unit_length; ///< The block length of the simple motion process
|
||||
int num_units; ///< The number of units inside the current superblock
|
||||
int block_sse[64]; ///< Sum of squared error of each unit
|
||||
int block_var[64]; ///< Variance of each unit
|
||||
} aom_sb_simple_motion_features_t;
|
||||
|
||||
/*!\brief Features of each super block.
|
||||
*
|
||||
* Features collected for each super block before partition search.
|
||||
*/
|
||||
typedef struct aom_sb_features {
|
||||
/*! Features from motion search */
|
||||
aom_sb_simple_motion_features_t motion_features;
|
||||
/*! Features from tpl process */
|
||||
aom_sb_tpl_features_t tpl_features;
|
||||
} aom_sb_features_t;
|
||||
|
||||
/*!\brief Features pass to the external model to make partition decisions.
|
||||
*
|
||||
* The encoder sends these features to the external model through
|
||||
* "func()" defined in .....
|
||||
*
|
||||
* NOTE: new member variables may be added to this structure in the future.
|
||||
* Once new features are finalized, bump the major version of libaom.
|
||||
*/
|
||||
typedef struct aom_partition_features {
|
||||
// Features for the current supervised multi-stage ML model.
|
||||
/*! Feature ID to indicate active features */
|
||||
AOM_EXT_PART_FEATURE_ID id;
|
||||
/*! Features collected before NONE partition */
|
||||
aom_partition_features_before_none_t before_part_none;
|
||||
/*! Features collected after NONE partition */
|
||||
aom_partition_features_none_t after_part_none;
|
||||
/*! Features collected after SPLIT partition */
|
||||
aom_partition_features_split_t after_part_split;
|
||||
/*! Features collected after RECTANGULAR partition */
|
||||
aom_partition_features_rect_t after_part_rect;
|
||||
/*! Features collected after AB partition */
|
||||
aom_partition_features_ab_t after_part_ab;
|
||||
|
||||
// Features for a new ML model.
|
||||
aom_sb_features_t sb_features; ///< Features collected for the super block
|
||||
int mi_row; ///< Mi_row position of the block
|
||||
int mi_col; ///< Mi_col position of the block
|
||||
int frame_width; ///< Frame width
|
||||
int frame_height; ///< Frame height
|
||||
int block_size; ///< As "BLOCK_SIZE" in av1/common/enums.h
|
||||
} aom_partition_features_t;
|
||||
|
||||
/*!\brief Partition decisions received from the external model.
|
||||
*
|
||||
* The encoder receives partition decisions and encodes the superblock
|
||||
* with the given partition type.
|
||||
* The encoder receives it from "func()" define in ....
|
||||
*
|
||||
* NOTE: new member variables may be added to this structure in the future.
|
||||
* Once new features are finalized, bump the major version of libaom.
|
||||
*/
|
||||
typedef struct aom_partition_decision {
|
||||
// Decisions for directly set partition types
|
||||
int is_final_decision; ///< The flag whether it's the final decision
|
||||
int num_nodes; ///< The number of leaf nodes
|
||||
int partition_decision[2048]; ///< Partition decisions
|
||||
int current_decision; ///< Partition decision for the current block
|
||||
|
||||
// Decisions for partition type pruning
|
||||
int terminate_partition_search; ///< Terminate further partition search
|
||||
int partition_none_allowed; ///< Allow partition none type
|
||||
int partition_rect_allowed[2]; ///< Allow rectangular partitions
|
||||
int do_rectangular_split; ///< Try rectangular split partition
|
||||
int do_square_split; ///< Try square split partition
|
||||
int prune_rect_part[2]; ///< Prune rectangular partition
|
||||
int horza_partition_allowed; ///< Allow HORZ_A partitioin
|
||||
int horzb_partition_allowed; ///< Allow HORZ_B partitioin
|
||||
int verta_partition_allowed; ///< Allow VERT_A partitioin
|
||||
int vertb_partition_allowed; ///< Allow VERT_B partitioin
|
||||
int partition_horz4_allowed; ///< Allow HORZ4 partition
|
||||
int partition_vert4_allowed; ///< Allow VERT4 partition
|
||||
} aom_partition_decision_t;
|
||||
|
||||
/*!\brief Encoding stats for the given partition decision.
|
||||
*
|
||||
* The encoding stats collected by encoding the superblock with the
|
||||
* given partition types.
|
||||
* The encoder sends the stats to the external model for training
|
||||
* or inference though "func()" defined in ....
|
||||
*/
|
||||
typedef struct aom_partition_stats {
|
||||
int rate; ///< Rate cost of the block
|
||||
int64_t dist; ///< Distortion of the block
|
||||
int64_t rdcost; ///< Rate-distortion cost of the block
|
||||
} aom_partition_stats_t;
|
||||
|
||||
/*!\brief Enum for return status.
|
||||
*/
|
||||
typedef enum aom_ext_part_status {
|
||||
AOM_EXT_PART_OK = 0, ///< Status of success
|
||||
AOM_EXT_PART_ERROR = 1, ///< Status of failure
|
||||
AOM_EXT_PART_TEST = 2, ///< Status used for tests
|
||||
} aom_ext_part_status_t;
|
||||
|
||||
/*!\brief Callback of creating an external partition model.
|
||||
*
|
||||
* The callback is invoked by the encoder to create an external partition
|
||||
* model.
|
||||
*
|
||||
* \param[in] priv Callback's private data
|
||||
* \param[in] part_config Config information pointer for model creation
|
||||
* \param[out] ext_part_model Pointer to the model
|
||||
*/
|
||||
typedef aom_ext_part_status_t (*aom_ext_part_create_model_fn_t)(
|
||||
void *priv, const aom_ext_part_config_t *part_config,
|
||||
aom_ext_part_model_t *ext_part_model);
|
||||
|
||||
/*!\brief Callback of sending features to the external partition model.
|
||||
*
|
||||
* The callback is invoked by the encoder to send features to the external
|
||||
* partition model.
|
||||
*
|
||||
* \param[in] ext_part_model The external model
|
||||
* \param[in] part_features Pointer to the features
|
||||
*/
|
||||
typedef aom_ext_part_status_t (*aom_ext_part_send_features_fn_t)(
|
||||
aom_ext_part_model_t ext_part_model,
|
||||
const aom_partition_features_t *part_features);
|
||||
|
||||
/*!\brief Callback of receiving partition decisions from the external
|
||||
* partition model.
|
||||
*
|
||||
* The callback is invoked by the encoder to receive partition decisions from
|
||||
* the external partition model.
|
||||
*
|
||||
* \param[in] ext_part_model The external model
|
||||
* \param[in] ext_part_decision Pointer to the partition decisions
|
||||
*/
|
||||
typedef aom_ext_part_status_t (*aom_ext_part_get_decision_fn_t)(
|
||||
aom_ext_part_model_t ext_part_model,
|
||||
aom_partition_decision_t *ext_part_decision);
|
||||
|
||||
/*!\brief Callback of sending stats to the external partition model.
|
||||
*
|
||||
* The callback is invoked by the encoder to send encoding stats to
|
||||
* the external partition model.
|
||||
*
|
||||
* \param[in] ext_part_model The external model
|
||||
* \param[in] ext_part_stats Pointer to the encoding stats
|
||||
*/
|
||||
typedef aom_ext_part_status_t (*aom_ext_part_send_partition_stats_fn_t)(
|
||||
aom_ext_part_model_t ext_part_model,
|
||||
const aom_partition_stats_t *ext_part_stats);
|
||||
|
||||
/*!\brief Callback of deleting the external partition model.
|
||||
*
|
||||
* The callback is invoked by the encoder to delete the external partition
|
||||
* model.
|
||||
*
|
||||
* \param[in] ext_part_model The external model
|
||||
*/
|
||||
typedef aom_ext_part_status_t (*aom_ext_part_delete_model_fn_t)(
|
||||
aom_ext_part_model_t ext_part_model);
|
||||
|
||||
/*!\brief Callback function set for external partition model.
|
||||
*
|
||||
* Uses can enable external partition model by registering a set of
|
||||
* callback functions with the flag: AV1E_SET_EXTERNAL_PARTITION_MODEL
|
||||
*/
|
||||
typedef struct aom_ext_part_funcs {
|
||||
/*!
|
||||
* Create an external partition model.
|
||||
*/
|
||||
aom_ext_part_create_model_fn_t create_model;
|
||||
|
||||
/*!
|
||||
* Send features to the external partition model to make partition decisions.
|
||||
*/
|
||||
aom_ext_part_send_features_fn_t send_features;
|
||||
|
||||
/*!
|
||||
* Get partition decisions from the external partition model.
|
||||
*/
|
||||
aom_ext_part_get_decision_fn_t get_partition_decision;
|
||||
|
||||
/*!
|
||||
* Send stats of the current partition to the external model.
|
||||
*/
|
||||
aom_ext_part_send_partition_stats_fn_t send_partition_stats;
|
||||
|
||||
/*!
|
||||
* Delete the external partition model.
|
||||
*/
|
||||
aom_ext_part_delete_model_fn_t delete_model;
|
||||
|
||||
/*!
|
||||
* The decision mode of the model.
|
||||
*/
|
||||
aom_ext_part_decision_mode_t decision_mode;
|
||||
|
||||
/*!
|
||||
* Private data for the external partition model.
|
||||
*/
|
||||
void *priv;
|
||||
} aom_ext_part_funcs_t;
|
||||
|
||||
/*!@} - end defgroup aom_encoder*/
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AOM_AOM_AOM_EXTERNAL_PARTITION_H_
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AOM_AOM_AOM_FRAME_BUFFER_H_
|
||||
#define AOM_AOM_AOM_FRAME_BUFFER_H_
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the decoder external frame buffer interface.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "aom/aom_integer.h"
|
||||
|
||||
/*!\brief The maximum number of work buffers used by libaom.
|
||||
* Support maximum 4 threads to decode video in parallel.
|
||||
* Each thread will use one work buffer.
|
||||
* TODO(hkuang): Add support to set number of worker threads dynamically.
|
||||
*/
|
||||
#define AOM_MAXIMUM_WORK_BUFFERS 8
|
||||
|
||||
/*!\brief The maximum number of reference buffers that a AV1 encoder may use.
|
||||
*/
|
||||
#define AOM_MAXIMUM_REF_BUFFERS 8
|
||||
|
||||
/*!\brief External frame buffer
|
||||
*
|
||||
* This structure holds allocated frame buffers used by the decoder.
|
||||
*/
|
||||
typedef struct aom_codec_frame_buffer {
|
||||
uint8_t *data; /**< Pointer to the data buffer */
|
||||
size_t size; /**< Size of data in bytes */
|
||||
void *priv; /**< Frame's private data */
|
||||
} aom_codec_frame_buffer_t;
|
||||
|
||||
/*!\brief get frame buffer callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to retrieve data for the frame
|
||||
* buffer in order for the decode call to complete. The callback must
|
||||
* allocate at least min_size in bytes and assign it to fb->data. The callback
|
||||
* must zero out all the data allocated. Then the callback must set fb->size
|
||||
* to the allocated size. The application does not need to align the allocated
|
||||
* data. The callback is triggered when the decoder needs a frame buffer to
|
||||
* decode a compressed image into. This function may be called more than once
|
||||
* for every call to aom_codec_decode. The application may set fb->priv to
|
||||
* some data which will be passed back in the aom_image_t and the release
|
||||
* function call. |fb| is guaranteed to not be NULL. On success the callback
|
||||
* must return 0. Any failure the callback must return a value less than 0.
|
||||
*
|
||||
* \param[in] priv Callback's private data
|
||||
* \param[in] new_size Size in bytes needed by the buffer
|
||||
* \param[in,out] fb Pointer to aom_codec_frame_buffer_t
|
||||
*/
|
||||
typedef int (*aom_get_frame_buffer_cb_fn_t)(void *priv, size_t min_size,
|
||||
aom_codec_frame_buffer_t *fb);
|
||||
|
||||
/*!\brief release frame buffer callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder when the frame buffer is not
|
||||
* referenced by any other buffers. |fb| is guaranteed to not be NULL. On
|
||||
* success the callback must return 0. Any failure the callback must return
|
||||
* a value less than 0.
|
||||
*
|
||||
* \param[in] priv Callback's private data
|
||||
* \param[in] fb Pointer to aom_codec_frame_buffer_t
|
||||
*/
|
||||
typedef int (*aom_release_frame_buffer_cb_fn_t)(void *priv,
|
||||
aom_codec_frame_buffer_t *fb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AOM_AOM_AOM_FRAME_BUFFER_H_
|
|
@ -0,0 +1,436 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the aom image descriptor and associated operations
|
||||
*
|
||||
*/
|
||||
#ifndef AOM_AOM_AOM_IMAGE_H_
|
||||
#define AOM_AOM_AOM_IMAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "aom/aom_integer.h"
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define AOM_IMAGE_ABI_VERSION (9) /**<\hideinitializer*/
|
||||
|
||||
#define AOM_IMG_FMT_PLANAR 0x100 /**< Image is a planar format. */
|
||||
#define AOM_IMG_FMT_UV_FLIP 0x200 /**< V plane precedes U in memory. */
|
||||
/** 0x400 used to signal alpha channel, skipping for backwards compatibility. */
|
||||
#define AOM_IMG_FMT_HIGHBITDEPTH 0x800 /**< Image uses 16bit framebuffer. */
|
||||
|
||||
/*!\brief List of supported image formats */
|
||||
typedef enum aom_img_fmt {
|
||||
AOM_IMG_FMT_NONE,
|
||||
AOM_IMG_FMT_YV12 =
|
||||
AOM_IMG_FMT_PLANAR | AOM_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
|
||||
AOM_IMG_FMT_I420 = AOM_IMG_FMT_PLANAR | 2,
|
||||
AOM_IMG_FMT_AOMYV12 = AOM_IMG_FMT_PLANAR | AOM_IMG_FMT_UV_FLIP |
|
||||
3, /** < planar 4:2:0 format with aom color space */
|
||||
AOM_IMG_FMT_AOMI420 = AOM_IMG_FMT_PLANAR | 4,
|
||||
AOM_IMG_FMT_I422 = AOM_IMG_FMT_PLANAR | 5,
|
||||
AOM_IMG_FMT_I444 = AOM_IMG_FMT_PLANAR | 6,
|
||||
AOM_IMG_FMT_I42016 = AOM_IMG_FMT_I420 | AOM_IMG_FMT_HIGHBITDEPTH,
|
||||
AOM_IMG_FMT_YV1216 = AOM_IMG_FMT_YV12 | AOM_IMG_FMT_HIGHBITDEPTH,
|
||||
AOM_IMG_FMT_I42216 = AOM_IMG_FMT_I422 | AOM_IMG_FMT_HIGHBITDEPTH,
|
||||
AOM_IMG_FMT_I44416 = AOM_IMG_FMT_I444 | AOM_IMG_FMT_HIGHBITDEPTH,
|
||||
} aom_img_fmt_t; /**< alias for enum aom_img_fmt */
|
||||
|
||||
/*!\brief List of supported color primaries */
|
||||
typedef enum aom_color_primaries {
|
||||
AOM_CICP_CP_RESERVED_0 = 0, /**< For future use */
|
||||
AOM_CICP_CP_BT_709 = 1, /**< BT.709 */
|
||||
AOM_CICP_CP_UNSPECIFIED = 2, /**< Unspecified */
|
||||
AOM_CICP_CP_RESERVED_3 = 3, /**< For future use */
|
||||
AOM_CICP_CP_BT_470_M = 4, /**< BT.470 System M (historical) */
|
||||
AOM_CICP_CP_BT_470_B_G = 5, /**< BT.470 System B, G (historical) */
|
||||
AOM_CICP_CP_BT_601 = 6, /**< BT.601 */
|
||||
AOM_CICP_CP_SMPTE_240 = 7, /**< SMPTE 240 */
|
||||
AOM_CICP_CP_GENERIC_FILM =
|
||||
8, /**< Generic film (color filters using illuminant C) */
|
||||
AOM_CICP_CP_BT_2020 = 9, /**< BT.2020, BT.2100 */
|
||||
AOM_CICP_CP_XYZ = 10, /**< SMPTE 428 (CIE 1921 XYZ) */
|
||||
AOM_CICP_CP_SMPTE_431 = 11, /**< SMPTE RP 431-2 */
|
||||
AOM_CICP_CP_SMPTE_432 = 12, /**< SMPTE EG 432-1 */
|
||||
AOM_CICP_CP_RESERVED_13 = 13, /**< For future use (values 13 - 21) */
|
||||
AOM_CICP_CP_EBU_3213 = 22, /**< EBU Tech. 3213-E */
|
||||
AOM_CICP_CP_RESERVED_23 = 23 /**< For future use (values 23 - 255) */
|
||||
} aom_color_primaries_t; /**< alias for enum aom_color_primaries */
|
||||
|
||||
/*!\brief List of supported transfer functions */
|
||||
typedef enum aom_transfer_characteristics {
|
||||
AOM_CICP_TC_RESERVED_0 = 0, /**< For future use */
|
||||
AOM_CICP_TC_BT_709 = 1, /**< BT.709 */
|
||||
AOM_CICP_TC_UNSPECIFIED = 2, /**< Unspecified */
|
||||
AOM_CICP_TC_RESERVED_3 = 3, /**< For future use */
|
||||
AOM_CICP_TC_BT_470_M = 4, /**< BT.470 System M (historical) */
|
||||
AOM_CICP_TC_BT_470_B_G = 5, /**< BT.470 System B, G (historical) */
|
||||
AOM_CICP_TC_BT_601 = 6, /**< BT.601 */
|
||||
AOM_CICP_TC_SMPTE_240 = 7, /**< SMPTE 240 M */
|
||||
AOM_CICP_TC_LINEAR = 8, /**< Linear */
|
||||
AOM_CICP_TC_LOG_100 = 9, /**< Logarithmic (100 : 1 range) */
|
||||
AOM_CICP_TC_LOG_100_SQRT10 =
|
||||
10, /**< Logarithmic (100 * Sqrt(10) : 1 range) */
|
||||
AOM_CICP_TC_IEC_61966 = 11, /**< IEC 61966-2-4 */
|
||||
AOM_CICP_TC_BT_1361 = 12, /**< BT.1361 */
|
||||
AOM_CICP_TC_SRGB = 13, /**< sRGB or sYCC*/
|
||||
AOM_CICP_TC_BT_2020_10_BIT = 14, /**< BT.2020 10-bit systems */
|
||||
AOM_CICP_TC_BT_2020_12_BIT = 15, /**< BT.2020 12-bit systems */
|
||||
AOM_CICP_TC_SMPTE_2084 = 16, /**< SMPTE ST 2084, ITU BT.2100 PQ */
|
||||
AOM_CICP_TC_SMPTE_428 = 17, /**< SMPTE ST 428 */
|
||||
AOM_CICP_TC_HLG = 18, /**< BT.2100 HLG, ARIB STD-B67 */
|
||||
AOM_CICP_TC_RESERVED_19 = 19 /**< For future use (values 19-255) */
|
||||
} aom_transfer_characteristics_t; /**< alias for enum aom_transfer_function */
|
||||
|
||||
/*!\brief List of supported matrix coefficients */
|
||||
typedef enum aom_matrix_coefficients {
|
||||
AOM_CICP_MC_IDENTITY = 0, /**< Identity matrix */
|
||||
AOM_CICP_MC_BT_709 = 1, /**< BT.709 */
|
||||
AOM_CICP_MC_UNSPECIFIED = 2, /**< Unspecified */
|
||||
AOM_CICP_MC_RESERVED_3 = 3, /**< For future use */
|
||||
AOM_CICP_MC_FCC = 4, /**< US FCC 73.628 */
|
||||
AOM_CICP_MC_BT_470_B_G = 5, /**< BT.470 System B, G (historical) */
|
||||
AOM_CICP_MC_BT_601 = 6, /**< BT.601 */
|
||||
AOM_CICP_MC_SMPTE_240 = 7, /**< SMPTE 240 M */
|
||||
AOM_CICP_MC_SMPTE_YCGCO = 8, /**< YCgCo */
|
||||
AOM_CICP_MC_BT_2020_NCL =
|
||||
9, /**< BT.2020 non-constant luminance, BT.2100 YCbCr */
|
||||
AOM_CICP_MC_BT_2020_CL = 10, /**< BT.2020 constant luminance */
|
||||
AOM_CICP_MC_SMPTE_2085 = 11, /**< SMPTE ST 2085 YDzDx */
|
||||
AOM_CICP_MC_CHROMAT_NCL =
|
||||
12, /**< Chromaticity-derived non-constant luminance */
|
||||
AOM_CICP_MC_CHROMAT_CL = 13, /**< Chromaticity-derived constant luminance */
|
||||
AOM_CICP_MC_ICTCP = 14, /**< BT.2100 ICtCp */
|
||||
AOM_CICP_MC_RESERVED_15 = 15 /**< For future use (values 15-255) */
|
||||
} aom_matrix_coefficients_t;
|
||||
|
||||
/*!\brief List of supported color range */
|
||||
typedef enum aom_color_range {
|
||||
AOM_CR_STUDIO_RANGE = 0, /**< Y [16..235], UV [16..240] */
|
||||
AOM_CR_FULL_RANGE = 1 /**< YUV/RGB [0..255] */
|
||||
} aom_color_range_t; /**< alias for enum aom_color_range */
|
||||
|
||||
/*!\brief List of chroma sample positions */
|
||||
typedef enum aom_chroma_sample_position {
|
||||
AOM_CSP_UNKNOWN = 0, /**< Unknown */
|
||||
AOM_CSP_VERTICAL = 1, /**< Horizontally co-located with luma(0, 0)*/
|
||||
/**< sample, between two vertical samples */
|
||||
AOM_CSP_COLOCATED = 2, /**< Co-located with luma(0, 0) sample */
|
||||
AOM_CSP_RESERVED = 3 /**< Reserved value */
|
||||
} aom_chroma_sample_position_t; /**< alias for enum aom_transfer_function */
|
||||
|
||||
/*!\brief List of insert flags for Metadata
|
||||
*
|
||||
* These flags control how the library treats metadata during encode.
|
||||
*
|
||||
* While encoding, when metadata is added to an aom_image via
|
||||
* aom_img_add_metadata(), the flag passed along with the metadata will
|
||||
* determine where the metadata OBU will be placed in the encoded OBU stream.
|
||||
* Metadata will be emitted into the output stream within the next temporal unit
|
||||
* if it satisfies the specified insertion flag.
|
||||
*
|
||||
* During decoding, when the library encounters a metadata OBU, it is always
|
||||
* flagged as AOM_MIF_ANY_FRAME and emitted with the next output aom_image.
|
||||
*/
|
||||
typedef enum aom_metadata_insert_flags {
|
||||
AOM_MIF_NON_KEY_FRAME = 0, /**< Adds metadata if it's not keyframe */
|
||||
AOM_MIF_KEY_FRAME = 1, /**< Adds metadata only if it's a keyframe */
|
||||
AOM_MIF_ANY_FRAME = 2 /**< Adds metadata to any type of frame */
|
||||
} aom_metadata_insert_flags_t;
|
||||
|
||||
/*!\brief Array of aom_metadata structs for an image. */
|
||||
typedef struct aom_metadata_array aom_metadata_array_t;
|
||||
|
||||
/*!\brief Metadata payload. */
|
||||
typedef struct aom_metadata {
|
||||
uint32_t type; /**< Metadata type */
|
||||
uint8_t *payload; /**< Metadata payload data */
|
||||
size_t sz; /**< Metadata payload size */
|
||||
aom_metadata_insert_flags_t insert_flag; /**< Metadata insertion flag */
|
||||
} aom_metadata_t;
|
||||
|
||||
/**\brief Image Descriptor */
|
||||
typedef struct aom_image {
|
||||
aom_img_fmt_t fmt; /**< Image Format */
|
||||
aom_color_primaries_t cp; /**< CICP Color Primaries */
|
||||
aom_transfer_characteristics_t tc; /**< CICP Transfer Characteristics */
|
||||
aom_matrix_coefficients_t mc; /**< CICP Matrix Coefficients */
|
||||
int monochrome; /**< Whether image is monochrome */
|
||||
aom_chroma_sample_position_t csp; /**< chroma sample position */
|
||||
aom_color_range_t range; /**< Color Range */
|
||||
|
||||
/* Image storage dimensions */
|
||||
unsigned int w; /**< Stored image width */
|
||||
unsigned int h; /**< Stored image height */
|
||||
unsigned int bit_depth; /**< Stored image bit-depth */
|
||||
|
||||
/* Image display dimensions */
|
||||
unsigned int d_w; /**< Displayed image width */
|
||||
unsigned int d_h; /**< Displayed image height */
|
||||
|
||||
/* Image intended rendering dimensions */
|
||||
unsigned int r_w; /**< Intended rendering image width */
|
||||
unsigned int r_h; /**< Intended rendering image height */
|
||||
|
||||
/* Chroma subsampling info */
|
||||
unsigned int x_chroma_shift; /**< subsampling order, X */
|
||||
unsigned int y_chroma_shift; /**< subsampling order, Y */
|
||||
|
||||
/* Image data pointers. */
|
||||
#define AOM_PLANE_PACKED 0 /**< To be used for all packed formats */
|
||||
#define AOM_PLANE_Y 0 /**< Y (Luminance) plane */
|
||||
#define AOM_PLANE_U 1 /**< U (Chroma) plane */
|
||||
#define AOM_PLANE_V 2 /**< V (Chroma) plane */
|
||||
unsigned char *planes[3]; /**< pointer to the top left pixel for each plane */
|
||||
int stride[3]; /**< stride between rows for each plane */
|
||||
size_t sz; /**< data size */
|
||||
|
||||
int bps; /**< bits per sample (for packed formats) */
|
||||
|
||||
int temporal_id; /**< Temporal layer Id of image */
|
||||
int spatial_id; /**< Spatial layer Id of image */
|
||||
|
||||
/*!\brief The following member may be set by the application to associate
|
||||
* data with this image.
|
||||
*/
|
||||
void *user_priv;
|
||||
|
||||
/* The following members should be treated as private. */
|
||||
unsigned char *img_data; /**< private */
|
||||
int img_data_owner; /**< private */
|
||||
int self_allocd; /**< private */
|
||||
|
||||
aom_metadata_array_t
|
||||
*metadata; /**< Metadata payloads associated with the image. */
|
||||
|
||||
void *fb_priv; /**< Frame buffer data associated with the image. */
|
||||
} aom_image_t; /**< alias for struct aom_image */
|
||||
|
||||
/*!\brief Open a descriptor, allocating storage for the underlying image
|
||||
*
|
||||
* Returns a descriptor for storing an image of the given format. The
|
||||
* storage for the image is allocated on the heap.
|
||||
*
|
||||
* \param[in] img Pointer to storage for descriptor. If this parameter
|
||||
* is NULL, the storage for the descriptor will be
|
||||
* allocated on the heap.
|
||||
* \param[in] fmt Format for the image
|
||||
* \param[in] d_w Width of the image
|
||||
* \param[in] d_h Height of the image
|
||||
* \param[in] align Alignment, in bytes, of the image buffer and
|
||||
* each row in the image (stride).
|
||||
*
|
||||
* \return Returns a pointer to the initialized image descriptor. If the img
|
||||
* parameter is non-null, the value of the img parameter will be
|
||||
* returned.
|
||||
*/
|
||||
aom_image_t *aom_img_alloc(aom_image_t *img, aom_img_fmt_t fmt,
|
||||
unsigned int d_w, unsigned int d_h,
|
||||
unsigned int align);
|
||||
|
||||
/*!\brief Open a descriptor, using existing storage for the underlying image
|
||||
*
|
||||
* Returns a descriptor for storing an image of the given format. The
|
||||
* storage for the image has been allocated elsewhere, and a descriptor is
|
||||
* desired to "wrap" that storage.
|
||||
*
|
||||
* \param[in] img Pointer to storage for descriptor. If this parameter
|
||||
* is NULL, the storage for the descriptor will be
|
||||
* allocated on the heap.
|
||||
* \param[in] fmt Format for the image
|
||||
* \param[in] d_w Width of the image
|
||||
* \param[in] d_h Height of the image
|
||||
* \param[in] align Alignment, in bytes, of each row in the image
|
||||
* (stride).
|
||||
* \param[in] img_data Storage to use for the image
|
||||
*
|
||||
* \return Returns a pointer to the initialized image descriptor. If the img
|
||||
* parameter is non-null, the value of the img parameter will be
|
||||
* returned.
|
||||
*/
|
||||
aom_image_t *aom_img_wrap(aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w,
|
||||
unsigned int d_h, unsigned int align,
|
||||
unsigned char *img_data);
|
||||
|
||||
/*!\brief Open a descriptor, allocating storage for the underlying image with a
|
||||
* border
|
||||
*
|
||||
* Returns a descriptor for storing an image of the given format and its
|
||||
* borders. The storage for the image is allocated on the heap.
|
||||
*
|
||||
* \param[in] img Pointer to storage for descriptor. If this parameter
|
||||
* is NULL, the storage for the descriptor will be
|
||||
* allocated on the heap.
|
||||
* \param[in] fmt Format for the image
|
||||
* \param[in] d_w Width of the image
|
||||
* \param[in] d_h Height of the image
|
||||
* \param[in] align Alignment, in bytes, of the image buffer and
|
||||
* each row in the image (stride).
|
||||
* \param[in] size_align Alignment, in pixels, of the image width and height.
|
||||
* \param[in] border A border that is padded on four sides of the image.
|
||||
*
|
||||
* \return Returns a pointer to the initialized image descriptor. If the img
|
||||
* parameter is non-null, the value of the img parameter will be
|
||||
* returned.
|
||||
*/
|
||||
aom_image_t *aom_img_alloc_with_border(aom_image_t *img, aom_img_fmt_t fmt,
|
||||
unsigned int d_w, unsigned int d_h,
|
||||
unsigned int align,
|
||||
unsigned int size_align,
|
||||
unsigned int border);
|
||||
|
||||
/*!\brief Set the rectangle identifying the displayed portion of the image
|
||||
*
|
||||
* Updates the displayed rectangle (aka viewport) on the image surface to
|
||||
* match the specified coordinates and size.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
* \param[in] x leftmost column
|
||||
* \param[in] y topmost row
|
||||
* \param[in] w width
|
||||
* \param[in] h height
|
||||
* \param[in] border A border that is padded on four sides of the image.
|
||||
*
|
||||
* \return 0 if the requested rectangle is valid, nonzero otherwise.
|
||||
*/
|
||||
int aom_img_set_rect(aom_image_t *img, unsigned int x, unsigned int y,
|
||||
unsigned int w, unsigned int h, unsigned int border);
|
||||
|
||||
/*!\brief Flip the image vertically (top for bottom)
|
||||
*
|
||||
* Adjusts the image descriptor's pointers and strides to make the image
|
||||
* be referenced upside-down.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
*/
|
||||
void aom_img_flip(aom_image_t *img);
|
||||
|
||||
/*!\brief Close an image descriptor
|
||||
*
|
||||
* Frees all allocated storage associated with an image descriptor.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
*/
|
||||
void aom_img_free(aom_image_t *img);
|
||||
|
||||
/*!\brief Get the width of a plane
|
||||
*
|
||||
* Get the width of a plane of an image
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
* \param[in] plane Plane index
|
||||
*/
|
||||
int aom_img_plane_width(const aom_image_t *img, int plane);
|
||||
|
||||
/*!\brief Get the height of a plane
|
||||
*
|
||||
* Get the height of a plane of an image
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
* \param[in] plane Plane index
|
||||
*/
|
||||
int aom_img_plane_height(const aom_image_t *img, int plane);
|
||||
|
||||
/*!\brief Add metadata to image.
|
||||
*
|
||||
* Adds metadata to aom_image_t.
|
||||
* Function makes a copy of the provided data parameter.
|
||||
* Metadata insertion point is controlled by insert_flag.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
* \param[in] type Metadata type
|
||||
* \param[in] data Metadata contents
|
||||
* \param[in] sz Metadata contents size
|
||||
* \param[in] insert_flag Metadata insert flag
|
||||
*
|
||||
* \return Returns 0 on success. If img or data is NULL, sz is 0, or memory
|
||||
* allocation fails, it returns -1.
|
||||
*/
|
||||
int aom_img_add_metadata(aom_image_t *img, uint32_t type, const uint8_t *data,
|
||||
size_t sz, aom_metadata_insert_flags_t insert_flag);
|
||||
|
||||
/*!\brief Return a metadata payload stored within the image metadata array.
|
||||
*
|
||||
* Gets the metadata (aom_metadata_t) at the indicated index in the image
|
||||
* metadata array.
|
||||
*
|
||||
* \param[in] img Pointer to image descriptor to get metadata from
|
||||
* \param[in] index Metadata index to get from metadata array
|
||||
*
|
||||
* \return Returns a const pointer to the selected metadata, if img and/or index
|
||||
* is invalid, it returns NULL.
|
||||
*/
|
||||
const aom_metadata_t *aom_img_get_metadata(const aom_image_t *img,
|
||||
size_t index);
|
||||
|
||||
/*!\brief Return the number of metadata blocks within the image.
|
||||
*
|
||||
* Gets the number of metadata blocks contained within the provided image
|
||||
* metadata array.
|
||||
*
|
||||
* \param[in] img Pointer to image descriptor to get metadata number
|
||||
* from.
|
||||
*
|
||||
* \return Returns the size of the metadata array. If img or metadata is NULL,
|
||||
* it returns 0.
|
||||
*/
|
||||
size_t aom_img_num_metadata(const aom_image_t *img);
|
||||
|
||||
/*!\brief Remove metadata from image.
|
||||
*
|
||||
* Removes all metadata in image metadata list and sets metadata list pointer
|
||||
* to NULL.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
*/
|
||||
void aom_img_remove_metadata(aom_image_t *img);
|
||||
|
||||
/*!\brief Allocate memory for aom_metadata struct.
|
||||
*
|
||||
* Allocates storage for the metadata payload, sets its type and copies the
|
||||
* payload data into the aom_metadata struct. A metadata payload buffer of size
|
||||
* sz is allocated and sz bytes are copied from data into the payload buffer.
|
||||
*
|
||||
* \param[in] type Metadata type
|
||||
* \param[in] data Metadata data pointer
|
||||
* \param[in] sz Metadata size
|
||||
* \param[in] insert_flag Metadata insert flag
|
||||
*
|
||||
* \return Returns the newly allocated aom_metadata struct. If data is NULL,
|
||||
* sz is 0, or memory allocation fails, it returns NULL.
|
||||
*/
|
||||
aom_metadata_t *aom_img_metadata_alloc(uint32_t type, const uint8_t *data,
|
||||
size_t sz,
|
||||
aom_metadata_insert_flags_t insert_flag);
|
||||
|
||||
/*!\brief Free metadata struct.
|
||||
*
|
||||
* Free metadata struct and its buffer.
|
||||
*
|
||||
* \param[in] metadata Metadata struct pointer
|
||||
*/
|
||||
void aom_img_metadata_free(aom_metadata_t *metadata);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AOM_AOM_AOM_IMAGE_H_
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
#ifndef AOM_AOM_AOM_INTEGER_H_
|
||||
#define AOM_AOM_AOM_INTEGER_H_
|
||||
|
||||
/* get ptrdiff_t, size_t, wchar_t, NULL */
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define AOM_FORCE_INLINE __forceinline
|
||||
#define AOM_INLINE __inline
|
||||
#else
|
||||
#define AOM_FORCE_INLINE __inline__ __attribute__((always_inline))
|
||||
#define AOM_INLINE inline
|
||||
#endif
|
||||
|
||||
/* Assume platforms have the C99 standard integer types. */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#if !defined(__STDC_FORMAT_MACROS)
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#endif
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
#define __STDC_LIMIT_MACROS
|
||||
#endif
|
||||
#endif // __cplusplus
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
// Returns size of uint64_t when encoded using LEB128.
|
||||
size_t aom_uleb_size_in_bytes(uint64_t value);
|
||||
|
||||
// Returns 0 on success, -1 on decode failure.
|
||||
// On success, 'value' stores the decoded LEB128 value and 'length' stores
|
||||
// the number of bytes decoded.
|
||||
int aom_uleb_decode(const uint8_t *buffer, size_t available, uint64_t *value,
|
||||
size_t *length);
|
||||
|
||||
// Encodes LEB128 integer. Returns 0 when successful, and -1 upon failure.
|
||||
int aom_uleb_encode(uint64_t value, size_t available, uint8_t *coded_value,
|
||||
size_t *coded_size);
|
||||
|
||||
// Encodes LEB128 integer to size specified. Returns 0 when successful, and -1
|
||||
// upon failure.
|
||||
// Note: This will write exactly pad_to_size bytes; if the value cannot be
|
||||
// encoded in this many bytes, then this will fail.
|
||||
int aom_uleb_encode_fixed_size(uint64_t value, size_t available,
|
||||
size_t pad_to_size, uint8_t *coded_value,
|
||||
size_t *coded_size);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern "C"
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // AOM_AOM_AOM_INTEGER_H_
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,417 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
/*!\defgroup aom_decoder AOMedia AOM/AV1 Decoder
|
||||
* \ingroup aom
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*!\file
|
||||
* \brief Provides definitions for using AOM or AV1 within the aom Decoder
|
||||
* interface.
|
||||
*/
|
||||
#ifndef AOM_AOM_AOMDX_H_
|
||||
#define AOM_AOM_AOMDX_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Include controls common to both the encoder and decoder */
|
||||
#include "aom/aom.h"
|
||||
|
||||
/*!\name Algorithm interface for AV1
|
||||
*
|
||||
* This interface provides the capability to decode AV1 streams.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief A single instance of the AV1 decoder.
|
||||
*\deprecated This access mechanism is provided for backwards compatibility;
|
||||
* prefer aom_codec_av1_dx().
|
||||
*/
|
||||
extern aom_codec_iface_t aom_codec_av1_dx_algo;
|
||||
/*!\brief The interface to the AV1 decoder.
|
||||
*/
|
||||
extern aom_codec_iface_t *aom_codec_av1_dx(void);
|
||||
|
||||
/*!@} - end algorithm interface member group */
|
||||
|
||||
/** Data structure that stores bit accounting for debug
|
||||
*/
|
||||
typedef struct Accounting Accounting;
|
||||
|
||||
#ifndef AOM_INSPECTION_H_
|
||||
/** Callback that inspects decoder frame data.
|
||||
*/
|
||||
typedef void (*aom_inspect_cb)(void *decoder, void *ctx);
|
||||
|
||||
#endif
|
||||
|
||||
/*!\brief Structure to hold inspection callback and context.
|
||||
*
|
||||
* Defines a structure to hold the inspection callback function and calling
|
||||
* context.
|
||||
*/
|
||||
typedef struct aom_inspect_init {
|
||||
/*! Inspection callback. */
|
||||
aom_inspect_cb inspect_cb;
|
||||
|
||||
/*! Inspection context. */
|
||||
void *inspect_ctx;
|
||||
} aom_inspect_init;
|
||||
|
||||
/*!\brief Structure to collect a buffer index when inspecting.
|
||||
*
|
||||
* Defines a structure to hold the buffer and return an index
|
||||
* when calling decode from inspect. This enables us to decode
|
||||
* non showable sub frames.
|
||||
*/
|
||||
typedef struct {
|
||||
/*! Pointer for new position in compressed buffer after decoding 1 OBU. */
|
||||
const unsigned char *buf;
|
||||
/*! Index into reference buffer array to see result of decoding 1 OBU. */
|
||||
int idx;
|
||||
/*! Is a show existing frame. */
|
||||
int show_existing;
|
||||
} Av1DecodeReturn;
|
||||
|
||||
/*!\brief Structure to hold a tile's start address and size in the bitstream.
|
||||
*
|
||||
* Defines a structure to hold a tile's start address and size in the bitstream.
|
||||
*/
|
||||
typedef struct aom_tile_data {
|
||||
/*! Tile data size. */
|
||||
size_t coded_tile_data_size;
|
||||
/*! Tile's start address. */
|
||||
const void *coded_tile_data;
|
||||
/*! Extra size information. */
|
||||
size_t extra_size;
|
||||
} aom_tile_data;
|
||||
|
||||
/*!\brief Structure to hold the external reference frame pointer.
|
||||
*
|
||||
* Define a structure to hold the external reference frame pointer.
|
||||
*/
|
||||
typedef struct av1_ext_ref_frame {
|
||||
/*! Start pointer of external references. */
|
||||
aom_image_t *img;
|
||||
/*! Number of available external references. */
|
||||
int num;
|
||||
} av1_ext_ref_frame_t;
|
||||
|
||||
/*!\enum aom_dec_control_id
|
||||
* \brief AOM decoder control functions
|
||||
*
|
||||
* This set of macros define the control functions available for the AOM
|
||||
* decoder interface.
|
||||
*
|
||||
* \sa #aom_codec_control(aom_codec_ctx_t *ctx, int ctrl_id, ...)
|
||||
*/
|
||||
enum aom_dec_control_id {
|
||||
/*!\brief Codec control function to get info on which reference frames were
|
||||
* updated by the last decode, int* parameter
|
||||
*/
|
||||
AOMD_GET_LAST_REF_UPDATES = AOM_DECODER_CTRL_ID_START,
|
||||
|
||||
/*!\brief Codec control function to check if the indicated frame is
|
||||
corrupted, int* parameter
|
||||
*/
|
||||
AOMD_GET_FRAME_CORRUPTED,
|
||||
|
||||
/*!\brief Codec control function to get info on which reference frames were
|
||||
* used by the last decode, int* parameter
|
||||
*/
|
||||
AOMD_GET_LAST_REF_USED,
|
||||
|
||||
/*!\brief Codec control function to get the dimensions that the current
|
||||
* frame is decoded at, int* parameter. This may be different to the
|
||||
* intended display size for the frame as specified in the wrapper or frame
|
||||
* header (see AV1D_GET_DISPLAY_SIZE).
|
||||
*/
|
||||
AV1D_GET_FRAME_SIZE,
|
||||
|
||||
/*!\brief Codec control function to get the current frame's intended display
|
||||
* dimensions (as specified in the wrapper or frame header), int* parameter.
|
||||
* This may be different to the decoded dimensions of this frame (see
|
||||
* AV1D_GET_FRAME_SIZE).
|
||||
*/
|
||||
AV1D_GET_DISPLAY_SIZE,
|
||||
|
||||
/*!\brief Codec control function to get the bit depth of the stream,
|
||||
* unsigned int* parameter
|
||||
*/
|
||||
AV1D_GET_BIT_DEPTH,
|
||||
|
||||
/*!\brief Codec control function to get the image format of the stream,
|
||||
* aom_img_fmt_t* parameter
|
||||
*/
|
||||
AV1D_GET_IMG_FORMAT,
|
||||
|
||||
/*!\brief Codec control function to get the size of the tile, unsigned int
|
||||
parameter */
|
||||
AV1D_GET_TILE_SIZE,
|
||||
|
||||
/*!\brief Codec control function to get the tile count in a tile list, int*
|
||||
* parameter
|
||||
*/
|
||||
AV1D_GET_TILE_COUNT,
|
||||
|
||||
/*!\brief Codec control function to set the byte alignment of the planes in
|
||||
* the reference buffers, int parameter
|
||||
*
|
||||
* Valid values are power of 2, from 32 to 1024. A value of 0 sets
|
||||
* legacy alignment. I.e. Y plane is aligned to 32 bytes, U plane directly
|
||||
* follows Y plane, and V plane directly follows U plane. Default value is 0.
|
||||
*/
|
||||
AV1_SET_BYTE_ALIGNMENT,
|
||||
|
||||
/*!\brief Codec control function to invert the decoding order to from right to
|
||||
* left, int parameter
|
||||
*
|
||||
* The function is used in a test to confirm the decoding independence of tile
|
||||
* columns. The function may be used in application where this order
|
||||
* of decoding is desired. int parameter
|
||||
*
|
||||
* TODO(yaowu): Rework the unit test that uses this control, and in a future
|
||||
* release, this test-only control shall be removed.
|
||||
*/
|
||||
AV1_INVERT_TILE_DECODE_ORDER,
|
||||
|
||||
/*!\brief Codec control function to set the skip loop filter flag, int
|
||||
* parameter
|
||||
*
|
||||
* Valid values are integers. The decoder will skip the loop filter
|
||||
* when its value is set to nonzero. If the loop filter is skipped the
|
||||
* decoder may accumulate decode artifacts. The default value is 0.
|
||||
*/
|
||||
AV1_SET_SKIP_LOOP_FILTER,
|
||||
|
||||
/*!\brief Codec control function to retrieve a pointer to the Accounting
|
||||
* struct, takes Accounting** as parameter
|
||||
*
|
||||
* If called before a frame has been decoded, this returns AOM_CODEC_ERROR.
|
||||
* The caller should ensure that AOM_CODEC_OK is returned before attempting
|
||||
* to dereference the Accounting pointer.
|
||||
*
|
||||
* \attention When compiled without --enable-accounting, this returns
|
||||
* AOM_CODEC_INCAPABLE.
|
||||
*/
|
||||
AV1_GET_ACCOUNTING,
|
||||
|
||||
/*!\brief Codec control function to get last decoded frame quantizer,
|
||||
* int* parameter
|
||||
*
|
||||
* Returned value uses internal quantizer scale defined by the codec.
|
||||
*/
|
||||
AOMD_GET_LAST_QUANTIZER,
|
||||
|
||||
/*!\brief Codec control function to set the range of tile decoding, int
|
||||
* parameter
|
||||
*
|
||||
* A value that is greater and equal to zero indicates only the specific
|
||||
* row/column is decoded. A value that is -1 indicates the whole row/column
|
||||
* is decoded. A special case is both values are -1 that means the whole
|
||||
* frame is decoded.
|
||||
*/
|
||||
AV1_SET_DECODE_TILE_ROW,
|
||||
AV1_SET_DECODE_TILE_COL,
|
||||
|
||||
/*!\brief Codec control function to set the tile coding mode, int parameter
|
||||
*
|
||||
* - 0 = tiles are coded in normal tile mode
|
||||
* - 1 = tiles are coded in large-scale tile mode
|
||||
*/
|
||||
AV1_SET_TILE_MODE,
|
||||
|
||||
/*!\brief Codec control function to get the frame header information of an
|
||||
* encoded frame, unsigned int* parameter
|
||||
*/
|
||||
AV1D_GET_FRAME_HEADER_INFO,
|
||||
|
||||
/*!\brief Codec control function to get the start address and size of a
|
||||
* tile in the coded bitstream, aom_tile_data* parameter.
|
||||
*/
|
||||
AV1D_GET_TILE_DATA,
|
||||
|
||||
/*!\brief Codec control function to set the external references' pointers in
|
||||
* the decoder, av1_ext_ref_frame_t* parameter.
|
||||
*
|
||||
* This is used while decoding the tile list OBU in large-scale tile coding
|
||||
* mode.
|
||||
*/
|
||||
AV1D_SET_EXT_REF_PTR,
|
||||
|
||||
/*!\brief Codec control function to enable the ext-tile software debug and
|
||||
* testing code in the decoder, unsigned int parameter
|
||||
*/
|
||||
AV1D_EXT_TILE_DEBUG,
|
||||
|
||||
/*!\brief Codec control function to enable the row based multi-threading of
|
||||
* decoding, unsigned int parameter
|
||||
*
|
||||
* - 0 = disabled
|
||||
* - 1 = enabled (default)
|
||||
*/
|
||||
AV1D_SET_ROW_MT,
|
||||
|
||||
/*!\brief Codec control function to indicate whether bitstream is in
|
||||
* Annex-B format, unsigned int parameter
|
||||
*/
|
||||
AV1D_SET_IS_ANNEXB,
|
||||
|
||||
/*!\brief Codec control function to indicate which operating point to use,
|
||||
* int parameter
|
||||
*
|
||||
* A scalable stream may define multiple operating points, each of which
|
||||
* defines a set of temporal and spatial layers to be processed. The
|
||||
* operating point index may take a value between 0 and
|
||||
* operating_points_cnt_minus_1 (which is at most 31).
|
||||
*/
|
||||
AV1D_SET_OPERATING_POINT,
|
||||
|
||||
/*!\brief Codec control function to indicate whether to output one frame per
|
||||
* temporal unit (the default), or one frame per spatial layer. int parameter
|
||||
*
|
||||
* In a scalable stream, each temporal unit corresponds to a single "frame"
|
||||
* of video, and within a temporal unit there may be multiple spatial layers
|
||||
* with different versions of that frame.
|
||||
* For video playback, only the highest-quality version (within the
|
||||
* selected operating point) is needed, but for some use cases it is useful
|
||||
* to have access to multiple versions of a frame when they are available.
|
||||
*/
|
||||
AV1D_SET_OUTPUT_ALL_LAYERS,
|
||||
|
||||
/*!\brief Codec control function to set an aom_inspect_cb callback that is
|
||||
* invoked each time a frame is decoded, aom_inspect_init* parameter
|
||||
*
|
||||
* \attention When compiled without --enable-inspection, this
|
||||
* returns AOM_CODEC_INCAPABLE.
|
||||
*/
|
||||
AV1_SET_INSPECTION_CALLBACK,
|
||||
|
||||
/*!\brief Codec control function to set the skip film grain flag, int
|
||||
* parameter
|
||||
*
|
||||
* Valid values are integers. The decoder will skip the film grain when its
|
||||
* value is set to nonzero. The default value is 0.
|
||||
*/
|
||||
AV1D_SET_SKIP_FILM_GRAIN,
|
||||
|
||||
AOM_DECODER_CTRL_ID_MAX,
|
||||
|
||||
AOMD_GET_FWD_KF_PRESENT,
|
||||
|
||||
/*!\brief Codec control function to get the frame flags of the previous frame
|
||||
* decoded. This will return a flag of type aom_codec_frame_flags_t.
|
||||
*/
|
||||
AOMD_GET_FRAME_FLAGS,
|
||||
};
|
||||
|
||||
/*!\cond */
|
||||
/*!\brief AOM decoder control function parameter type
|
||||
*
|
||||
* Defines the data types that AOMD control functions take.
|
||||
*
|
||||
* \note Additional common controls are defined in aom.h.
|
||||
*
|
||||
* \note For each control ID "X", a macro-define of
|
||||
* AOM_CTRL_X is provided. It is used at compile time to determine
|
||||
* if the control ID is supported by the libaom library available,
|
||||
* when the libaom version cannot be controlled.
|
||||
*/
|
||||
AOM_CTRL_USE_TYPE(AOMD_GET_LAST_REF_UPDATES, int *)
|
||||
#define AOM_CTRL_AOMD_GET_LAST_REF_UPDATES
|
||||
|
||||
AOM_CTRL_USE_TYPE(AOMD_GET_FRAME_CORRUPTED, int *)
|
||||
#define AOM_CTRL_AOMD_GET_FRAME_CORRUPTED
|
||||
|
||||
AOM_CTRL_USE_TYPE(AOMD_GET_LAST_REF_USED, int *)
|
||||
#define AOM_CTRL_AOMD_GET_LAST_REF_USED
|
||||
|
||||
AOM_CTRL_USE_TYPE(AOMD_GET_LAST_QUANTIZER, int *)
|
||||
#define AOM_CTRL_AOMD_GET_LAST_QUANTIZER
|
||||
|
||||
AOM_CTRL_USE_TYPE(AOMD_GET_FWD_KF_PRESENT, int *)
|
||||
#define AOM_CTRL_AOMD_GET_FWD_KF_PRESENT
|
||||
|
||||
AOM_CTRL_USE_TYPE(AOMD_GET_FRAME_FLAGS, int *)
|
||||
#define AOM_CTRL_AOMD_GET_FRAME_FLAGS
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1D_GET_DISPLAY_SIZE, int *)
|
||||
#define AOM_CTRL_AV1D_GET_DISPLAY_SIZE
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1D_GET_BIT_DEPTH, unsigned int *)
|
||||
#define AOM_CTRL_AV1D_GET_BIT_DEPTH
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1D_GET_IMG_FORMAT, aom_img_fmt_t *)
|
||||
#define AOM_CTRL_AV1D_GET_IMG_FORMAT
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1D_GET_TILE_SIZE, unsigned int *)
|
||||
#define AOM_CTRL_AV1D_GET_TILE_SIZE
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1D_GET_TILE_COUNT, unsigned int *)
|
||||
#define AOM_CTRL_AV1D_GET_TILE_COUNT
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1D_GET_FRAME_SIZE, int *)
|
||||
#define AOM_CTRL_AV1D_GET_FRAME_SIZE
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1_INVERT_TILE_DECODE_ORDER, int)
|
||||
#define AOM_CTRL_AV1_INVERT_TILE_DECODE_ORDER
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1_GET_ACCOUNTING, Accounting **)
|
||||
#define AOM_CTRL_AV1_GET_ACCOUNTING
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1_SET_DECODE_TILE_ROW, int)
|
||||
#define AOM_CTRL_AV1_SET_DECODE_TILE_ROW
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1_SET_DECODE_TILE_COL, int)
|
||||
#define AOM_CTRL_AV1_SET_DECODE_TILE_COL
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1_SET_TILE_MODE, unsigned int)
|
||||
#define AOM_CTRL_AV1_SET_TILE_MODE
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1D_GET_FRAME_HEADER_INFO, aom_tile_data *)
|
||||
#define AOM_CTRL_AV1D_GET_FRAME_HEADER_INFO
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1D_GET_TILE_DATA, aom_tile_data *)
|
||||
#define AOM_CTRL_AV1D_GET_TILE_DATA
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1D_SET_EXT_REF_PTR, av1_ext_ref_frame_t *)
|
||||
#define AOM_CTRL_AV1D_SET_EXT_REF_PTR
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1D_EXT_TILE_DEBUG, unsigned int)
|
||||
#define AOM_CTRL_AV1D_EXT_TILE_DEBUG
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1D_SET_ROW_MT, unsigned int)
|
||||
#define AOM_CTRL_AV1D_SET_ROW_MT
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1D_SET_SKIP_FILM_GRAIN, int)
|
||||
#define AOM_CTRL_AV1D_SET_SKIP_FILM_GRAIN
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1D_SET_IS_ANNEXB, unsigned int)
|
||||
#define AOM_CTRL_AV1D_SET_IS_ANNEXB
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1D_SET_OPERATING_POINT, int)
|
||||
#define AOM_CTRL_AV1D_SET_OPERATING_POINT
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1D_SET_OUTPUT_ALL_LAYERS, int)
|
||||
#define AOM_CTRL_AV1D_SET_OUTPUT_ALL_LAYERS
|
||||
|
||||
AOM_CTRL_USE_TYPE(AV1_SET_INSPECTION_CALLBACK, aom_inspect_init *)
|
||||
#define AOM_CTRL_AV1_SET_INSPECTION_CALLBACK
|
||||
/*!\endcond */
|
||||
/*! @} - end defgroup aom_decoder */
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AOM_AOM_AOMDX_H_
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// AVIFDecoder.h
|
||||
// AVIFQuickLook
|
||||
//
|
||||
// Created by lizhuoli on 2019/4/15.
|
||||
// Copyright © 2019 dreampiggy. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface AVIFDecoder : NSObject
|
||||
|
||||
+ (nullable CGImageRef)createAVIFImageAtPath:(nonnull NSString *)path CF_RETURNS_RETAINED;
|
||||
+ (nullable CGImageRef)createAVIFImageWithData:(nonnull NSData *)data CF_RETURNS_RETAINED;
|
||||
+ (BOOL)isAVIFFormatForData:(nullable NSData *)data;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
|
@ -0,0 +1,131 @@
|
|||
//
|
||||
// AVIFDecoder.m
|
||||
// AVIFQuickLook
|
||||
//
|
||||
// Created by lizhuoli on 2019/4/15.
|
||||
// Copyright © 2019 dreampiggy. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AVIFDecoder.h"
|
||||
#import <Accelerate/Accelerate.h>
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <avif/avif.h>
|
||||
|
||||
// Convert 8/10/12bit AVIF image into RGBA8888
|
||||
static void ConvertAvifImagePlanarToRGB(avifImage *avif, uint8_t *outPixels) {
|
||||
BOOL hasAlpha = avif->alphaPlane != NULL;
|
||||
avifRGBImage avifRgb = {0};
|
||||
avifRGBImageSetDefaults(&avifRgb, avif);
|
||||
avifRgb.format = hasAlpha ? AVIF_RGB_FORMAT_RGBA : AVIF_RGB_FORMAT_RGB;
|
||||
avifRgb.depth = 8;
|
||||
avifRgb.rowBytes = avif->width * avifRGBImagePixelSize(&avifRgb);
|
||||
avifRgb.pixels = malloc(avifRgb.rowBytes * avifRgb.height);
|
||||
if(avifRgb.pixels) {
|
||||
size_t components = hasAlpha ? 4 : 3;
|
||||
avifImageYUVToRGB(avif, &avifRgb);
|
||||
for(int j = 0; j < avifRgb.height; ++j) {
|
||||
for(int i = 0; i < avifRgb.width; ++i) {
|
||||
uint8_t *pixel = &outPixels[components * (i + (j * avifRgb.width))];
|
||||
pixel[0] = avifRgb.pixels[i * components + (j * avifRgb.rowBytes) + 0];
|
||||
pixel[1] = avifRgb.pixels[i * components + (j * avifRgb.rowBytes) + 1];
|
||||
pixel[2] = avifRgb.pixels[i * components + (j * avifRgb.rowBytes) + 2];
|
||||
if(hasAlpha) {
|
||||
pixel[3] = avifRgb.pixels[i * components + (j * avifRgb.rowBytes) + 3];
|
||||
}
|
||||
}
|
||||
}
|
||||
free(avifRgb.pixels);
|
||||
}
|
||||
}
|
||||
|
||||
static void FreeImageData(void *info, const void *data, size_t size) {
|
||||
free((void *)data);
|
||||
}
|
||||
|
||||
@implementation AVIFDecoder
|
||||
|
||||
+ (nullable CGImageRef)createAVIFImageAtPath:(nonnull NSString *)path {
|
||||
NSData *data = [NSData dataWithContentsOfFile:path];
|
||||
if(!data) {
|
||||
return nil;
|
||||
}
|
||||
if(![AVIFDecoder isAVIFFormatForData:data]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return [AVIFDecoder createAVIFImageWithData:data];
|
||||
}
|
||||
|
||||
+ (nullable CGImageRef)createAVIFImageWithData:(nonnull NSData *)data CF_RETURNS_RETAINED {
|
||||
// Decode it
|
||||
avifDecoder *decoder = avifDecoderCreate();
|
||||
avifImage *avif = avifImageCreateEmpty();
|
||||
avifResult result = avifDecoderReadMemory(decoder, avif, [data bytes], [data length]);
|
||||
if(result != AVIF_RESULT_OK) {
|
||||
avifImageDestroy(avif);
|
||||
avifDecoderDestroy(decoder);
|
||||
return nil;
|
||||
}
|
||||
|
||||
int width = avif->width;
|
||||
int height = avif->height;
|
||||
BOOL hasAlpha = avif->alphaPlane != NULL;
|
||||
size_t components = hasAlpha ? 4 : 3;
|
||||
size_t bitsPerComponent = 8;
|
||||
size_t bitsPerPixel = components * bitsPerComponent;
|
||||
size_t rowBytes = width * bitsPerPixel / 8;
|
||||
|
||||
uint8_t *dest = calloc(width * components * height, sizeof(uint8_t));
|
||||
if(!dest) {
|
||||
avifImageDestroy(avif);
|
||||
avifDecoderDestroy(decoder);
|
||||
return nil;
|
||||
}
|
||||
// convert planar to RGB888/RGBA8888
|
||||
ConvertAvifImagePlanarToRGB(avif, dest);
|
||||
|
||||
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, dest, rowBytes * height, FreeImageData);
|
||||
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
|
||||
bitmapInfo |= hasAlpha ? kCGImageAlphaPremultipliedLast : kCGImageAlphaNone;
|
||||
CGColorSpaceRef colorSpaceRef = [self colorSpaceGetDeviceRGB];
|
||||
CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;
|
||||
CGImageRef imageRef = CGImageCreate(width, height, bitsPerComponent, bitsPerPixel, rowBytes, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent);
|
||||
|
||||
// clean up
|
||||
CGDataProviderRelease(provider);
|
||||
avifImageDestroy(avif);
|
||||
avifDecoderDestroy(decoder);
|
||||
|
||||
return imageRef;
|
||||
}
|
||||
|
||||
#pragma mark - Helper
|
||||
+ (BOOL)isAVIFFormatForData:(nullable NSData *)data {
|
||||
if(!data) {
|
||||
return NO;
|
||||
}
|
||||
if(data.length >= 12) {
|
||||
//....ftypavif ....ftypavis
|
||||
NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(4, 8)] encoding:NSASCIIStringEncoding];
|
||||
if([testString isEqualToString:@"ftypavif"] || [testString isEqualToString:@"ftypavis"]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (CGColorSpaceRef)colorSpaceGetDeviceRGB {
|
||||
CGColorSpaceRef screenColorSpace = NSScreen.mainScreen.colorSpace.CGColorSpace;
|
||||
if(screenColorSpace) {
|
||||
return screenColorSpace;
|
||||
}
|
||||
static CGColorSpaceRef colorSpace;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
});
|
||||
return colorSpace;
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in New Issue