Issue #1737 - Import libaom 2.0.2 source (excluding aom_ports/aom_once.h)

This commit is contained in:
roytam1 2021-03-04 09:29:28 +08:00
commit 7537b4d23a
767 changed files with 152707 additions and 85235 deletions

View file

@ -1,7 +1,7 @@
---
Language: Cpp
# BasedOnStyle: Google
# Generated with clang-format 5.0.0
# Generated with clang-format 7.0.1
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
@ -12,7 +12,6 @@ AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
@ -30,6 +29,7 @@ BraceWrapping:
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
@ -39,6 +39,7 @@ BraceWrapping:
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
@ -59,7 +60,10 @@ ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
@ -68,6 +72,7 @@ IncludeCategories:
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
@ -77,6 +82,7 @@ MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: false
@ -85,20 +91,53 @@ PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Right
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false

View file

@ -1,13 +1,11 @@
# Generated with cmake-format 0.3.6
# Generated with cmake-format 0.5.1
# How wide to allow formatted cmake files
line_width = 80
# How many spaces to tab for indent
tab_size = 2
# If arglists are longer than this, break them always. This introduces some
# interesting effects with complicated 'if' statements. However, we want file
# lists to look reasonable. Try to strike a balance.
# If arglists are longer than this, break them always
max_subargs_per_line = 10
# If true, separate flow control names from their parentheses with a space
@ -21,10 +19,10 @@ separate_fn_name_with_space = False
dangle_parens = False
# What character to use for bulleted lists
bullet_char = u'*'
bullet_char = '*'
# What character to use as punctuation after numerals in an enumerated list
enum_char = u'.'
enum_char = '.'
# What style line endings to use in the output.
line_ending = u'unix'
@ -32,6 +30,9 @@ line_ending = u'unix'
# Format command names consistently as 'lower' or 'upper' case
command_case = u'lower'
# Format keywords consistently as 'lower' or 'upper' case
keyword_case = u'unchanged'
# Specify structure for custom cmake functions
additional_commands = {
"foo": {
@ -46,3 +47,56 @@ additional_commands = {
}
}
}
# A list of command names which should always be wrapped
always_wrap = []
# Specify the order of wrapping algorithms during successive reflow attempts
algorithm_order = [0, 1, 2, 3, 4]
# If true, the argument lists which are known to be sortable will be sorted
# lexicographicall
autosort = False
# enable comment markup parsing and reflow
enable_markup = True
# If comment markup is enabled, don't reflow the first comment block in
# eachlistfile. Use this to preserve formatting of your
# copyright/licensestatements.
first_comment_is_literal = False
# If comment markup is enabled, don't reflow any comment block which matchesthis
# (regex) pattern. Default is `None` (disabled).
literal_comment_pattern = None
# Regular expression to match preformat fences in comments
# default=r'^\s*([`~]{3}[`~]*)(.*)$'
fence_pattern = u'^\\s*([`~]{3}[`~]*)(.*)$'
# Regular expression to match rulers in comments
# default=r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'
ruler_pattern = u'^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
# If true, emit the unicode byte-order mark (BOM) at the start of the file
emit_byteorder_mark = False
# If a comment line starts with at least this many consecutive hash characters,
# then don't lstrip() them off. This allows for lazy hash rulers where the first
# hash char is not separated by space
hashruler_min_length = 10
# If true, then insert a space between the first hash char and remaining hash
# chars in a hash ruler, and normalize it's length to fill the column
canonicalize_hashrulers = True
# Specify the encoding of the input file. Defaults to utf-8.
input_encoding = u'utf-8'
# Specify the encoding of the output file. Defaults to utf-8. Note that cmake
# only claims to support utf-8 so be careful when using anything else
output_encoding = u'utf-8'
# A dictionary containing any per-command configuration overrides. Currently
# only `command_case` is supported.
per_command = {}

18
media/libaom/src/.gitattributes vendored Normal file
View file

@ -0,0 +1,18 @@
*.[chs] filter=fixtabswsp
*.[ch]pp filter=fixtabswsp
*.[ch]xx filter=fixtabswsp
*.asm filter=fixtabswsp
*.php filter=fixtabswsp
*.pl filter=fixtabswsp
*.sh filter=fixtabswsp
*.txt filter=fixwsp
[Mm]akefile filter=fixwsp
*.mk filter=fixwsp
*.rc -crlf
*.ds[pw] -crlf
*.bat -crlf
*.mmp -crlf
*.dpj -crlf
*.pjt -crlf
*.vcp -crlf
*.inf -crlf

View file

@ -3,32 +3,89 @@ Aex Converse <aconverse@google.com>
Aex Converse <aconverse@google.com> <alex.converse@gmail.com>
Alexis Ballier <aballier@gentoo.org> <alexis.ballier@gmail.com>
Alpha Lam <hclam@google.com> <hclam@chromium.org>
Andrey Norkin <anorkin@netflix.com>
Angie Chiang <angiebird@google.com>
Arild Fuldseth <arilfuld@cisco.com> <arild.fuldseth@gmail.com>
Arild Fuldseth <arilfuld@cisco.com> <arilfuld@cisco.com>
Bohan Li <bohanli@google.com>
Changjun Yang <changjun.yang@intel.com>
Chi Yo Tsai <chiyotsai@google.com>
Chi Yo Tsai <chiyotsai@google.com> <chiyotsai@dhcp-100-106-128-213.corp.google.com>
Chm <chm@rock-chips.com>
Damon Shen <yjshen@google.com>
Daniele Castagna <dcastagna@chromium.org> <dcastagna@google.com>
Deb Mukherjee <debargha@google.com>
Elliott Karpilovsky <elliottk@google.com>
Emil Keyder <emilkeyder@google.com>
Erik Niemeyer <erik.a.niemeyer@intel.com> <erik.a.niemeyer@gmail.com>
Guillaume Martres <gmartres@google.com> <smarter3@gmail.com>
Frederic Barbier <frederic.barbier@allegrodvt.com> <fbarbier.contact@gmail.com>
Fyodor Kyslov <kyslov@google.com>
Grant Hsu <grant.hsu@cidana.com> <grant.hsu@gmail.com>
Guillaume Martres <smarter@ubuntu.com>
Guillaume Martres <smarter@ubuntu.com> <gmartres@google.com>
Guillaume Martres <smarter@ubuntu.com> <smarter3@gmail.com>
Guillaume Martres <smarter@ubuntu.com> <gmartres@mozilla.com>
Hangyu Kuang <hkuang@google.com>
Hui Su <huisu@google.com>
Iole Moccagatta <iole.moccagatta@gmail.com>
Jacky Chen <jackychen@google.com>
James Zern <jzern@google.com> <jzern@google.cOm>
Jean-Marc Valin <jmvalin@jmvalin.ca> <jmvalin@mozilla.com>
Jim Bankoski <jimbankoski@google.com>
Johann Koenig <johannkoenig@google.com>
Johann Koenig <johannkoenig@google.com> <johann.koenig@duck.com>
Johann Koenig <johannkoenig@google.com> <johann.koenig@gmail.com>
Johann Koenig <johannkoenig@google.com> <johannkoenig@chromium.org>
John Koleszar <jkoleszar@google.com>
Joshua Litt <joshualitt@google.com> <joshualitt@chromium.org>
Lokeshwar Reddy B <lokeshwar.reddy@ittiam.com>
Logan Goldberg <logangw@google.com>
Luc Trudeau <luc@trud.ca>
Luc Trudeau <luc@trud.ca> <ltrudeau@mozilla.com>
Marco Paniconi <marpan@google.com>
Marco Paniconi <marpan@google.com> <marpan@chromium.org>
Michael Bebenita <mbebenita@gmail.com> <mbebenita@mozilla.com>
Michael Horowitz <mhoro@webrtc.org> <mhoro@google.com>
Mingliang Chen <mlchen@google.com>
Monty Montgomery <cmontgomery@mozilla.com>
Nathan E. Egge <negge@mozilla.com>
Nathan E. Egge <negge@mozilla.com> <negge@dgql.org>
Pascal Massimino <pascal.massimino@gmail.com>
Pascal Massimino <pascal.massimino@gmail.com> <skal@google.com>
Paul Wilkins <paulwilkins@google.com>
Peng Bin <binpengsmail@gmail.com>
Peng Bin <binpengsmail@gmail.com> <pengbin@kingsoft.com>
Peter de Rivaz <peter.derivaz@gmail.com> <peter.derivaz@argondesign.com>
Ralph Giles <giles@xiph.org> <giles@entropywave.com>
Ralph Giles <giles@xiph.org> <giles@mozilla.com>
Remya Prakasan <remya.prakasan@ittiam.com>
Roger Zhou <youzhou@microsoft.com>
Ronald S. Bultje <rsbultje@gmail.com> <rbultje@google.com>
Ryan Lei <ryan.z.lei@intel.com>
Ryan Lei <ryan.z.lei@intel.com> <ryan.lei@intel.com>
Ryan Lei <ryan.z.lei@intel.com> <zlei3@ZLEI3-DESK.amr.corp.intel.com>
Sachin Kumar Garg <sachin.kumargarg@ittiam.com>
Sai Deng <sdeng@google.com>
Sami Pietilä <samipietila@google.com>
Sarah Parker <sarahparker@google.com>
Tamar Levy <tamar.levy@intel.com>
Tamar Levy <tamar.levy@intel.com> <levytamar82@gmail.com>
Tero Rintaluoma <teror@google.com> <tero.rintaluoma@on2.com>
Thomas Davies Thomas <thdavies@cisco.com>
Timothy B. Terriberry <tterribe@xiph.org>
Timothy B. Terriberry <tterribe@xiph.org> <tterriberry@mozilla.com>
Timothy B. Terriberry <tterribe@xiph.org> Tim Terriberry <tterriberry@mozilla.com>
Tom Finegan <tomfinegan@google.com>
Tom Finegan <tomfinegan@google.com> <tomfinegan@chromium.org>
Tristan Matthews <tmatth@videolan.org> <le.businessman@gmail.com>
Venkat Sanampudi <sanampudi.venkatarao@ittiam.com>
Wei-Ting Lin <weitinglin@google.com>
Wei-Ting Lin <weitinglin@google.com> <weitingco@gmail.com>
Wenyao Liu <wenyao.liu@cidana.com>
Yaowu Xu <yaowu@google.com> <adam@xuyaowu.com>
Yaowu Xu <yaowu@google.com> <yaowu@xuyaowu.com>
Yaowu Xu <yaowu@google.com> <yaowu@yaowu-macbookpro.roam.corp.google.com>
Yaowu Xu <yaowu@google.com> <Yaowu Xu>
Yaowu Xu <yaowu@google.com> <yaowu.google.com>
Zhipin Deng <zhipin.deng@intel.com>
Zoe Liu <zoeliu@gmail.com> <zoeliu@google.com>

View file

@ -1,13 +1,16 @@
# This file is automatically generated from the git commit history
# by tools/gen_authors.sh.
Aamir Anis <aanis@google.com>
Aaron Watry <awatry@gmail.com>
Aasaipriya <aasaipriya.c@ittiam.com>
Abo Talib Mahfoodh <ab.mahfoodh@gmail.com>
Adam Xu <adam@xuyaowu.com>
Adrian Grange <agrange@google.com>
Aex Converse <aconverse@google.com>
Ahmad Sharif <asharif@google.com>
Akshata Jadhav <akshata.jadhav@ittiam.com>
Alexander Bokov <alexanderbokov@google.com>
Alexander Voronov <avoronov@graphics.cs.msu.ru>
Aex Converse <aconverse@google.com>
Alexis Ballier <aballier@gentoo.org>
Alok Ahuja <waveletcoeff@gmail.com>
Alpha Lam <hclam@google.com>
@ -16,39 +19,82 @@ Ami Fischman <fischman@chromium.org>
Andoni Morales Alastruey <ylatuya@gmail.com>
Andres Mejia <mcitadel@gmail.com>
Andrew Russell <anrussell@google.com>
Andrey Norkin <anorkin@netflix.com>
Angie Chiang <angiebird@google.com>
Aniket Dhok <aniket.dhok@ittiam.com>
Ankur Saxena <ankurs@nvidia.com>
Arild Fuldseth <arilfuld@cisco.com>
Aron Rosenberg <arosenberg@logitech.com>
Attila Nagy <attilanagy@google.com>
Bohan Li <bohanli@google.com>
Brennan Shacklett <bshacklett@mozilla.com>
Brion Vibber <bvibber@wikimedia.org>
changjun.yang <changjun.yang@intel.com>
Bruno Berthier <bruno.berthier@allegrodvt.com>
Changjun Yang <changjun.yang@intel.com>
Charles 'Buck' Krasic <ckrasic@google.com>
chm <chm@rock-chips.com>
Cheng Chen <chengchen@google.com>
Cherma Rajan A <cherma.rajan@ittiam.com>
Chi Yo Tsai <chiyotsai@google.com>
Chm <chm@rock-chips.com>
Christian Duvivier <cduvivier@google.com>
Cyril Concolato <cconcolato@netflix.com>
Dake He <dkhe@google.com>
Damon Shen <yjshen@google.com>
Dandan Ding <vickyddding@gmail.com>
Daniele Castagna <dcastagna@chromium.org>
Daniel Kang <ddkang@google.com>
Daniel Max Valenzuela <daniel.vt@samsung.com>
Danil Chapovalov <danilchap@google.com>
David Barker <david.barker@argondesign.com>
David Major <dmajor@mozilla.com>
David Michael Barr <b@rr-dav.id.au>
David Turner <david.turner@argondesign.com>
Deb Mukherjee <debargha@google.com>
Deepa K G <deepa.kg@ittiam.com>
Deng <zhipin.deng@intel.com>
Di Chen <chendixi@google.com>
Dim Temp <dimtemp0@gmail.com>
Dmitry Kovalev <dkovalev@google.com>
Dominic Symes <dominic.symes@arm.com>
Dragan Mrdjan <dmrdjan@mips.com>
Ed Baker <edward.baker@intel.com>
Edward Hervey <edward@centricular.com>
Ehsan Akhgari <ehsan.akhgari@gmail.com>
Elliott Karpilovsky <elliottk@google.com>
Emil Keyder <emilkeyder@google.com>
Erik Niemeyer <erik.a.niemeyer@intel.com>
Fabio Pedretti <fabio.ped@libero.it>
Fangwen Fu <fangwen.fu@intel.com>
Fergus Simpson <afergs@google.com>
Frank Bossen <fbossen@gmail.com>
Frank Galligan <fgalligan@google.com>
Frederic Barbier <frederic.barbier@allegrodvt.com>
Fredrik Söderquist <fs@opera.com>
Fritz Koenig <frkoenig@google.com>
Fyodor Kyslov <kyslov@google.com>
Gaute Strokkenes <gaute.strokkenes@broadcom.com>
Geza Lore <gezalore@gmail.com>
Ghislain MARY <ghislainmary2@gmail.com>
Giuseppe Scrivano <gscrivano@gnu.org>
Gordana Cmiljanovic <gordana.cmiljanovic@imgtec.com>
Guillaume Martres <gmartres@google.com>
Grant Hsu <grant.hsu@cidana.com>
Guillaume Martres <smarter@ubuntu.com>
Guillermo Ballester Valor <gbvalor@gmail.com>
Hamsalekha S <hamsalekha.s@ittiam.com>
Hangyu Kuang <hkuang@google.com>
Hanno Böck <hanno@hboeck.de>
Harish Mahendrakar <harish.mahendrakar@ittiam.com>
Henrik Lundin <hlundin@google.com>
Hien Ho <hienho@google.com>
Hui Su <huisu@google.com>
Ilie Halip <ilie.halip@gmail.com>
Ilya Brailovskiy <brailovs@lab126.com>
Imdad Sardharwalla <imdad.sardharwalla@argondesign.com>
iole moccagatta <iole.moccagatta@gmail.com>
Ivan Krasin <krasin@chromium.org>
Ivan Maltz <ivanmaltz@google.com>
Jacek Caban <cjacek@gmail.com>
Jack Haughton <jack.haughton@argondesign.com>
Jacky Chen <jackychen@google.com>
James Berry <jamesberry@google.com>
James Yu <james.yu@linaro.org>
@ -56,29 +102,42 @@ James Zern <jzern@google.com>
Jan Gerber <j@mailb.org>
Jan Kratochvil <jan.kratochvil@redhat.com>
Janne Salonen <jsalonen@google.com>
Jean-Marc Valin <jmvalin@jmvalin.ca>
Jayasanker J <jayasanker.j@ittiam.com>
Jean-Marc Valin <jmvalin@mozilla.com>
Jean-Yves Avenard <jyavenard@mozilla.com>
Jeff Faust <jfaust@google.com>
Jeff Muizelaar <jmuizelaar@mozilla.com>
Jeff Petkau <jpet@chromium.org>
Jerome Jiang <jianj@google.com>
Jia Jia <jia.jia@linaro.org>
Jian Zhou <zhoujian@google.com>
Jim Bankoski <jimbankoski@google.com>
Jingning Han <jingning@google.com>
Joe Young <joeyoung@google.com>
Joey Parrish <joeyparrish@google.com>
Johann Koenig <johannkoenig@chromium.org>
Johann Koenig <johannkoenig@google.com>
John Koleszar <jkoleszar@google.com>
Johnny Klonaris <google@jawknee.com>
John Stark <jhnstrk@gmail.com>
Jonathan Matthews <jonathan.matthews@argondesign.com>
Joshua Bleecher Snyder <josh@treelinelabs.com>
Joshua Litt <joshualitt@google.com>
Julia Robson <juliamrobson@gmail.com>
Justin Clift <justin@salasaga.org>
Justin Lebar <justin.lebar@gmail.com>
Katsuhisa Yuasa <berupon@gmail.com>
KO Myung-Hun <komh@chollian.net>
Krishna Malladi <kmalladi@google.com>
Kyle Siefring <kylesiefring@gmail.com>
Larisa Markeeva <lmarkeeva@google.com>
Lawrence Velázquez <larryv@macports.org>
Lester Lu <kslu@google.com>
Linfeng Zhang <linfengz@google.com>
Logan Goldberg <logangw@google.com>
Lokeshwar Reddy B <lokeshwar.reddy@ittiam.com>
Lou Quillio <louquillio@google.com>
Luca Barbato <lu_zero@gentoo.org>
Luc Trudeau <ltrudeau@mozilla.com>
Makoto Kato <makoto.kt@gmail.com>
Mans Rullgard <mans@mansr.com>
Marco Paniconi <marpan@google.com>
@ -86,40 +145,78 @@ Mark Mentovai <mark@chromium.org>
Martin Ettl <ettl.martin78@googlemail.com>
Martin Storsjo <martin@martin.st>
Matthew Heaney <matthewjheaney@chromium.org>
Matthieu Vaudano <matthieu.vaudano@allegrodvt.com>
Mattias Hansson <mattias.hansson@arm.com>
Maxym Dmytrychenko <maxim.d33@gmail.com>
Michael Bebenita <mbebenita@mozilla.com>
Michael Horowitz <mhoro@webrtc.org>
Michael Kohler <michaelkohler@live.com>
Michelle Findlay-Olynyk <mfo@google.com>
Mike Frysinger <vapier@chromium.org>
Mike Hommey <mhommey@mozilla.com>
Mikhal Shemer <mikhal@google.com>
Minghai Shang <minghai@google.com>
Mingliang Chen <mlchen@google.com>
Mirko Bonadei <mbonadei@google.com>
Monty Montgomery <cmontgomery@mozilla.com>
Morton Jonuschat <yabawock@gmail.com>
Nathan E. Egge <negge@dgql.org>
Mufaddal Chakera <mufaddal.chakera@ittiam.com>
Nathan E. Egge <negge@mozilla.com>
Neil Birkbeck <birkbeck@google.com>
Nico Weber <thakis@chromium.org>
Nithya V S <nithya.vs@ittiam.com>
Ola Hugosson <ola.hugosson@arm.com>
Oleg Nalivayko <o13g86@gmail.com>
Parag Salasakar <img.mips1@gmail.com>
Pascal Massimino <pascal.massimino@gmail.com>
Patrik Westin <patrik.westin@gmail.com>
Paul Wilkins <paulwilkins@google.com>
Pavel Frolov <pavel.frolov@vicuesoft.com>
Pavol Rusnak <stick@gk2.sk>
Paweł Hajdan <phajdan@google.com>
Peng Bin <binpengsmail@gmail.com>
Pengchong Jin <pengchong@google.com>
Peter de Rivaz <peter.derivaz@argondesign.com>
Peter Boström <pbos@google.com>
Peter de Rivaz <peter.derivaz@gmail.com>
Philip Jägenstedt <philipj@opera.com>
Priit Laes <plaes@plaes.org>
Rafael Ávila de Espíndola <rafael.espindola@gmail.com>
Rafaël Carré <funman@videolan.org>
Ralph Giles <giles@xiph.org>
Ranjit Kumar Tulabandu <ranjit.tulabandu@ittiam.com>
Ravi Chaudhary <ravi.chaudhary@ittiam.com>
Remya Prakasan <remya.prakasan@ittiam.com>
Remy Foray <remy.foray@allegrodvt.com>
Rob Bradford <rob@linux.intel.com>
Robert-André Mauchin <zebob.m@gmail.com>
RogerZhou <youzhou@microsoft.com>
Rohit Athavale <rathaval@xilinx.com>
Ronald S. Bultje <rsbultje@gmail.com>
Rostislav Pehlivanov <rpehlivanov@mozilla.com>
Ruiling Song <ruiling.song@intel.com>
Rui Ueyama <ruiu@google.com>
Rupert Swarbrick <rupert.swarbrick@argondesign.com>
Ryan Lei <ryan.lei@intel.com>
Ryan Overbeck <rover@google.com>
Sachin Kumar Garg <sachin.kumargarg@ittiam.com>
Sai Deng <sdeng@google.com>
Sami Pietilä <samipietila@google.com>
Sarah Parker <sarahparker@google.com>
Sasi Inguva <isasi@google.com>
Satish Kumar Suman <satish.suman@ittiam.com>
Scott Graham <scottmg@chromium.org>
Scott LaVarnway <slavarnway@google.com>
Sean DuBois <sean@siobud.com>
Sean McGovern <gseanmcg@gmail.com>
Sean Purser-Haskell <seanhaskell@google.com>
Sebastien Alaiwan <sebastien.alaiwan@allegrodvt.com>
Sergey Kolomenkin <kolomenkin@gmail.com>
Sergey Ulanov <sergeyu@chromium.org>
Shimon Doodkin <helpmepro1@gmail.com>
Shunyao Li <shunyaoli@google.com>
SmilingWolf <lupo996@gmail.com>
Soo-Chul Han <shan@vidyo.com>
Stanislav Vitvitskyy <vitvitskyy@google.com>
Stefan Holmer <holmer@google.com>
Steinar Midtskogen <stemidts@cisco.com>
Suman Sunkara <sunkaras@google.com>
@ -127,18 +224,37 @@ Taekhyun Kim <takim@nvidia.com>
Takanori MATSUURA <t.matsuu@gmail.com>
Tamar Levy <tamar.levy@intel.com>
Tao Bai <michaelbai@chromium.org>
Tarek AMARA <amatarek@justin.tv>
Tero Rintaluoma <teror@google.com>
Thijs Vermeir <thijsvermeir@gmail.com>
Thomas Daede <tdaede@mozilla.com>
Thomas Davies <thdavies@cisco.com>
Thomas <thdavies@cisco.com>
Thomas Davies Thomas <thdavies@cisco.com>
Tim Kopp <tkopp@google.com>
Timothy B. Terriberry <tterribe@xiph.org>
Timo Witte <timo.witte@gmail.com>
Todd Nguyen <toddnguyen@google.com>
Tom Anderson <thomasanderson@google.com>
Tom Finegan <tomfinegan@google.com>
Tristan Matthews <le.businessman@gmail.com>
Tristan Matthews <tmatth@videolan.org>
Umang Saini <umang.saini@ittiam.com>
Urvang Joshi <urvang@google.com>
Venkat Sanampudi <sanampudi.venkatarao@ittiam.com>
Victoria Zhislina <niva213@gmail.com>
Vignesh Venkatasubramanian <vigneshv@google.com>
Vishesh <vishesh.garg@ittiam.com>
Wan-Teh Chang <wtc@google.com>
Wei-Ting Lin <weitinglin@google.com>
Wenyao Liu <wenyao.liu@cidana.com>
Xing Jin <ddvfinite@gmail.com>
Xin Zhao <xinzzhao@tencent.com>
Yaowu Xu <yaowu.google.com>
Yaowu Xu <yaowu@google.com>
Yi Luo <luoyi@google.com>
Yongzhe Wang <yongzhe@google.com>
Yue Chen <yuec@google.com>
Yunqing Wang <yunqingwang@google.com>
Zoe Liu <zoeliu@google.com>
Yury Gitman <yuryg@google.com>
Yushin Cho <ycho@mozilla.com>
Zhijie Yang <zhijie.yang@broadcom.com>
zhipin deng <zhipin.deng@intel.com>
Zoe Liu <zoeliu@gmail.com>

View file

@ -1,3 +1,49 @@
2021-02-09 v2.0.2
This release includes several bug fixes.
- Bug fixes:
Issue 2643: Modify the assertion in temporal filter intrinsics.
Issue 2648: Fix unit test ThreadTestLarge.EncoderResultTest/49
assertion failure.
Issue 2869: Add -Wimplicit-function-declaration as C flag only.
Issue 2878: Avoid memset in the av1_filter_intra_predictor module
functions.
Issue 2903: Fix a typo bug in apply_temporal_filter_planewise.
Call av1_setup_frame_size() when dropping a frame in the
encode_frame_to_data_rate() function in av1/encoder/encoder.c.
2020-11-25 v2.0.1
This release includes two bug fixes.
- Bug fixes:
Issue 2723: Fix crash in chroma_check() when generating a monochrome
encoded stream in real-time mode.
Issue 2833: Fix crash on some input when reduced still picture header is
used in real-time mode and speed >=7.
2020-05-07 v2.0.0 "Applejack"
First official release of libaom.
This release includes new real-time mode and SVC support.
- Upgrading:
AOM_SET_POSTPROC, AOM_CODEC_CAP_POSTPROC and AOM_CODEC_USE_POSTPROC are
removed.
AOM_SET_DBG_* is removed.
Multi-resolution encoding is removed.
put_frame and put_slice callbacks are removed.
- Enhancements:
Full-sweep document update for codec controls.
2018-06-28 v1.0.0
AOMedia Codec Workgroup Approved version 1.0

View file

@ -9,32 +9,34 @@
# can obtain it at www.aomedia.org/license/patent.
#
cmake_minimum_required(VERSION 3.5)
project(AOM C CXX)
if(NOT EMSCRIPTEN)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release"
CACHE "Build type: Debug, Release, RelWithDebInfo or MinSizeRel" STRING
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE
"Release"
CACHE STRING "Build type: Debug, Release, RelWithDebInfo or MinSizeRel"
FORCE)
endif()
endif()
project(AOM C CXX)
set(AOM_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
set(AOM_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include"
CACHE PATH "Installation path of includes")
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib"
CACHE PATH "Installation path of libraries")
if("${AOM_ROOT}" STREQUAL "${AOM_CONFIG_DIR}")
message(FATAL_ERROR
"Building from within the aom source tree is not supported.\n"
"Hint: Run these commands\n" "$ rm -rf CMakeCache.txt CMakeFiles\n"
"$ mkdir -p ../aom_build\n" "$ cd ../aom_build\n"
"And re-run CMake from the aom_build directory.")
message(
FATAL_ERROR "Building from within the aom source tree is not supported.\n"
"Hint: Run these commands\n"
"$ rm -rf CMakeCache.txt CMakeFiles\n"
"$ mkdir -p ../aom_build\n" "$ cd ../aom_build\n"
"And re-run CMake from the aom_build directory.")
endif()
# Updating version info.
# https://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
set(SO_VERSION 2)
set(SO_FILE_VERSION 2.0.2)
include("${AOM_ROOT}/build/cmake/aom_configure.cmake")
include("${AOM_ROOT}/aom_dsp/aom_dsp.cmake")
include("${AOM_ROOT}/aom_mem/aom_mem.cmake")
@ -42,9 +44,10 @@ include("${AOM_ROOT}/aom_ports/aom_ports.cmake")
include("${AOM_ROOT}/aom_scale/aom_scale.cmake")
include("${AOM_ROOT}/aom_util/aom_util.cmake")
include("${AOM_ROOT}/av1/av1.cmake")
include("${AOM_ROOT}/test/test.cmake")
include("${AOM_ROOT}/build/cmake/aom_install.cmake")
include("${AOM_ROOT}/build/cmake/sanitizers.cmake")
include("${AOM_ROOT}/build/cmake/util.cmake")
include("${AOM_ROOT}/test/test.cmake")
list(APPEND AOM_RTCD_SOURCES
"${AOM_CONFIG_DIR}/config/aom_dsp_rtcd.h"
@ -116,6 +119,7 @@ list(APPEND AOM_SOURCES
"${AOM_ROOT}/aom/aomcx.h"
"${AOM_ROOT}/aom/aomdx.h"
"${AOM_ROOT}/aom/internal/aom_codec_internal.h"
"${AOM_ROOT}/aom/internal/aom_image_internal.h"
"${AOM_ROOT}/aom/src/aom_codec.c"
"${AOM_ROOT}/aom/src/aom_decoder.c"
"${AOM_ROOT}/aom/src/aom_encoder.c"
@ -158,8 +162,6 @@ list(APPEND AOM_ENCODER_STATS_SOURCES "${AOM_ROOT}/stats/aomstats.c"
"${AOM_ROOT}/stats/aomstats.h" "${AOM_ROOT}/stats/rate_hist.c"
"${AOM_ROOT}/stats/rate_hist.h")
list(APPEND AOM_PKG_CONFIG_SOURCES "${AOM_CONFIG_DIR}/aom.pc")
list(APPEND AOM_VERSION_SOURCES "${AOM_CONFIG_DIR}/config/aom_version.h")
list(APPEND AOM_WEBM_DECODER_SOURCES "${AOM_ROOT}/common/webmdec.cc"
@ -181,33 +183,32 @@ add_custom_command(OUTPUT "${AOM_CONFIG_DIR}/config/aom_version.h"
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DPERL_EXECUTABLE=${PERL_EXECUTABLE} -P
"${AOM_ROOT}/build/cmake/version.cmake"
COMMENT "Writing aom_version.h" VERBATIM)
COMMENT "Writing aom_version.h"
VERBATIM)
add_custom_target(aom_version_check
COMMAND ${CMAKE_COMMAND} -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
COMMAND ${CMAKE_COMMAND}
-DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
-DAOM_ROOT=${AOM_ROOT}
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DPERL_EXECUTABLE=${PERL_EXECUTABLE} -P
"${AOM_ROOT}/build/cmake/version.cmake"
COMMENT "Updating version info if necessary." VERBATIM)
add_dependencies(aom_version aom_version_check)
COMMENT "Updating version info if necessary."
VERBATIM)
if(NOT MSVC)
add_library(aom_pc ${AOM_PKG_CONFIG_SOURCES})
add_dummy_source_file_to_target(aom_pc c)
add_custom_command(OUTPUT "${AOM_CONFIG_DIR}/aom.pc"
COMMAND ${CMAKE_COMMAND} ARGS
-DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
-DAOM_ROOT=${AOM_ROOT}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DCMAKE_PROJECT_NAME=${CMAKE_PROJECT_NAME}
-DCONFIG_MULTITHREAD=${CONFIG_MULTITHREAD}
-DHAVE_PTHREAD_H=${HAVE_PTHREAD_H} -P
"${AOM_ROOT}/build/cmake/pkg_config.cmake"
COMMENT "Writing aom.pc" VERBATIM)
add_dependencies(aom_pc aom_version)
if(BUILD_SHARED_LIBS AND NOT MSVC)
# Generate version file immediately for non-MSVC shared builds: The version
# string is needed for the aom target.
execute_process(COMMAND ${CMAKE_COMMAND}
-DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
-DAOM_ROOT=${AOM_ROOT}
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DPERL_EXECUTABLE=${PERL_EXECUTABLE} -P
"${AOM_ROOT}/build/cmake/version.cmake")
endif()
add_dependencies(aom_version aom_version_check)
# TODO(tomfinegan): Move rtcd target setup where it belongs for each rtcd
# source.
add_rtcd_build_step("${AOM_ROOT}/aom_dsp/aom_dsp_rtcd_defs.pl"
@ -227,15 +228,46 @@ if(ENABLE_EXAMPLES)
add_library(aom_encoder_stats OBJECT ${AOM_ENCODER_STATS_SOURCES})
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_encoder_stats)
endif()
add_library(aom ${AOM_SOURCES} $<TARGET_OBJECTS:aom_rtcd>)
if(BUILD_SHARED_LIBS)
add_library(aom_static STATIC ${AOM_SOURCES} $<TARGET_OBJECTS:aom_rtcd>)
set_target_properties(aom_static PROPERTIES OUTPUT_NAME aom)
if(NOT MSVC)
# Extract version string and set VERSION/SOVERSION for the aom target.
extract_version_string("${AOM_CONFIG_DIR}/config/aom_version.h"
aom_version_triple)
# Strip any trailing version information, if present.
string(FIND "${aom_version_triple}" "-" dash_pos)
if(NOT dash_pos EQUAL -1)
string(SUBSTRING "${aom_version_triple}" 0 ${dash_pos} aom_version_triple)
endif()
# cmake-format: off
# VERSION is embedded in the .so file name.
# libaom.so -> libaom.so.SOVERSION
# libaom.so.SOVERSION -> libaom.so.VERSION
# libaom.so.VERSION
# cmake-format: on
set_target_properties(aom PROPERTIES SOVERSION ${SO_VERSION})
set_target_properties(aom PROPERTIES VERSION ${SO_FILE_VERSION})
endif()
endif()
if(NOT MSVC AND NOT APPLE)
target_link_libraries(aom ${AOM_LIB_LINK_TYPE} m)
if(BUILD_SHARED_LIBS)
target_link_libraries(aom_static ${AOM_LIB_LINK_TYPE} m)
endif()
endif()
# List of object and static library targets.
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_rtcd aom_encoder_stats aom_mem
aom_scale aom)
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_rtcd aom_mem aom_scale aom)
if(BUILD_SHARED_LIBS)
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_static)
endif()
# Setup dependencies.
setup_aom_dsp_targets()
@ -258,7 +290,7 @@ endforeach()
# other pieces of the util support without defining usage_exit().
file(WRITE "${AOM_GEN_SRC_DIR}/usage_exit.c" "void usage_exit(void) {}")
file(WRITE "${AOM_GEN_SRC_DIR}/usage_exit.cc"
"extern \"C\" void usage_exit(void) {}")
"extern \"C\" void usage_exit(void) {}")
#
# Application and application support targets.
@ -277,31 +309,31 @@ endif()
if((CONFIG_AV1_DECODER OR CONFIG_AV1_ENCODER) AND ENABLE_EXAMPLES)
add_executable(resize_util "${AOM_ROOT}/examples/resize_util.c"
$<TARGET_OBJECTS:aom_common_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>)
list(APPEND AOM_APP_TARGETS resize_util)
endif()
if(CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
add_executable(aomdec "${AOM_ROOT}/apps/aomdec.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
add_executable(decode_to_md5 "${AOM_ROOT}/examples/decode_to_md5.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
add_executable(decode_with_drops "${AOM_ROOT}/examples/decode_with_drops.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
add_executable(simple_decoder "${AOM_ROOT}/examples/simple_decoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
add_executable(scalable_decoder "${AOM_ROOT}/examples/scalable_decoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
if(CONFIG_ANALYZER)
add_executable(analyzer "${AOM_ROOT}/examples/analyzer.cc"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
target_link_libraries(analyzer ${AOM_LIB_LINK_TYPE} ${wxWidgets_LIBRARIES})
list(APPEND AOM_APP_TARGETS analyzer)
list(APPEND AOM_DECODER_EXAMPLE_TARGETS analyzer)
@ -309,14 +341,17 @@ if(CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
if(CONFIG_INSPECTION)
add_executable(inspect "${AOM_ROOT}/examples/inspect.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
list(APPEND AOM_DECODER_EXAMPLE_TARGETS inspect)
if(EMSCRIPTEN)
add_preproc_definition(_POSIX_SOURCE)
append_link_flag_to_target("inspect" "-s TOTAL_MEMORY=402653184")
append_link_flag_to_target("inspect" "--emrun")
append_link_flag_to_target("inspect" "-s USE_PTHREADS=0")
append_link_flag_to_target("inspect" "-s WASM=1")
append_link_flag_to_target("inspect" "-s MODULARIZE=1")
append_link_flag_to_target("inspect" "-s ALLOW_MEMORY_GROWTH=1")
append_link_flag_to_target(
"inspect" "-s \'EXTRA_EXPORTED_RUNTIME_METHODS=[\"UTF8ToString\"]\'")
append_link_flag_to_target("inspect"
@ -334,8 +369,8 @@ if(CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
endif()
# Maintain a list of decoder example targets.
list(APPEND AOM_DECODER_EXAMPLE_TARGETS aomdec decode_to_md5
decode_with_drops scalable_decoder simple_decoder)
list(APPEND AOM_DECODER_EXAMPLE_TARGETS aomdec decode_to_md5 decode_with_drops
scalable_decoder simple_decoder)
# Add decoder examples to the app targets list.
list(APPEND AOM_APP_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS})
@ -344,31 +379,36 @@ endif()
if(CONFIG_AV1_ENCODER)
if(ENABLE_EXAMPLES)
add_executable(aomenc "${AOM_ROOT}/apps/aomenc.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>
$<TARGET_OBJECTS:aom_encoder_stats>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>
$<TARGET_OBJECTS:aom_encoder_stats>)
add_executable(lossless_encoder "${AOM_ROOT}/examples/lossless_encoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
add_executable(set_maps "${AOM_ROOT}/examples/set_maps.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
add_executable(simple_encoder "${AOM_ROOT}/examples/simple_encoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
add_executable(twopass_encoder "${AOM_ROOT}/examples/twopass_encoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
add_executable(noise_model "${AOM_ROOT}/examples/noise_model.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
add_executable(scalable_encoder "${AOM_ROOT}/examples/scalable_encoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
add_executable(svc_encoder_rtc "${AOM_ROOT}/examples/svc_encoder_rtc.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
# Maintain a list of encoder example targets.
list(APPEND AOM_ENCODER_EXAMPLE_TARGETS aomenc lossless_encoder noise_model
set_maps simple_encoder scalable_encoder twopass_encoder)
set_maps simple_encoder scalable_encoder twopass_encoder
svc_encoder_rtc)
endif()
if(ENABLE_TOOLS)
@ -377,7 +417,8 @@ if(CONFIG_AV1_ENCODER)
# TODO(tomfinegan): Sort out why a simple link command with
# aom_entropy_optimizer.c won't work on macos, but dragging in all the
# helper machinery allows the link to succeed.
add_executable(aom_entropy_optimizer "${AOM_GEN_SRC_DIR}/usage_exit.c"
add_executable(aom_entropy_optimizer
"${AOM_GEN_SRC_DIR}/usage_exit.c"
"${AOM_ROOT}/tools/aom_entropy_optimizer.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
@ -390,6 +431,19 @@ if(CONFIG_AV1_ENCODER)
# Add encoder examples and tools to the targets list.
list(APPEND AOM_APP_TARGETS ${AOM_ENCODER_EXAMPLE_TARGETS}
${AOM_ENCODER_TOOL_TARGETS})
if(CONFIG_TUNE_VMAF)
find_library(VMAF libvmaf.a vmaf)
if(NOT VMAF)
message(FATAL_ERROR "VMAF library not found.")
endif()
message("-- Found VMAF library: " ${VMAF})
set_target_properties(aom PROPERTIES LINKER_LANGUAGE CXX)
if(BUILD_SHARED_LIBS)
set_target_properties(aom_static PROPERTIES LINKER_LANGUAGE CXX)
endif()
target_link_libraries(aom PRIVATE ${VMAF})
endif()
endif()
if(ENABLE_EXAMPLES)
@ -403,21 +457,16 @@ endif()
if(ENABLE_TOOLS)
if(CONFIG_AV1_DECODER)
require_cxx_flag_nomsvc("-std=c++11" NO)
add_executable(dump_obu "${AOM_GEN_SRC_DIR}/usage_exit.cc"
"${AOM_ROOT}/tools/dump_obu.cc"
"${AOM_ROOT}/tools/obu_parser.cc"
"${AOM_ROOT}/tools/obu_parser.h"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
"${AOM_ROOT}/tools/dump_obu.cc"
"${AOM_ROOT}/tools/obu_parser.cc"
"${AOM_ROOT}/tools/obu_parser.h"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
list(APPEND AOM_TOOL_TARGETS dump_obu)
list(APPEND AOM_APP_TARGETS dump_obu)
if(NOT MSVC)
target_compile_options(dump_obu PUBLIC -std=c++11)
endif()
# Maintain a separate variable listing only the examples to facilitate
# installation of example programs into an tools sub directory of
# $AOM_DIST_DIR/bin when building the dist target.
@ -428,16 +477,16 @@ endif()
if(ENABLE_EXAMPLES AND CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
add_executable(aom_cx_set_ref "${AOM_ROOT}/examples/aom_cx_set_ref.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
list(APPEND AOM_EXAMPLE_TARGETS aom_cx_set_ref)
list(APPEND AOM_APP_TARGETS aom_cx_set_ref)
endif()
if(ENABLE_EXAMPLES AND CONFIG_AV1_ENCODER)
add_executable(lightfield_encoder "${AOM_ROOT}/examples/lightfield_encoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_encoder_app_util>)
list(APPEND AOM_EXAMPLE_TARGETS lightfield_encoder)
list(APPEND AOM_APP_TARGETS lightfield_encoder)
endif()
@ -453,8 +502,8 @@ endif()
if(ENABLE_EXAMPLES AND CONFIG_AV1_DECODER)
add_executable(lightfield_decoder "${AOM_ROOT}/examples/lightfield_decoder.c"
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
$<TARGET_OBJECTS:aom_common_app_util>
$<TARGET_OBJECTS:aom_decoder_app_util>)
list(APPEND AOM_EXAMPLE_TARGETS lightfield_decoder)
list(APPEND AOM_APP_TARGETS lightfield_decoder)
endif()
@ -489,8 +538,6 @@ if(ENABLE_EXAMPLES OR ENABLE_TESTS OR ENABLE_TOOLS)
endif()
if(CONFIG_WEBM_IO)
require_cxx_flag_nomsvc("-std=c++11" NO)
add_library(webm OBJECT ${AOM_LIBWEBM_SOURCES})
include_directories("${AOM_ROOT}/third_party/libwebm")
target_compile_definitions(webm PRIVATE __STDC_CONSTANT_MACROS)
@ -498,7 +545,6 @@ if(ENABLE_EXAMPLES OR ENABLE_TESTS OR ENABLE_TOOLS)
if(NOT MSVC)
target_compile_options(webm PRIVATE -Wno-shadow)
target_compile_options(webm PUBLIC -std=c++11)
endif()
# Add to existing targets.
@ -526,6 +572,9 @@ endif()
if(HAVE_PTHREAD_H AND CONFIG_MULTITHREAD)
find_package(Threads)
target_link_libraries(aom ${AOM_LIB_LINK_TYPE} Threads::Threads)
if(BUILD_SHARED_LIBS)
target_link_libraries(aom_static ${AOM_LIB_LINK_TYPE} Threads::Threads)
endif()
endif()
if(XCODE)
@ -575,7 +624,6 @@ endif()
if(BUILD_SHARED_LIBS)
include("${AOM_ROOT}/build/cmake/exports.cmake")
setup_exports_target()
set_target_properties(aom PROPERTIES SOVERSION 0)
endif()
# Handle user supplied compile and link flags last to ensure they're obeyed.
@ -593,46 +641,6 @@ if(ENABLE_DOCS)
endif()
endif()
if(NOT (MSVC OR XCODE))
# Aomedia install rule.
list(APPEND AOM_INSTALL_INCS "${AOM_ROOT}/aom/aom.h"
"${AOM_ROOT}/aom/aom_codec.h"
"${AOM_ROOT}/aom/aom_frame_buffer.h"
"${AOM_ROOT}/aom/aom_image.h" "${AOM_ROOT}/aom/aom_integer.h"
"${AOM_ROOT}/aom/aom.h")
if(CONFIG_AV1_DECODER)
if(ENABLE_EXAMPLES)
list(APPEND AOM_INSTALL_BINS aomdec)
endif()
list(APPEND AOM_INSTALL_INCS "${AOM_ROOT}/aom/aom_decoder.h"
"${AOM_ROOT}/aom/aomdx.h")
endif()
if(CONFIG_AV1_ENCODER)
if(ENABLE_EXAMPLES)
list(APPEND AOM_INSTALL_BINS aomenc)
endif()
list(APPEND AOM_INSTALL_INCS "${AOM_ROOT}/aom/aomcx.h"
"${AOM_ROOT}/aom/aom_encoder.h")
endif()
set(AOM_INSTALL_LIBS aom)
install(FILES ${AOM_INSTALL_INCS} DESTINATION "${INCLUDE_INSTALL_DIR}/aom")
install(FILES "${AOM_CONFIG_DIR}/aom.pc" DESTINATION
"${LIB_INSTALL_DIR}/pkgconfig")
install(TARGETS ${AOM_INSTALL_LIBS} DESTINATION "${LIB_INSTALL_DIR}")
if(ENABLE_EXAMPLES)
install(TARGETS ${AOM_INSTALL_BINS} DESTINATION
"${CMAKE_INSTALL_PREFIX}/bin")
endif()
endif()
# Aomedia dist rule.
if(CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
list(APPEND AOM_DIST_APPS $<TARGET_FILE:aomdec>)
@ -658,7 +666,8 @@ if(NOT AOM_DIST_DIR)
endif()
add_custom_target(dist
COMMAND ${CMAKE_COMMAND} -DAOM_ROOT=${AOM_ROOT}
COMMAND ${CMAKE_COMMAND}
-DAOM_ROOT=${AOM_ROOT}
-DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
-DAOM_DIST_DIR=${AOM_DIST_DIR}
-DAOM_DIST_APPS="${AOM_DIST_APPS}"
@ -679,8 +688,8 @@ endif()
# Collect all variables containing libaom source files.
get_cmake_property(all_cmake_vars VARIABLES)
foreach(var ${all_cmake_vars})
if("${var}" MATCHES "SOURCES$\|_INTRIN_\|_ASM_" AND NOT "${var}" MATCHES
"_APP_\|DOXYGEN\|LIBWEBM\|LIBYUV\|_PKG_\|TEST")
if("${var}" MATCHES "SOURCES$\|_INTRIN_\|_ASM_"
AND NOT "${var}" MATCHES "_APP_\|DOXYGEN\|LIBWEBM\|LIBYUV\|_PKG_\|TEST")
list(APPEND aom_source_vars ${var})
endif()
endforeach()
@ -699,9 +708,8 @@ foreach(aom_source_var ${aom_source_vars})
endforeach()
endforeach()
file(APPEND
"${libaom_srcs_txt_file}"
"# Files below this line are generated by the libaom build system.\n")
file(APPEND "${libaom_srcs_txt_file}"
"# Files below this line are generated by the libaom build system.\n")
foreach(aom_source_var ${aom_source_vars})
foreach(file ${${aom_source_var}})
if("${file}" MATCHES "${AOM_CONFIG_DIR}")
@ -734,15 +742,14 @@ foreach(aom_source_var ${aom_source_vars})
endif()
endforeach()
file(APPEND
"${libaom_srcs_gni_file}"
"\n# Files below this line are generated by the libaom build system.\n")
file(APPEND "${libaom_srcs_gni_file}"
"\n# Files below this line are generated by the libaom build system.\n")
foreach(aom_source_var ${aom_source_vars})
if("${${aom_source_var}}" MATCHES "${AOM_CONFIG_DIR}")
string(TOLOWER ${aom_source_var} aom_source_var_lowercase)
file(APPEND "${libaom_srcs_gni_file}"
"\n${aom_source_var_lowercase}_gen = [\n")
"\n${aom_source_var_lowercase}_gen = [\n")
endif()
foreach(file ${${aom_source_var}})
if(NOT "${file}" MATCHES "${AOM_ROOT}")
@ -756,3 +763,6 @@ foreach(aom_source_var ${aom_source_vars})
file(APPEND "${libaom_srcs_gni_file}" "]\n")
endif()
endforeach()
# Generate aom.pc and setup install rule.
setup_aom_install_targets()

View file

@ -57,10 +57,10 @@ Alliance for Open Media Patent License 1.0
2. Definitions.
2.1. Affiliate. <EFBFBD>Affiliate<EFBFBD> means an entity that directly or indirectly
2.1. Affiliate. "Affiliate" means an entity that directly or indirectly
Controls, is Controlled by, or is under common Control of that party.
2.2. Control. <EFBFBD>Control<EFBFBD> means direct or indirect control of more than 50% of
2.2. Control. "Control" means direct or indirect control of more than 50% of
the voting power to elect directors of that corporation, or for any other
entity, the power to direct management of such entity.
@ -70,7 +70,7 @@ Alliance for Open Media Patent License 1.0
2.4. Encoder. "Encoder" means any encoder that produces a bitstream that can
be decoded by a Decoder only to the extent it produces such a bitstream.
2.5. Final Deliverable. <EFBFBD>Final Deliverable<6C> means the final version of a
2.5. Final Deliverable. "Final Deliverable" means the final version of a
deliverable approved by the Alliance for Open Media as a Final
Deliverable.
@ -79,9 +79,9 @@ Alliance for Open Media Patent License 1.0
Implementation also includes components of an Implementation only to the
extent they are used as part of an Implementation.
2.7. License. <EFBFBD>License<EFBFBD> means this license.
2.7. License. "License" means this license.
2.8. Licensee. <EFBFBD>Licensee<EFBFBD> means any person or entity who exercises patent
2.8. Licensee. "Licensee" means any person or entity who exercises patent
rights granted under this License.
2.9. Licensor. "Licensor" means (i) any Licensee that makes, sells, offers
@ -98,11 +98,11 @@ Alliance for Open Media Patent License 1.0
as if the Specification was a W3C Recommendation; or (ii) are infringed
by the Reference Implementation.
2.11. Reference Implementation. <EFBFBD>Reference Implementation<6F> means an Encoder
2.11. Reference Implementation. "Reference Implementation" means an Encoder
and/or Decoder released by the Alliance for Open Media as a Final
Deliverable.
2.12. Specification. <EFBFBD>Specification<EFBFBD> means the specification designated by
2.12. Specification. "Specification" means the specification designated by
the Alliance for Open Media as a Final Deliverable for which this
License was issued.

View file

@ -14,6 +14,7 @@
- [Xcode builds](#xcode-builds)
- [Emscripten builds](#emscripten-builds)
- [Extra Build Flags](#extra-build-flags)
- [Build with VMAF support](#build-with-vmaf)
2. [Testing the library](#testing-the-av1-codec)
- [Basics](#testing-basics)
- [Unit tests](#1_unit-tests)
@ -47,7 +48,9 @@
2. [Git](https://git-scm.com/).
3. [Perl](https://www.perl.org/).
4. For x86 targets, [yasm](http://yasm.tortall.net/), which is preferred, or a
recent version of [nasm](http://www.nasm.us/).
recent version of [nasm](http://www.nasm.us/). If you download yasm with
the intention to work with Visual Studio, please download win32.exe or
win64.exe and rename it into yasm.exe. DO NOT download or use vsyasm.exe.
5. Building the documentation requires [doxygen](http://doxygen.org).
6. Building the unit tests requires [Python](https://www.python.org/).
7. Emscripten builds require the portable
@ -210,15 +213,34 @@ compiler documentation to determine which, if any, are available.
### Microsoft Visual Studio builds
Building the AV1 codec library in Microsoft Visual Studio is supported. The
following example demonstrates generating projects and a solution for the
Microsoft IDE:
Building the AV1 codec library in Microsoft Visual Studio is supported. Visual
Studio 2017 (15.0) or later is required. The following example demonstrates
generating projects and a solution for the Microsoft IDE:
~~~
# This does not require a bash shell; command.exe is fine.
$ cmake path/to/aom -G "Visual Studio 15 2017"
# This does not require a bash shell; Command Prompt (cmd.exe) is fine.
# This assumes the build host is a Windows x64 computer.
# To build with Visual Studio 2019 for the x64 target:
$ cmake path/to/aom -G "Visual Studio 16 2019"
$ cmake --build .
# To build with Visual Studio 2019 for the 32-bit x86 target:
$ cmake path/to/aom -G "Visual Studio 16 2019" -A Win32
$ cmake --build .
# To build with Visual Studio 2017 for the x64 target:
$ cmake path/to/aom -G "Visual Studio 15 2017" -T host=x64 -A x64
$ cmake --build .
# To build with Visual Studio 2017 for the 32-bit x86 target:
$ cmake path/to/aom -G "Visual Studio 15 2017" -T host=x64
$ cmake --build .
~~~
NOTE: The build system targets Windows 7 or later by compiling files with
`-D_WIN32_WINNT=0x0601`.
### Xcode builds
Building the AV1 codec library in Xcode is supported. The following example
@ -290,6 +312,24 @@ These flags can be used, for example, to enable asserts in a release build:
-DAOM_EXTRA_CXX_FLAGS=-UNDEBUG
~~~
### Build with VMAF support
After installing
[libvmaf.a](https://github.com/Netflix/vmaf/blob/master/resource/doc/libvmaf.md),
you can use it with the encoder:
~~~
$ cmake path/to/aom -DCONFIG_TUNE_VMAF=1
~~~
Please note that the default VMAF model
("/usr/local/share/model/vmaf_v0.6.1.pkl")
will be used unless you set the following flag when running the encoder:
~~~
# --vmaf-model-path=path/to/model
~~~
## Testing the AV1 codec
### Testing basics

View file

@ -0,0 +1,35 @@
#sample config file
super_block_size = 128 # super block size. 0, 64 or 128
max_partition_size = 128 # max partition size(8, 16, 32, 64, 128)
min_partition_size = 4 # min partition size(4, 8, 16, 32, 64)
disable_rect_partition_type = 0 # disable rectangle partition type
disable_ab_partition_type = 0 # disable AB partition type
disable_1to4_partition_type = 0 # disable 1 to 4 and 4 to 1 partition type
disable_intra_angle_delta = 0 # disable intra angle delta
disable_paeth_intra = 0 # disable paeth intra
disable_smooth_intra = 0 # disable intra smooth mode
disable_intra_edge_filter = 0 # disable intra edge filter
disable_filter_intra = 0 # disable filter intra
disable_intrabc = 0 # disable Intra Block Copy
disable_cfl = 0 # disable chroma from luma prediction
disable_palette = 0 # disable Palette
disable_flip_idtx = 0 # disable flip and identity transform
disable_tx_64x64 = 0 # disable 64x64 transform
reduced_tx_type_set = 0 # use reduced transform type set
reduced_reference_set = 0 # use reduced reference frame set
disable_obmc = 0 # disable OBMC
disable_warp_motion = 0 # disable Warped Motion
disable_global_motion = 0 # disable global motion
disable_ref_frame_mv = 0 # disable ref mv
disable_dual_filter = 0 # disable dual interpolation filter
disable_one_sided_comp = 0 # disable one sided compound mode
disable_masked_comp = 0 # disable masked compound prediction
disable_diff_wtd_comp = 0 # disable difference weighted compound mode
disable_inter_inter_wedge = 0 # disable inter/inter wedge comp
disable_dist_wtd_comp = 0 # disable distant weighted compound mode
disable_inter_intra_comp = 0 # disable inter/intra compound mode.
disable_inter_intra_wedge = 0 # disable inter/intra wedge comp
disable_smooth_inter_intra = 0 # disable smooth inter/intra
disable_cdef = 0 # disable CDEF filter
disable_lr = 0 # disable Loop Restoration Filter
disable_trellis_quant = 0 # disable trellis quantization

View file

@ -43,64 +43,27 @@ extern "C" {
* The set of macros define the control functions of AOM interface
*/
enum aom_com_control_id {
/*!\brief pass in an external frame into decoder to be used as reference frame
/* 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.
*/
AOM_SET_POSTPROC = 3, /**< set the decoder's post processing settings */
AOM_SET_DBG_COLOR_REF_FRAME =
4, /**< set the reference frames to color for each macroblock */
AOM_SET_DBG_COLOR_MB_MODES = 5, /**< set which macro block modes to color */
AOM_SET_DBG_COLOR_B_MODES = 6, /**< set which blocks modes to color */
AOM_SET_DBG_DISPLAY_MV = 7, /**< set which motion vector modes to draw */
/* TODO(jkoleszar): The encoder incorrectly reuses some of these values (5+)
* for its control ids. 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_SET_REFERENCE = 129, /**< write a frame into a reference buffer */
AV1_COPY_REFERENCE =
130, /**< get a copy of reference frame from the decoder */
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 */
AV1_COPY_NEW_FRAME_IMAGE =
193, /**< copy the new frame to an external buffer */
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 post process flags
*
* The set of macros define AOM decoder post processing flags
*/
enum aom_postproc_level {
AOM_NOFILTERING = 0,
AOM_DEBLOCK = 1 << 0,
AOM_DEMACROBLOCK = 1 << 1,
AOM_ADDNOISE = 1 << 2,
AOM_DEBUG_TXT_FRAME_INFO = 1 << 3, /**< print frame information */
AOM_DEBUG_TXT_MBLK_MODES =
1 << 4, /**< print macro block modes over each macro block */
AOM_DEBUG_TXT_DC_DIFF = 1 << 5, /**< print dc diff for each macro block */
AOM_DEBUG_TXT_RATE_INFO = 1 << 6, /**< print video rate info (encoder only) */
AOM_MFQE = 1 << 10
};
/*!\brief post process flags
*
* This define a structure that describe the post processing settings. For
* the best objective measure (using the PSNR metric) set post_proc_flag
* to AOM_DEBLOCK and deblocking_level to 1.
*/
typedef struct aom_postproc_cfg {
/*!\brief the types of post processing to be done, should be combination of
* "aom_postproc_level" */
int post_proc_flag;
int deblocking_level; /**< the strength of deblocking, valid range [0, 16] */
int noise_level; /**< the strength of additive noise, valid range [0, 16] */
} aom_postproc_cfg_t;
/*!\brief AV1 specific reference frame data struct
*
* Define the data struct to access av1 reference frames.
@ -114,26 +77,25 @@ typedef struct av1_ref_frame {
/*!\cond */
/*!\brief aom decoder control function parameter type
*
* defines the data type for each of AOM decoder control function requires
* 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(AOM_SET_POSTPROC, aom_postproc_cfg_t *)
#define AOM_CTRL_AOM_SET_POSTPROC
AOM_CTRL_USE_TYPE(AOM_SET_DBG_COLOR_REF_FRAME, int)
#define AOM_CTRL_AOM_SET_DBG_COLOR_REF_FRAME
AOM_CTRL_USE_TYPE(AOM_SET_DBG_COLOR_MB_MODES, int)
#define AOM_CTRL_AOM_SET_DBG_COLOR_MB_MODES
AOM_CTRL_USE_TYPE(AOM_SET_DBG_COLOR_B_MODES, int)
#define AOM_CTRL_AOM_SET_DBG_COLOR_B_MODES
AOM_CTRL_USE_TYPE(AOM_SET_DBG_DISPLAY_MV, int)
#define AOM_CTRL_AOM_SET_DBG_DISPLAY_MV
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

View file

@ -95,7 +95,7 @@ extern "C" {
* types, removing or reassigning enums, adding/removing/rearranging
* fields to structures
*/
#define AOM_CODEC_ABI_VERSION (3 + AOM_IMAGE_ABI_VERSION) /**<\hideinitializer*/
#define AOM_CODEC_ABI_VERSION (5 + AOM_IMAGE_ABI_VERSION) /**<\hideinitializer*/
/*!\brief Algorithm return codes */
typedef enum {
@ -173,10 +173,25 @@ typedef long aom_codec_caps_t;
*/
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.
* implementation. This structure is opaque to the application. Common
* functions used with this structure:
* - aom_codec_iface_name: get the name of the codec
* - aom_codec_get_caps: returns the capabilities of the codec (see
* aom_encoder.h for more details)
* - aom_codec_enc_config_default: generate the default config to use
* when initializing the encoder
* - aom_codec_dec_init, aom_codec_enc_init: initialize the codec context
* structure (see documentation on aom_codec_ctx for more information).
*/
typedef const struct aom_codec_iface aom_codec_iface_t;
@ -370,19 +385,24 @@ aom_codec_err_t aom_codec_destroy(aom_codec_ctx_t *ctx);
*/
aom_codec_caps_t aom_codec_get_caps(aom_codec_iface_t *iface);
/*!\brief Control algorithm
/*!\name Codec Control
*
* This function is used to exchange algorithm specific data with the codec
* instance. This can be used to implement features specific to a particular
* algorithm.
* 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).
*
* This wrapper function dispatches the request to the helper function
* associated with the given ctrl_id. It tries to call this function
* transparently, but will return #AOM_CODEC_ERROR if the request could not
* be dispatched.
* 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
*
* Note that this function should not be used directly. Call the
* #aom_codec_control wrapper macro instead.
* 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
@ -394,85 +414,33 @@ aom_codec_caps_t aom_codec_get_caps(aom_codec_iface_t *iface);
* \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, ...);
#if defined(AOM_DISABLE_CTRL_TYPECHECKS) && AOM_DISABLE_CTRL_TYPECHECKS
#define aom_codec_control(ctx, id, data) aom_codec_control_(ctx, id, data)
#define AOM_CTRL_USE_TYPE(id, typ)
#define AOM_CTRL_USE_TYPE_DEPRECATED(id, typ)
#define AOM_CTRL_VOID(id, typ)
aom_codec_err_t aom_codec_control(aom_codec_ctx_t *ctx, int ctrl_id, ...);
#else
/*!\brief aom_codec_control wrapper macro
/*!\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_().
*
* \internal
* It works by dispatching the call to the control function through a wrapper
* function named with the id 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(ctx, id, data) \
aom_codec_control_##id(ctx, id, data) /**<\hideinitializer*/
#define AOM_CODEC_CONTROL_TYPECHECKED(ctx, id, data) \
aom_codec_control_typechecked_##id(ctx, id, data) /**<\hideinitializer*/
/*!\brief aom_codec_control type definition macro
/*!\brief Creates typechecking mechanisms for aom_codec_control
*
* This macro allows for type safe conversions across the variadic parameter
* to aom_codec_control_(). It defines the type of the argument for a given
* control identifier.
*
* \internal
* It defines a static function with
* the correctly typed arguments as a wrapper to the type-unsafe internal
* function.
* 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_##id(aom_codec_ctx_t *, int, typ) \
AOM_UNUSED; \
\
static aom_codec_err_t aom_codec_control_##id(aom_codec_ctx_t *ctx, \
int ctrl_id, typ data) { \
return aom_codec_control_(ctx, ctrl_id, data); \
} /**<\hideinitializer*/
/*!\brief aom_codec_control deprecated type definition macro
*
* Like #AOM_CTRL_USE_TYPE, but indicates that the specified control is
* deprecated and should not be used. Consult the documentation for your
* codec for more information.
*
* \internal
* It defines a static function with the correctly typed arguments as a
* wrapper to the type-unsafe internal function.
*/
#define AOM_CTRL_USE_TYPE_DEPRECATED(id, typ) \
AOM_DECLSPEC_DEPRECATED static aom_codec_err_t aom_codec_control_##id( \
aom_codec_ctx_t *, int, typ) AOM_DEPRECATED AOM_UNUSED; \
\
AOM_DECLSPEC_DEPRECATED static aom_codec_err_t aom_codec_control_##id( \
aom_codec_ctx_t *ctx, int ctrl_id, typ data) { \
return aom_codec_control_(ctx, ctrl_id, data); \
} /**<\hideinitializer*/
/*!\brief aom_codec_control void type definition macro
*
* This macro allows for type safe conversions across the variadic parameter
* to aom_codec_control_(). It indicates that a given control identifier takes
* no argument.
*
* \internal
* It defines a static function without a data argument as a wrapper to the
* type-unsafe internal function.
*/
#define AOM_CTRL_VOID(id) \
static aom_codec_err_t aom_codec_control_##id(aom_codec_ctx_t *, int) \
AOM_UNUSED; \
\
static aom_codec_err_t aom_codec_control_##id(aom_codec_ctx_t *ctx, \
int ctrl_id) { \
return aom_codec_control_(ctx, ctrl_id); \
} /**<\hideinitializer*/
#endif
#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 {
@ -503,19 +471,6 @@ typedef enum {
*/
const char *aom_obu_type_to_string(OBU_TYPE type);
/*!\brief Config Options
*
* This type allows to enumerate and control options defined for control
* via config file at runtime.
*/
typedef struct cfg_options {
/*!\brief Reflects if ext_partition should be enabled
*
* If this value is non-zero it enabled the feature
*/
unsigned int ext_partition;
} cfg_options_t;
/*!@} - end defgroup codec*/
#ifdef __cplusplus
}

View file

@ -42,7 +42,7 @@ extern "C" {
* fields to structures
*/
#define AOM_DECODER_ABI_VERSION \
(3 + AOM_CODEC_ABI_VERSION) /**<\hideinitializer*/
(6 + AOM_CODEC_ABI_VERSION) /**<\hideinitializer*/
/*! \brief Decoder capabilities bitfield
*
@ -52,11 +52,8 @@ extern "C" {
*
* The available flags are specified by AOM_CODEC_CAP_* defines.
*/
#define AOM_CODEC_CAP_PUT_SLICE 0x10000 /**< Will issue put_slice callbacks */
#define AOM_CODEC_CAP_PUT_FRAME 0x20000 /**< Will issue put_frame callbacks */
#define AOM_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */
/*!\brief Can receive encoded frames one fragment at a time */
#define AOM_CODEC_CAP_INPUT_FRAGMENTS 0x100000
/*!brief Can support external frame buffers */
#define AOM_CODEC_CAP_EXTERNAL_FRAME_BUFFER 0x200000
/*! \brief Initialization-time Feature Enabling
*
@ -65,15 +62,6 @@ extern "C" {
*
* The available flags are specified by AOM_CODEC_USE_* defines.
*/
/*!\brief Can support frame-based multi-threading */
#define AOM_CODEC_CAP_FRAME_THREADING 0x200000
/*!brief Can support external frame buffers */
#define AOM_CODEC_CAP_EXTERNAL_FRAME_BUFFER 0x400000
#define AOM_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */
/*!\brief The input frame should be passed to the decoder one fragment at a
* time */
#define AOM_CODEC_USE_INPUT_FRAGMENTS 0x40000
/*!\brief Stream properties
*
@ -105,7 +93,6 @@ typedef struct aom_codec_dec_cfg {
unsigned int w; /**< Width */
unsigned int h; /**< Height */
unsigned int allow_lowbitdepth; /**< Allow use of low-bitdepth coding path */
cfg_options_t cfg; /**< Options defined per config attributes */
} aom_codec_dec_cfg_t; /**< alias for struct aom_codec_dec_cfg */
/*!\brief Initialize a decoder instance
@ -115,8 +102,8 @@ typedef struct aom_codec_dec_cfg {
* function directly, to ensure that the ABI version number parameter
* is properly initialized.
*
* If the library was configured with --disable-multithread, this call
* is not thread safe and should be guarded with a lock if being used
* 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.
@ -186,23 +173,12 @@ aom_codec_err_t aom_codec_get_stream_info(aom_codec_ctx_t *ctx,
/*!\brief Decode data
*
* Processes a buffer of coded data. If the processing results in a new
* decoded frame becoming available, PUT_SLICE and PUT_FRAME events may be
* generated, as appropriate. Encoded data \ref MUST be passed in DTS (decode
* time stamp) order. Frames produced will always be in PTS (presentation
* time stamp) order.
* If the decoder is configured with AOM_CODEC_USE_INPUT_FRAGMENTS enabled,
* data and data_sz can contain a fragment of the encoded frame. Fragment
* \#n must contain at least partition \#n, but can also contain subsequent
* partitions (\#n+1 - \#n+i), and if so, fragments \#n+1, .., \#n+i must
* be empty. When no more data is available, this function should be called
* with NULL as data and 0 as data_sz. The memory passed to this function
* must be available until the frame has been decoded.
* 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. If
* NULL, a AOM_CODEC_CB_PUT_FRAME event is posted
* for the previously decoded frame.
* \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.
@ -233,95 +209,12 @@ aom_codec_err_t aom_codec_decode(aom_codec_ctx_t *ctx, const uint8_t *data,
*/
aom_image_t *aom_codec_get_frame(aom_codec_ctx_t *ctx, aom_codec_iter_t *iter);
/*!\defgroup cap_put_frame Frame-Based Decoding Functions
*
* The following functions are required to be implemented for all decoders
* that advertise the AOM_CODEC_CAP_PUT_FRAME capability. Calling these
* functions
* for codecs that don't advertise this capability will result in an error
* code being returned, usually AOM_CODEC_ERROR
* @{
*/
/*!\brief put frame callback prototype
*
* This callback is invoked by the decoder to notify the application of
* the availability of decoded image data.
*/
typedef void (*aom_codec_put_frame_cb_fn_t)(void *user_priv,
const aom_image_t *img);
/*!\brief Register for notification of frame completion.
*
* Registers a given function to be called when a decoded frame is
* available.
*
* \param[in] ctx Pointer to this instance's context
* \param[in] cb Pointer to the callback function
* \param[in] user_priv User's private data
*
* \retval #AOM_CODEC_OK
* Callback successfully registered.
* \retval #AOM_CODEC_ERROR
* Decoder context not initialized, or algorithm not capable of
* posting slice completion.
*/
aom_codec_err_t aom_codec_register_put_frame_cb(aom_codec_ctx_t *ctx,
aom_codec_put_frame_cb_fn_t cb,
void *user_priv);
/*!@} - end defgroup cap_put_frame */
/*!\defgroup cap_put_slice Slice-Based Decoding Functions
*
* The following functions are required to be implemented for all decoders
* that advertise the AOM_CODEC_CAP_PUT_SLICE capability. Calling these
* functions
* for codecs that don't advertise this capability will result in an error
* code being returned, usually AOM_CODEC_ERROR
* @{
*/
/*!\brief put slice callback prototype
*
* This callback is invoked by the decoder to notify the application of
* the availability of partially decoded image data. The
*/
typedef void (*aom_codec_put_slice_cb_fn_t)(void *user_priv,
const aom_image_t *img,
const aom_image_rect_t *valid,
const aom_image_rect_t *update);
/*!\brief Register for notification of slice completion.
*
* Registers a given function to be called when a decoded slice is
* available.
*
* \param[in] ctx Pointer to this instance's context
* \param[in] cb Pointer to the callback function
* \param[in] user_priv User's private data
*
* \retval #AOM_CODEC_OK
* Callback successfully registered.
* \retval #AOM_CODEC_ERROR
* Decoder context not initialized, or algorithm not capable of
* posting slice completion.
*/
aom_codec_err_t aom_codec_register_put_slice_cb(aom_codec_ctx_t *ctx,
aom_codec_put_slice_cb_fn_t cb,
void *user_priv);
/*!@} - end defgroup cap_put_slice*/
/*!\defgroup cap_external_frame_buffer External Frame Buffer Functions
*
* The following section is required to be implemented for all decoders
* 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_ERROR.
*
* \note
* Currently this only works with AV1.
* will result in an error code being returned, usually AOM_CODEC_INCAPABLE.
* @{
*/
@ -343,13 +236,13 @@ aom_codec_err_t aom_codec_register_put_slice_cb(aom_codec_ctx_t *ctx,
* \retval #AOM_CODEC_INVALID_PARAM
* One or more of the callbacks were NULL.
* \retval #AOM_CODEC_ERROR
* Decoder context not initialized, or algorithm not capable of
* using external frame buffers.
* 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_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,

View file

@ -41,7 +41,7 @@ extern "C" {
* fields to structures
*/
#define AOM_ENCODER_ABI_VERSION \
(5 + AOM_CODEC_ABI_VERSION) /**<\hideinitializer*/
(8 + AOM_CODEC_ABI_VERSION) /**<\hideinitializer*/
/*! \brief Encoder capabilities bitfield
*
@ -74,17 +74,10 @@ extern "C" {
* This structure is able to hold a reference to any fixed size buffer.
*/
typedef struct aom_fixed_buf {
void *buf; /**< Pointer to the data */
void *buf; /**< Pointer to the data. Does NOT own the data! */
size_t sz; /**< Length of the buffer, in chars */
} aom_fixed_buf_t; /**< alias for struct aom_fixed_buf */
/*!\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 Compressed Frame Flags
*
* This type represents a bitfield containing information about a compressed
@ -97,10 +90,14 @@ typedef uint32_t aom_codec_frame_flags_t;
/*!\brief frame can be dropped without affecting the stream (no future frame
* depends on this one) */
#define AOM_FRAME_IS_DROPPABLE 0x2
/*!\brief frame should be decoded but will not be shown */
#define AOM_FRAME_IS_INVISIBLE 0x4
/*!\brief this is a fragment of the encoded frame */
#define AOM_FRAME_IS_FRAGMENT 0x8
/*!\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 Error Resilient flags
*
@ -205,6 +202,154 @@ enum aom_kf_mode {
AOM_KF_DISABLED = 0 /**< Encoder does not place keyframes. */
};
/*!\brief Encoder Config Options
*
* This type allows to enumerate and control flags defined for encoder control
* via config file at runtime.
*/
typedef struct cfg_options {
/*!\brief Indicate init by cfg file
* 0 or 1
*/
unsigned int init_by_cfg_file;
/*!\brief Superblock size
* 0, 64 or 128
*/
unsigned int super_block_size;
/*!\brief max partition size
* 8, 16, 32, 64, 128
*/
unsigned int max_partition_size;
/*!\brief min partition size
* 8, 16, 32, 64, 128
*/
unsigned int min_partition_size;
/*!\brief disable AB Shape partition type
*
*/
unsigned int disable_ab_partition_type;
/*!\brief disable rectangular partition type
*
*/
unsigned int disable_rect_partition_type;
/*!\brief disable 1:4/4:1 partition type
*
*/
unsigned int disable_1to4_partition_type;
/*!\brief disable flip and identity transform type
*
*/
unsigned int disable_flip_idtx;
/*!\brief disable CDEF filter
*
*/
unsigned int disable_cdef;
/*!\brief disable Loop Restoration Filter
*
*/
unsigned int disable_lr;
/*!\brief disable OBMC
*
*/
unsigned int disable_obmc;
/*!\brief disable Warped Motion
*
*/
unsigned int disable_warp_motion;
/*!\brief disable global motion
*
*/
unsigned int disable_global_motion;
/*!\brief disable dist weighted compound
*
*/
unsigned int disable_dist_wtd_comp;
/*!\brief disable diff weighted compound
*
*/
unsigned int disable_diff_wtd_comp;
/*!\brief disable inter/intra compound
*
*/
unsigned int disable_inter_intra_comp;
/*!\brief disable masked compound
*
*/
unsigned int disable_masked_comp;
/*!\brief disable one sided compound
*
*/
unsigned int disable_one_sided_comp;
/*!\brief disable Palette
*
*/
unsigned int disable_palette;
/*!\brief disable Intra Block Copy
*
*/
unsigned int disable_intrabc;
/*!\brief disable chroma from luma
*
*/
unsigned int disable_cfl;
/*!\brief disable intra smooth mode
*
*/
unsigned int disable_smooth_intra;
/*!\brief disable filter intra
*
*/
unsigned int disable_filter_intra;
/*!\brief disable dual filter
*
*/
unsigned int disable_dual_filter;
/*!\brief disable intra angle delta
*
*/
unsigned int disable_intra_angle_delta;
/*!\brief disable intra edge filter
*
*/
unsigned int disable_intra_edge_filter;
/*!\brief disable 64x64 transform
*
*/
unsigned int disable_tx_64x64;
/*!\brief disable smooth inter/intra
*
*/
unsigned int disable_smooth_inter_intra;
/*!\brief disable inter/inter wedge comp
*
*/
unsigned int disable_inter_inter_wedge;
/*!\brief disable inter/intra wedge comp
*
*/
unsigned int disable_inter_intra_wedge;
/*!\brief disable paeth intra
*
*/
unsigned int disable_paeth_intra;
/*!\brief disable trellis quantization
*
*/
unsigned int disable_trellis_quant;
/*!\brief disable ref frame MV
*
*/
unsigned int disable_ref_frame_mv;
/*!\brief use reduced reference frame set
*
*/
unsigned int reduced_reference_set;
/*!\brief use reduced transform type set
*
*/
unsigned int reduced_tx_type_set;
} cfg_options_t;
/*!\brief Encoded Frame Flags
*
* This type indicates a bitfield to be passed to aom_codec_encode(), defining
@ -402,8 +547,7 @@ typedef struct aom_codec_enc_cfg {
* upscaling after the encode/decode process. Taking control of upscaling and
* using restoration filters should allow it to outperform normal resizing.
*
* Mode 0 is SUPERRES_NONE, mode 1 is SUPERRES_FIXED, mode 2 is
* SUPERRES_RANDOM and mode 3 is SUPERRES_QTHRESH.
* Valid values are 0 to 4 as defined in enum SUPERRES_MODE.
*/
unsigned int rc_superres_mode;
@ -721,10 +865,46 @@ typedef struct aom_codec_enc_cfg {
*/
int tile_heights[MAX_TILE_HEIGHTS];
/*!\brief Whether encoder should use fixed QP offsets.
*
* If a value of 1 is provided, encoder will use fixed QP offsets for frames
* at different levels of the pyramid.
* - If 'fixed_qp_offsets' is also provided, encoder will use the given
* offsets
* - If not, encoder will select the fixed offsets based on the cq-level
* provided.
* If a value of 0 is provided and fixed_qp_offset are not provided, encoder
* will NOT use fixed QP offsets.
* Note: This option is only relevant for --end-usage=q.
*/
unsigned int use_fixed_qp_offsets;
/*!\brief Number of fixed QP offsets
*
* This defines the number of elements in the fixed_qp_offsets array.
*/
#define FIXED_QP_OFFSET_COUNT 5
/*!\brief Array of fixed QP offsets
*
* This array specifies fixed QP offsets (range: 0 to 63) for frames at
* different levels of the pyramid. It is a comma-separated list of 5 values:
* - QP offset for keyframe
* - QP offset for ALTREF frame
* - QP offset for 1st level internal ARF
* - QP offset for 2nd level internal ARF
* - QP offset for 3rd level internal ARF
* Notes:
* - QP offset for leaf level frames is not explicitly specified. These frames
* use the worst quality allowed (--cq-level).
* - This option is only relevant for --end-usage=q.
*/
int fixed_qp_offsets[FIXED_QP_OFFSET_COUNT];
/*!\brief Options defined per config file
*
*/
cfg_options_t cfg;
cfg_options_t encoder_cfg;
} aom_codec_enc_cfg_t; /**< alias for struct aom_codec_enc_cfg */
/*!\brief Initialize an encoder instance
@ -761,41 +941,9 @@ aom_codec_err_t aom_codec_enc_init_ver(aom_codec_ctx_t *ctx,
#define aom_codec_enc_init(ctx, iface, cfg, flags) \
aom_codec_enc_init_ver(ctx, iface, cfg, flags, AOM_ENCODER_ABI_VERSION)
/*!\brief Initialize multi-encoder instance
/*!\brief Get the default configuration for a usage.
*
* Initializes multi-encoder context using the given interface.
* Applications should call the aom_codec_enc_init_multi convenience macro
* instead of this function directly, to ensure that the ABI version number
* parameter is properly initialized.
*
* \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.
* \param[in] num_enc Total number of encoders.
* \param[in] flags Bitfield of AOM_CODEC_USE_* flags
* \param[in] dsf Pointer to down-sampling factors.
* \param[in] ver ABI version number. Must be set to
* AOM_ENCODER_ABI_VERSION
* \retval #AOM_CODEC_OK
* The decoder algorithm initialized.
* \retval #AOM_CODEC_MEM_ERROR
* Memory allocation failed.
*/
aom_codec_err_t aom_codec_enc_init_multi_ver(
aom_codec_ctx_t *ctx, aom_codec_iface_t *iface, aom_codec_enc_cfg_t *cfg,
int num_enc, aom_codec_flags_t flags, aom_rational_t *dsf, int ver);
/*!\brief Convenience macro for aom_codec_enc_init_multi_ver()
*
* Ensures the ABI version parameter is properly set.
*/
#define aom_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \
aom_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \
AOM_ENCODER_ABI_VERSION)
/*!\brief Get a default configuration
*
* Initializes a encoder configuration structure with default values. Supports
* Initializes an encoder configuration structure with default values. Supports
* the notion of "usages" so that an algorithm may offer different default
* settings depending on the user's intended goal. This function \ref SHOULD
* be called by all applications to initialize the configuration structure
@ -803,7 +951,9 @@ aom_codec_err_t aom_codec_enc_init_multi_ver(
*
* \param[in] iface Pointer to the algorithm interface to use.
* \param[out] cfg Configuration buffer to populate.
* \param[in] reserved Must set to 0.
* \param[in] usage Algorithm specific usage value. For AV1, must be
* set to AOM_USAGE_GOOD_QUALITY (0) or
* AOM_USAGE_REALTIME (1).
*
* \retval #AOM_CODEC_OK
* The configuration was populated.
@ -814,7 +964,7 @@ aom_codec_err_t aom_codec_enc_init_multi_ver(
*/
aom_codec_err_t aom_codec_enc_config_default(aom_codec_iface_t *iface,
aom_codec_enc_cfg_t *cfg,
unsigned int reserved);
unsigned int usage);
/*!\brief Set or change configuration
*
@ -858,6 +1008,11 @@ aom_codec_err_t aom_codec_enc_config_set(aom_codec_ctx_t *ctx,
*/
aom_fixed_buf_t *aom_codec_get_global_headers(aom_codec_ctx_t *ctx);
/*!\brief usage parameter analogous to AV1 GOOD QUALITY mode. */
#define AOM_USAGE_GOOD_QUALITY (0)
/*!\brief usage parameter analogous to AV1 REALTIME mode. */
#define AOM_USAGE_REALTIME (1)
/*!\brief Encode a frame
*
* Encodes a video frame at the given "presentation time." The presentation

View file

@ -53,9 +53,9 @@ typedef struct aom_codec_frame_buffer {
* 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 ximage 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.
* 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

View file

@ -30,11 +30,11 @@ extern "C" {
* types, removing or reassigning enums, adding/removing/rearranging
* fields to structures
*/
#define AOM_IMAGE_ABI_VERSION (4) /**<\hideinitializer*/
#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. */
#define AOM_IMG_FMT_HAS_ALPHA 0x400 /**< Image has an alpha channel. */
#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 */
@ -48,8 +48,8 @@ typedef enum aom_img_fmt {
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_444A = AOM_IMG_FMT_PLANAR | AOM_IMG_FMT_HAS_ALPHA | 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 */
@ -137,6 +137,36 @@ typedef enum aom_chroma_sample_position {
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 */
@ -169,9 +199,8 @@ typedef struct aom_image {
#define AOM_PLANE_Y 0 /**< Y (Luminance) plane */
#define AOM_PLANE_U 1 /**< U (Chroma) plane */
#define AOM_PLANE_V 2 /**< V (Chroma) plane */
#define AOM_PLANE_ALPHA 3 /**< A (Transparency) plane */
unsigned char *planes[4]; /**< pointer to the top left pixel for each plane */
int stride[4]; /**< stride between rows for each 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) */
@ -189,21 +218,16 @@ typedef struct aom_image {
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 Representation of a rectangle on a surface */
typedef struct aom_image_rect {
unsigned int x; /**< leftmost column */
unsigned int y; /**< topmost row */
unsigned int w; /**< width */
unsigned int h; /**< height */
} aom_image_rect_t; /**< alias for struct aom_image_rect */
/*!\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 descriptor is allocated on the heap.
* 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
@ -212,7 +236,7 @@ typedef struct aom_image_rect {
* \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).
* 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
@ -225,7 +249,7 @@ aom_image_t *aom_img_alloc(aom_image_t *img, aom_img_fmt_t fmt,
/*!\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 descriptor has been allocated elsewhere, and a descriptor is
* 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
@ -234,7 +258,8 @@ aom_image_t *aom_img_alloc(aom_image_t *img, aom_img_fmt_t fmt,
* \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.
* \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
@ -249,7 +274,7 @@ aom_image_t *aom_img_wrap(aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w,
* border
*
* Returns a descriptor for storing an image of the given format and its
* borders. The storage for the descriptor is allocated on the heap.
* 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
@ -258,8 +283,8 @@ aom_image_t *aom_img_wrap(aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w,
* \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 bytes, of the image width and height.
* 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
@ -324,6 +349,80 @@ int aom_img_plane_width(const aom_image_t *img, int plane);
*/
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
*/
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
*/
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

View file

@ -19,7 +19,6 @@
#define AOM_INLINE __inline
#else
#define AOM_FORCE_INLINE __inline__ __attribute__((always_inline))
// TODO(jbb): Allow a way to force inline off for older compilers.
#define AOM_INLINE inline
#endif
@ -72,8 +71,6 @@ typedef size_t uintptr_t;
#define INT32_MIN (-2147483647 - 1)
#endif
#define NELEMENTS(x) (int)(sizeof(x) / sizeof(x[0]))
#if defined(__cplusplus)
extern "C" {
#endif // __cplusplus

File diff suppressed because it is too large Load diff

View file

@ -45,6 +45,7 @@ typedef struct Accounting Accounting;
/** Callback that inspects decoder frame data.
*/
typedef void (*aom_inspect_cb)(void *decoder, void *ctx);
#endif
/*!\brief Structure to hold inspection callback and context.
@ -60,6 +61,21 @@ typedef struct aom_inspect_init {
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.
@ -90,146 +106,195 @@ typedef struct av1_ext_ref_frame {
* This set of macros define the control functions available for the AOM
* decoder interface.
*
* \sa #aom_codec_control
* \sa #aom_codec_control(aom_codec_ctx_t *ctx, int ctrl_id, ...)
*/
enum aom_dec_control_id {
/** control function to get info on which reference frames were updated
* by the last decode
/*!\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,
/** check if the indicated frame is corrupted */
/*!\brief Codec control function to check if the indicated frame is
corrupted, int* parameter
*/
AOMD_GET_FRAME_CORRUPTED,
/** control function to get info on which reference frames were used
* by the last decode
/*!\brief Codec control function to get info on which reference frames were
* used by the last decode, int* parameter
*/
AOMD_GET_LAST_REF_USED,
/** control function to get the dimensions that the current frame is decoded
* at. 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). */
/*!\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,
/** control function to get the current frame's intended display dimensions
* (as specified in the wrapper or frame header). This may be different to
* the decoded dimensions of this frame (see 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,
/** control function to get the bit depth of the stream. */
/*!\brief Codec control function to get the bit depth of the stream,
* unsigned int* parameter
*/
AV1D_GET_BIT_DEPTH,
/** control function to get the image format of the stream. */
/*!\brief Codec control function to get the image format of the stream,
* aom_img_fmt_t* parameter
*/
AV1D_GET_IMG_FORMAT,
/** control function to get the size of the tile. */
/*!\brief Codec control function to get the size of the tile, unsigned int
parameter */
AV1D_GET_TILE_SIZE,
/** control function to set the byte alignment of the planes in the reference
* buffers. Valid values are power of 2, from 32 to 1024. A value of 0 sets
/*!\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,
/** control function to invert the decoding order to from right to left. The
* function is used in a test to confirm the decoding independence of tile
/*!\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.
* 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,
/** control function to set the skip loop filter flag. 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.
/*!\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,
/** control function to retrieve a pointer to the Accounting struct. When
* compiled without --enable-accounting, this returns AOM_CODEC_INCAPABLE.
/*!\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,
/** control function to get last decoded frame quantizer. Returned value uses
* internal quantizer scale defined by the codec.
/*!\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,
/** control function to set the range of tile decoding. 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.
/*!\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,
/** control function to set the tile coding mode. A value that is equal to
* zero indicates the tiles are coded in normal tile mode. A value that is
* 1 indicates the tiles are coded in large-scale tile mode.
/*!\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,
/** control function to get the frame header information of an encoded frame
* in the bitstream. This provides a way to access a frame's header data.
/*!\brief Codec control function to get the frame header information of an
* encoded frame, unsigned int* parameter
*/
AV1D_GET_FRAME_HEADER_INFO,
/** control function to get the start address and size of a tile in the coded
* bitstream. This provides a way to access a specific tile's bitstream data.
/*!\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,
/** control function to set the external references' pointers in the decoder.
* This is used while decoding the tile list OBU in large-scale tile coding
* mode.
/*!\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,
/** control function to enable the ext-tile software debug and testing code in
* the decoder.
/*!\brief Codec control function to enable the ext-tile software debug and
* testing code in the decoder, unsigned int parameter
*/
AV1D_EXT_TILE_DEBUG,
/** control function to enable the row based multi-threading of decoding. A
* value that is equal to 1 indicates that row based multi-threading is
* enabled.
/*!\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,
/** control function to indicate whether bitstream is in Annex-B format. */
/*!\brief Codec control function to indicate whether bitstream is in
* Annex-B format, unsigned int parameter
*/
AV1D_SET_IS_ANNEXB,
/** control function to indicate which operating point to use. 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).
/*!\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,
/** control function to indicate whether to output one frame per temporal
* unit (the default), or one frame per spatial layer.
* 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.
/*!\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,
/** control function to set an aom_inspect_cb callback that is invoked each
* time a frame is decoded. When compiled without --enable-inspection, this
/*!\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,
/** control function to set the skip film grain flag. Valid values are
* integers. The decoder will skip the film grain when its value is set to
* nonzero. The default value is 0.
/*!\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,
@ -239,57 +304,87 @@ enum aom_dec_control_id {
/*!\cond */
/*!\brief AOM decoder control function parameter type
*
* Defines the data types that AOMD control functions take. Note that
* additional common controls are defined in aom.h
* 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(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 */

View file

@ -1,5 +1,5 @@
text aom_codec_build_config
text aom_codec_control_
text aom_codec_control
text aom_codec_destroy
text aom_codec_err_to_string
text aom_codec_error
@ -9,12 +9,21 @@ text aom_codec_iface_name
text aom_codec_version
text aom_codec_version_extra_str
text aom_codec_version_str
text aom_free
text aom_img_add_metadata
text aom_img_alloc
text aom_img_alloc_with_border
text aom_img_flip
text aom_img_free
text aom_img_get_metadata
text aom_img_metadata_array_free
text aom_img_metadata_array_alloc
text aom_img_metadata_free
text aom_img_metadata_alloc
text aom_img_num_metadata
text aom_img_plane_height
text aom_img_plane_width
text aom_img_remove_metadata
text aom_img_set_rect
text aom_img_wrap
text aom_malloc

View file

@ -3,8 +3,6 @@ text aom_codec_decode
text aom_codec_get_frame
text aom_codec_get_stream_info
text aom_codec_peek_stream_info
text aom_codec_register_put_frame_cb
text aom_codec_register_put_slice_cb
text aom_codec_set_frame_buffer_functions
text aom_obu_type_to_string
text aom_read_obu_header

View file

@ -1,6 +1,5 @@
text aom_codec_enc_config_default
text aom_codec_enc_config_set
text aom_codec_enc_init_multi_ver
text aom_codec_enc_init_ver
text aom_codec_encode
text aom_codec_get_cx_data

View file

@ -1,2 +1,4 @@
text aom_copy_metadata_to_frame_buffer
text aom_dsp_rtcd
text aom_remove_metadata_from_frame_buffer
text aom_scale_rtcd

View file

@ -59,10 +59,9 @@ extern "C" {
* types, removing or reassigning enums, adding/removing/rearranging
* fields to structures
*/
#define AOM_CODEC_INTERNAL_ABI_VERSION (5) /**<\hideinitializer*/
#define AOM_CODEC_INTERNAL_ABI_VERSION (7) /**<\hideinitializer*/
typedef struct aom_codec_alg_priv aom_codec_alg_priv_t;
typedef struct aom_codec_priv_enc_mr_cfg aom_codec_priv_enc_mr_cfg_t;
/*!\brief init function pointer prototype
*
@ -77,8 +76,7 @@ typedef struct aom_codec_priv_enc_mr_cfg aom_codec_priv_enc_mr_cfg_t;
* \retval #AOM_CODEC_MEM_ERROR
* Memory operation failed.
*/
typedef aom_codec_err_t (*aom_codec_init_fn_t)(
aom_codec_ctx_t *ctx, aom_codec_priv_enc_mr_cfg_t *data);
typedef aom_codec_err_t (*aom_codec_init_fn_t)(aom_codec_ctx_t *ctx);
/*!\brief destroy function pointer prototype
*
@ -138,7 +136,7 @@ typedef aom_codec_err_t (*aom_codec_get_si_fn_t)(aom_codec_alg_priv_t *ctx,
* function, so plugins implementing this interface may trust the input
* parameters to be properly initialized. However, this interface does not
* provide type safety for the exchanged data or assign meanings to the
* control codes. Those details should be specified in the algorithm's
* control IDs. Those details should be specified in the algorithm's
* header file. In particular, the ctrl_id parameter is guaranteed to exist
* in the algorithm's control mapping table, and the data parameter may be NULL.
*
@ -171,17 +169,12 @@ typedef const struct aom_codec_ctrl_fn_map {
/*!\brief decode data function pointer prototype
*
* Processes a buffer of coded data. If the processing results in a new
* decoded frame becoming available, #AOM_CODEC_CB_PUT_SLICE and
* #AOM_CODEC_CB_PUT_FRAME events are generated as appropriate. This
* function is called by the generic aom_codec_decode() wrapper function,
* so plugins implementing this interface may trust the input parameters
* to be properly initialized.
* Processes a buffer of coded data. This function is called by the generic
* aom_codec_decode() wrapper function, so plugins implementing this interface
* may trust the input parameters to be properly initialized.
*
* \param[in] ctx Pointer to this instance's context
* \param[in] data Pointer to this block of new coded data. If
* NULL, a #AOM_CODEC_CB_PUT_FRAME event is posted
* for the previously decoded frame.
* \param[in] data Pointer to this block of new coded data.
* \param[in] data_sz Size of the coded data, in bytes.
*
* \return Returns #AOM_CODEC_OK if the coded data was processed completely
@ -259,24 +252,6 @@ typedef aom_fixed_buf_t *(*aom_codec_get_global_headers_fn_t)(
typedef aom_image_t *(*aom_codec_get_preview_frame_fn_t)(
aom_codec_alg_priv_t *ctx);
typedef aom_codec_err_t (*aom_codec_enc_mr_get_mem_loc_fn_t)(
const aom_codec_enc_cfg_t *cfg, void **mem_loc);
/*!\brief usage configuration mapping
*
* This structure stores the mapping between usage identifiers and
* configuration structures. Each algorithm provides a list of these
* mappings. This list is searched by the aom_codec_enc_config_default()
* wrapper function to determine which config to return. The special value
* {-1, {0}} is used to indicate end-of-list, and must be present. At least
* one mapping must be present, in addition to the end-of-list.
*
*/
typedef const struct aom_codec_enc_cfg_map {
int usage;
aom_codec_enc_cfg_t cfg;
} aom_codec_enc_cfg_map_t;
/*!\brief Decoder algorithm interface interface
*
* All decoders \ref MUST expose a variable of this type.
@ -297,10 +272,9 @@ struct aom_codec_iface {
aom_codec_set_fb_fn_t set_fb_fn; /**< \copydoc ::aom_codec_set_fb_fn_t */
} dec;
struct aom_codec_enc_iface {
int cfg_map_count;
aom_codec_enc_cfg_map_t
*cfg_maps; /**< \copydoc ::aom_codec_enc_cfg_map_t */
aom_codec_encode_fn_t encode; /**< \copydoc ::aom_codec_encode_fn_t */
int cfg_count;
const aom_codec_enc_cfg_t *cfgs; /**< \copydoc ::aom_codec_enc_cfg_t */
aom_codec_encode_fn_t encode; /**< \copydoc ::aom_codec_encode_fn_t */
aom_codec_get_cx_data_fn_t
get_cx_data; /**< \copydoc ::aom_codec_get_cx_data_fn_t */
aom_codec_enc_config_set_fn_t
@ -309,20 +283,9 @@ struct aom_codec_iface {
get_glob_hdrs; /**< \copydoc ::aom_codec_get_global_headers_fn_t */
aom_codec_get_preview_frame_fn_t
get_preview; /**< \copydoc ::aom_codec_get_preview_frame_fn_t */
aom_codec_enc_mr_get_mem_loc_fn_t
mr_get_mem_loc; /**< \copydoc ::aom_codec_enc_mr_get_mem_loc_fn_t */
} enc;
};
/*!\brief Callback function pointer / user data pair storage */
typedef struct aom_codec_priv_cb_pair {
union {
aom_codec_put_frame_cb_fn_t put_frame;
aom_codec_put_slice_cb_fn_t put_slice;
} u;
void *user_priv;
} aom_codec_priv_cb_pair_t;
/*!\brief Instance private storage
*
* This structure is allocated by the algorithm's init function. It can be
@ -334,38 +297,15 @@ typedef struct aom_codec_priv_cb_pair {
struct aom_codec_priv {
const char *err_detail;
aom_codec_flags_t init_flags;
struct {
aom_codec_priv_cb_pair_t put_frame_cb;
aom_codec_priv_cb_pair_t put_slice_cb;
} dec;
struct {
aom_fixed_buf_t cx_data_dst_buf;
unsigned int cx_data_pad_before;
unsigned int cx_data_pad_after;
aom_codec_cx_pkt_t cx_data_pkt;
unsigned int total_encoders;
} enc;
};
/*
* Multi-resolution encoding internal configuration
*/
struct aom_codec_priv_enc_mr_cfg {
unsigned int mr_total_resolutions;
unsigned int mr_encoder_id;
struct aom_rational mr_down_sampling_factor;
void *mr_low_res_mode_info;
};
#undef AOM_CTRL_USE_TYPE
#define AOM_CTRL_USE_TYPE(id, typ) \
static AOM_INLINE typ id##__value(va_list args) { return va_arg(args, typ); }
#undef AOM_CTRL_USE_TYPE_DEPRECATED
#define AOM_CTRL_USE_TYPE_DEPRECATED(id, typ) \
static AOM_INLINE typ id##__value(va_list args) { return va_arg(args, typ); }
#define CAST(id, arg) id##__value(arg)
#define CAST(id, arg) va_arg((arg), aom_codec_control_type_##id)
/* CODEC_INTERFACE convenience macro
*

View file

@ -0,0 +1,93 @@
/*
* Copyright (c) 2019, 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 internal functions associated with the aom image
* descriptor.
*
*/
#ifndef AOM_AOM_INTERNAL_AOM_IMAGE_INTERNAL_H_
#define AOM_AOM_INTERNAL_AOM_IMAGE_INTERNAL_H_
#include "aom/aom_image.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!\brief Array of aom_metadata structs for an image. */
struct aom_metadata_array {
size_t sz; /* Number of metadata structs in the list */
aom_metadata_t **metadata_array; /* Array of metadata structs */
};
/*!\brief Alloc memory for aom_metadata_array struct.
*
* Allocate memory for aom_metadata_array struct.
* If sz is 0 the aom_metadata_array structs internal buffer list will be NULL,
* but the aom_metadata_array struct itself will still be allocated.
* Returns a pointer to the allocated struct or NULL on failure.
*
* \param[in] sz Size of internal metadata list buffer
*/
aom_metadata_array_t *aom_img_metadata_array_alloc(size_t sz);
/*!\brief Free metadata array struct.
*
* Free metadata array struct and all metadata structs inside.
*
* \param[in] arr Metadata array struct pointer
*/
void aom_img_metadata_array_free(aom_metadata_array_t *arr);
typedef void *(*aom_alloc_img_data_cb_fn_t)(void *priv, size_t size);
/*!\brief Open a descriptor, allocating storage for the underlying image by
* using the provided callback function.
*
* Returns a descriptor for storing an image of the given format. The storage
* for the image is allocated by using the provided callback function. Unlike
* aom_img_alloc(), the returned descriptor does not own the storage for the
* image. The caller is responsible for freeing the storage for the image.
*
* Note: If the callback function is invoked and succeeds,
* aom_img_alloc_with_cb() is guaranteed to succeed. Therefore, if
* aom_img_alloc_with_cb() fails, the caller is assured that no storage was
* allocated.
*
* \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] alloc_cb Callback function used to allocate storage for the
* image.
* \param[in] cb_priv The first argument ('priv') for the callback
* function.
*
* \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_cb(aom_image_t *img, aom_img_fmt_t fmt,
unsigned int d_w, unsigned int d_h,
unsigned int align,
aom_alloc_img_data_cb_fn_t alloc_cb,
void *cb_priv);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // AOM_AOM_INTERNAL_AOM_IMAGE_INTERNAL_H_

View file

@ -89,7 +89,7 @@ aom_codec_caps_t aom_codec_get_caps(aom_codec_iface_t *iface) {
return (iface) ? iface->caps : 0;
}
aom_codec_err_t aom_codec_control_(aom_codec_ctx_t *ctx, int ctrl_id, ...) {
aom_codec_err_t aom_codec_control(aom_codec_ctx_t *ctx, int ctrl_id, ...) {
aom_codec_err_t res;
if (!ctx || !ctrl_id)

View file

@ -34,12 +34,6 @@ aom_codec_err_t aom_codec_dec_init_ver(aom_codec_ctx_t *ctx,
res = AOM_CODEC_INVALID_PARAM;
else if (iface->abi_version != AOM_CODEC_INTERNAL_ABI_VERSION)
res = AOM_CODEC_ABI_MISMATCH;
else if ((flags & AOM_CODEC_USE_POSTPROC) &&
!(iface->caps & AOM_CODEC_CAP_POSTPROC))
res = AOM_CODEC_INCAPABLE;
else if ((flags & AOM_CODEC_USE_INPUT_FRAGMENTS) &&
!(iface->caps & AOM_CODEC_CAP_INPUT_FRAGMENTS))
res = AOM_CODEC_INCAPABLE;
else if (!(iface->caps & AOM_CODEC_CAP_DECODER))
res = AOM_CODEC_INCAPABLE;
else {
@ -50,7 +44,7 @@ aom_codec_err_t aom_codec_dec_init_ver(aom_codec_ctx_t *ctx,
ctx->init_flags = flags;
ctx->config.dec = cfg;
res = ctx->iface->init(ctx, NULL);
res = ctx->iface->init(ctx);
if (res) {
ctx->err_detail = ctx->priv ? ctx->priv->err_detail : NULL;
aom_codec_destroy(ctx);
@ -123,44 +117,6 @@ aom_image_t *aom_codec_get_frame(aom_codec_ctx_t *ctx, aom_codec_iter_t *iter) {
return img;
}
aom_codec_err_t aom_codec_register_put_frame_cb(aom_codec_ctx_t *ctx,
aom_codec_put_frame_cb_fn_t cb,
void *user_priv) {
aom_codec_err_t res;
if (!ctx || !cb)
res = AOM_CODEC_INVALID_PARAM;
else if (!ctx->iface || !ctx->priv ||
!(ctx->iface->caps & AOM_CODEC_CAP_PUT_FRAME))
res = AOM_CODEC_ERROR;
else {
ctx->priv->dec.put_frame_cb.u.put_frame = cb;
ctx->priv->dec.put_frame_cb.user_priv = user_priv;
res = AOM_CODEC_OK;
}
return SAVE_STATUS(ctx, res);
}
aom_codec_err_t aom_codec_register_put_slice_cb(aom_codec_ctx_t *ctx,
aom_codec_put_slice_cb_fn_t cb,
void *user_priv) {
aom_codec_err_t res;
if (!ctx || !cb)
res = AOM_CODEC_INVALID_PARAM;
else if (!ctx->iface || !ctx->priv ||
!(ctx->iface->caps & AOM_CODEC_CAP_PUT_SLICE))
res = AOM_CODEC_ERROR;
else {
ctx->priv->dec.put_slice_cb.u.put_slice = cb;
ctx->priv->dec.put_slice_cb.user_priv = user_priv;
res = AOM_CODEC_OK;
}
return SAVE_STATUS(ctx, res);
}
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) {
@ -168,9 +124,10 @@ aom_codec_err_t aom_codec_set_frame_buffer_functions(
if (!ctx || !cb_get || !cb_release) {
res = AOM_CODEC_INVALID_PARAM;
} else if (!ctx->iface || !ctx->priv ||
!(ctx->iface->caps & AOM_CODEC_CAP_EXTERNAL_FRAME_BUFFER)) {
} else if (!ctx->iface || !ctx->priv) {
res = AOM_CODEC_ERROR;
} else if (!(ctx->iface->caps & AOM_CODEC_CAP_EXTERNAL_FRAME_BUFFER)) {
res = AOM_CODEC_INCAPABLE;
} else {
res = ctx->iface->dec.set_fb_fn(get_alg_priv(ctx), cb_get, cb_release,
cb_priv);

View file

@ -24,6 +24,8 @@
#include <limits.h>
#include <string.h>
#include "aom/aom_encoder.h"
#include "aom/internal/aom_codec_internal.h"
#define SAVE_STATUS(ctx, var) (ctx ? (ctx->err = var) : var)
@ -54,7 +56,7 @@ aom_codec_err_t aom_codec_enc_init_ver(aom_codec_ctx_t *ctx,
ctx->priv = NULL;
ctx->init_flags = flags;
ctx->config.enc = cfg;
res = ctx->iface->init(ctx, NULL);
res = ctx->iface->init(ctx);
if (res) {
ctx->err_detail = ctx->priv ? ctx->priv->err_detail : NULL;
@ -65,113 +67,35 @@ aom_codec_err_t aom_codec_enc_init_ver(aom_codec_ctx_t *ctx,
return SAVE_STATUS(ctx, res);
}
aom_codec_err_t aom_codec_enc_init_multi_ver(
aom_codec_ctx_t *ctx, aom_codec_iface_t *iface, aom_codec_enc_cfg_t *cfg,
int num_enc, aom_codec_flags_t flags, aom_rational_t *dsf, int ver) {
aom_codec_err_t res = AOM_CODEC_OK;
if (ver != AOM_ENCODER_ABI_VERSION)
res = AOM_CODEC_ABI_MISMATCH;
else if (!ctx || !iface || !cfg || (num_enc > 16 || num_enc < 1))
res = AOM_CODEC_INVALID_PARAM;
else if (iface->abi_version != AOM_CODEC_INTERNAL_ABI_VERSION)
res = AOM_CODEC_ABI_MISMATCH;
else if (!(iface->caps & AOM_CODEC_CAP_ENCODER))
res = AOM_CODEC_INCAPABLE;
else if ((flags & AOM_CODEC_USE_PSNR) && !(iface->caps & AOM_CODEC_CAP_PSNR))
res = AOM_CODEC_INCAPABLE;
else {
int i;
void *mem_loc = NULL;
if (!(res = iface->enc.mr_get_mem_loc(cfg, &mem_loc))) {
for (i = 0; i < num_enc; i++) {
aom_codec_priv_enc_mr_cfg_t mr_cfg;
/* Validate down-sampling factor. */
if (dsf->num < 1 || dsf->num > 4096 || dsf->den < 1 ||
dsf->den > dsf->num) {
res = AOM_CODEC_INVALID_PARAM;
break;
}
mr_cfg.mr_low_res_mode_info = mem_loc;
mr_cfg.mr_total_resolutions = num_enc;
mr_cfg.mr_encoder_id = num_enc - 1 - i;
mr_cfg.mr_down_sampling_factor.num = dsf->num;
mr_cfg.mr_down_sampling_factor.den = dsf->den;
/* Force Key-frame synchronization. Namely, encoder at higher
* resolution always use the same frame_type chosen by the
* lowest-resolution encoder.
*/
if (mr_cfg.mr_encoder_id) cfg->kf_mode = AOM_KF_DISABLED;
ctx->iface = iface;
ctx->name = iface->name;
ctx->priv = NULL;
ctx->init_flags = flags;
ctx->config.enc = cfg;
res = ctx->iface->init(ctx, &mr_cfg);
if (res) {
const char *error_detail = ctx->priv ? ctx->priv->err_detail : NULL;
/* Destroy current ctx */
ctx->err_detail = error_detail;
aom_codec_destroy(ctx);
/* Destroy already allocated high-level ctx */
while (i) {
ctx--;
ctx->err_detail = error_detail;
aom_codec_destroy(ctx);
i--;
}
}
if (res) break;
ctx++;
cfg++;
dsf++;
}
ctx--;
}
}
return SAVE_STATUS(ctx, res);
}
aom_codec_err_t aom_codec_enc_config_default(aom_codec_iface_t *iface,
aom_codec_enc_cfg_t *cfg,
unsigned int usage) {
aom_codec_err_t res;
aom_codec_enc_cfg_map_t *map;
int i;
if (!iface || !cfg || usage > INT_MAX)
if (!iface || !cfg)
res = AOM_CODEC_INVALID_PARAM;
else if (!(iface->caps & AOM_CODEC_CAP_ENCODER))
res = AOM_CODEC_INCAPABLE;
else {
res = AOM_CODEC_INVALID_PARAM;
for (i = 0; i < iface->enc.cfg_map_count; ++i) {
map = iface->enc.cfg_maps + i;
if (map->usage == (int)usage) {
*cfg = map->cfg;
cfg->g_usage = usage;
for (i = 0; i < iface->enc.cfg_count; ++i) {
if (iface->enc.cfgs[i].g_usage == usage) {
*cfg = iface->enc.cfgs[i];
res = AOM_CODEC_OK;
break;
}
}
}
/* default values */
if (cfg) {
cfg->cfg.ext_partition = 1;
memset(&cfg->encoder_cfg, 0, sizeof(cfg->encoder_cfg));
cfg->encoder_cfg.super_block_size = 0; // Dynamic
cfg->encoder_cfg.max_partition_size = 128;
cfg->encoder_cfg.min_partition_size = 4;
cfg->encoder_cfg.disable_trellis_quant = 3;
}
return res;
}
@ -190,8 +114,11 @@ aom_codec_err_t aom_codec_enc_config_default(aom_codec_iface_t *iface,
#if HAVE_FEXCEPT && CONFIG_DEBUG
#define FLOATING_POINT_SET_EXCEPTIONS \
const int float_excepts = feenableexcept(FE_DIVBYZERO);
#define FLOATING_POINT_RESTORE_EXCEPTIONS feenableexcept(float_excepts);
const int float_excepts = \
feenableexcept(FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW);
#define FLOATING_POINT_RESTORE_EXCEPTIONS \
fedisableexcept(FE_ALL_EXCEPT); \
feenableexcept(float_excepts);
#else
#define FLOATING_POINT_SET_EXCEPTIONS
#define FLOATING_POINT_RESTORE_EXCEPTIONS
@ -221,38 +148,11 @@ aom_codec_err_t aom_codec_encode(aom_codec_ctx_t *ctx, const aom_image_t *img,
else if (!(ctx->iface->caps & AOM_CODEC_CAP_ENCODER))
res = AOM_CODEC_INCAPABLE;
else {
unsigned int num_enc = ctx->priv->enc.total_encoders;
/* Execute in a normalized floating point environment, if the platform
* requires it.
*/
FLOATING_POINT_INIT
if (num_enc == 1)
res =
ctx->iface->enc.encode(get_alg_priv(ctx), img, pts, duration, flags);
else {
/* Multi-resolution encoding:
* Encode multi-levels in reverse order. For example,
* if mr_total_resolutions = 3, first encode level 2,
* then encode level 1, and finally encode level 0.
*/
int i;
ctx += num_enc - 1;
if (img) img += num_enc - 1;
for (i = num_enc - 1; i >= 0; i--) {
if ((res = ctx->iface->enc.encode(get_alg_priv(ctx), img, pts, duration,
flags)))
break;
ctx--;
if (img) img--;
}
ctx++;
}
res = ctx->iface->enc.encode(get_alg_priv(ctx), img, pts, duration, flags);
FLOATING_POINT_RESTORE
}

View file

@ -14,6 +14,7 @@
#include "aom/aom_image.h"
#include "aom/aom_integer.h"
#include "aom/internal/aom_image_internal.h"
#include "aom_mem/aom_mem.h"
static INLINE unsigned int align_image_dimension(unsigned int d,
@ -29,8 +30,12 @@ static INLINE unsigned int align_image_dimension(unsigned int d,
static aom_image_t *img_alloc_helper(
aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w, unsigned int d_h,
unsigned int buf_align, unsigned int stride_align, unsigned int size_align,
unsigned char *img_data, unsigned int border) {
unsigned int h, w, s, xcs, ycs, bps;
unsigned int border, unsigned char *img_data,
aom_alloc_img_data_cb_fn_t alloc_cb, void *cb_priv) {
/* NOTE: In this function, bit_depth is either 8 or 16 (if
* AOM_IMG_FMT_HIGHBITDEPTH is set), never 10 or 12.
*/
unsigned int h, w, s, xcs, ycs, bps, bit_depth;
unsigned int stride_in_bytes;
/* Treat align==0 like align==1 */
@ -57,14 +62,17 @@ static aom_image_t *img_alloc_helper(
case AOM_IMG_FMT_YV12:
case AOM_IMG_FMT_AOMI420:
case AOM_IMG_FMT_AOMYV12: bps = 12; break;
case AOM_IMG_FMT_I422:
case AOM_IMG_FMT_I422: bps = 16; break;
case AOM_IMG_FMT_I444: bps = 24; break;
case AOM_IMG_FMT_YV1216:
case AOM_IMG_FMT_I42016: bps = 24; break;
case AOM_IMG_FMT_I42216:
case AOM_IMG_FMT_I42216: bps = 32; break;
case AOM_IMG_FMT_I44416: bps = 48; break;
default: bps = 16; break;
}
bit_depth = (fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 16 : 8;
/* Get chroma shift values for this format */
switch (fmt) {
case AOM_IMG_FMT_I420:
@ -73,6 +81,7 @@ static aom_image_t *img_alloc_helper(
case AOM_IMG_FMT_AOMYV12:
case AOM_IMG_FMT_I422:
case AOM_IMG_FMT_I42016:
case AOM_IMG_FMT_YV1216:
case AOM_IMG_FMT_I42216: xcs = 1; break;
default: xcs = 0; break;
}
@ -82,6 +91,7 @@ static aom_image_t *img_alloc_helper(
case AOM_IMG_FMT_YV12:
case AOM_IMG_FMT_AOMI420:
case AOM_IMG_FMT_AOMYV12:
case AOM_IMG_FMT_YV1216:
case AOM_IMG_FMT_I42016: ycs = 1; break;
default: ycs = 0; break;
}
@ -90,9 +100,9 @@ static aom_image_t *img_alloc_helper(
w = align_image_dimension(d_w, xcs, size_align);
h = align_image_dimension(d_h, ycs, size_align);
s = (fmt & AOM_IMG_FMT_PLANAR) ? w : bps * w / 8;
s = (fmt & AOM_IMG_FMT_PLANAR) ? w : bps * w / bit_depth;
s = (s + 2 * border + stride_align - 1) & ~(stride_align - 1);
stride_in_bytes = (fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? s * 2 : s;
stride_in_bytes = s * bit_depth / 8;
/* Allocate the new image */
if (!img) {
@ -110,19 +120,29 @@ static aom_image_t *img_alloc_helper(
if (!img_data) {
const uint64_t alloc_size =
(fmt & AOM_IMG_FMT_PLANAR)
? (uint64_t)(h + 2 * border) * stride_in_bytes * bps / 8
? (uint64_t)(h + 2 * border) * stride_in_bytes * bps / bit_depth
: (uint64_t)(h + 2 * border) * stride_in_bytes;
if (alloc_size != (size_t)alloc_size) goto fail;
img->img_data = (uint8_t *)aom_memalign(buf_align, (size_t)alloc_size);
img->img_data_owner = 1;
if (alloc_cb) {
const size_t padded_alloc_size = (size_t)alloc_size + buf_align - 1;
img->img_data = (uint8_t *)alloc_cb(cb_priv, padded_alloc_size);
if (img->img_data) {
img->img_data = (uint8_t *)aom_align_addr(img->img_data, buf_align);
}
img->img_data_owner = 0;
} else {
img->img_data = (uint8_t *)aom_memalign(buf_align, (size_t)alloc_size);
img->img_data_owner = 1;
}
img->sz = (size_t)alloc_size;
}
if (!img->img_data) goto fail;
img->fmt = fmt;
img->bit_depth = (fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 16 : 8;
img->bit_depth = bit_depth;
// aligned width and aligned height
img->w = w;
img->h = h;
@ -131,11 +151,13 @@ static aom_image_t *img_alloc_helper(
img->bps = bps;
/* Calculate strides */
img->stride[AOM_PLANE_Y] = img->stride[AOM_PLANE_ALPHA] = stride_in_bytes;
img->stride[AOM_PLANE_Y] = stride_in_bytes;
img->stride[AOM_PLANE_U] = img->stride[AOM_PLANE_V] = stride_in_bytes >> xcs;
/* Default viewport to entire image */
if (!aom_img_set_rect(img, 0, 0, d_w, d_h, border)) return img;
/* Default viewport to entire image. (This aom_img_set_rect call always
* succeeds.) */
aom_img_set_rect(img, 0, 0, d_w, d_h, border);
return img;
fail:
aom_img_free(img);
@ -145,15 +167,26 @@ fail:
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) {
return img_alloc_helper(img, fmt, d_w, d_h, align, align, 1, NULL, 0);
return img_alloc_helper(img, fmt, d_w, d_h, align, align, 1, 0, NULL, NULL,
NULL);
}
aom_image_t *aom_img_alloc_with_cb(aom_image_t *img, aom_img_fmt_t fmt,
unsigned int d_w, unsigned int d_h,
unsigned int align,
aom_alloc_img_data_cb_fn_t alloc_cb,
void *cb_priv) {
return img_alloc_helper(img, fmt, d_w, d_h, align, align, 1, 0, NULL,
alloc_cb, cb_priv);
}
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 stride_align,
unsigned char *img_data) {
/* By setting buf_align = 1, we don't change buffer alignment in this
* function. */
return img_alloc_helper(img, fmt, d_w, d_h, 1, stride_align, 1, img_data, 0);
/* Set buf_align = 1. It is ignored by img_alloc_helper because img_data is
* not NULL. */
return img_alloc_helper(img, fmt, d_w, d_h, 1, stride_align, 1, 0, img_data,
NULL, NULL);
}
aom_image_t *aom_img_alloc_with_border(aom_image_t *img, aom_img_fmt_t fmt,
@ -161,8 +194,8 @@ aom_image_t *aom_img_alloc_with_border(aom_image_t *img, aom_img_fmt_t fmt,
unsigned int align,
unsigned int size_align,
unsigned int border) {
return img_alloc_helper(img, fmt, d_w, d_h, align, align, size_align, NULL,
border);
return img_alloc_helper(img, fmt, d_w, d_h, align, align, size_align, border,
NULL, NULL, NULL);
}
int aom_img_set_rect(aom_image_t *img, unsigned int x, unsigned int y,
@ -185,12 +218,6 @@ int aom_img_set_rect(aom_image_t *img, unsigned int x, unsigned int y,
(img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) ? 2 : 1;
data = img->img_data;
if (img->fmt & AOM_IMG_FMT_HAS_ALPHA) {
img->planes[AOM_PLANE_ALPHA] =
data + x * bytes_per_sample + y * img->stride[AOM_PLANE_ALPHA];
data += (img->h + 2 * border) * img->stride[AOM_PLANE_ALPHA];
}
img->planes[AOM_PLANE_Y] =
data + x * bytes_per_sample + y * img->stride[AOM_PLANE_Y];
data += (img->h + 2 * border) * img->stride[AOM_PLANE_Y];
@ -236,14 +263,11 @@ void aom_img_flip(aom_image_t *img) {
img->planes[AOM_PLANE_V] += (signed)((img->d_h >> img->y_chroma_shift) - 1) *
img->stride[AOM_PLANE_V];
img->stride[AOM_PLANE_V] = -img->stride[AOM_PLANE_V];
img->planes[AOM_PLANE_ALPHA] +=
(signed)(img->d_h - 1) * img->stride[AOM_PLANE_ALPHA];
img->stride[AOM_PLANE_ALPHA] = -img->stride[AOM_PLANE_ALPHA];
}
void aom_img_free(aom_image_t *img) {
if (img) {
aom_img_remove_metadata(img);
if (img->img_data && img->img_data_owner) aom_free(img->img_data);
if (img->self_allocd) free(img);
@ -263,3 +287,109 @@ int aom_img_plane_height(const aom_image_t *img, int plane) {
else
return img->d_h;
}
aom_metadata_t *aom_img_metadata_alloc(
uint32_t type, const uint8_t *data, size_t sz,
aom_metadata_insert_flags_t insert_flag) {
if (!data || sz == 0) return NULL;
aom_metadata_t *metadata = (aom_metadata_t *)malloc(sizeof(aom_metadata_t));
if (!metadata) return NULL;
metadata->type = type;
metadata->payload = (uint8_t *)malloc(sz);
if (!metadata->payload) {
free(metadata);
return NULL;
}
memcpy(metadata->payload, data, sz);
metadata->sz = sz;
metadata->insert_flag = insert_flag;
return metadata;
}
void aom_img_metadata_free(aom_metadata_t *metadata) {
if (metadata) {
if (metadata->payload) free(metadata->payload);
free(metadata);
}
}
aom_metadata_array_t *aom_img_metadata_array_alloc(size_t sz) {
aom_metadata_array_t *arr =
(aom_metadata_array_t *)calloc(1, sizeof(aom_metadata_array_t));
if (!arr) return NULL;
if (sz > 0) {
arr->metadata_array =
(aom_metadata_t **)calloc(sz, sizeof(aom_metadata_t *));
if (!arr->metadata_array) {
aom_img_metadata_array_free(arr);
return NULL;
}
arr->sz = sz;
}
return arr;
}
void aom_img_metadata_array_free(aom_metadata_array_t *arr) {
if (arr) {
if (arr->metadata_array) {
for (size_t i = 0; i < arr->sz; i++) {
aom_img_metadata_free(arr->metadata_array[i]);
}
free(arr->metadata_array);
}
free(arr);
}
}
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) {
if (!img) return -1;
if (!img->metadata) {
img->metadata = aom_img_metadata_array_alloc(0);
if (!img->metadata) return -1;
}
aom_metadata_t *metadata =
aom_img_metadata_alloc(type, data, sz, insert_flag);
if (!metadata) goto fail;
if (!img->metadata->metadata_array) {
img->metadata->metadata_array =
(aom_metadata_t **)calloc(1, sizeof(metadata));
if (!img->metadata->metadata_array || img->metadata->sz != 0) {
aom_img_metadata_free(metadata);
goto fail;
}
} else {
img->metadata->metadata_array =
(aom_metadata_t **)realloc(img->metadata->metadata_array,
(img->metadata->sz + 1) * sizeof(metadata));
}
img->metadata->metadata_array[img->metadata->sz] = metadata;
img->metadata->sz++;
return 0;
fail:
aom_img_metadata_array_free(img->metadata);
img->metadata = NULL;
return -1;
}
void aom_img_remove_metadata(aom_image_t *img) {
if (img && img->metadata) {
aom_img_metadata_array_free(img->metadata);
img->metadata = NULL;
}
}
const aom_metadata_t *aom_img_get_metadata(const aom_image_t *img,
size_t index) {
if (!img) return NULL;
const aom_metadata_array_t *array = img->metadata;
if (array && index < array->sz) {
return array->metadata_array[index];
}
return NULL;
}
size_t aom_img_num_metadata(const aom_image_t *img) {
if (!img || !img->metadata) return 0;
return img->metadata->sz;
}

View file

@ -1,73 +0,0 @@
/*
* 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.
*/
#include <math.h>
#include <stdlib.h>
#include "config/aom_config.h"
#include "config/aom_dsp_rtcd.h"
#include "aom/aom_integer.h"
#include "aom_ports/mem.h"
void aom_plane_add_noise_c(uint8_t *start, char *noise, char blackclamp[16],
char whiteclamp[16], char bothclamp[16],
unsigned int width, unsigned int height, int pitch) {
unsigned int i, j;
for (i = 0; i < height; ++i) {
uint8_t *pos = start + i * pitch;
char *ref = (char *)(noise + (rand() & 0xff)); // NOLINT
for (j = 0; j < width; ++j) {
int v = pos[j];
v = clamp(v - blackclamp[0], 0, 255);
v = clamp(v + bothclamp[0], 0, 255);
v = clamp(v - whiteclamp[0], 0, 255);
pos[j] = v + ref[j];
}
}
}
static double gaussian(double sigma, double mu, double x) {
return 1 / (sigma * sqrt(2.0 * 3.14159265)) *
(exp(-(x - mu) * (x - mu) / (2 * sigma * sigma)));
}
int aom_setup_noise(double sigma, int size, char *noise) {
char char_dist[256];
int next = 0, i, j;
// set up a 256 entry lookup that matches gaussian distribution
for (i = -32; i < 32; ++i) {
const int a_i = (int)(0.5 + 256 * gaussian(sigma, 0, i));
if (a_i) {
for (j = 0; j < a_i; ++j) {
char_dist[next + j] = (char)i;
}
next = next + j;
}
}
// Rounding error - might mean we have less than 256.
for (; next < 256; ++next) {
char_dist[next] = 0;
}
for (i = 0; i < size; ++i) {
noise[i] = char_dist[rand() & 0xff]; // NOLINT
}
// Returns the highest non 0 value used in distribution.
return -char_dist[0];
}

View file

@ -74,7 +74,6 @@ static void convolve_vert(const uint8_t *src, ptrdiff_t src_stride,
static const InterpKernel *get_filter_base(const int16_t *filter) {
// NOTE: This assumes that the filter table is 256-byte aligned.
// TODO(agrange) Modify to make independent of table alignment.
return (const InterpKernel *)(((intptr_t)filter) & ~((intptr_t)0xFF));
}
@ -130,6 +129,7 @@ void aom_convolve_copy_c(const uint8_t *src, ptrdiff_t src_stride, uint8_t *dst,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE int highbd_vert_scalar_product(const uint16_t *a,
ptrdiff_t a_stride,
const int16_t *b) {
@ -236,3 +236,4 @@ void aom_highbd_convolve_copy_c(const uint8_t *src8, ptrdiff_t src_stride,
dst += dst_stride;
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -35,6 +35,7 @@ list(APPEND AOM_DSP_COMMON_SOURCES
"${AOM_ROOT}/aom_dsp/intrapred_common.h"
"${AOM_ROOT}/aom_dsp/loopfilter.c"
"${AOM_ROOT}/aom_dsp/prob.h"
"${AOM_ROOT}/aom_dsp/recenter.h"
"${AOM_ROOT}/aom_dsp/simd/v128_intrinsics.h"
"${AOM_ROOT}/aom_dsp/simd/v128_intrinsics_c.h"
"${AOM_ROOT}/aom_dsp/simd/v256_intrinsics.h"
@ -43,7 +44,8 @@ list(APPEND AOM_DSP_COMMON_SOURCES
"${AOM_ROOT}/aom_dsp/simd/v64_intrinsics_c.h"
"${AOM_ROOT}/aom_dsp/subtract.c"
"${AOM_ROOT}/aom_dsp/txfm_common.h"
"${AOM_ROOT}/aom_dsp/x86/convolve_common_intrin.h")
"${AOM_ROOT}/aom_dsp/x86/convolve_common_intrin.h"
"${AOM_ROOT}/aom_dsp/avg.c")
list(APPEND AOM_DSP_COMMON_ASM_SSE2
"${AOM_ROOT}/aom_dsp/x86/aom_convolve_copy_sse2.asm"
@ -51,24 +53,35 @@ list(APPEND AOM_DSP_COMMON_ASM_SSE2
"${AOM_ROOT}/aom_dsp/x86/aom_high_subpixel_bilinear_sse2.asm"
"${AOM_ROOT}/aom_dsp/x86/aom_subpixel_8t_sse2.asm"
"${AOM_ROOT}/aom_dsp/x86/aom_subpixel_bilinear_sse2.asm"
"${AOM_ROOT}/aom_dsp/x86/highbd_intrapred_sse2.asm"
"${AOM_ROOT}/aom_dsp/x86/intrapred_sse2.asm"
"${AOM_ROOT}/aom_dsp/x86/highbd_intrapred_asm_sse2.asm"
"${AOM_ROOT}/aom_dsp/x86/intrapred_asm_sse2.asm"
"${AOM_ROOT}/aom_dsp/x86/inv_wht_sse2.asm")
list(APPEND AOM_DSP_COMMON_INTRIN_SSE2
"${AOM_ROOT}/aom_dsp/x86/aom_subpixel_8t_intrin_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/aom_asm_stubs.c"
"${AOM_ROOT}/aom_dsp/x86/convolve.h"
"${AOM_ROOT}/aom_dsp/x86/convolve_sse2.h"
"${AOM_ROOT}/aom_dsp/x86/fft_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_convolve_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_intrapred_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_loopfilter_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/intrapred_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/intrapred_x86.h"
"${AOM_ROOT}/aom_dsp/x86/loopfilter_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/lpf_common_sse2.h"
"${AOM_ROOT}/aom_dsp/x86/mem_sse2.h"
"${AOM_ROOT}/aom_dsp/x86/transpose_sse2.h"
"${AOM_ROOT}/aom_dsp/x86/txfm_common_sse2.h"
"${AOM_ROOT}/aom_dsp/x86/sum_squares_sse2.h")
"${AOM_ROOT}/aom_dsp/x86/sum_squares_sse2.h"
"${AOM_ROOT}/aom_dsp/x86/avg_intrin_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/bitdepth_conversion_sse2.h")
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(REMOVE_ITEM AOM_DSP_COMMON_INTRIN_SSE2
"${AOM_ROOT}/aom_dsp/x86/highbd_convolve_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_loopfilter_sse2.c")
endif()
list(APPEND AOM_DSP_COMMON_ASM_SSSE3
"${AOM_ROOT}/aom_dsp/x86/aom_subpixel_8t_ssse3.asm"
@ -79,6 +92,11 @@ list(APPEND AOM_DSP_COMMON_INTRIN_SSSE3
"${AOM_ROOT}/aom_dsp/x86/highbd_convolve_ssse3.c"
"${AOM_ROOT}/aom_dsp/x86/intrapred_ssse3.c")
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(REMOVE_ITEM AOM_DSP_COMMON_INTRIN_SSSE3
"${AOM_ROOT}/aom_dsp/x86/highbd_convolve_ssse3.c")
endif()
list(APPEND AOM_DSP_COMMON_INTRIN_SSE4_1
"${AOM_ROOT}/aom_dsp/x86/blend_mask_sse4.h"
"${AOM_ROOT}/aom_dsp/x86/blend_a64_hmask_sse4.c"
@ -94,10 +112,17 @@ list(APPEND AOM_DSP_COMMON_INTRIN_AVX2
"${AOM_ROOT}/aom_dsp/x86/highbd_convolve_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_loopfilter_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/intrapred_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/blend_a64_mask_avx2.c")
"${AOM_ROOT}/aom_dsp/x86/blend_a64_mask_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/avg_intrin_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/bitdepth_conversion_avx2.h")
list(APPEND AOM_DSP_COMMON_INTRIN_NEON
"${AOM_ROOT}/aom_dsp/arm/fwd_txfm_neon.c"
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(REMOVE_ITEM AOM_DSP_COMMON_INTRIN_AVX2
"${AOM_ROOT}/aom_dsp/x86/highbd_convolve_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_loopfilter_avx2.c")
endif()
list(APPEND AOM_DSP_COMMON_INTRIN_NEON "${AOM_ROOT}/aom_dsp/arm/fwd_txfm_neon.c"
"${AOM_ROOT}/aom_dsp/arm/loopfilter_neon.c"
"${AOM_ROOT}/aom_dsp/arm/intrapred_neon.c"
"${AOM_ROOT}/aom_dsp/arm/subtract_neon.c"
@ -130,10 +155,9 @@ if(CONFIG_AV1_DECODER)
list(APPEND AOM_DSP_DECODER_SOURCES
"${AOM_ROOT}/aom_dsp/binary_codes_reader.c"
"${AOM_ROOT}/aom_dsp/binary_codes_reader.h"
"${AOM_ROOT}/aom_dsp/bitreader.h"
"${AOM_ROOT}/aom_dsp/daalaboolreader.c"
"${AOM_ROOT}/aom_dsp/daalaboolreader.h"
"${AOM_ROOT}/aom_dsp/entdec.c" "${AOM_ROOT}/aom_dsp/entdec.h"
"${AOM_ROOT}/aom_dsp/bitreader.c"
"${AOM_ROOT}/aom_dsp/bitreader.h" "${AOM_ROOT}/aom_dsp/entdec.c"
"${AOM_ROOT}/aom_dsp/entdec.h"
"${AOM_ROOT}/aom_dsp/grain_synthesis.c"
"${AOM_ROOT}/aom_dsp/grain_synthesis.h")
endif()
@ -142,9 +166,9 @@ if(CONFIG_AV1_ENCODER)
list(APPEND AOM_DSP_ENCODER_SOURCES
"${AOM_ROOT}/aom_dsp/binary_codes_writer.c"
"${AOM_ROOT}/aom_dsp/binary_codes_writer.h"
"${AOM_ROOT}/aom_dsp/bitwriter.c"
"${AOM_ROOT}/aom_dsp/bitwriter.h"
"${AOM_ROOT}/aom_dsp/daalaboolwriter.c"
"${AOM_ROOT}/aom_dsp/daalaboolwriter.h"
"${AOM_ROOT}/aom_dsp/blk_sse_sum.c"
"${AOM_ROOT}/aom_dsp/entenc.c"
"${AOM_ROOT}/aom_dsp/entenc.h"
"${AOM_ROOT}/aom_dsp/fwd_txfm.c"
@ -175,6 +199,9 @@ if(CONFIG_AV1_ENCODER)
"${AOM_ROOT}/aom_dsp/x86/subpel_variance_sse2.asm"
"${AOM_ROOT}/aom_dsp/x86/subtract_sse2.asm")
list(APPEND AOM_DSP_ENCODER_ASM_SSE2_X86_64
"${AOM_ROOT}/aom_dsp/x86/ssim_sse2_x86_64.asm")
list(APPEND AOM_DSP_ENCODER_INTRIN_SSE2
"${AOM_ROOT}/aom_dsp/x86/fwd_txfm_impl_sse2.h"
"${AOM_ROOT}/aom_dsp/x86/fwd_txfm_sse2.c"
@ -183,18 +210,30 @@ if(CONFIG_AV1_ENCODER)
"${AOM_ROOT}/aom_dsp/x86/highbd_subtract_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_variance_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/quantize_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/adaptive_quantize_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_adaptive_quantize_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/quantize_x86.h"
"${AOM_ROOT}/aom_dsp/x86/blk_sse_sum_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/sum_squares_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/variance_sse2.c")
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(REMOVE_ITEM AOM_DSP_ENCODER_INTRIN_SSE2
"${AOM_ROOT}/aom_dsp/x86/highbd_adaptive_quantize_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_quantize_intrin_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_subtract_sse2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_variance_sse2.c")
endif()
list(APPEND AOM_DSP_ENCODER_ASM_SSSE3_X86_64
"${AOM_ROOT}/aom_dsp/x86/fwd_txfm_ssse3_x86_64.asm"
"${AOM_ROOT}/aom_dsp/x86/ssim_opt_x86_64.asm")
"${AOM_ROOT}/aom_dsp/x86/quantize_ssse3_x86_64.asm")
list(APPEND AOM_DSP_ENCODER_INTRIN_AVX2
"${AOM_ROOT}/aom_dsp/x86/masked_sad_intrin_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/subtract_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_quantize_intrin_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/adaptive_quantize_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/highbd_adaptive_quantize_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/sad4d_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/sad_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/sad_highbd_avx2.c"
@ -205,19 +244,19 @@ if(CONFIG_AV1_ENCODER)
"${AOM_ROOT}/aom_dsp/x86/variance_impl_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/obmc_sad_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/obmc_variance_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/blk_sse_sum_avx2.c"
"${AOM_ROOT}/aom_dsp/x86/sum_squares_avx2.c")
list(APPEND AOM_DSP_ENCODER_ASM_SSSE3_X86_64
"${AOM_ROOT}/aom_dsp/x86/quantize_ssse3_x86_64.asm")
list(APPEND AOM_DSP_ENCODER_AVX_ASM_X86_64
"${AOM_ROOT}/aom_dsp/x86/quantize_avx_x86_64.asm")
list(APPEND AOM_DSP_ENCODER_INTRIN_SSSE3
"${AOM_ROOT}/aom_dsp/x86/masked_sad_intrin_ssse3.h"
"${AOM_ROOT}/aom_dsp/x86/masked_sad_intrin_ssse3.c"
"${AOM_ROOT}/aom_dsp/x86/masked_sad4d_ssse3.c"
"${AOM_ROOT}/aom_dsp/x86/masked_variance_intrin_ssse3.h"
"${AOM_ROOT}/aom_dsp/x86/masked_variance_intrin_ssse3.c"
"${AOM_ROOT}/aom_dsp/x86/quantize_ssse3.c"
"${AOM_ROOT}/aom_dsp/x86/variance_impl_ssse3.c"
"${AOM_ROOT}/aom_dsp/x86/jnt_variance_ssse3.c"
"${AOM_ROOT}/aom_dsp/x86/jnt_sad_ssse3.c")
@ -228,11 +267,18 @@ if(CONFIG_AV1_ENCODER)
"${AOM_ROOT}/aom_dsp/x86/obmc_sad_sse4.c"
"${AOM_ROOT}/aom_dsp/x86/obmc_variance_sse4.c")
list(APPEND AOM_DSP_ENCODER_INTRIN_NEON
"${AOM_ROOT}/aom_dsp/arm/sad4d_neon.c"
if(NOT CONFIG_AV1_HIGHBITDEPTH)
list(REMOVE_ITEM AOM_DSP_ENCODER_INTRIN_SSE4_1
"${AOM_ROOT}/aom_dsp/x86/highbd_variance_sse4.c")
endif()
list(APPEND AOM_DSP_ENCODER_INTRIN_NEON "${AOM_ROOT}/aom_dsp/arm/sad4d_neon.c"
"${AOM_ROOT}/aom_dsp/arm/sad_neon.c"
"${AOM_ROOT}/aom_dsp/arm/subpel_variance_neon.c"
"${AOM_ROOT}/aom_dsp/arm/variance_neon.c")
"${AOM_ROOT}/aom_dsp/arm/variance_neon.c"
"${AOM_ROOT}/aom_dsp/arm/hadamard_neon.c"
"${AOM_ROOT}/aom_dsp/arm/avg_neon.c"
"${AOM_ROOT}/aom_dsp/arm/sse_neon.c")
list(APPEND AOM_DSP_ENCODER_INTRIN_MSA "${AOM_ROOT}/aom_dsp/mips/sad_msa.c"
"${AOM_ROOT}/aom_dsp/mips/subtract_msa.c"
@ -244,6 +290,11 @@ if(CONFIG_AV1_ENCODER)
"${AOM_ROOT}/aom_dsp/psnrhvs.c" "${AOM_ROOT}/aom_dsp/ssim.c"
"${AOM_ROOT}/aom_dsp/ssim.h")
endif()
if(CONFIG_TUNE_VMAF)
list(APPEND AOM_DSP_ENCODER_SOURCES "${AOM_ROOT}/aom_dsp/vmaf.c"
"${AOM_ROOT}/aom_dsp/vmaf.h")
endif()
endif()
# Creates aom_dsp build targets. Must not be called until after libaom target
@ -254,6 +305,9 @@ function(setup_aom_dsp_targets)
create_dummy_source_file("aom_av1" "c" "dummy_source_file")
add_library(aom_dsp OBJECT "${dummy_source_file}")
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_dsp_common>)
if(BUILD_SHARED_LIBS)
target_sources(aom_static PRIVATE $<TARGET_OBJECTS:aom_dsp_common>)
endif()
list(APPEND AOM_LIB_TARGETS aom_dsp)
# Not all generators support libraries consisting only of object files. Add a
@ -264,92 +318,104 @@ function(setup_aom_dsp_targets)
add_library(aom_dsp_decoder OBJECT ${AOM_DSP_DECODER_SOURCES})
list(APPEND AOM_LIB_TARGETS aom_dsp_decoder)
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_dsp_decoder>)
if(BUILD_SHARED_LIBS)
target_sources(aom_static PRIVATE $<TARGET_OBJECTS:aom_dsp_decoder>)
endif()
endif()
if(CONFIG_AV1_ENCODER)
add_library(aom_dsp_encoder OBJECT ${AOM_DSP_ENCODER_SOURCES})
list(APPEND AOM_LIB_TARGETS aom_dsp_encoder)
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_dsp_encoder>)
if(BUILD_SHARED_LIBS)
target_sources(aom_static PRIVATE $<TARGET_OBJECTS:aom_dsp_encoder>)
endif()
endif()
if(HAVE_SSE2)
add_asm_library("aom_dsp_common_sse2" "AOM_DSP_COMMON_ASM_SSE2" "aom")
add_asm_library("aom_dsp_common_sse2" "AOM_DSP_COMMON_ASM_SSE2")
add_intrinsics_object_library("-msse2" "sse2" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_SSE2" "aom")
"AOM_DSP_COMMON_INTRIN_SSE2")
if(CONFIG_AV1_ENCODER)
add_asm_library("aom_dsp_encoder_sse2" "AOM_DSP_ENCODER_ASM_SSE2" "aom")
if("${AOM_TARGET_CPU}" STREQUAL "x86_64")
list(APPEND AOM_DSP_ENCODER_ASM_SSE2 ${AOM_DSP_ENCODER_ASM_SSE2_X86_64})
endif()
add_asm_library("aom_dsp_encoder_sse2" "AOM_DSP_ENCODER_ASM_SSE2")
add_intrinsics_object_library("-msse2" "sse2" "aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_SSE2" "aom")
"AOM_DSP_ENCODER_INTRIN_SSE2")
endif()
endif()
if(HAVE_SSSE3)
add_asm_library("aom_dsp_common_ssse3" "AOM_DSP_COMMON_ASM_SSSE3" "aom")
add_asm_library("aom_dsp_common_ssse3" "AOM_DSP_COMMON_ASM_SSSE3")
add_intrinsics_object_library("-mssse3" "ssse3" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_SSSE3" "aom")
"AOM_DSP_COMMON_INTRIN_SSSE3")
if(CONFIG_AV1_ENCODER)
if("${AOM_TARGET_CPU}" STREQUAL "x86_64")
list(APPEND AOM_DSP_ENCODER_ASM_SSSE3
${AOM_DSP_ENCODER_ASM_SSSE3_X86_64})
endif()
add_asm_library("aom_dsp_encoder_ssse3" "AOM_DSP_ENCODER_ASM_SSSE3" "aom")
add_asm_library("aom_dsp_encoder_ssse3" "AOM_DSP_ENCODER_ASM_SSSE3")
add_intrinsics_object_library("-mssse3" "ssse3" "aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_SSSE3" "aom")
"AOM_DSP_ENCODER_INTRIN_SSSE3")
endif()
endif()
if(HAVE_SSE4_1)
add_intrinsics_object_library("-msse4.1" "sse4_1" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_SSE4_1" "aom")
"AOM_DSP_COMMON_INTRIN_SSE4_1")
if(CONFIG_AV1_ENCODER)
add_intrinsics_object_library("-msse4.1" "sse4_1" "aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_SSE4_1" "aom")
"AOM_DSP_ENCODER_INTRIN_SSE4_1")
endif()
endif()
if(HAVE_AVX AND "${AOM_TARGET_CPU}" STREQUAL "x86_64")
if(CONFIG_AV1_ENCODER)
add_asm_library("aom_dsp_encoder_avx" "AOM_DSP_ENCODER_AVX_ASM_X86_64"
"aom")
add_asm_library("aom_dsp_encoder_avx" "AOM_DSP_ENCODER_AVX_ASM_X86_64")
endif()
endif()
if(HAVE_AVX2)
add_intrinsics_object_library("-mavx2" "avx2" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_AVX2" "aom")
"AOM_DSP_COMMON_INTRIN_AVX2")
if(CONFIG_AV1_ENCODER)
add_intrinsics_object_library("-mavx2" "avx2" "aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_AVX2" "aom")
"AOM_DSP_ENCODER_INTRIN_AVX2")
endif()
endif()
if(HAVE_NEON)
add_intrinsics_object_library("${AOM_NEON_INTRIN_FLAG}" "neon"
"aom_dsp_common" "AOM_DSP_COMMON_INTRIN_NEON"
"aom")
"aom_dsp_common" "AOM_DSP_COMMON_INTRIN_NEON")
if(CONFIG_AV1_ENCODER)
add_intrinsics_object_library("${AOM_NEON_INTRIN_FLAG}" "neon"
"aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_NEON" "aom")
"AOM_DSP_ENCODER_INTRIN_NEON")
endif()
endif()
if(HAVE_DSPR2)
add_intrinsics_object_library("" "dspr2" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_DSPR2" "aom")
"AOM_DSP_COMMON_INTRIN_DSPR2")
endif()
if(HAVE_MSA)
add_intrinsics_object_library("" "msa" "aom_dsp_common"
"AOM_DSP_COMMON_INTRIN_MSA" "aom")
"AOM_DSP_COMMON_INTRIN_MSA")
if(CONFIG_AV1_ENCODER)
add_intrinsics_object_library("" "msa" "aom_dsp_encoder"
"AOM_DSP_ENCODER_INTRIN_MSA" "aom")
"AOM_DSP_ENCODER_INTRIN_MSA")
endif()
endif()
target_sources(aom PRIVATE $<TARGET_OBJECTS:aom_dsp>)
if(BUILD_SHARED_LIBS)
target_sources(aom_static PRIVATE $<TARGET_OBJECTS:aom_dsp>)
endif()
# Pass the new lib targets up to the parent scope instance of
# $AOM_LIB_TARGETS.
set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} PARENT_SCOPE)

View file

@ -27,6 +27,9 @@ extern "C" {
#define AOMMIN(x, y) (((x) < (y)) ? (x) : (y))
#define AOMMAX(x, y) (((x) > (y)) ? (x) : (y))
#define AOMSIGN(x) ((x) < 0 ? -1 : 0)
#define NELEMENTS(x) (int)(sizeof(x) / sizeof(x[0]))
#define IMPLIES(a, b) (!(a) || (b)) // Logical 'a implies b' (or 'a -> b')

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,74 @@
/*
* Copyright (c) 2019, Alliance for Open Media. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <arm_neon.h>
#include "config/aom_dsp_rtcd.h"
#include "aom/aom_integer.h"
#include "aom_dsp/arm/sum_neon.h"
#include "av1/common/arm/mem_neon.h"
#include "av1/common/arm/transpose_neon.h"
unsigned int aom_avg_4x4_neon(const uint8_t *a, int a_stride) {
const uint8x16_t b = load_unaligned_u8q(a, a_stride);
const uint16x8_t c = vaddl_u8(vget_low_u8(b), vget_high_u8(b));
#if defined(__aarch64__)
const uint32_t d = vaddlvq_u16(c);
return (d + 8) >> 4;
#else
const uint32x2_t d = horizontal_add_u16x8(c);
return vget_lane_u32(vrshr_n_u32(d, 4), 0);
#endif
}
unsigned int aom_avg_8x8_neon(const uint8_t *a, int a_stride) {
uint16x8_t sum;
uint32x2_t d;
uint8x8_t b = vld1_u8(a);
a += a_stride;
uint8x8_t c = vld1_u8(a);
a += a_stride;
sum = vaddl_u8(b, c);
for (int i = 0; i < 6; ++i) {
const uint8x8_t e = vld1_u8(a);
a += a_stride;
sum = vaddw_u8(sum, e);
}
d = horizontal_add_u16x8(sum);
return vget_lane_u32(vrshr_n_u32(d, 6), 0);
}
int aom_satd_lp_neon(const int16_t *coeff, int length) {
const int16x4_t zero = vdup_n_s16(0);
int32x4_t accum = vdupq_n_s32(0);
do {
const int16x8_t src0 = vld1q_s16(coeff);
const int16x8_t src8 = vld1q_s16(coeff + 8);
accum = vabal_s16(accum, vget_low_s16(src0), zero);
accum = vabal_s16(accum, vget_high_s16(src0), zero);
accum = vabal_s16(accum, vget_low_s16(src8), zero);
accum = vabal_s16(accum, vget_high_s16(src8), zero);
length -= 16;
coeff += 16;
} while (length != 0);
{
// satd: 26 bits, dynamic range [-32640 * 1024, 32640 * 1024]
const int64x2_t s0 = vpaddlq_s32(accum); // cascading summation of 'accum'.
const int32x2_t s1 = vadd_s32(vreinterpret_s32_s64(vget_low_s64(s0)),
vreinterpret_s32_s64(vget_high_s64(s0)));
const int satd = vget_lane_s32(s1, 0);
return satd;
}
}

View file

@ -14,9 +14,103 @@
#include "config/aom_config.h"
#include "aom_dsp/txfm_common.h"
#include "av1/common/arm/mem_neon.h"
#include "av1/common/arm/transpose_neon.h"
static void aom_fdct4x4_helper(const int16_t *input, int stride,
int16x4_t *input_0, int16x4_t *input_1,
int16x4_t *input_2, int16x4_t *input_3) {
*input_0 = vshl_n_s16(vld1_s16(input + 0 * stride), 4);
*input_1 = vshl_n_s16(vld1_s16(input + 1 * stride), 4);
*input_2 = vshl_n_s16(vld1_s16(input + 2 * stride), 4);
*input_3 = vshl_n_s16(vld1_s16(input + 3 * stride), 4);
// If the very first value != 0, then add 1.
if (input[0] != 0) {
const int16x4_t one = vreinterpret_s16_s64(vdup_n_s64(1));
*input_0 = vadd_s16(*input_0, one);
}
for (int i = 0; i < 2; ++i) {
const int16x8_t input_01 = vcombine_s16(*input_0, *input_1);
const int16x8_t input_32 = vcombine_s16(*input_3, *input_2);
// in_0 +/- in_3, in_1 +/- in_2
const int16x8_t s_01 = vaddq_s16(input_01, input_32);
const int16x8_t s_32 = vsubq_s16(input_01, input_32);
// step_0 +/- step_1, step_2 +/- step_3
const int16x4_t s_0 = vget_low_s16(s_01);
const int16x4_t s_1 = vget_high_s16(s_01);
const int16x4_t s_2 = vget_high_s16(s_32);
const int16x4_t s_3 = vget_low_s16(s_32);
// (s_0 +/- s_1) * cospi_16_64
// Must expand all elements to s32. See 'needs32' comment in fwd_txfm.c.
const int32x4_t s_0_p_s_1 = vaddl_s16(s_0, s_1);
const int32x4_t s_0_m_s_1 = vsubl_s16(s_0, s_1);
const int32x4_t temp1 = vmulq_n_s32(s_0_p_s_1, cospi_16_64);
const int32x4_t temp2 = vmulq_n_s32(s_0_m_s_1, cospi_16_64);
// fdct_round_shift
int16x4_t out_0 = vrshrn_n_s32(temp1, DCT_CONST_BITS);
int16x4_t out_2 = vrshrn_n_s32(temp2, DCT_CONST_BITS);
// s_3 * cospi_8_64 + s_2 * cospi_24_64
// s_3 * cospi_24_64 - s_2 * cospi_8_64
const int32x4_t s_3_cospi_8_64 = vmull_n_s16(s_3, cospi_8_64);
const int32x4_t s_3_cospi_24_64 = vmull_n_s16(s_3, cospi_24_64);
const int32x4_t temp3 = vmlal_n_s16(s_3_cospi_8_64, s_2, cospi_24_64);
const int32x4_t temp4 = vmlsl_n_s16(s_3_cospi_24_64, s_2, cospi_8_64);
// fdct_round_shift
int16x4_t out_1 = vrshrn_n_s32(temp3, DCT_CONST_BITS);
int16x4_t out_3 = vrshrn_n_s32(temp4, DCT_CONST_BITS);
transpose_s16_4x4d(&out_0, &out_1, &out_2, &out_3);
*input_0 = out_0;
*input_1 = out_1;
*input_2 = out_2;
*input_3 = out_3;
}
}
void aom_fdct4x4_neon(const int16_t *input, tran_low_t *final_output,
int stride) {
// input[M * stride] * 16
int16x4_t input_0, input_1, input_2, input_3;
aom_fdct4x4_helper(input, stride, &input_0, &input_1, &input_2, &input_3);
// Not quite a rounding shift. Only add 1 despite shifting by 2.
const int16x8_t one = vdupq_n_s16(1);
int16x8_t out_01 = vcombine_s16(input_0, input_1);
int16x8_t out_23 = vcombine_s16(input_2, input_3);
out_01 = vshrq_n_s16(vaddq_s16(out_01, one), 2);
out_23 = vshrq_n_s16(vaddq_s16(out_23, one), 2);
store_s16q_to_tran_low(final_output + 0 * 8, out_01);
store_s16q_to_tran_low(final_output + 1 * 8, out_23);
}
void aom_fdct4x4_lp_neon(const int16_t *input, int16_t *final_output,
int stride) {
// input[M * stride] * 16
int16x4_t input_0, input_1, input_2, input_3;
aom_fdct4x4_helper(input, stride, &input_0, &input_1, &input_2, &input_3);
// Not quite a rounding shift. Only add 1 despite shifting by 2.
const int16x8_t one = vdupq_n_s16(1);
int16x8_t out_01 = vcombine_s16(input_0, input_1);
int16x8_t out_23 = vcombine_s16(input_2, input_3);
out_01 = vshrq_n_s16(vaddq_s16(out_01, one), 2);
out_23 = vshrq_n_s16(vaddq_s16(out_23, one), 2);
vst1q_s16(final_output + 0 * 8, out_01);
vst1q_s16(final_output + 1 * 8, out_23);
}
void aom_fdct8x8_neon(const int16_t *input, int16_t *final_output, int stride) {
int i;
// stage 1
int16x8_t input_0 = vshlq_n_s16(vld1q_s16(&input[0 * stride]), 2);
int16x8_t input_1 = vshlq_n_s16(vld1q_s16(&input[1 * stride]), 2);
@ -26,7 +120,7 @@ void aom_fdct8x8_neon(const int16_t *input, int16_t *final_output, int stride) {
int16x8_t input_5 = vshlq_n_s16(vld1q_s16(&input[5 * stride]), 2);
int16x8_t input_6 = vshlq_n_s16(vld1q_s16(&input[6 * stride]), 2);
int16x8_t input_7 = vshlq_n_s16(vld1q_s16(&input[7 * stride]), 2);
for (i = 0; i < 2; ++i) {
for (int i = 0; i < 2; ++i) {
int16x8_t out_0, out_1, out_2, out_3, out_4, out_5, out_6, out_7;
const int16x8_t v_s0 = vaddq_s16(input_0, input_7);
const int16x8_t v_s1 = vaddq_s16(input_1, input_6);

View file

@ -0,0 +1,183 @@
/*
* Copyright (c) 2019, Alliance for Open Media. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <arm_neon.h>
#include "config/aom_dsp_rtcd.h"
#include "aom/aom_integer.h"
#include "av1/common/arm/mem_neon.h"
#include "av1/common/arm/transpose_neon.h"
static void hadamard8x8_one_pass(int16x8_t *a0, int16x8_t *a1, int16x8_t *a2,
int16x8_t *a3, int16x8_t *a4, int16x8_t *a5,
int16x8_t *a6, int16x8_t *a7) {
const int16x8_t b0 = vaddq_s16(*a0, *a1);
const int16x8_t b1 = vsubq_s16(*a0, *a1);
const int16x8_t b2 = vaddq_s16(*a2, *a3);
const int16x8_t b3 = vsubq_s16(*a2, *a3);
const int16x8_t b4 = vaddq_s16(*a4, *a5);
const int16x8_t b5 = vsubq_s16(*a4, *a5);
const int16x8_t b6 = vaddq_s16(*a6, *a7);
const int16x8_t b7 = vsubq_s16(*a6, *a7);
const int16x8_t c0 = vaddq_s16(b0, b2);
const int16x8_t c1 = vaddq_s16(b1, b3);
const int16x8_t c2 = vsubq_s16(b0, b2);
const int16x8_t c3 = vsubq_s16(b1, b3);
const int16x8_t c4 = vaddq_s16(b4, b6);
const int16x8_t c5 = vaddq_s16(b5, b7);
const int16x8_t c6 = vsubq_s16(b4, b6);
const int16x8_t c7 = vsubq_s16(b5, b7);
*a0 = vaddq_s16(c0, c4);
*a1 = vsubq_s16(c2, c6);
*a2 = vsubq_s16(c0, c4);
*a3 = vaddq_s16(c2, c6);
*a4 = vaddq_s16(c3, c7);
*a5 = vsubq_s16(c3, c7);
*a6 = vsubq_s16(c1, c5);
*a7 = vaddq_s16(c1, c5);
}
void aom_hadamard_8x8_neon(const int16_t *src_diff, ptrdiff_t src_stride,
tran_low_t *coeff) {
int16x8_t a0 = vld1q_s16(src_diff);
int16x8_t a1 = vld1q_s16(src_diff + src_stride);
int16x8_t a2 = vld1q_s16(src_diff + 2 * src_stride);
int16x8_t a3 = vld1q_s16(src_diff + 3 * src_stride);
int16x8_t a4 = vld1q_s16(src_diff + 4 * src_stride);
int16x8_t a5 = vld1q_s16(src_diff + 5 * src_stride);
int16x8_t a6 = vld1q_s16(src_diff + 6 * src_stride);
int16x8_t a7 = vld1q_s16(src_diff + 7 * src_stride);
hadamard8x8_one_pass(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
transpose_s16_8x8(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
hadamard8x8_one_pass(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
// Skip the second transpose because it is not required.
store_s16q_to_tran_low(coeff + 0, a0);
store_s16q_to_tran_low(coeff + 8, a1);
store_s16q_to_tran_low(coeff + 16, a2);
store_s16q_to_tran_low(coeff + 24, a3);
store_s16q_to_tran_low(coeff + 32, a4);
store_s16q_to_tran_low(coeff + 40, a5);
store_s16q_to_tran_low(coeff + 48, a6);
store_s16q_to_tran_low(coeff + 56, a7);
}
void aom_hadamard_lp_8x8_neon(const int16_t *src_diff, ptrdiff_t src_stride,
int16_t *coeff) {
int16x8_t a0 = vld1q_s16(src_diff);
int16x8_t a1 = vld1q_s16(src_diff + src_stride);
int16x8_t a2 = vld1q_s16(src_diff + 2 * src_stride);
int16x8_t a3 = vld1q_s16(src_diff + 3 * src_stride);
int16x8_t a4 = vld1q_s16(src_diff + 4 * src_stride);
int16x8_t a5 = vld1q_s16(src_diff + 5 * src_stride);
int16x8_t a6 = vld1q_s16(src_diff + 6 * src_stride);
int16x8_t a7 = vld1q_s16(src_diff + 7 * src_stride);
hadamard8x8_one_pass(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
transpose_s16_8x8(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
hadamard8x8_one_pass(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7);
// Skip the second transpose because it is not required.
vst1q_s16(coeff + 0, a0);
vst1q_s16(coeff + 8, a1);
vst1q_s16(coeff + 16, a2);
vst1q_s16(coeff + 24, a3);
vst1q_s16(coeff + 32, a4);
vst1q_s16(coeff + 40, a5);
vst1q_s16(coeff + 48, a6);
vst1q_s16(coeff + 56, a7);
}
void aom_hadamard_lp_16x16_neon(const int16_t *src_diff, ptrdiff_t src_stride,
int16_t *coeff) {
/* Rearrange 16x16 to 8x32 and remove stride.
* Top left first. */
aom_hadamard_lp_8x8_neon(src_diff + 0 + 0 * src_stride, src_stride,
coeff + 0);
/* Top right. */
aom_hadamard_lp_8x8_neon(src_diff + 8 + 0 * src_stride, src_stride,
coeff + 64);
/* Bottom left. */
aom_hadamard_lp_8x8_neon(src_diff + 0 + 8 * src_stride, src_stride,
coeff + 128);
/* Bottom right. */
aom_hadamard_lp_8x8_neon(src_diff + 8 + 8 * src_stride, src_stride,
coeff + 192);
for (int i = 0; i < 64; i += 8) {
const int16x8_t a0 = vld1q_s16(coeff + 0);
const int16x8_t a1 = vld1q_s16(coeff + 64);
const int16x8_t a2 = vld1q_s16(coeff + 128);
const int16x8_t a3 = vld1q_s16(coeff + 192);
const int16x8_t b0 = vhaddq_s16(a0, a1);
const int16x8_t b1 = vhsubq_s16(a0, a1);
const int16x8_t b2 = vhaddq_s16(a2, a3);
const int16x8_t b3 = vhsubq_s16(a2, a3);
const int16x8_t c0 = vaddq_s16(b0, b2);
const int16x8_t c1 = vaddq_s16(b1, b3);
const int16x8_t c2 = vsubq_s16(b0, b2);
const int16x8_t c3 = vsubq_s16(b1, b3);
vst1q_s16(coeff + 0, c0);
vst1q_s16(coeff + 64, c1);
vst1q_s16(coeff + 128, c2);
vst1q_s16(coeff + 192, c3);
coeff += 8;
}
}
void aom_hadamard_16x16_neon(const int16_t *src_diff, ptrdiff_t src_stride,
tran_low_t *coeff) {
/* Rearrange 16x16 to 8x32 and remove stride.
* Top left first. */
aom_hadamard_8x8_neon(src_diff + 0 + 0 * src_stride, src_stride, coeff + 0);
/* Top right. */
aom_hadamard_8x8_neon(src_diff + 8 + 0 * src_stride, src_stride, coeff + 64);
/* Bottom left. */
aom_hadamard_8x8_neon(src_diff + 0 + 8 * src_stride, src_stride, coeff + 128);
/* Bottom right. */
aom_hadamard_8x8_neon(src_diff + 8 + 8 * src_stride, src_stride, coeff + 192);
for (int i = 0; i < 64; i += 8) {
const int16x8_t a0 = load_tran_low_to_s16q(coeff + 0);
const int16x8_t a1 = load_tran_low_to_s16q(coeff + 64);
const int16x8_t a2 = load_tran_low_to_s16q(coeff + 128);
const int16x8_t a3 = load_tran_low_to_s16q(coeff + 192);
const int16x8_t b0 = vhaddq_s16(a0, a1);
const int16x8_t b1 = vhsubq_s16(a0, a1);
const int16x8_t b2 = vhaddq_s16(a2, a3);
const int16x8_t b3 = vhsubq_s16(a2, a3);
const int16x8_t c0 = vaddq_s16(b0, b2);
const int16x8_t c1 = vaddq_s16(b1, b3);
const int16x8_t c2 = vsubq_s16(b0, b2);
const int16x8_t c3 = vsubq_s16(b1, b3);
store_s16q_to_tran_low(coeff + 0, c0);
store_s16q_to_tran_low(coeff + 64, c1);
store_s16q_to_tran_low(coeff + 128, c2);
store_s16q_to_tran_low(coeff + 192, c3);
coeff += 8;
}
}

View file

@ -785,16 +785,15 @@ void aom_lpf_vertical_4_neon(uint8_t *src, int stride, const uint8_t *blimit,
const uint8_t *limit, const uint8_t *thresh) {
uint32x2x2_t p1q0_p0q1, p1q1_p0q0, p1p0_q1q0;
uint32x2_t pq_rev;
uint8x8_t UNINITIALIZED_IS_SAFE(p1p0), q0q1, p0q0, p1q1;
uint8x8_t UNINITIALIZED_IS_SAFE(p1p0), UNINITIALIZED_IS_SAFE(q0q1);
uint8x8_t p0q0, p1q1;
// row0: p1 p0 | q0 q1
// row1: p1 p0 | q0 q1
// row2: p1 p0 | q0 q1
// row3: p1 p0 | q0 q1
load_u8_4x1(src - 2, &p1p0, 0);
load_u8_4x1((src - 2) + 1 * stride, &p1p0, 1);
load_u8_4x1((src - 2) + 2 * stride, &q0q1, 0);
load_u8_4x1((src - 2) + 3 * stride, &q0q1, 1);
load_unaligned_u8_4x4(src - 2, stride, (uint32x2_t *)&p1p0,
(uint32x2_t *)&q0q1);
transpose_u8_4x4(&p1p0, &q0q1);
@ -815,10 +814,10 @@ void aom_lpf_vertical_4_neon(uint8_t *src, int stride, const uint8_t *blimit,
transpose_u8_4x4(&p1p0, &q0q1);
store_u8_4x1(src - 2, p1p0, 0);
store_u8_4x1((src - 2) + 1 * stride, q0q1, 0);
store_u8_4x1((src - 2) + 2 * stride, p1p0, 1);
store_u8_4x1((src - 2) + 3 * stride, q0q1, 1);
store_unaligned_u8_4x1(src - 2, p1p0, 0);
store_unaligned_u8_4x1((src - 2) + 1 * stride, q0q1, 0);
store_unaligned_u8_4x1((src - 2) + 2 * stride, p1p0, 1);
store_unaligned_u8_4x1((src - 2) + 3 * stride, q0q1, 1);
}
void aom_lpf_horizontal_14_neon(uint8_t *src, int stride, const uint8_t *blimit,

View file

@ -0,0 +1,487 @@
/*
* Copyright (c) 2020, Alliance for Open Media. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <arm_neon.h>
#include "config/aom_config.h"
#include "config/aom_dsp_rtcd.h"
#include "aom/aom_integer.h"
static INLINE uint32_t sse_W16x1_neon(uint8x16_t q2, uint8x16_t q3) {
const uint16_t sse1 = 0;
const uint16x8_t q1 = vld1q_dup_u16(&sse1);
uint32_t sse;
uint8x16_t q4 = vabdq_u8(q2, q3); // diff = abs(a[x] - b[x])
uint8x8_t d0 = vget_low_u8(q4);
uint8x8_t d1 = vget_high_u8(q4);
uint16x8_t q6 = vmlal_u8(q1, d0, d0);
uint16x8_t q7 = vmlal_u8(q1, d1, d1);
uint32x4_t q8 = vaddl_u16(vget_low_u16(q6), vget_high_u16(q6));
uint32x4_t q9 = vaddl_u16(vget_low_u16(q7), vget_high_u16(q7));
uint32x2_t d4 = vadd_u32(vget_low_u32(q8), vget_high_u32(q8));
uint32x2_t d5 = vadd_u32(vget_low_u32(q9), vget_high_u32(q9));
uint32x2_t d6 = vadd_u32(d4, d5);
sse = vget_lane_u32(d6, 0);
sse += vget_lane_u32(d6, 1);
return sse;
}
int64_t aom_sse_neon(const uint8_t *a, int a_stride, const uint8_t *b,
int b_stride, int width, int height) {
const uint8x16_t q0 = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
};
int addinc, x, y;
uint8x8_t d0, d1, d2, d3;
uint8_t dx;
uint8x16_t q2, q3, q4, q5;
uint32_t sse = 0;
uint8x8x2_t tmp, tmp2;
switch (width) {
case 4:
for (y = 0; y < height; y += 4) {
d0 = vld1_u8(a); // load 4 data
a += a_stride;
d1 = vld1_u8(a);
a += a_stride;
d2 = vld1_u8(a);
a += a_stride;
d3 = vld1_u8(a);
a += a_stride;
tmp = vzip_u8(d0, d1);
tmp2 = vzip_u8(d2, d3);
q2 = vcombine_u8(tmp.val[0], tmp2.val[0]); // make a 16 data vector
d0 = vld1_u8(b);
b += b_stride;
d1 = vld1_u8(b);
b += b_stride;
d2 = vld1_u8(b);
b += b_stride;
d3 = vld1_u8(b);
b += b_stride;
tmp = vzip_u8(d0, d1);
tmp2 = vzip_u8(d2, d3);
q3 = vcombine_u8(tmp.val[0], tmp2.val[0]);
sse += sse_W16x1_neon(q2, q3);
}
break;
case 8:
for (y = 0; y < height; y += 2) {
d0 = vld1_u8(a); // load 8 data
d1 = vld1_u8(a + a_stride);
q2 = vcombine_u8(d0, d1); // make a 16 data vector
d0 = vld1_u8(b);
d1 = vld1_u8(b + b_stride);
q3 = vcombine_u8(d0, d1);
sse += sse_W16x1_neon(q2, q3);
a += 2 * a_stride;
b += 2 * b_stride;
}
break;
case 16:
for (y = 0; y < height; y++) {
q2 = vld1q_u8(a);
q3 = vld1q_u8(b);
sse += sse_W16x1_neon(q2, q3);
a += a_stride;
b += b_stride;
}
break;
case 32:
for (y = 0; y < height; y++) {
q2 = vld1q_u8(a);
q3 = vld1q_u8(b);
sse += sse_W16x1_neon(q2, q3);
q2 = vld1q_u8(a + 16);
q3 = vld1q_u8(b + 16);
sse += sse_W16x1_neon(q2, q3);
a += a_stride;
b += b_stride;
}
break;
case 64:
for (y = 0; y < height; y++) {
q2 = vld1q_u8(a);
q3 = vld1q_u8(b);
sse += sse_W16x1_neon(q2, q3);
q2 = vld1q_u8(a + 16);
q3 = vld1q_u8(b + 16);
sse += sse_W16x1_neon(q2, q3);
q2 = vld1q_u8(a + 32);
q3 = vld1q_u8(b + 32);
sse += sse_W16x1_neon(q2, q3);
q2 = vld1q_u8(a + 48);
q3 = vld1q_u8(b + 48);
sse += sse_W16x1_neon(q2, q3);
a += a_stride;
b += b_stride;
}
break;
case 128:
for (y = 0; y < height; y++) {
q2 = vld1q_u8(a);
q3 = vld1q_u8(b);
sse += sse_W16x1_neon(q2, q3);
q2 = vld1q_u8(a + 16);
q3 = vld1q_u8(b + 16);
sse += sse_W16x1_neon(q2, q3);
q2 = vld1q_u8(a + 32);
q3 = vld1q_u8(b + 32);
sse += sse_W16x1_neon(q2, q3);
q2 = vld1q_u8(a + 48);
q3 = vld1q_u8(b + 48);
sse += sse_W16x1_neon(q2, q3);
q2 = vld1q_u8(a + 64);
q3 = vld1q_u8(b + 64);
sse += sse_W16x1_neon(q2, q3);
q2 = vld1q_u8(a + 80);
q3 = vld1q_u8(b + 80);
sse += sse_W16x1_neon(q2, q3);
q2 = vld1q_u8(a + 96);
q3 = vld1q_u8(b + 96);
sse += sse_W16x1_neon(q2, q3);
q2 = vld1q_u8(a + 112);
q3 = vld1q_u8(b + 112);
sse += sse_W16x1_neon(q2, q3);
a += a_stride;
b += b_stride;
}
break;
default:
for (y = 0; y < height; y++) {
x = width;
while (x > 0) {
addinc = width - x;
q2 = vld1q_u8(a + addinc);
q3 = vld1q_u8(b + addinc);
if (x < 16) {
dx = x;
q4 = vld1q_dup_u8(&dx);
q5 = vcltq_u8(q0, q4);
q2 = vandq_u8(q2, q5);
q3 = vandq_u8(q3, q5);
}
sse += sse_W16x1_neon(q2, q3);
x -= 16;
}
a += a_stride;
b += b_stride;
}
}
return (int64_t)sse;
}
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE uint32_t highbd_sse_W8x1_neon(uint16x8_t q2, uint16x8_t q3) {
uint32_t sse;
const uint32_t sse1 = 0;
const uint32x4_t q1 = vld1q_dup_u32(&sse1);
uint16x8_t q4 = vabdq_u16(q2, q3); // diff = abs(a[x] - b[x])
uint16x4_t d0 = vget_low_u16(q4);
uint16x4_t d1 = vget_high_u16(q4);
uint32x4_t q6 = vmlal_u16(q1, d0, d0);
uint32x4_t q7 = vmlal_u16(q1, d1, d1);
uint32x2_t d4 = vadd_u32(vget_low_u32(q6), vget_high_u32(q6));
uint32x2_t d5 = vadd_u32(vget_low_u32(q7), vget_high_u32(q7));
uint32x2_t d6 = vadd_u32(d4, d5);
sse = vget_lane_u32(d6, 0);
sse += vget_lane_u32(d6, 1);
return sse;
}
int64_t aom_highbd_sse_neon(const uint8_t *a8, int a_stride, const uint8_t *b8,
int b_stride, int width, int height) {
const uint16x8_t q0 = { 0, 1, 2, 3, 4, 5, 6, 7 };
int64_t sse = 0;
uint16_t *a = CONVERT_TO_SHORTPTR(a8);
uint16_t *b = CONVERT_TO_SHORTPTR(b8);
int x, y;
int addinc;
uint16x4_t d0, d1, d2, d3;
uint16_t dx;
uint16x8_t q2, q3, q4, q5;
switch (width) {
case 4:
for (y = 0; y < height; y += 2) {
d0 = vld1_u16(a); // load 4 data
a += a_stride;
d1 = vld1_u16(a);
a += a_stride;
d2 = vld1_u16(b);
b += b_stride;
d3 = vld1_u16(b);
b += b_stride;
q2 = vcombine_u16(d0, d1); // make a 8 data vector
q3 = vcombine_u16(d2, d3);
sse += highbd_sse_W8x1_neon(q2, q3);
}
break;
case 8:
for (y = 0; y < height; y++) {
q2 = vld1q_u16(a);
q3 = vld1q_u16(b);
sse += highbd_sse_W8x1_neon(q2, q3);
a += a_stride;
b += b_stride;
}
break;
case 16:
for (y = 0; y < height; y++) {
q2 = vld1q_u16(a);
q3 = vld1q_u16(b);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 8);
q3 = vld1q_u16(b + 8);
sse += highbd_sse_W8x1_neon(q2, q3);
a += a_stride;
b += b_stride;
}
break;
case 32:
for (y = 0; y < height; y++) {
q2 = vld1q_u16(a);
q3 = vld1q_u16(b);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 8);
q3 = vld1q_u16(b + 8);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 16);
q3 = vld1q_u16(b + 16);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 24);
q3 = vld1q_u16(b + 24);
sse += highbd_sse_W8x1_neon(q2, q3);
a += a_stride;
b += b_stride;
}
break;
case 64:
for (y = 0; y < height; y++) {
q2 = vld1q_u16(a);
q3 = vld1q_u16(b);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 8);
q3 = vld1q_u16(b + 8);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 16);
q3 = vld1q_u16(b + 16);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 24);
q3 = vld1q_u16(b + 24);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 32);
q3 = vld1q_u16(b + 32);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 40);
q3 = vld1q_u16(b + 40);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 48);
q3 = vld1q_u16(b + 48);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 56);
q3 = vld1q_u16(b + 56);
sse += highbd_sse_W8x1_neon(q2, q3);
a += a_stride;
b += b_stride;
}
break;
case 128:
for (y = 0; y < height; y++) {
q2 = vld1q_u16(a);
q3 = vld1q_u16(b);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 8);
q3 = vld1q_u16(b + 8);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 16);
q3 = vld1q_u16(b + 16);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 24);
q3 = vld1q_u16(b + 24);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 32);
q3 = vld1q_u16(b + 32);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 40);
q3 = vld1q_u16(b + 40);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 48);
q3 = vld1q_u16(b + 48);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 56);
q3 = vld1q_u16(b + 56);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 64);
q3 = vld1q_u16(b + 64);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 72);
q3 = vld1q_u16(b + 72);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 80);
q3 = vld1q_u16(b + 80);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 88);
q3 = vld1q_u16(b + 88);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 96);
q3 = vld1q_u16(b + 96);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 104);
q3 = vld1q_u16(b + 104);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 112);
q3 = vld1q_u16(b + 112);
sse += highbd_sse_W8x1_neon(q2, q3);
q2 = vld1q_u16(a + 120);
q3 = vld1q_u16(b + 120);
sse += highbd_sse_W8x1_neon(q2, q3);
a += a_stride;
b += b_stride;
}
break;
default:
for (y = 0; y < height; y++) {
x = width;
while (x > 0) {
addinc = width - x;
q2 = vld1q_u16(a + addinc);
q3 = vld1q_u16(b + addinc);
if (x < 8) {
dx = x;
q4 = vld1q_dup_u16(&dx);
q5 = vcltq_u16(q0, q4);
q2 = vandq_u16(q2, q5);
q3 = vandq_u16(q3, q5);
}
sse += highbd_sse_W8x1_neon(q2, q3);
x -= 8;
}
a += a_stride;
b += b_stride;
}
}
return (int64_t)sse;
}
#endif

View file

@ -0,0 +1,37 @@
/*
* Copyright (c) 2019, Alliance for Open Media. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "config/aom_dsp_rtcd.h"
#include "config/aom_config.h"
#include "aom/aom_integer.h"
#include "aom_ports/mem.h"
static INLINE int horizontal_add_s16x8(const int16x8_t v_16x8) {
const int32x4_t a = vpaddlq_s16(v_16x8);
const int64x2_t b = vpaddlq_s32(a);
const int32x2_t c = vadd_s32(vreinterpret_s32_s64(vget_low_s64(b)),
vreinterpret_s32_s64(vget_high_s64(b)));
return vget_lane_s32(c, 0);
}
static INLINE int horizontal_add_s32x4(const int32x4_t v_32x4) {
const int64x2_t b = vpaddlq_s32(v_32x4);
const int32x2_t c = vadd_s32(vreinterpret_s32_s64(vget_low_s64(b)),
vreinterpret_s32_s64(vget_high_s64(b)));
return vget_lane_s32(c, 0);
}
static INLINE uint32x2_t horizontal_add_u16x8(const uint16x8_t a) {
const uint32x4_t b = vpaddlq_u16(a);
const uint64x2_t c = vpaddlq_u32(b);
return vadd_u32(vreinterpret_u32_u64(vget_low_u64(c)),
vreinterpret_u32_u64(vget_high_u64(c)));
}

View file

@ -13,25 +13,10 @@
#include "config/aom_dsp_rtcd.h"
#include "config/aom_config.h"
#include "aom_dsp/arm/sum_neon.h"
#include "aom/aom_integer.h"
#include "aom_ports/mem.h"
static INLINE int horizontal_add_s16x8(const int16x8_t v_16x8) {
const int32x4_t a = vpaddlq_s16(v_16x8);
const int64x2_t b = vpaddlq_s32(a);
const int32x2_t c = vadd_s32(vreinterpret_s32_s64(vget_low_s64(b)),
vreinterpret_s32_s64(vget_high_s64(b)));
return vget_lane_s32(c, 0);
}
static INLINE int horizontal_add_s32x4(const int32x4_t v_32x4) {
const int64x2_t b = vpaddlq_s32(v_32x4);
const int32x2_t c = vadd_s32(vreinterpret_s32_s64(vget_low_s64(b)),
vreinterpret_s32_s64(vget_high_s64(b)));
return vget_lane_s32(c, 0);
}
// w * h must be less than 2048 or local variable v_sum may overflow.
static void variance_neon_w8(const uint8_t *a, int a_stride, const uint8_t *b,
int b_stride, int w, int h, uint32_t *sse,
@ -145,6 +130,24 @@ unsigned int aom_variance64x64_neon(const uint8_t *a, int a_stride,
return *sse - (unsigned int)(((int64_t)sum1 * sum1) >> 12);
}
unsigned int aom_variance128x128_neon(const uint8_t *a, int a_stride,
const uint8_t *b, int b_stride,
unsigned int *sse) {
int sum1, sum2;
uint32_t sse1, sse2;
sum1 = sse1 = 0;
for (int i = 0; i < 16; i++) {
variance_neon_w8(a + (8 * i * a_stride), a_stride, b + (8 * i * b_stride),
b_stride, 128, 8, &sse2, &sum2);
sse1 += sse2;
sum1 += sum2;
}
*sse = sse1;
return *sse - (unsigned int)(((int64_t)sum1 * sum1) >> 14);
}
unsigned int aom_variance16x8_neon(const unsigned char *src_ptr,
int source_stride,
const unsigned char *ref_ptr,
@ -370,9 +373,7 @@ unsigned int aom_get4x4sse_cs_neon(const unsigned char *src_ptr,
d6u8 = vld1_u8(ref_ptr);
ref_ptr += recon_stride;
d3u8 = vld1_u8(src_ptr);
src_ptr += source_stride;
d7u8 = vld1_u8(ref_ptr);
ref_ptr += recon_stride;
q11u16 = vsubl_u8(d0u8, d4u8);
q12u16 = vsubl_u8(d1u8, d5u8);

View file

@ -0,0 +1,486 @@
/*
* 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.
*/
#include <stdlib.h>
#include "config/aom_dsp_rtcd.h"
#include "aom_ports/mem.h"
void aom_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp,
int *min, int *max) {
int i, j;
*min = 255;
*max = 0;
for (i = 0; i < 8; ++i, s += p, d += dp) {
for (j = 0; j < 8; ++j) {
int diff = abs(s[j] - d[j]);
*min = diff < *min ? diff : *min;
*max = diff > *max ? diff : *max;
}
}
}
unsigned int aom_avg_4x4_c(const uint8_t *s, int p) {
int i, j;
int sum = 0;
for (i = 0; i < 4; ++i, s += p)
for (j = 0; j < 4; sum += s[j], ++j) {
}
return (sum + 8) >> 4;
}
unsigned int aom_avg_8x8_c(const uint8_t *s, int p) {
int i, j;
int sum = 0;
for (i = 0; i < 8; ++i, s += p)
for (j = 0; j < 8; sum += s[j], ++j) {
}
return (sum + 32) >> 6;
}
#if CONFIG_AV1_HIGHBITDEPTH
unsigned int aom_highbd_avg_8x8_c(const uint8_t *s8, int p) {
int i, j;
int sum = 0;
const uint16_t *s = CONVERT_TO_SHORTPTR(s8);
for (i = 0; i < 8; ++i, s += p)
for (j = 0; j < 8; sum += s[j], ++j) {
}
return (sum + 32) >> 6;
}
unsigned int aom_highbd_avg_4x4_c(const uint8_t *s8, int p) {
int i, j;
int sum = 0;
const uint16_t *s = CONVERT_TO_SHORTPTR(s8);
for (i = 0; i < 4; ++i, s += p)
for (j = 0; j < 4; sum += s[j], ++j) {
}
return (sum + 8) >> 4;
}
void aom_highbd_minmax_8x8_c(const uint8_t *s8, int p, const uint8_t *d8,
int dp, int *min, int *max) {
int i, j;
const uint16_t *s = CONVERT_TO_SHORTPTR(s8);
const uint16_t *d = CONVERT_TO_SHORTPTR(d8);
*min = 255;
*max = 0;
for (i = 0; i < 8; ++i, s += p, d += dp) {
for (j = 0; j < 8; ++j) {
int diff = abs(s[j] - d[j]);
*min = diff < *min ? diff : *min;
*max = diff > *max ? diff : *max;
}
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH
// src_diff: first pass, 9 bit, dynamic range [-255, 255]
// second pass, 12 bit, dynamic range [-2040, 2040]
static void hadamard_col8(const int16_t *src_diff, ptrdiff_t src_stride,
int16_t *coeff) {
int16_t b0 = src_diff[0 * src_stride] + src_diff[1 * src_stride];
int16_t b1 = src_diff[0 * src_stride] - src_diff[1 * src_stride];
int16_t b2 = src_diff[2 * src_stride] + src_diff[3 * src_stride];
int16_t b3 = src_diff[2 * src_stride] - src_diff[3 * src_stride];
int16_t b4 = src_diff[4 * src_stride] + src_diff[5 * src_stride];
int16_t b5 = src_diff[4 * src_stride] - src_diff[5 * src_stride];
int16_t b6 = src_diff[6 * src_stride] + src_diff[7 * src_stride];
int16_t b7 = src_diff[6 * src_stride] - src_diff[7 * src_stride];
int16_t c0 = b0 + b2;
int16_t c1 = b1 + b3;
int16_t c2 = b0 - b2;
int16_t c3 = b1 - b3;
int16_t c4 = b4 + b6;
int16_t c5 = b5 + b7;
int16_t c6 = b4 - b6;
int16_t c7 = b5 - b7;
coeff[0] = c0 + c4;
coeff[7] = c1 + c5;
coeff[3] = c2 + c6;
coeff[4] = c3 + c7;
coeff[2] = c0 - c4;
coeff[6] = c1 - c5;
coeff[1] = c2 - c6;
coeff[5] = c3 - c7;
}
// The order of the output coeff of the hadamard is not important. For
// optimization purposes the final transpose may be skipped.
void aom_hadamard_8x8_c(const int16_t *src_diff, ptrdiff_t src_stride,
tran_low_t *coeff) {
int idx;
int16_t buffer[64];
int16_t buffer2[64];
int16_t *tmp_buf = &buffer[0];
for (idx = 0; idx < 8; ++idx) {
hadamard_col8(src_diff, src_stride, tmp_buf); // src_diff: 9 bit
// dynamic range [-255, 255]
tmp_buf += 8;
++src_diff;
}
tmp_buf = &buffer[0];
for (idx = 0; idx < 8; ++idx) {
hadamard_col8(tmp_buf, 8, buffer2 + 8 * idx); // tmp_buf: 12 bit
// dynamic range [-2040, 2040]
// buffer2: 15 bit
// dynamic range [-16320, 16320]
++tmp_buf;
}
for (idx = 0; idx < 64; ++idx) coeff[idx] = (tran_low_t)buffer2[idx];
}
void aom_hadamard_lp_8x8_c(const int16_t *src_diff, ptrdiff_t src_stride,
int16_t *coeff) {
int16_t buffer[64];
int16_t buffer2[64];
int16_t *tmp_buf = &buffer[0];
for (int idx = 0; idx < 8; ++idx) {
hadamard_col8(src_diff, src_stride, tmp_buf); // src_diff: 9 bit
// dynamic range [-255, 255]
tmp_buf += 8;
++src_diff;
}
tmp_buf = &buffer[0];
for (int idx = 0; idx < 8; ++idx) {
hadamard_col8(tmp_buf, 8, buffer2 + 8 * idx); // tmp_buf: 12 bit
// dynamic range [-2040, 2040]
// buffer2: 15 bit
// dynamic range [-16320, 16320]
++tmp_buf;
}
for (int idx = 0; idx < 64; ++idx) coeff[idx] = buffer2[idx];
}
// In place 16x16 2D Hadamard transform
void aom_hadamard_16x16_c(const int16_t *src_diff, ptrdiff_t src_stride,
tran_low_t *coeff) {
int idx;
for (idx = 0; idx < 4; ++idx) {
// src_diff: 9 bit, dynamic range [-255, 255]
const int16_t *src_ptr =
src_diff + (idx >> 1) * 8 * src_stride + (idx & 0x01) * 8;
aom_hadamard_8x8_c(src_ptr, src_stride, coeff + idx * 64);
}
// coeff: 15 bit, dynamic range [-16320, 16320]
for (idx = 0; idx < 64; ++idx) {
tran_low_t a0 = coeff[0];
tran_low_t a1 = coeff[64];
tran_low_t a2 = coeff[128];
tran_low_t a3 = coeff[192];
tran_low_t b0 = (a0 + a1) >> 1; // (a0 + a1): 16 bit, [-32640, 32640]
tran_low_t b1 = (a0 - a1) >> 1; // b0-b3: 15 bit, dynamic range
tran_low_t b2 = (a2 + a3) >> 1; // [-16320, 16320]
tran_low_t b3 = (a2 - a3) >> 1;
coeff[0] = b0 + b2; // 16 bit, [-32640, 32640]
coeff[64] = b1 + b3;
coeff[128] = b0 - b2;
coeff[192] = b1 - b3;
++coeff;
}
}
void aom_hadamard_lp_16x16_c(const int16_t *src_diff, ptrdiff_t src_stride,
int16_t *coeff) {
for (int idx = 0; idx < 4; ++idx) {
// src_diff: 9 bit, dynamic range [-255, 255]
const int16_t *src_ptr =
src_diff + (idx >> 1) * 8 * src_stride + (idx & 0x01) * 8;
aom_hadamard_lp_8x8_c(src_ptr, src_stride, coeff + idx * 64);
}
for (int idx = 0; idx < 64; ++idx) {
int16_t a0 = coeff[0];
int16_t a1 = coeff[64];
int16_t a2 = coeff[128];
int16_t a3 = coeff[192];
int16_t b0 = (a0 + a1) >> 1; // (a0 + a1): 16 bit, [-32640, 32640]
int16_t b1 = (a0 - a1) >> 1; // b0-b3: 15 bit, dynamic range
int16_t b2 = (a2 + a3) >> 1; // [-16320, 16320]
int16_t b3 = (a2 - a3) >> 1;
coeff[0] = b0 + b2; // 16 bit, [-32640, 32640]
coeff[64] = b1 + b3;
coeff[128] = b0 - b2;
coeff[192] = b1 - b3;
++coeff;
}
}
void aom_hadamard_32x32_c(const int16_t *src_diff, ptrdiff_t src_stride,
tran_low_t *coeff) {
int idx;
for (idx = 0; idx < 4; ++idx) {
// src_diff: 9 bit, dynamic range [-255, 255]
const int16_t *src_ptr =
src_diff + (idx >> 1) * 16 * src_stride + (idx & 0x01) * 16;
aom_hadamard_16x16_c(src_ptr, src_stride, coeff + idx * 256);
}
// coeff: 15 bit, dynamic range [-16320, 16320]
for (idx = 0; idx < 256; ++idx) {
tran_low_t a0 = coeff[0];
tran_low_t a1 = coeff[256];
tran_low_t a2 = coeff[512];
tran_low_t a3 = coeff[768];
tran_low_t b0 = (a0 + a1) >> 2; // (a0 + a1): 16 bit, [-32640, 32640]
tran_low_t b1 = (a0 - a1) >> 2; // b0-b3: 15 bit, dynamic range
tran_low_t b2 = (a2 + a3) >> 2; // [-16320, 16320]
tran_low_t b3 = (a2 - a3) >> 2;
coeff[0] = b0 + b2; // 16 bit, [-32640, 32640]
coeff[256] = b1 + b3;
coeff[512] = b0 - b2;
coeff[768] = b1 - b3;
++coeff;
}
}
#if CONFIG_AV1_HIGHBITDEPTH
static void hadamard_highbd_col8_first_pass(const int16_t *src_diff,
ptrdiff_t src_stride,
int16_t *coeff) {
int16_t b0 = src_diff[0 * src_stride] + src_diff[1 * src_stride];
int16_t b1 = src_diff[0 * src_stride] - src_diff[1 * src_stride];
int16_t b2 = src_diff[2 * src_stride] + src_diff[3 * src_stride];
int16_t b3 = src_diff[2 * src_stride] - src_diff[3 * src_stride];
int16_t b4 = src_diff[4 * src_stride] + src_diff[5 * src_stride];
int16_t b5 = src_diff[4 * src_stride] - src_diff[5 * src_stride];
int16_t b6 = src_diff[6 * src_stride] + src_diff[7 * src_stride];
int16_t b7 = src_diff[6 * src_stride] - src_diff[7 * src_stride];
int16_t c0 = b0 + b2;
int16_t c1 = b1 + b3;
int16_t c2 = b0 - b2;
int16_t c3 = b1 - b3;
int16_t c4 = b4 + b6;
int16_t c5 = b5 + b7;
int16_t c6 = b4 - b6;
int16_t c7 = b5 - b7;
coeff[0] = c0 + c4;
coeff[7] = c1 + c5;
coeff[3] = c2 + c6;
coeff[4] = c3 + c7;
coeff[2] = c0 - c4;
coeff[6] = c1 - c5;
coeff[1] = c2 - c6;
coeff[5] = c3 - c7;
}
// src_diff: 16 bit, dynamic range [-32760, 32760]
// coeff: 19 bit
static void hadamard_highbd_col8_second_pass(const int16_t *src_diff,
ptrdiff_t src_stride,
int32_t *coeff) {
int32_t b0 = src_diff[0 * src_stride] + src_diff[1 * src_stride];
int32_t b1 = src_diff[0 * src_stride] - src_diff[1 * src_stride];
int32_t b2 = src_diff[2 * src_stride] + src_diff[3 * src_stride];
int32_t b3 = src_diff[2 * src_stride] - src_diff[3 * src_stride];
int32_t b4 = src_diff[4 * src_stride] + src_diff[5 * src_stride];
int32_t b5 = src_diff[4 * src_stride] - src_diff[5 * src_stride];
int32_t b6 = src_diff[6 * src_stride] + src_diff[7 * src_stride];
int32_t b7 = src_diff[6 * src_stride] - src_diff[7 * src_stride];
int32_t c0 = b0 + b2;
int32_t c1 = b1 + b3;
int32_t c2 = b0 - b2;
int32_t c3 = b1 - b3;
int32_t c4 = b4 + b6;
int32_t c5 = b5 + b7;
int32_t c6 = b4 - b6;
int32_t c7 = b5 - b7;
coeff[0] = c0 + c4;
coeff[7] = c1 + c5;
coeff[3] = c2 + c6;
coeff[4] = c3 + c7;
coeff[2] = c0 - c4;
coeff[6] = c1 - c5;
coeff[1] = c2 - c6;
coeff[5] = c3 - c7;
}
// The order of the output coeff of the hadamard is not important. For
// optimization purposes the final transpose may be skipped.
void aom_highbd_hadamard_8x8_c(const int16_t *src_diff, ptrdiff_t src_stride,
tran_low_t *coeff) {
int idx;
int16_t buffer[64];
int32_t buffer2[64];
int16_t *tmp_buf = &buffer[0];
for (idx = 0; idx < 8; ++idx) {
// src_diff: 13 bit
// buffer: 16 bit, dynamic range [-32760, 32760]
hadamard_highbd_col8_first_pass(src_diff, src_stride, tmp_buf);
tmp_buf += 8;
++src_diff;
}
tmp_buf = &buffer[0];
for (idx = 0; idx < 8; ++idx) {
// buffer: 16 bit
// buffer2: 19 bit, dynamic range [-262080, 262080]
hadamard_highbd_col8_second_pass(tmp_buf, 8, buffer2 + 8 * idx);
++tmp_buf;
}
for (idx = 0; idx < 64; ++idx) coeff[idx] = (tran_low_t)buffer2[idx];
}
// In place 16x16 2D Hadamard transform
void aom_highbd_hadamard_16x16_c(const int16_t *src_diff, ptrdiff_t src_stride,
tran_low_t *coeff) {
int idx;
for (idx = 0; idx < 4; ++idx) {
// src_diff: 13 bit, dynamic range [-4095, 4095]
const int16_t *src_ptr =
src_diff + (idx >> 1) * 8 * src_stride + (idx & 0x01) * 8;
aom_highbd_hadamard_8x8_c(src_ptr, src_stride, coeff + idx * 64);
}
// coeff: 19 bit, dynamic range [-262080, 262080]
for (idx = 0; idx < 64; ++idx) {
tran_low_t a0 = coeff[0];
tran_low_t a1 = coeff[64];
tran_low_t a2 = coeff[128];
tran_low_t a3 = coeff[192];
tran_low_t b0 = (a0 + a1) >> 1;
tran_low_t b1 = (a0 - a1) >> 1;
tran_low_t b2 = (a2 + a3) >> 1;
tran_low_t b3 = (a2 - a3) >> 1;
// new coeff dynamic range: 20 bit
coeff[0] = b0 + b2;
coeff[64] = b1 + b3;
coeff[128] = b0 - b2;
coeff[192] = b1 - b3;
++coeff;
}
}
void aom_highbd_hadamard_32x32_c(const int16_t *src_diff, ptrdiff_t src_stride,
tran_low_t *coeff) {
int idx;
for (idx = 0; idx < 4; ++idx) {
// src_diff: 13 bit, dynamic range [-4095, 4095]
const int16_t *src_ptr =
src_diff + (idx >> 1) * 16 * src_stride + (idx & 0x01) * 16;
aom_highbd_hadamard_16x16_c(src_ptr, src_stride, coeff + idx * 256);
}
// coeff: 20 bit
for (idx = 0; idx < 256; ++idx) {
tran_low_t a0 = coeff[0];
tran_low_t a1 = coeff[256];
tran_low_t a2 = coeff[512];
tran_low_t a3 = coeff[768];
tran_low_t b0 = (a0 + a1) >> 2;
tran_low_t b1 = (a0 - a1) >> 2;
tran_low_t b2 = (a2 + a3) >> 2;
tran_low_t b3 = (a2 - a3) >> 2;
// new coeff dynamic range: 20 bit
coeff[0] = b0 + b2;
coeff[256] = b1 + b3;
coeff[512] = b0 - b2;
coeff[768] = b1 - b3;
++coeff;
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH
// coeff: 16 bits, dynamic range [-32640, 32640].
// length: value range {16, 64, 256, 1024}.
int aom_satd_c(const tran_low_t *coeff, int length) {
int i;
int satd = 0;
for (i = 0; i < length; ++i) satd += abs(coeff[i]);
// satd: 26 bits, dynamic range [-32640 * 1024, 32640 * 1024]
return satd;
}
int aom_satd_lp_c(const int16_t *coeff, int length) {
int satd = 0;
for (int i = 0; i < length; ++i) satd += abs(coeff[i]);
// satd: 26 bits, dynamic range [-32640 * 1024, 32640 * 1024]
return satd;
}
// Integer projection onto row vectors.
// height: value range {16, 32, 64, 128}.
void aom_int_pro_row_c(int16_t hbuf[16], const uint8_t *ref,
const int ref_stride, const int height) {
int idx;
const int norm_factor = height >> 1;
for (idx = 0; idx < 16; ++idx) {
int i;
hbuf[idx] = 0;
// hbuf[idx]: 14 bit, dynamic range [0, 32640].
for (i = 0; i < height; ++i) hbuf[idx] += ref[i * ref_stride];
// hbuf[idx]: 9 bit, dynamic range [0, 1020].
hbuf[idx] /= norm_factor;
++ref;
}
}
// width: value range {16, 32, 64, 128}.
int16_t aom_int_pro_col_c(const uint8_t *ref, const int width) {
int idx;
int16_t sum = 0;
// sum: 14 bit, dynamic range [0, 32640]
for (idx = 0; idx < width; ++idx) sum += ref[idx];
return sum;
}
// ref: [0 - 510]
// src: [0 - 510]
// bwl: {2, 3, 4, 5}
int aom_vector_var_c(const int16_t *ref, const int16_t *src, const int bwl) {
int i;
int width = 4 << bwl;
int sse = 0, mean = 0, var;
for (i = 0; i < width; ++i) {
int diff = ref[i] - src[i]; // diff: dynamic range [-510, 510], 10 bits.
mean += diff; // mean: dynamic range 16 bits.
sse += diff * diff; // sse: dynamic range 26 bits.
}
// (mean * mean): dynamic range 31 bits.
var = sse - ((mean * mean) >> (bwl + 2));
return var;
}

View file

@ -10,29 +10,9 @@
*/
#include "aom_dsp/binary_codes_reader.h"
#include "aom_dsp/recenter.h"
#include "av1/common/common.h"
// Inverse recenters a non-negative literal v around a reference r
static uint16_t inv_recenter_nonneg(uint16_t r, uint16_t v) {
if (v > (r << 1))
return v;
else if ((v & 1) == 0)
return (v >> 1) + r;
else
return r - ((v + 1) >> 1);
}
// Inverse recenters a non-negative literal v in [0, n-1] around a
// reference r also in [0, n-1]
static uint16_t inv_recenter_finite_nonneg(uint16_t n, uint16_t r, uint16_t v) {
if ((r << 1) <= n) {
return inv_recenter_nonneg(r, v);
} else {
return n - 1 - inv_recenter_nonneg(n - 1 - r, v);
}
}
uint16_t aom_read_primitive_quniform_(aom_reader *r,
uint16_t n ACCT_STR_PARAM) {
if (n <= 1) return 0;
@ -42,15 +22,6 @@ uint16_t aom_read_primitive_quniform_(aom_reader *r,
return v < m ? v : (v << 1) - m + aom_read_bit(r, ACCT_STR_NAME);
}
static uint16_t aom_rb_read_primitive_quniform(struct aom_read_bit_buffer *rb,
uint16_t n) {
if (n <= 1) return 0;
const int l = get_msb(n) + 1;
const int m = (1 << l) - n;
const int v = aom_rb_read_literal(rb, l - 1);
return v < m ? v : (v << 1) - m + aom_rb_read_bit(rb);
}
// Decode finite subexponential code that for a symbol v in [0, n-1] with
// parameter k
uint16_t aom_read_primitive_subexpfin_(aom_reader *r, uint16_t n,
@ -78,46 +49,8 @@ uint16_t aom_read_primitive_subexpfin_(aom_reader *r, uint16_t n,
return 0;
}
static uint16_t aom_rb_read_primitive_subexpfin(struct aom_read_bit_buffer *rb,
uint16_t n, uint16_t k) {
int i = 0;
int mk = 0;
while (1) {
int b = (i ? k + i - 1 : k);
int a = (1 << b);
if (n <= mk + 3 * a) {
return aom_rb_read_primitive_quniform(rb, n - mk) + mk;
}
if (!aom_rb_read_bit(rb)) {
return aom_rb_read_literal(rb, b) + mk;
}
i = i + 1;
mk += a;
}
assert(0);
return 0;
}
uint16_t aom_read_primitive_refsubexpfin_(aom_reader *r, uint16_t n, uint16_t k,
uint16_t ref ACCT_STR_PARAM) {
return inv_recenter_finite_nonneg(
n, ref, aom_read_primitive_subexpfin(r, n, k, ACCT_STR_NAME));
}
static uint16_t aom_rb_read_primitive_refsubexpfin(
struct aom_read_bit_buffer *rb, uint16_t n, uint16_t k, uint16_t ref) {
return inv_recenter_finite_nonneg(n, ref,
aom_rb_read_primitive_subexpfin(rb, n, k));
}
int16_t aom_rb_read_signed_primitive_refsubexpfin(
struct aom_read_bit_buffer *rb, uint16_t n, uint16_t k, int16_t ref) {
ref += n - 1;
const uint16_t scaled_n = (n << 1) - 1;
return aom_rb_read_primitive_refsubexpfin(rb, scaled_n, k, ref) - n + 1;
}

View file

@ -37,9 +37,6 @@ uint16_t aom_read_primitive_subexpfin_(aom_reader *r, uint16_t n,
uint16_t aom_read_primitive_refsubexpfin_(aom_reader *r, uint16_t n, uint16_t k,
uint16_t ref ACCT_STR_PARAM);
int16_t aom_rb_read_signed_primitive_refsubexpfin(
struct aom_read_bit_buffer *rb, uint16_t n, uint16_t k, int16_t ref);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -11,29 +11,10 @@
#include "aom_dsp/bitwriter.h"
#include "aom_dsp/binary_codes_writer.h"
#include "aom_dsp/recenter.h"
#include "aom_ports/bitops.h"
#include "av1/common/common.h"
// Recenters a non-negative literal v around a reference r
static uint16_t recenter_nonneg(uint16_t r, uint16_t v) {
if (v > (r << 1))
return v;
else if (v >= r)
return ((v - r) << 1);
else
return ((r - v) << 1) - 1;
}
// Recenters a non-negative literal v in [0, n-1] around a
// reference r also in [0, n-1]
static uint16_t recenter_finite_nonneg(uint16_t n, uint16_t r, uint16_t v) {
if ((r << 1) <= n) {
return recenter_nonneg(r, v);
} else {
return recenter_nonneg(n - 1 - r, n - 1 - v);
}
}
// Codes a symbol v in [-2^mag_bits, 2^mag_bits].
// mag_bits is number of bits for magnitude. The alphabet is of size
// 2 * 2^mag_bits + 1, symmetric around 0, where one bit is used to
@ -69,19 +50,6 @@ void aom_write_primitive_quniform(aom_writer *w, uint16_t n, uint16_t v) {
}
}
static void aom_wb_write_primitive_quniform(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t v) {
if (n <= 1) return;
const int l = get_msb(n) + 1;
const int m = (1 << l) - n;
if (v < m) {
aom_wb_write_literal(wb, v, l - 1);
} else {
aom_wb_write_literal(wb, m + ((v - m) >> 1), l - 1);
aom_wb_write_bit(wb, (v - m) & 1);
}
}
int aom_count_primitive_quniform(uint16_t n, uint16_t v) {
if (n <= 1) return 0;
const int l = get_msb(n) + 1;
@ -114,31 +82,6 @@ void aom_write_primitive_subexpfin(aom_writer *w, uint16_t n, uint16_t k,
}
}
static void aom_wb_write_primitive_subexpfin(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t k,
uint16_t v) {
int i = 0;
int mk = 0;
while (1) {
int b = (i ? k + i - 1 : k);
int a = (1 << b);
if (n <= mk + 3 * a) {
aom_wb_write_primitive_quniform(wb, n - mk, v - mk);
break;
} else {
int t = (v >= mk + a);
aom_wb_write_bit(wb, t);
if (t) {
i = i + 1;
mk += a;
} else {
aom_wb_write_literal(wb, v - mk, b);
break;
}
}
}
}
int aom_count_primitive_subexpfin(uint16_t n, uint16_t k, uint16_t v) {
int count = 0;
int i = 0;
@ -172,12 +115,6 @@ void aom_write_primitive_refsubexpfin(aom_writer *w, uint16_t n, uint16_t k,
aom_write_primitive_subexpfin(w, n, k, recenter_finite_nonneg(n, ref, v));
}
static void aom_wb_write_primitive_refsubexpfin(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t k,
uint16_t ref, uint16_t v) {
aom_wb_write_primitive_subexpfin(wb, n, k, recenter_finite_nonneg(n, ref, v));
}
void aom_write_signed_primitive_refsubexpfin(aom_writer *w, uint16_t n,
uint16_t k, int16_t ref,
int16_t v) {
@ -187,15 +124,6 @@ void aom_write_signed_primitive_refsubexpfin(aom_writer *w, uint16_t n,
aom_write_primitive_refsubexpfin(w, scaled_n, k, ref, v);
}
void aom_wb_write_signed_primitive_refsubexpfin(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t k,
int16_t ref, int16_t v) {
ref += n - 1;
v += n - 1;
const uint16_t scaled_n = (n << 1) - 1;
aom_wb_write_primitive_refsubexpfin(wb, scaled_n, k, ref, v);
}
int aom_count_primitive_refsubexpfin(uint16_t n, uint16_t k, uint16_t ref,
uint16_t v) {
return aom_count_primitive_subexpfin(n, k, recenter_finite_nonneg(n, ref, v));

View file

@ -49,10 +49,6 @@ void aom_write_signed_primitive_refsubexpfin(aom_writer *w, uint16_t n,
uint16_t k, int16_t ref,
int16_t v);
void aom_wb_write_signed_primitive_refsubexpfin(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t k,
int16_t ref, int16_t v);
// Functions that counts bits for the above primitives
int aom_count_primitive_symmetric(int16_t v, unsigned int mag_bits);
int aom_count_primitive_quniform(uint16_t n, uint16_t v);
@ -61,6 +57,7 @@ int aom_count_primitive_refsubexpfin(uint16_t n, uint16_t k, uint16_t ref,
uint16_t v);
int aom_count_signed_primitive_refsubexpfin(uint16_t n, uint16_t k, int16_t ref,
int16_t v);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -9,39 +9,33 @@
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#include "aom_dsp/daalaboolreader.h"
#include "aom_dsp/bitreader.h"
int aom_daala_reader_init(daala_reader *r, const uint8_t *buffer, int size) {
int aom_reader_init(aom_reader *r, const uint8_t *buffer, size_t size) {
if (size && !buffer) {
return 1;
}
r->buffer_end = buffer + size;
r->buffer = buffer;
od_ec_dec_init(&r->ec, buffer, size);
od_ec_dec_init(&r->ec, buffer, (uint32_t)size);
#if CONFIG_ACCOUNTING
r->accounting = NULL;
#endif
return 0;
}
const uint8_t *aom_daala_reader_find_begin(daala_reader *r) {
return r->buffer;
}
const uint8_t *aom_reader_find_begin(aom_reader *r) { return r->buffer; }
const uint8_t *aom_daala_reader_find_end(daala_reader *r) {
return r->buffer_end;
}
const uint8_t *aom_reader_find_end(aom_reader *r) { return r->buffer_end; }
uint32_t aom_daala_reader_tell(const daala_reader *r) {
return od_ec_dec_tell(&r->ec);
}
uint32_t aom_reader_tell(const aom_reader *r) { return od_ec_dec_tell(&r->ec); }
uint32_t aom_daala_reader_tell_frac(const daala_reader *r) {
uint32_t aom_reader_tell_frac(const aom_reader *r) {
return od_ec_dec_tell_frac(&r->ec);
}
int aom_daala_reader_has_overflowed(const daala_reader *r) {
const uint32_t tell_bits = aom_daala_reader_tell(r);
int aom_reader_has_overflowed(const aom_reader *r) {
const uint32_t tell_bits = aom_reader_tell(r);
const uint32_t tell_bytes = (tell_bits + 7) >> 3;
return ((ptrdiff_t)tell_bytes > r->buffer_end - r->buffer);
}

View file

@ -19,7 +19,7 @@
#include "aom/aomdx.h"
#include "aom/aom_integer.h"
#include "aom_dsp/daalaboolreader.h"
#include "aom_dsp/entdec.h"
#include "aom_dsp/prob.h"
#include "av1/common/odintrin.h"
@ -50,40 +50,33 @@
extern "C" {
#endif
typedef struct daala_reader aom_reader;
struct aom_reader {
const uint8_t *buffer;
const uint8_t *buffer_end;
od_ec_dec ec;
#if CONFIG_ACCOUNTING
Accounting *accounting;
#endif
uint8_t allow_update_cdf;
};
static INLINE int aom_reader_init(aom_reader *r, const uint8_t *buffer,
size_t size) {
return aom_daala_reader_init(r, buffer, (int)size);
}
typedef struct aom_reader aom_reader;
static INLINE const uint8_t *aom_reader_find_begin(aom_reader *r) {
return aom_daala_reader_find_begin(r);
}
int aom_reader_init(aom_reader *r, const uint8_t *buffer, size_t size);
static INLINE const uint8_t *aom_reader_find_end(aom_reader *r) {
return aom_daala_reader_find_end(r);
}
const uint8_t *aom_reader_find_begin(aom_reader *r);
static INLINE int aom_reader_has_error(aom_reader *r) {
return aom_daala_reader_has_error(r);
}
const uint8_t *aom_reader_find_end(aom_reader *r);
// Returns true if the bit reader has tried to decode more data from the buffer
// than was actually provided.
static INLINE int aom_reader_has_overflowed(const aom_reader *r) {
return aom_daala_reader_has_overflowed(r);
}
int aom_reader_has_overflowed(const aom_reader *r);
// Returns the position in the bit reader in bits.
static INLINE uint32_t aom_reader_tell(const aom_reader *r) {
return aom_daala_reader_tell(r);
}
uint32_t aom_reader_tell(const aom_reader *r);
// Returns the position in the bit reader in 1/8th bits.
static INLINE uint32_t aom_reader_tell_frac(const aom_reader *r) {
return aom_daala_reader_tell_frac(r);
}
uint32_t aom_reader_tell_frac(const aom_reader *r);
#if CONFIG_ACCOUNTING
static INLINE void aom_process_accounting(const aom_reader *r ACCT_STR_PARAM) {
@ -105,13 +98,48 @@ static INLINE void aom_update_symb_counts(const aom_reader *r, int is_binary) {
#endif
static INLINE int aom_read_(aom_reader *r, int prob ACCT_STR_PARAM) {
int ret;
ret = aom_daala_read(r, prob);
int p = (0x7FFFFF - (prob << 15) + prob) >> 8;
int bit = od_ec_decode_bool_q15(&r->ec, p);
#if CONFIG_BITSTREAM_DEBUG
{
int i;
int ref_bit, ref_nsymbs;
aom_cdf_prob ref_cdf[16];
const int queue_r = bitstream_queue_get_read();
const int frame_idx = aom_bitstream_queue_get_frame_read();
bitstream_queue_pop(&ref_bit, ref_cdf, &ref_nsymbs);
if (ref_nsymbs != 2) {
fprintf(stderr,
"\n *** [bit] nsymbs error, frame_idx_r %d nsymbs %d ref_nsymbs "
"%d queue_r %d\n",
frame_idx, 2, ref_nsymbs, queue_r);
assert(0);
}
if ((ref_nsymbs != 2) || (ref_cdf[0] != (aom_cdf_prob)p) ||
(ref_cdf[1] != 32767)) {
fprintf(stderr,
"\n *** [bit] cdf error, frame_idx_r %d cdf {%d, %d} ref_cdf {%d",
frame_idx, p, 32767, ref_cdf[0]);
for (i = 1; i < ref_nsymbs; ++i) fprintf(stderr, ", %d", ref_cdf[i]);
fprintf(stderr, "} queue_r %d\n", queue_r);
assert(0);
}
if (bit != ref_bit) {
fprintf(stderr,
"\n *** [bit] symb error, frame_idx_r %d symb %d ref_symb %d "
"queue_r %d\n",
frame_idx, bit, ref_bit, queue_r);
assert(0);
}
}
#endif
#if CONFIG_ACCOUNTING
if (ACCT_STR_NAME) aom_process_accounting(r, ACCT_STR_NAME);
aom_update_symb_counts(r, 1);
#endif
return ret;
return bit;
}
static INLINE int aom_read_bit_(aom_reader *r ACCT_STR_PARAM) {
@ -135,14 +163,54 @@ static INLINE int aom_read_literal_(aom_reader *r, int bits ACCT_STR_PARAM) {
static INLINE int aom_read_cdf_(aom_reader *r, const aom_cdf_prob *cdf,
int nsymbs ACCT_STR_PARAM) {
int ret;
ret = daala_read_symbol(r, cdf, nsymbs);
int symb;
assert(cdf != NULL);
symb = od_ec_decode_cdf_q15(&r->ec, cdf, nsymbs);
#if CONFIG_BITSTREAM_DEBUG
{
int i;
int cdf_error = 0;
int ref_symb, ref_nsymbs;
aom_cdf_prob ref_cdf[16];
const int queue_r = bitstream_queue_get_read();
const int frame_idx = aom_bitstream_queue_get_frame_read();
bitstream_queue_pop(&ref_symb, ref_cdf, &ref_nsymbs);
if (nsymbs != ref_nsymbs) {
fprintf(stderr,
"\n *** nsymbs error, frame_idx_r %d nsymbs %d ref_nsymbs %d "
"queue_r %d\n",
frame_idx, nsymbs, ref_nsymbs, queue_r);
cdf_error = 0;
assert(0);
} else {
for (i = 0; i < nsymbs; ++i)
if (cdf[i] != ref_cdf[i]) cdf_error = 1;
}
if (cdf_error) {
fprintf(stderr, "\n *** cdf error, frame_idx_r %d cdf {%d", frame_idx,
cdf[0]);
for (i = 1; i < nsymbs; ++i) fprintf(stderr, ", %d", cdf[i]);
fprintf(stderr, "} ref_cdf {%d", ref_cdf[0]);
for (i = 1; i < ref_nsymbs; ++i) fprintf(stderr, ", %d", ref_cdf[i]);
fprintf(stderr, "} queue_r %d\n", queue_r);
assert(0);
}
if (symb != ref_symb) {
fprintf(
stderr,
"\n *** symb error, frame_idx_r %d symb %d ref_symb %d queue_r %d\n",
frame_idx, symb, ref_symb, queue_r);
assert(0);
}
}
#endif
#if CONFIG_ACCOUNTING
if (ACCT_STR_NAME) aom_process_accounting(r, ACCT_STR_NAME);
aom_update_symb_counts(r, (nsymbs == 2));
#endif
return ret;
return symb;
}
static INLINE int aom_read_symbol_(aom_reader *r, aom_cdf_prob *cdf,

View file

@ -14,6 +14,8 @@
#include "config/aom_config.h"
#include "aom_dsp/bitreader_buffer.h"
#include "aom_dsp/recenter.h"
#include "aom_ports/bitops.h"
size_t aom_rb_bytes_read(const struct aom_read_bit_buffer *rb) {
return (rb->bit_offset + 7) >> 3;
@ -58,10 +60,57 @@ int aom_rb_read_inv_signed_literal(struct aom_read_bit_buffer *rb, int bits) {
uint32_t aom_rb_read_uvlc(struct aom_read_bit_buffer *rb) {
int leading_zeros = 0;
while (!aom_rb_read_bit(rb)) ++leading_zeros;
while (leading_zeros < 32 && !aom_rb_read_bit(rb)) ++leading_zeros;
// Maximum 32 bits.
if (leading_zeros >= 32) return UINT32_MAX;
if (leading_zeros == 32) return UINT32_MAX;
const uint32_t base = (1u << leading_zeros) - 1;
const uint32_t value = aom_rb_read_literal(rb, leading_zeros);
return base + value;
}
static uint16_t aom_rb_read_primitive_quniform(struct aom_read_bit_buffer *rb,
uint16_t n) {
if (n <= 1) return 0;
const int l = get_msb(n) + 1;
const int m = (1 << l) - n;
const int v = aom_rb_read_literal(rb, l - 1);
return v < m ? v : (v << 1) - m + aom_rb_read_bit(rb);
}
static uint16_t aom_rb_read_primitive_subexpfin(struct aom_read_bit_buffer *rb,
uint16_t n, uint16_t k) {
int i = 0;
int mk = 0;
while (1) {
int b = (i ? k + i - 1 : k);
int a = (1 << b);
if (n <= mk + 3 * a) {
return aom_rb_read_primitive_quniform(rb, n - mk) + mk;
}
if (!aom_rb_read_bit(rb)) {
return aom_rb_read_literal(rb, b) + mk;
}
i = i + 1;
mk += a;
}
assert(0);
return 0;
}
static uint16_t aom_rb_read_primitive_refsubexpfin(
struct aom_read_bit_buffer *rb, uint16_t n, uint16_t k, uint16_t ref) {
return inv_recenter_finite_nonneg(n, ref,
aom_rb_read_primitive_subexpfin(rb, n, k));
}
int16_t aom_rb_read_signed_primitive_refsubexpfin(
struct aom_read_bit_buffer *rb, uint16_t n, uint16_t k, int16_t ref) {
ref += n - 1;
const uint16_t scaled_n = (n << 1) - 1;
return aom_rb_read_primitive_refsubexpfin(rb, scaled_n, k, ref) - n + 1;
}

View file

@ -43,6 +43,9 @@ int aom_rb_read_inv_signed_literal(struct aom_read_bit_buffer *rb, int bits);
uint32_t aom_rb_read_uvlc(struct aom_read_bit_buffer *rb);
int16_t aom_rb_read_signed_primitive_refsubexpfin(
struct aom_read_bit_buffer *rb, uint16_t n, uint16_t k, int16_t ref);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -10,22 +10,22 @@
*/
#include <string.h>
#include "aom_dsp/daalaboolwriter.h"
#include "aom_dsp/bitwriter.h"
void aom_daala_start_encode(daala_writer *br, uint8_t *source) {
br->buffer = source;
br->pos = 0;
od_ec_enc_init(&br->ec, 62025);
void aom_start_encode(aom_writer *w, uint8_t *source) {
w->buffer = source;
w->pos = 0;
od_ec_enc_init(&w->ec, 62025);
}
int aom_daala_stop_encode(daala_writer *br) {
int aom_stop_encode(aom_writer *w) {
int nb_bits;
uint32_t daala_bytes;
unsigned char *daala_data;
daala_data = od_ec_enc_done(&br->ec, &daala_bytes);
nb_bits = od_ec_enc_tell(&br->ec);
memcpy(br->buffer, daala_data, daala_bytes);
br->pos = daala_bytes;
od_ec_enc_clear(&br->ec);
uint32_t bytes;
unsigned char *data;
data = od_ec_enc_done(&w->ec, &bytes);
nb_bits = od_ec_enc_tell(&w->ec);
memcpy(w->buffer, data, bytes);
w->pos = bytes;
od_ec_enc_clear(&w->ec);
return nb_bits;
}

View file

@ -16,7 +16,7 @@
#include "config/aom_config.h"
#include "aom_dsp/daalaboolwriter.h"
#include "aom_dsp/entenc.h"
#include "aom_dsp/prob.h"
#if CONFIG_RD_DEBUG
@ -28,7 +28,14 @@
extern "C" {
#endif
typedef struct daala_writer aom_writer;
struct aom_writer {
unsigned int pos;
uint8_t *buffer;
od_ec_enc ec;
uint8_t allow_update_cdf;
};
typedef struct aom_writer aom_writer;
typedef struct TOKEN_STATS {
int cost;
@ -49,16 +56,26 @@ static INLINE void init_token_stats(TOKEN_STATS *token_stats) {
token_stats->cost = 0;
}
static INLINE void aom_start_encode(aom_writer *bc, uint8_t *buffer) {
aom_daala_start_encode(bc, buffer);
}
void aom_start_encode(aom_writer *w, uint8_t *buffer);
static INLINE int aom_stop_encode(aom_writer *bc) {
return aom_daala_stop_encode(bc);
}
int aom_stop_encode(aom_writer *w);
static INLINE void aom_write(aom_writer *br, int bit, int probability) {
aom_daala_write(br, bit, probability);
static INLINE void aom_write(aom_writer *w, int bit, int probability) {
int p = (0x7FFFFF - (probability << 15) + probability) >> 8;
#if CONFIG_BITSTREAM_DEBUG
aom_cdf_prob cdf[2] = { (aom_cdf_prob)p, 32767 };
/*int queue_r = 0;
int frame_idx_r = 0;
int queue_w = bitstream_queue_get_write();
int frame_idx_w = aom_bitstream_queue_get_frame_writee();
if (frame_idx_w == frame_idx_r && queue_w == queue_r) {
fprintf(stderr, "\n *** bitstream queue at frame_idx_w %d queue_w %d\n",
frame_idx_w, queue_w);
}*/
bitstream_queue_push(bit, cdf, 2);
#endif
od_ec_encode_bool_q15(&w->ec, bit, p);
}
static INLINE void aom_write_bit(aom_writer *w, int bit) {
@ -73,7 +90,19 @@ static INLINE void aom_write_literal(aom_writer *w, int data, int bits) {
static INLINE void aom_write_cdf(aom_writer *w, int symb,
const aom_cdf_prob *cdf, int nsymbs) {
daala_write_symbol(w, symb, cdf, nsymbs);
#if CONFIG_BITSTREAM_DEBUG
/*int queue_r = 0;
int frame_idx_r = 0;
int queue_w = bitstream_queue_get_write();
int frame_idx_w = aom_bitstream_queue_get_frame_writee();
if (frame_idx_w == frame_idx_r && queue_w == queue_r) {
fprintf(stderr, "\n *** bitstream queue at frame_idx_w %d queue_w %d\n",
frame_idx_w, queue_w);
}*/
bitstream_queue_push(symb, cdf, nsymbs);
#endif
od_ec_encode_cdf_q15(&w->ec, symb, cdf, nsymbs);
}
static INLINE void aom_write_symbol(aom_writer *w, int symb, aom_cdf_prob *cdf,

View file

@ -16,6 +16,8 @@
#include "config/aom_config.h"
#include "aom_dsp/bitwriter_buffer.h"
#include "aom_dsp/recenter.h"
#include "aom_ports/bitops.h"
int aom_wb_is_byte_aligned(const struct aom_write_bit_buffer *wb) {
return (wb->bit_offset % CHAR_BIT == 0);
@ -85,3 +87,55 @@ void aom_wb_write_uvlc(struct aom_write_bit_buffer *wb, uint32_t v) {
aom_wb_write_literal(wb, 0, leading_zeroes >> 1);
aom_wb_write_unsigned_literal(wb, v, (leading_zeroes + 1) >> 1);
}
static void wb_write_primitive_quniform(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t v) {
if (n <= 1) return;
const int l = get_msb(n) + 1;
const int m = (1 << l) - n;
if (v < m) {
aom_wb_write_literal(wb, v, l - 1);
} else {
aom_wb_write_literal(wb, m + ((v - m) >> 1), l - 1);
aom_wb_write_bit(wb, (v - m) & 1);
}
}
static void wb_write_primitive_subexpfin(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t k, uint16_t v) {
int i = 0;
int mk = 0;
while (1) {
int b = (i ? k + i - 1 : k);
int a = (1 << b);
if (n <= mk + 3 * a) {
wb_write_primitive_quniform(wb, n - mk, v - mk);
break;
} else {
int t = (v >= mk + a);
aom_wb_write_bit(wb, t);
if (t) {
i = i + 1;
mk += a;
} else {
aom_wb_write_literal(wb, v - mk, b);
break;
}
}
}
}
static void wb_write_primitive_refsubexpfin(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t k,
uint16_t ref, uint16_t v) {
wb_write_primitive_subexpfin(wb, n, k, recenter_finite_nonneg(n, ref, v));
}
void aom_wb_write_signed_primitive_refsubexpfin(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t k,
int16_t ref, int16_t v) {
ref += n - 1;
v += n - 1;
const uint16_t scaled_n = (n << 1) - 1;
wb_write_primitive_refsubexpfin(wb, scaled_n, k, ref, v);
}

View file

@ -44,6 +44,10 @@ void aom_wb_write_inv_signed_literal(struct aom_write_bit_buffer *wb, int data,
void aom_wb_write_uvlc(struct aom_write_bit_buffer *wb, uint32_t v);
void aom_wb_write_signed_primitive_refsubexpfin(struct aom_write_bit_buffer *wb,
uint16_t n, uint16_t k,
int16_t ref, int16_t v);
#ifdef __cplusplus
} // extern "C"
#endif

View file

@ -40,6 +40,7 @@ void aom_blend_a64_hmask_c(uint8_t *dst, uint32_t dst_stride,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_blend_a64_hmask_c(uint8_t *dst_8, uint32_t dst_stride,
const uint8_t *src0_8, uint32_t src0_stride,
const uint8_t *src1_8, uint32_t src1_stride,
@ -67,3 +68,4 @@ void aom_highbd_blend_a64_hmask_c(uint8_t *dst_8, uint32_t dst_stride,
}
}
}
#endif

View file

@ -22,7 +22,7 @@
// as described for AOM_BLEND_A64 in aom_dsp/blend.h. src0 or src1 can
// be the same as dst, or dst can be different from both sources.
// NOTE(david.barker): The input and output of aom_blend_a64_d32_mask_c() are
// NOTE(david.barker): The input and output of aom_blend_a64_d16_mask_c() are
// in a higher intermediate precision, and will later be rounded down to pixel
// precision.
// Thus, in order to avoid double-rounding, we want to use normal right shifts
@ -30,7 +30,7 @@
// This works because of the identity:
// ROUND_POWER_OF_TWO(x >> y, z) == ROUND_POWER_OF_TWO(x, y+z)
//
// In contrast, the output of the non-d32 functions will not be further rounded,
// In contrast, the output of the non-d16 functions will not be further rounded,
// so we *should* use ROUND_POWER_OF_TWO there.
void aom_lowbd_blend_a64_d16_mask_c(
@ -120,6 +120,7 @@ void aom_lowbd_blend_a64_d16_mask_c(
}
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_blend_a64_d16_mask_c(
uint8_t *dst_8, uint32_t dst_stride, const CONV_BUF_TYPE *src0,
uint32_t src0_stride, const CONV_BUF_TYPE *src1, uint32_t src1_stride,
@ -219,6 +220,7 @@ void aom_highbd_blend_a64_d16_mask_c(
}
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH
// Blending with alpha mask. Mask values come from the range [0, 64],
// as described for AOM_BLEND_A64 in aom_dsp/blend.h. src0 or src1 can
@ -281,6 +283,7 @@ void aom_blend_a64_mask_c(uint8_t *dst, uint32_t dst_stride,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_blend_a64_mask_c(uint8_t *dst_8, uint32_t dst_stride,
const uint8_t *src0_8, uint32_t src0_stride,
const uint8_t *src1_8, uint32_t src1_stride,
@ -343,3 +346,4 @@ void aom_highbd_blend_a64_mask_c(uint8_t *dst_8, uint32_t dst_stride,
}
}
}
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -41,6 +41,7 @@ void aom_blend_a64_vmask_c(uint8_t *dst, uint32_t dst_stride,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_blend_a64_vmask_c(uint8_t *dst_8, uint32_t dst_stride,
const uint8_t *src0_8, uint32_t src0_stride,
const uint8_t *src1_8, uint32_t src1_stride,
@ -69,3 +70,4 @@ void aom_highbd_blend_a64_vmask_c(uint8_t *dst_8, uint32_t dst_stride,
}
}
}
#endif

View file

@ -0,0 +1,26 @@
/*
* Copyright (c) 2019, 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.
*/
#include "config/aom_dsp_rtcd.h"
void aom_get_blk_sse_sum_c(const int16_t *data, int stride, int bw, int bh,
int *x_sum, int64_t *x2_sum) {
*x_sum = 0;
*x2_sum = 0;
for (int i = 0; i < bh; ++i) {
for (int j = 0; j < bw; ++j) {
const int val = data[j];
*x_sum += val;
*x2_sum += val * val;
}
data += stride;
}
}

View file

@ -1,70 +0,0 @@
/*
* 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.
*/
#include <string.h>
#include "aom_dsp/buf_ans.h"
#include "aom_mem/aom_mem.h"
#include "aom/internal/aom_codec_internal.h"
void aom_buf_ans_alloc(struct BufAnsCoder *c,
struct aom_internal_error_info *error) {
c->error = error;
assert(c->size > 1);
AOM_CHECK_MEM_ERROR(error, c->buf, aom_malloc(c->size * sizeof(*c->buf)));
// Initialize to overfull to trigger the assert in write.
c->offset = c->size + 1;
}
void aom_buf_ans_free(struct BufAnsCoder *c) {
aom_free(c->buf);
c->buf = NULL;
c->size = 0;
}
#if !ANS_MAX_SYMBOLS
void aom_buf_ans_grow(struct BufAnsCoder *c) {
struct buffered_ans_symbol *new_buf = NULL;
int new_size = c->size * 2;
AOM_CHECK_MEM_ERROR(c->error, new_buf,
aom_malloc(new_size * sizeof(*new_buf)));
memcpy(new_buf, c->buf, c->size * sizeof(*c->buf));
aom_free(c->buf);
c->buf = new_buf;
c->size = new_size;
}
#endif
void aom_buf_ans_flush(struct BufAnsCoder *const c) {
int offset;
#if ANS_MAX_SYMBOLS
if (c->offset == 0) return;
#endif
assert(c->offset > 0);
offset = c->offset - 1;
// Code the first symbol such that it brings the state to the smallest normal
// state from an initial state that would have been a subnormal/refill state.
if (c->buf[offset].method == ANS_METHOD_RANS) {
c->ans.state += c->buf[offset].val_start;
} else {
c->ans.state += c->buf[offset].val_start ? c->buf[offset].prob : 0;
}
for (offset = offset - 1; offset >= 0; --offset) {
if (c->buf[offset].method == ANS_METHOD_RANS) {
rans_write(&c->ans, c->buf[offset].val_start, c->buf[offset].prob);
} else {
rabs_write(&c->ans, (uint8_t)c->buf[offset].val_start,
(AnsP8)c->buf[offset].prob);
}
}
c->offset = 0;
c->output_bytes += ans_write_end(&c->ans);
}

View file

@ -1,136 +0,0 @@
/*
* 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_DSP_BUF_ANS_H_
#define AOM_AOM_DSP_BUF_ANS_H_
// Buffered forward ANS writer.
// Symbols are written to the writer in forward (decode) order and serialized
// backwards due to ANS's stack like behavior.
#include <assert.h>
#include "config/aom_config.h"
#include "aom/aom_integer.h"
#include "aom_dsp/ans.h"
#include "aom_dsp/answriter.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#define ANS_METHOD_RABS 0
#define ANS_METHOD_RANS 1
struct buffered_ans_symbol {
unsigned int method : 1; // one of ANS_METHOD_RABS or ANS_METHOD_RANS
// TODO(aconverse): Should be possible to write this in terms of start for ABS
unsigned int val_start : RANS_PROB_BITS; // Boolean value for ABS
// start in symbol cycle for Rans
unsigned int prob : RANS_PROB_BITS; // Probability of this symbol
};
struct BufAnsCoder {
struct aom_internal_error_info *error;
struct buffered_ans_symbol *buf;
struct AnsCoder ans;
int size;
int offset;
int output_bytes;
#if ANS_MAX_SYMBOLS
int window_size;
#endif
int pos; // Dummy variable to store the output buffer after closing
uint8_t allow_update_cdf;
};
// Allocate a buffered ANS coder to store size symbols.
// When ANS_MAX_SYMBOLS is turned on, the size is the fixed size of each ANS
// partition.
// When ANS_MAX_SYMBOLS is turned off, size is merely an initial hint and the
// buffer will grow on demand
void aom_buf_ans_alloc(struct BufAnsCoder *c,
struct aom_internal_error_info *error);
void aom_buf_ans_free(struct BufAnsCoder *c);
#if !ANS_MAX_SYMBOLS
void aom_buf_ans_grow(struct BufAnsCoder *c);
#endif
void aom_buf_ans_flush(struct BufAnsCoder *const c);
static INLINE void buf_ans_write_init(struct BufAnsCoder *const c,
uint8_t *const output_buffer) {
c->offset = 0;
c->output_bytes = 0;
ans_write_init(&c->ans, output_buffer);
}
static INLINE void buf_rabs_write(struct BufAnsCoder *const c, uint8_t val,
AnsP8 prob) {
assert(c->offset <= c->size);
#if !ANS_MAX_SYMBOLS
if (c->offset == c->size) {
aom_buf_ans_grow(c);
}
#endif
c->buf[c->offset].method = ANS_METHOD_RABS;
c->buf[c->offset].val_start = val;
c->buf[c->offset].prob = prob;
++c->offset;
#if ANS_MAX_SYMBOLS
if (c->offset == c->size) aom_buf_ans_flush(c);
#endif
}
// Buffer one symbol for encoding using rANS.
// cum_prob: The cumulative probability before this symbol (the offset of
// the symbol in the symbol cycle)
// prob: The probability of this symbol (l_s from the paper)
// RANS_PRECISION takes the place of m from the paper.
static INLINE void buf_rans_write(struct BufAnsCoder *const c,
aom_cdf_prob cum_prob, aom_cdf_prob prob) {
assert(c->offset <= c->size);
#if !ANS_MAX_SYMBOLS
if (c->offset == c->size) {
aom_buf_ans_grow(c);
}
#endif
c->buf[c->offset].method = ANS_METHOD_RANS;
c->buf[c->offset].val_start = cum_prob;
c->buf[c->offset].prob = prob;
++c->offset;
#if ANS_MAX_SYMBOLS
if (c->offset == c->size) aom_buf_ans_flush(c);
#endif
}
static INLINE void buf_rabs_write_bit(struct BufAnsCoder *c, int bit) {
buf_rabs_write(c, bit, 128);
}
static INLINE void buf_rabs_write_literal(struct BufAnsCoder *c, int literal,
int bits) {
int bit;
assert(bits < 31);
for (bit = bits - 1; bit >= 0; bit--)
buf_rabs_write_bit(c, 1 & (literal >> bit));
}
static INLINE int buf_ans_write_end(struct BufAnsCoder *const c) {
assert(c->offset == 0);
return c->output_bytes;
}
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // AOM_AOM_DSP_BUF_ANS_H_

View file

@ -1,160 +0,0 @@
/*
* 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_DSP_DAALABOOLREADER_H_
#define AOM_AOM_DSP_DAALABOOLREADER_H_
#include "aom/aom_integer.h"
#include "aom_dsp/entdec.h"
#include "aom_dsp/prob.h"
#if CONFIG_ACCOUNTING
#include "av1/decoder/accounting.h"
#endif
#if CONFIG_BITSTREAM_DEBUG
#include <stdio.h>
#include "aom_util/debug_util.h"
#endif // CONFIG_BITSTREAM_DEBUG
#ifdef __cplusplus
extern "C" {
#endif
struct daala_reader {
const uint8_t *buffer;
const uint8_t *buffer_end;
od_ec_dec ec;
#if CONFIG_ACCOUNTING
Accounting *accounting;
#endif
uint8_t allow_update_cdf;
};
typedef struct daala_reader daala_reader;
int aom_daala_reader_init(daala_reader *r, const uint8_t *buffer, int size);
const uint8_t *aom_daala_reader_find_begin(daala_reader *r);
const uint8_t *aom_daala_reader_find_end(daala_reader *r);
uint32_t aom_daala_reader_tell(const daala_reader *r);
uint32_t aom_daala_reader_tell_frac(const daala_reader *r);
// Returns true if the reader has tried to decode more data from the buffer
// than was actually provided.
int aom_daala_reader_has_overflowed(const daala_reader *r);
static INLINE int aom_daala_read(daala_reader *r, int prob) {
int bit;
int p = (0x7FFFFF - (prob << 15) + prob) >> 8;
#if CONFIG_BITSTREAM_DEBUG
/*{
const int queue_r = bitstream_queue_get_read();
const int frame_idx = bitstream_queue_get_frame_read();
if (frame_idx == 0 && queue_r == 0) {
fprintf(stderr, "\n *** bitstream queue at frame_idx_r %d queue_r %d\n",
frame_idx, queue_r);
}
}*/
#endif
bit = od_ec_decode_bool_q15(&r->ec, p);
#if CONFIG_BITSTREAM_DEBUG
{
int i;
int ref_bit, ref_nsymbs;
aom_cdf_prob ref_cdf[16];
const int queue_r = bitstream_queue_get_read();
const int frame_idx = bitstream_queue_get_frame_read();
bitstream_queue_pop(&ref_bit, ref_cdf, &ref_nsymbs);
if (ref_nsymbs != 2) {
fprintf(stderr,
"\n *** [bit] nsymbs error, frame_idx_r %d nsymbs %d ref_nsymbs "
"%d queue_r %d\n",
frame_idx, 2, ref_nsymbs, queue_r);
assert(0);
}
if ((ref_nsymbs != 2) || (ref_cdf[0] != (aom_cdf_prob)p) ||
(ref_cdf[1] != 32767)) {
fprintf(stderr,
"\n *** [bit] cdf error, frame_idx_r %d cdf {%d, %d} ref_cdf {%d",
frame_idx, p, 32767, ref_cdf[0]);
for (i = 1; i < ref_nsymbs; ++i) fprintf(stderr, ", %d", ref_cdf[i]);
fprintf(stderr, "} queue_r %d\n", queue_r);
assert(0);
}
if (bit != ref_bit) {
fprintf(stderr,
"\n *** [bit] symb error, frame_idx_r %d symb %d ref_symb %d "
"queue_r %d\n",
frame_idx, bit, ref_bit, queue_r);
assert(0);
}
}
#endif
return bit;
}
static INLINE int aom_daala_reader_has_error(daala_reader *r) {
return r->ec.error;
}
static INLINE int daala_read_symbol(daala_reader *r, const aom_cdf_prob *cdf,
int nsymbs) {
int symb;
assert(cdf != NULL);
symb = od_ec_decode_cdf_q15(&r->ec, cdf, nsymbs);
#if CONFIG_BITSTREAM_DEBUG
{
int i;
int cdf_error = 0;
int ref_symb, ref_nsymbs;
aom_cdf_prob ref_cdf[16];
const int queue_r = bitstream_queue_get_read();
const int frame_idx = bitstream_queue_get_frame_read();
bitstream_queue_pop(&ref_symb, ref_cdf, &ref_nsymbs);
if (nsymbs != ref_nsymbs) {
fprintf(stderr,
"\n *** nsymbs error, frame_idx_r %d nsymbs %d ref_nsymbs %d "
"queue_r %d\n",
frame_idx, nsymbs, ref_nsymbs, queue_r);
cdf_error = 0;
assert(0);
} else {
for (i = 0; i < nsymbs; ++i)
if (cdf[i] != ref_cdf[i]) cdf_error = 1;
}
if (cdf_error) {
fprintf(stderr, "\n *** cdf error, frame_idx_r %d cdf {%d", frame_idx,
cdf[0]);
for (i = 1; i < nsymbs; ++i) fprintf(stderr, ", %d", cdf[i]);
fprintf(stderr, "} ref_cdf {%d", ref_cdf[0]);
for (i = 1; i < ref_nsymbs; ++i) fprintf(stderr, ", %d", ref_cdf[i]);
fprintf(stderr, "} queue_r %d\n", queue_r);
assert(0);
}
if (symb != ref_symb) {
fprintf(
stderr,
"\n *** symb error, frame_idx_r %d symb %d ref_symb %d queue_r %d\n",
frame_idx, symb, ref_symb, queue_r);
assert(0);
}
}
#endif
return symb;
}
#ifdef __cplusplus
} // extern "C"
#endif
#endif // AOM_AOM_DSP_DAALABOOLREADER_H_

View file

@ -1,78 +0,0 @@
/*
* 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_DSP_DAALABOOLWRITER_H_
#define AOM_AOM_DSP_DAALABOOLWRITER_H_
#include <stdio.h>
#include "aom_dsp/entenc.h"
#include "aom_dsp/prob.h"
#if CONFIG_BITSTREAM_DEBUG
#include "aom_util/debug_util.h"
#endif // CONFIG_BITSTREAM_DEBUG
#ifdef __cplusplus
extern "C" {
#endif
struct daala_writer {
unsigned int pos;
uint8_t *buffer;
od_ec_enc ec;
uint8_t allow_update_cdf;
};
typedef struct daala_writer daala_writer;
void aom_daala_start_encode(daala_writer *w, uint8_t *buffer);
int aom_daala_stop_encode(daala_writer *w);
static INLINE void aom_daala_write(daala_writer *w, int bit, int prob) {
int p = (0x7FFFFF - (prob << 15) + prob) >> 8;
#if CONFIG_BITSTREAM_DEBUG
aom_cdf_prob cdf[2] = { (aom_cdf_prob)p, 32767 };
/*int queue_r = 0;
int frame_idx_r = 0;
int queue_w = bitstream_queue_get_write();
int frame_idx_w = bitstream_queue_get_frame_write();
if (frame_idx_w == frame_idx_r && queue_w == queue_r) {
fprintf(stderr, "\n *** bitstream queue at frame_idx_w %d queue_w %d\n",
frame_idx_w, queue_w);
}*/
bitstream_queue_push(bit, cdf, 2);
#endif
od_ec_encode_bool_q15(&w->ec, bit, p);
}
static INLINE void daala_write_symbol(daala_writer *w, int symb,
const aom_cdf_prob *cdf, int nsymbs) {
#if CONFIG_BITSTREAM_DEBUG
/*int queue_r = 0;
int frame_idx_r = 0;
int queue_w = bitstream_queue_get_write();
int frame_idx_w = bitstream_queue_get_frame_write();
if (frame_idx_w == frame_idx_r && queue_w == queue_r) {
fprintf(stderr, "\n *** bitstream queue at frame_idx_w %d queue_w %d\n",
frame_idx_w, queue_w);
}*/
bitstream_queue_push(symb, cdf, nsymbs);
#endif
od_ec_encode_cdf_q15(&w->ec, symb, cdf, nsymbs);
}
#ifdef __cplusplus
} // extern "C"
#endif
#endif // AOM_AOM_DSP_DAALABOOLWRITER_H_

View file

@ -24,6 +24,7 @@
on a larger type, you can speed up the decoder by using it here.*/
typedef uint32_t od_ec_window;
/*The size in bits of od_ec_window.*/
#define OD_EC_WINDOW_SIZE ((int)sizeof(od_ec_window) * CHAR_BIT)
/*The resolution of fractional-precision bit usage measurements, i.e.,

View file

@ -87,11 +87,25 @@ static void od_ec_dec_refill(od_ec_dec *dec) {
end = dec->end;
s = OD_EC_WINDOW_SIZE - 9 - (cnt + 15);
for (; s >= 0 && bptr < end; s -= 8, bptr++) {
/*Each time a byte is inserted into the window (dif), bptr advances and cnt
is incremented by 8, so the total number of consumed bits (the return
value of od_ec_dec_tell) does not change.*/
assert(s <= OD_EC_WINDOW_SIZE - 8);
dif ^= (od_ec_window)bptr[0] << s;
cnt += 8;
}
if (bptr >= end) {
/*We've reached the end of the buffer. It is perfectly valid for us to need
to fill the window with additional bits past the end of the buffer (and
this happens in normal operation). These bits should all just be taken
as zero. But we cannot increment bptr past 'end' (this is undefined
behavior), so we start to increment dec->tell_offs. We also don't want
to keep testing bptr against 'end', so we set cnt to OD_EC_LOTS_OF_BITS
and adjust dec->tell_offs so that the total number of unconsumed bits in
the window (dec->cnt - dec->tell_offs) does not change. This effectively
puts lots of zero bits into the window, and means we won't try to refill
it from the buffer for a very long time (at which point we'll put lots
of zero bits into the window again).*/
dec->tell_offs += OD_EC_LOTS_OF_BITS - cnt;
cnt = OD_EC_LOTS_OF_BITS;
}
@ -112,8 +126,9 @@ static int od_ec_dec_normalize(od_ec_dec *dec, od_ec_window dif, unsigned rng,
int ret) {
int d;
assert(rng <= 65535U);
// The number of leading zeros in the 16-bit binary representation of rng.
/*The number of leading zeros in the 16-bit binary representation of rng.*/
d = 16 - OD_ILOG_NZ(rng);
/*d bits in dec->dif are consumed.*/
dec->cnt -= d;
/*This is equivalent to shifting in 1's instead of 0's.*/
dec->dif = ((dif + 1) << d) - 1;
@ -124,7 +139,7 @@ static int od_ec_dec_normalize(od_ec_dec *dec, od_ec_window dif, unsigned rng,
/*Initializes the decoder.
buf: The input buffer to use.
Return: 0 on success, or a negative value on error.*/
storage: The size in bytes of the input buffer.*/
void od_ec_dec_init(od_ec_dec *dec, const unsigned char *buf,
uint32_t storage) {
dec->buf = buf;
@ -134,7 +149,6 @@ void od_ec_dec_init(od_ec_dec *dec, const unsigned char *buf,
dec->dif = ((od_ec_window)1 << (OD_EC_WINDOW_SIZE - 1)) - 1;
dec->rng = 0x8000;
dec->cnt = -15;
dec->error = 0;
od_ec_dec_refill(dec);
}
@ -215,6 +229,10 @@ int od_ec_decode_cdf_q15(od_ec_dec *dec, const uint16_t *icdf, int nsyms) {
This will always be slightly larger than the exact value (e.g., all
rounding error is in the positive direction).*/
int od_ec_dec_tell(const od_ec_dec *dec) {
/*There is a window of bits stored in dec->dif. The difference
(dec->bptr - dec->buf) tells us how many bytes have been read into this
window. The difference (dec->cnt - dec->tell_offs) tells us how many of
the bits in that window remain unconsumed.*/
return (int)((dec->bptr - dec->buf) * 8 - dec->cnt + dec->tell_offs);
}

View file

@ -34,7 +34,7 @@ struct od_ec_dec {
const unsigned char *buf;
/*An offset used to keep track of tell after reaching the end of the stream.
This is constant throughout most of the decoding process, but becomes
important once we hit the end of the buffer and stop incrementing pointers
important once we hit the end of the buffer and stop incrementing bptr
(and instead pretend cnt has lots of bits).*/
int32_t tell_offs;
/*The end of the current input buffer.*/
@ -53,8 +53,6 @@ struct od_ec_dec {
uint16_t rng;
/*The number of bits of data in the current value.*/
int16_t cnt;
/*Nonzero if an error occurred.*/
int error;
};
/*See entdec.c for further documentation.*/

View file

@ -60,7 +60,7 @@ static void od_ec_enc_normalize(od_ec_enc *enc, od_ec_window low,
int s;
c = enc->cnt;
assert(rng <= 65535U);
// The number of leading zeros in the 16-bit binary representation of rng.
/*The number of leading zeros in the 16-bit binary representation of rng.*/
d = 16 - OD_ILOG_NZ(rng);
s = c + d;
/*TODO: Right now we flush every time we have at least one byte available.

View file

@ -13,6 +13,130 @@
#include "aom_dsp/txfm_common.h"
#include "config/aom_dsp_rtcd.h"
void aom_fdct4x4_c(const int16_t *input, tran_low_t *output, int stride) {
// The 2D transform is done with two passes which are actually pretty
// similar. In the first one, we transform the columns and transpose
// the results. In the second one, we transform the rows. To achieve that,
// as the first pass results are transposed, we transpose the columns (that
// is the transposed rows) and transpose the results (so that it goes back
// in normal/row positions).
// We need an intermediate buffer between passes.
tran_low_t intermediate[4 * 4];
const tran_low_t *in_low = NULL;
tran_low_t *out = intermediate;
// Do the two transform/transpose passes
for (int pass = 0; pass < 2; ++pass) {
tran_high_t in_high[4]; // canbe16
tran_high_t step[4]; // canbe16
tran_high_t temp1, temp2; // needs32
for (int i = 0; i < 4; ++i) {
// Load inputs.
if (pass == 0) {
in_high[0] = input[0 * stride] * 16;
in_high[1] = input[1 * stride] * 16;
in_high[2] = input[2 * stride] * 16;
in_high[3] = input[3 * stride] * 16;
if (i == 0 && in_high[0]) {
++in_high[0];
}
} else {
assert(in_low != NULL);
in_high[0] = in_low[0 * 4];
in_high[1] = in_low[1 * 4];
in_high[2] = in_low[2 * 4];
in_high[3] = in_low[3 * 4];
++in_low;
}
// Transform.
step[0] = in_high[0] + in_high[3];
step[1] = in_high[1] + in_high[2];
step[2] = in_high[1] - in_high[2];
step[3] = in_high[0] - in_high[3];
temp1 = (step[0] + step[1]) * cospi_16_64;
temp2 = (step[0] - step[1]) * cospi_16_64;
out[0] = (tran_low_t)fdct_round_shift(temp1);
out[2] = (tran_low_t)fdct_round_shift(temp2);
temp1 = step[2] * cospi_24_64 + step[3] * cospi_8_64;
temp2 = -step[2] * cospi_8_64 + step[3] * cospi_24_64;
out[1] = (tran_low_t)fdct_round_shift(temp1);
out[3] = (tran_low_t)fdct_round_shift(temp2);
// Do next column (which is a transposed row in second/horizontal pass)
++input;
out += 4;
}
// Setup in/out for next pass.
in_low = intermediate;
out = output;
}
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j)
output[j + i * 4] = (output[j + i * 4] + 1) >> 2;
}
}
void aom_fdct4x4_lp_c(const int16_t *input, int16_t *output, int stride) {
// The 2D transform is done with two passes which are actually pretty
// similar. In the first one, we transform the columns and transpose
// the results. In the second one, we transform the rows. To achieve that,
// as the first pass results are transposed, we transpose the columns (that
// is the transposed rows) and transpose the results (so that it goes back
// in normal/row positions).
// We need an intermediate buffer between passes.
int16_t intermediate[4 * 4];
const int16_t *in_low = NULL;
int16_t *out = intermediate;
// Do the two transform/transpose passes
for (int pass = 0; pass < 2; ++pass) {
int32_t in_high[4]; // canbe16
int32_t step[4]; // canbe16
int32_t temp1, temp2; // needs32
for (int i = 0; i < 4; ++i) {
// Load inputs.
if (pass == 0) {
in_high[0] = input[0 * stride] * 16;
in_high[1] = input[1 * stride] * 16;
in_high[2] = input[2 * stride] * 16;
in_high[3] = input[3 * stride] * 16;
if (i == 0 && in_high[0]) {
++in_high[0];
}
} else {
assert(in_low != NULL);
in_high[0] = in_low[0 * 4];
in_high[1] = in_low[1 * 4];
in_high[2] = in_low[2 * 4];
in_high[3] = in_low[3 * 4];
++in_low;
}
// Transform.
step[0] = in_high[0] + in_high[3];
step[1] = in_high[1] + in_high[2];
step[2] = in_high[1] - in_high[2];
step[3] = in_high[0] - in_high[3];
temp1 = (step[0] + step[1]) * (int32_t)cospi_16_64;
temp2 = (step[0] - step[1]) * (int32_t)cospi_16_64;
out[0] = (int16_t)fdct_round_shift(temp1);
out[2] = (int16_t)fdct_round_shift(temp2);
temp1 = step[2] * (int32_t)cospi_24_64 + step[3] * (int32_t)cospi_8_64;
temp2 = -step[2] * (int32_t)cospi_8_64 + step[3] * (int32_t)cospi_24_64;
out[1] = (int16_t)fdct_round_shift(temp1);
out[3] = (int16_t)fdct_round_shift(temp2);
// Do next column (which is a transposed row in second/horizontal pass)
++input;
out += 4;
}
// Setup in/out for next pass.
in_low = intermediate;
out = output;
}
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j)
output[j + i * 4] = (output[j + i * 4] + 1) >> 2;
}
}
void aom_fdct8x8_c(const int16_t *input, tran_low_t *final_output, int stride) {
int i, j;
tran_low_t intermediate[64];
@ -97,7 +221,9 @@ void aom_fdct8x8_c(const int16_t *input, tran_low_t *final_output, int stride) {
}
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_fdct8x8_c(const int16_t *input, tran_low_t *final_output,
int stride) {
aom_fdct8x8_c(input, final_output, stride);
}
#endif

View file

@ -232,7 +232,6 @@ static int scaling_lut_y[256];
static int scaling_lut_cb[256];
static int scaling_lut_cr[256];
static int grain_center;
static int grain_min;
static int grain_max;
@ -1077,9 +1076,9 @@ int av1_add_film_grain_run(const aom_film_grain_t *params, uint8_t *luma,
int overlap = params->overlap_flag;
int bit_depth = params->bit_depth;
grain_center = 128 << (bit_depth - 8);
const int grain_center = 128 << (bit_depth - 8);
grain_min = 0 - grain_center;
grain_max = (256 << (bit_depth - 8)) - 1 - grain_center;
grain_max = grain_center - 1;
init_arrays(params, luma_stride, chroma_stride, &pred_pos_luma,
&pred_pos_chroma, &luma_grain_block, &cb_grain_block,

View file

@ -20,6 +20,8 @@
extern "C" {
#endif
#include <string.h>
#include "aom_dsp/aom_dsp_common.h"
#include "aom/aom_image.h"
@ -28,6 +30,9 @@ extern "C" {
* This structure contains input parameters for film grain synthesis
*/
typedef struct {
// This structure is compared element-by-element in the function
// av1_check_grain_params_equiv: this function must be updated if any changes
// are made to this structure.
int apply_grain;
int update_parameters;
@ -79,8 +84,73 @@ typedef struct {
int grain_scale_shift;
uint16_t random_seed;
// This structure is compared element-by-element in the function
// av1_check_grain_params_equiv: this function must be updated if any changes
// are made to this structure.
} aom_film_grain_t;
/*!\brief Check if two film grain parameters structs are equivalent
*
* Check if two film grain parameters are equal, except for the
* update_parameters and random_seed elements which are ignored.
*
* \param[in] pa The first set of parameters to compare
* \param[in] pb The second set of parameters to compare
* \return Returns 1 if the params are equivalent, 0 otherwise
*/
static INLINE int av1_check_grain_params_equiv(
const aom_film_grain_t *const pa, const aom_film_grain_t *const pb) {
if (pa->apply_grain != pb->apply_grain) return 0;
// Don't compare update_parameters
if (pa->num_y_points != pb->num_y_points) return 0;
if (memcmp(pa->scaling_points_y, pb->scaling_points_y,
pa->num_y_points * 2 * sizeof(*pa->scaling_points_y)) != 0)
return 0;
if (pa->num_cb_points != pb->num_cb_points) return 0;
if (memcmp(pa->scaling_points_cb, pb->scaling_points_cb,
pa->num_cb_points * 2 * sizeof(*pa->scaling_points_cb)) != 0)
return 0;
if (pa->num_cr_points != pb->num_cr_points) return 0;
if (memcmp(pa->scaling_points_cr, pb->scaling_points_cr,
pa->num_cr_points * 2 * sizeof(*pa->scaling_points_cr)) != 0)
return 0;
if (pa->scaling_shift != pb->scaling_shift) return 0;
if (pa->ar_coeff_lag != pb->ar_coeff_lag) return 0;
const int num_pos = 2 * pa->ar_coeff_lag * (pa->ar_coeff_lag + 1);
if (memcmp(pa->ar_coeffs_y, pb->ar_coeffs_y,
num_pos * sizeof(*pa->ar_coeffs_y)) != 0)
return 0;
if (memcmp(pa->ar_coeffs_cb, pb->ar_coeffs_cb,
num_pos * sizeof(*pa->ar_coeffs_cb)) != 0)
return 0;
if (memcmp(pa->ar_coeffs_cr, pb->ar_coeffs_cr,
num_pos * sizeof(*pa->ar_coeffs_cr)) != 0)
return 0;
if (pa->ar_coeff_shift != pb->ar_coeff_shift) return 0;
if (pa->cb_mult != pb->cb_mult) return 0;
if (pa->cb_luma_mult != pb->cb_luma_mult) return 0;
if (pa->cb_offset != pb->cb_offset) return 0;
if (pa->cr_mult != pb->cr_mult) return 0;
if (pa->cr_luma_mult != pb->cr_luma_mult) return 0;
if (pa->cr_offset != pb->cr_offset) return 0;
if (pa->overlap_flag != pb->overlap_flag) return 0;
if (pa->clip_to_restricted_range != pb->clip_to_restricted_range) return 0;
if (pa->bit_depth != pb->bit_depth) return 0;
if (pa->chroma_scaling_from_luma != pb->chroma_scaling_from_luma) return 0;
if (pa->grain_scale_shift != pb->grain_scale_shift) return 0;
return 1;
}
/*!\brief Add film grain
*
* Add film grain to an image

View file

@ -134,7 +134,8 @@ static void grain_table_entry_read(FILE *file,
}
}
void grain_table_entry_write(FILE *file, aom_film_grain_table_entry_t *entry) {
static void grain_table_entry_write(FILE *file,
aom_film_grain_table_entry_t *entry) {
const aom_film_grain_t *pars = &entry->params;
fprintf(file, "E %" PRId64 " %" PRId64 " %d %d %d\n", entry->start_time,
entry->end_time, pars->apply_grain, pars->random_seed,
@ -202,7 +203,7 @@ int aom_film_grain_table_lookup(aom_film_grain_table_t *t, int64_t time_stamp,
aom_film_grain_t *grain) {
aom_film_grain_table_entry_t *entry = t->head;
aom_film_grain_table_entry_t *prev_entry = 0;
int16_t random_seed = grain ? grain->random_seed : 0;
uint16_t random_seed = grain ? grain->random_seed : 0;
if (grain) memset(grain, 0, sizeof(*grain));
while (entry) {

View file

@ -239,23 +239,23 @@ static INLINE int divide_using_multiply_shift(int num, int shift1,
return interm * multiplier >> shift2;
}
// The constants (multiplier and shifts) for a given block size are obtained
// as follows:
// - Let sum_w_h = block width + block height.
// - Shift 'sum_w_h' right until we reach an odd number. Let the number of
// shifts for that block size be called 'shift1' (see the parameter in
// dc_predictor_rect() function), and let the odd number be 'd'. [d has only 2
// possible values: d = 3 for a 1:2 rect block and d = 5 for a 1:4 rect
// block].
// - Find multipliers for (i) dividing by 3, and (ii) dividing by 5,
// using the "Algorithm 1" in:
// http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=1467632
// by ensuring that m + n = 16 (in that algorithm). This ensures that our 2nd
// shift will be 16, regardless of the block size.
// The constants (multiplier and shifts) for a given block size are obtained
// as follows:
// - Let sum_w_h = block width + block height.
// - Shift 'sum_w_h' right until we reach an odd number. Let the number of
// shifts for that block size be called 'shift1' (see the parameter in
// dc_predictor_rect() function), and let the odd number be 'd'. [d has only 2
// possible values: d = 3 for a 1:2 rect block and d = 5 for a 1:4 rect
// block].
// - Find multipliers for (i) dividing by 3, and (ii) dividing by 5,
// using the "Algorithm 1" in:
// http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=1467632
// by ensuring that m + n = 16 (in that algorithm). This ensures that our 2nd
// shift will be 16, regardless of the block size.
// Note: For low bitdepth, assembly code may be optimized by using smaller
// constants for smaller block sizes, where the range of the 'sum' is
// restricted to fewer bits.
// Note: For low bitdepth, assembly code may be optimized by using smaller
// constants for smaller block sizes, where the range of the 'sum' is
// restricted to fewer bits.
#define DC_MULTIPLIER_1X2 0x5556
#define DC_MULTIPLIER_1X4 0x3334

View file

@ -21,6 +21,7 @@ static INLINE int8_t signed_char_clamp(int t) {
return (int8_t)clamp(t, -128, 127);
}
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE int16_t signed_char_clamp_high(int t, int bd) {
switch (bd) {
case 10: return (int16_t)clamp(t, -128 * 4, 128 * 4 - 1);
@ -29,6 +30,7 @@ static INLINE int16_t signed_char_clamp_high(int t, int bd) {
default: return (int16_t)clamp(t, -128, 128 - 1);
}
}
#endif
// should we apply any filter at all: 11111111 yes, 00000000 no
static INLINE int8_t filter_mask2(uint8_t limit, uint8_t blimit, uint8_t p1,
@ -103,11 +105,11 @@ static INLINE void filter4(int8_t mask, uint8_t thresh, uint8_t *op1,
uint8_t *op0, uint8_t *oq0, uint8_t *oq1) {
int8_t filter1, filter2;
const int8_t ps1 = (int8_t)*op1 ^ 0x80;
const int8_t ps0 = (int8_t)*op0 ^ 0x80;
const int8_t qs0 = (int8_t)*oq0 ^ 0x80;
const int8_t qs1 = (int8_t)*oq1 ^ 0x80;
const uint8_t hev = hev_mask(thresh, *op1, *op0, *oq0, *oq1);
const int8_t ps1 = (int8_t)(*op1 ^ 0x80);
const int8_t ps0 = (int8_t)(*op0 ^ 0x80);
const int8_t qs0 = (int8_t)(*oq0 ^ 0x80);
const int8_t qs1 = (int8_t)(*oq1 ^ 0x80);
const int8_t hev = hev_mask(thresh, *op1, *op0, *oq0, *oq1);
// add outer taps if we have high edge variance
int8_t filter = signed_char_clamp(ps1 - qs1) & hev;
@ -121,14 +123,14 @@ static INLINE void filter4(int8_t mask, uint8_t thresh, uint8_t *op1,
filter1 = signed_char_clamp(filter + 4) >> 3;
filter2 = signed_char_clamp(filter + 3) >> 3;
*oq0 = signed_char_clamp(qs0 - filter1) ^ 0x80;
*op0 = signed_char_clamp(ps0 + filter2) ^ 0x80;
*oq0 = (uint8_t)(signed_char_clamp(qs0 - filter1) ^ 0x80);
*op0 = (uint8_t)(signed_char_clamp(ps0 + filter2) ^ 0x80);
// outer tap adjustments
filter = ROUND_POWER_OF_TWO(filter1, 1) & ~hev;
*oq1 = signed_char_clamp(qs1 - filter) ^ 0x80;
*op1 = signed_char_clamp(ps1 + filter) ^ 0x80;
*oq1 = (uint8_t)(signed_char_clamp(qs1 - filter) ^ 0x80);
*op1 = (uint8_t)(signed_char_clamp(ps1 + filter) ^ 0x80);
}
void aom_lpf_horizontal_4_c(uint8_t *s, int p /* pitch */,
@ -442,6 +444,7 @@ void aom_lpf_vertical_14_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0,
mb_lpf_vertical_edge_w(s + 4 * pitch, pitch, blimit1, limit1, thresh1, 4);
}
#if CONFIG_AV1_HIGHBITDEPTH
// Should we apply any filter at all: 11111111 yes, 00000000 no ?
static INLINE int8_t highbd_filter_mask2(uint8_t limit, uint8_t blimit,
uint16_t p1, uint16_t p0, uint16_t q0,
@ -539,7 +542,7 @@ static INLINE void highbd_filter4(int8_t mask, uint8_t thresh, uint16_t *op1,
const int16_t ps0 = (int16_t)*op0 - (0x80 << shift);
const int16_t qs0 = (int16_t)*oq0 - (0x80 << shift);
const int16_t qs1 = (int16_t)*oq1 - (0x80 << shift);
const uint16_t hev = highbd_hev_mask(thresh, *op1, *op0, *oq0, *oq1, bd);
const int16_t hev = highbd_hev_mask(thresh, *op1, *op0, *oq0, *oq1, bd);
// Add outer taps if we have high edge variance.
int16_t filter = signed_char_clamp_high(ps1 - qs1, bd) & hev;
@ -865,10 +868,10 @@ static void highbd_mb_lpf_horizontal_edge_w(uint16_t *s, int p,
}
}
void aom_highbd_lpf_horizontal_14_c(uint16_t *s, int p, const uint8_t *blimit,
const uint8_t *limit, const uint8_t *thresh,
int bd) {
highbd_mb_lpf_horizontal_edge_w(s, p, blimit, limit, thresh, 1, bd);
void aom_highbd_lpf_horizontal_14_c(uint16_t *s, int pitch,
const uint8_t *blimit, const uint8_t *limit,
const uint8_t *thresh, int bd) {
highbd_mb_lpf_horizontal_edge_w(s, pitch, blimit, limit, thresh, 1, bd);
}
void aom_highbd_lpf_horizontal_14_dual_c(
@ -923,3 +926,4 @@ void aom_highbd_lpf_vertical_14_dual_c(
highbd_mb_lpf_vertical_edge_w(s + 4 * pitch, pitch, blimit1, limit1, thresh1,
4, bd);
}
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -1,61 +0,0 @@
/*
* 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.
*/
#include <stdlib.h>
#include "aom_dsp/mips/macros_msa.h"
void aom_plane_add_noise_msa(uint8_t *start_ptr, char *noise,
char blackclamp[16], char whiteclamp[16],
char bothclamp[16], uint32_t width,
uint32_t height, int32_t pitch) {
uint32_t i, j;
for (i = 0; i < height / 2; ++i) {
uint8_t *pos0_ptr = start_ptr + (2 * i) * pitch;
int8_t *ref0_ptr = (int8_t *)(noise + (rand() & 0xff));
uint8_t *pos1_ptr = start_ptr + (2 * i + 1) * pitch;
int8_t *ref1_ptr = (int8_t *)(noise + (rand() & 0xff));
for (j = width / 16; j--;) {
v16i8 temp00_s, temp01_s;
v16u8 temp00, temp01, black_clamp, white_clamp;
v16u8 pos0, ref0, pos1, ref1;
v16i8 const127 = __msa_ldi_b(127);
pos0 = LD_UB(pos0_ptr);
ref0 = LD_UB(ref0_ptr);
pos1 = LD_UB(pos1_ptr);
ref1 = LD_UB(ref1_ptr);
black_clamp = (v16u8)__msa_fill_b(blackclamp[0]);
white_clamp = (v16u8)__msa_fill_b(whiteclamp[0]);
temp00 = (pos0 < black_clamp);
pos0 = __msa_bmnz_v(pos0, black_clamp, temp00);
temp01 = (pos1 < black_clamp);
pos1 = __msa_bmnz_v(pos1, black_clamp, temp01);
XORI_B2_128_UB(pos0, pos1);
temp00_s = __msa_adds_s_b((v16i8)white_clamp, const127);
temp00 = (v16u8)(temp00_s < pos0);
pos0 = (v16u8)__msa_bmnz_v((v16u8)pos0, (v16u8)temp00_s, temp00);
temp01_s = __msa_adds_s_b((v16i8)white_clamp, const127);
temp01 = (temp01_s < pos1);
pos1 = (v16u8)__msa_bmnz_v((v16u8)pos1, (v16u8)temp01_s, temp01);
XORI_B2_128_UB(pos0, pos1);
pos0 += ref0;
ST_UB(pos0, pos0_ptr);
pos1 += ref1;
ST_UB(pos1, pos1_ptr);
pos0_ptr += 16;
pos1_ptr += 16;
ref0_ptr += 16;
ref1_ptr += 16;
}
}
}

View file

@ -446,7 +446,6 @@ static void common_hz_2t_8x8mult_msa(const uint8_t *src, int32_t src_stride,
vec2, vec3);
SRARI_H4_UH(vec0, vec1, vec2, vec3, FILTER_BITS);
LD_SB4(src, src_stride, src0, src1, src2, src3);
src += (4 * src_stride);
PCKEV_B2_SB(vec1, vec0, vec3, vec2, out0, out1);
ST8x4_UB(out0, out1, dst, dst_stride);

View file

@ -313,7 +313,6 @@ static void common_vt_2t_4x4_msa(const uint8_t *src, int32_t src_stride,
filt0 = (v16u8)__msa_splati_h(filt, 0);
LD_SB5(src, src_stride, src0, src1, src2, src3, src4);
src += (5 * src_stride);
ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, src10_r, src21_r,
src32_r, src43_r);
@ -341,7 +340,6 @@ static void common_vt_2t_4x8_msa(const uint8_t *src, int32_t src_stride,
src += (8 * src_stride);
src8 = LD_SB(src);
src += src_stride;
ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, src10_r, src21_r,
src32_r, src43_r);

View file

@ -214,6 +214,7 @@ static void set_chroma_coefficient_fallback_soln(aom_equation_system_t *eqns) {
int aom_noise_strength_lut_init(aom_noise_strength_lut_t *lut, int num_points) {
if (!lut) return 0;
lut->num_points = 0;
lut->points = (double(*)[2])aom_malloc(num_points * sizeof(*lut->points));
if (!lut->points) return 0;
lut->num_points = num_points;
@ -426,6 +427,9 @@ int aom_flat_block_finder_init(aom_flat_block_finder_t *block_finder,
double *AtA_inv = 0;
double *A = 0;
int x = 0, y = 0, i = 0, j = 0;
block_finder->A = NULL;
block_finder->AtA_inv = NULL;
if (!equation_system_init(&eqns, kLowPolyNumParams)) {
fprintf(stderr, "Failed to init equation system for block_size=%d\n",
block_size);
@ -632,10 +636,12 @@ int aom_flat_block_finder_run(const aom_flat_block_finder_t *block_finder,
// [{var}, {ratio}, {trace}, {norm}, offset]
// with one of the most discriminative being simply the variance.
const double weights[5] = { -6682, -0.2056, 13087, -12434, 2.5694 };
const float score =
(float)(1.0 / (1 + exp(-(weights[0] * var + weights[1] * ratio +
weights[2] * trace + weights[3] * norm +
weights[4]))));
double sum_weights = weights[0] * var + weights[1] * ratio +
weights[2] * trace + weights[3] * norm +
weights[4];
// clamp the value to [-25.0, 100.0] to prevent overflow
sum_weights = fclamp(sum_weights, -25.0, 100.0);
const float score = (float)(1.0 / (1 + exp(-sum_weights)));
flat_blocks[by * num_blocks_w + bx] = is_flat ? 255 : 0;
scores[by * num_blocks_w + bx].score = var > kVarThreshold ? score : 0;
scores[by * num_blocks_w + bx].index = by * num_blocks_w + bx;

View file

@ -158,10 +158,10 @@ int aom_flat_block_finder_run(const aom_flat_block_finder_t *block_finder,
int stride, uint8_t *flat_blocks);
// The noise shape indicates the allowed coefficients in the AR model.
typedef enum {
enum {
AOM_NOISE_SHAPE_DIAMOND = 0,
AOM_NOISE_SHAPE_SQUARE = 1
} aom_noise_shape;
} UENUM1BYTE(aom_noise_shape);
// The parameters of the noise model include the shape type, lag, the
// bit depth of the input images provided, and whether the input images
@ -202,13 +202,13 @@ typedef struct {
} aom_noise_model_t;
/*!\brief Result of a noise model update. */
typedef enum {
enum {
AOM_NOISE_STATUS_OK = 0,
AOM_NOISE_STATUS_INVALID_ARGUMENT,
AOM_NOISE_STATUS_INSUFFICIENT_FLAT_BLOCKS,
AOM_NOISE_STATUS_DIFFERENT_NOISE_TYPE,
AOM_NOISE_STATUS_INTERNAL_ERROR,
} aom_noise_status_t;
} UENUM1BYTE(aom_noise_status_t);
/*!\brief Initializes a noise model with the given parameters.
*

View file

@ -96,7 +96,9 @@ void aom_noise_tx_filter(struct aom_noise_tx_t *noise_tx, const float *psd) {
for (int x = 0; x < block_size; ++x) {
int i = y * block_size + x;
float *c = noise_tx->tx_block + 2 * i;
const float p = c[0] * c[0] + c[1] * c[1];
const float c0 = AOMMAX((float)fabs(c[0]), 1e-8f);
const float c1 = AOMMAX((float)fabs(c[1]), 1e-8f);
const float p = c0 * c0 + c1 * c1;
if (p > kBeta * psd[i] && p > 1e-6) {
noise_tx->tx_block[2 * i + 0] *= (p - psd[i]) / AOMMAX(p, kEps);
noise_tx->tx_block[2 * i + 1] *= (p - psd[i]) / AOMMAX(p, kEps);

View file

@ -26,7 +26,6 @@
extern "C" {
#endif
// TODO(negge): Rename this aom_prob once we remove vpxbool.
typedef uint16_t aom_cdf_prob;
#define CDF_SIZE(x) ((x) + 1)
@ -641,7 +640,7 @@ static INLINE uint8_t get_prob(unsigned int num, unsigned int den) {
}
}
static INLINE void update_cdf(aom_cdf_prob *cdf, int val, int nsymbs) {
static INLINE void update_cdf(aom_cdf_prob *cdf, int8_t val, int nsymbs) {
int rate;
int i, tmp;

View file

@ -26,9 +26,6 @@ double aom_sse_to_psnr(double samples, double peak, double sse) {
}
}
/* TODO(yaowu): The block_variance calls the unoptimized versions of variance()
* and highbd_8_variance(). It should not.
*/
static void encoder_variance(const uint8_t *a, int a_stride, const uint8_t *b,
int b_stride, int w, int h, unsigned int *sse,
int *sum) {
@ -49,6 +46,7 @@ static void encoder_variance(const uint8_t *a, int a_stride, const uint8_t *b,
}
}
#if CONFIG_AV1_HIGHBITDEPTH
static void encoder_highbd_variance64(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride, int w,
int h, uint64_t *sse, int64_t *sum) {
@ -81,6 +79,7 @@ static void encoder_highbd_8_variance(const uint8_t *a8, int a_stride,
*sse = (unsigned int)sse_long;
*sum = (int)sum_long;
}
#endif // CONFIG_AV1_HIGHBITDEPTH
static int64_t get_sse(const uint8_t *a, int a_stride, const uint8_t *b,
int b_stride, int width, int height) {
@ -122,6 +121,7 @@ static int64_t get_sse(const uint8_t *a, int a_stride, const uint8_t *b,
return total_sse;
}
#if CONFIG_AV1_HIGHBITDEPTH
static int64_t highbd_get_sse_shift(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride, int width,
int height, unsigned int input_shift) {
@ -174,6 +174,28 @@ static int64_t highbd_get_sse(const uint8_t *a, int a_stride, const uint8_t *b,
}
return total_sse;
}
#endif // CONFIG_AV1_HIGHBITDEPTH
uint64_t aom_get_y_var(const YV12_BUFFER_CONFIG *a, int hstart, int width,
int vstart, int height) {
return aom_var_2d_u8(a->y_buffer + vstart * a->y_stride + hstart, a->y_stride,
width, height) /
(width * height);
}
uint64_t aom_get_u_var(const YV12_BUFFER_CONFIG *a, int hstart, int width,
int vstart, int height) {
return aom_var_2d_u8(a->u_buffer + vstart * a->uv_stride + hstart,
a->uv_stride, width, height) /
(width * height);
}
uint64_t aom_get_v_var(const YV12_BUFFER_CONFIG *a, int hstart, int width,
int vstart, int height) {
return aom_var_2d_u8(a->v_buffer + vstart * a->uv_stride + hstart,
a->uv_stride, width, height) /
(width * height);
}
int64_t aom_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, int hstart, int width,
@ -226,6 +248,28 @@ int64_t aom_get_v_sse(const YV12_BUFFER_CONFIG *a,
a->uv_crop_width, a->uv_crop_height);
}
#if CONFIG_AV1_HIGHBITDEPTH
uint64_t aom_highbd_get_y_var(const YV12_BUFFER_CONFIG *a, int hstart,
int width, int vstart, int height) {
return aom_var_2d_u16(a->y_buffer + vstart * a->y_stride + hstart,
a->y_stride, width, height) /
(width * height);
}
uint64_t aom_highbd_get_u_var(const YV12_BUFFER_CONFIG *a, int hstart,
int width, int vstart, int height) {
return aom_var_2d_u16(a->u_buffer + vstart * a->uv_stride + hstart,
a->uv_stride, width, height) /
(width * height);
}
uint64_t aom_highbd_get_v_var(const YV12_BUFFER_CONFIG *a, int hstart,
int width, int vstart, int height) {
return aom_var_2d_u16(a->v_buffer + vstart * a->uv_stride + hstart,
a->uv_stride, width, height) /
(width * height);
}
int64_t aom_highbd_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, int hstart,
int width, int vstart, int height) {
@ -284,9 +328,11 @@ int64_t aom_highbd_get_v_sse(const YV12_BUFFER_CONFIG *a,
return highbd_get_sse(a->v_buffer, a->uv_stride, b->v_buffer, b->uv_stride,
a->uv_crop_width, a->uv_crop_height);
}
#endif // CONFIG_AV1_HIGHBITDEPTH
int64_t aom_get_sse_plane(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, int plane, int highbd) {
#if CONFIG_AV1_HIGHBITDEPTH
if (highbd) {
switch (plane) {
case 0: return aom_highbd_get_y_sse(a, b);
@ -294,15 +340,26 @@ int64_t aom_get_sse_plane(const YV12_BUFFER_CONFIG *a,
case 2: return aom_highbd_get_v_sse(a, b);
default: assert(plane >= 0 && plane <= 2); return 0;
}
} else {
switch (plane) {
case 0: return aom_get_y_sse(a, b);
case 1: return aom_get_u_sse(a, b);
case 2: return aom_get_v_sse(a, b);
default: assert(plane >= 0 && plane <= 2); return 0;
}
}
#else
(void)highbd;
switch (plane) {
case 0: return aom_get_y_sse(a, b);
case 1: return aom_get_u_sse(a, b);
case 2: return aom_get_v_sse(a, b);
default: assert(plane >= 0 && plane <= 2); return 0;
}
#endif
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr,
uint32_t bit_depth, uint32_t in_bit_depth) {
@ -347,6 +404,7 @@ void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a,
psnr->psnr[0] =
aom_sse_to_psnr((double)total_samples, peak, (double)total_sse);
}
#endif
void aom_calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b,
PSNR_STATS *psnr) {

View file

@ -35,6 +35,12 @@ typedef struct {
* \param[in] sse Sum of squared errors
*/
double aom_sse_to_psnr(double samples, double peak, double sse);
uint64_t aom_get_y_var(const YV12_BUFFER_CONFIG *a, int hstart, int width,
int vstart, int height);
uint64_t aom_get_u_var(const YV12_BUFFER_CONFIG *a, int hstart, int width,
int vstart, int height);
uint64_t aom_get_v_var(const YV12_BUFFER_CONFIG *a, int hstart, int width,
int vstart, int height);
int64_t aom_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, int hstart, int width,
int vstart, int height);
@ -49,6 +55,13 @@ int64_t aom_get_v_sse_part(const YV12_BUFFER_CONFIG *a,
int64_t aom_get_v_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b);
int64_t aom_get_sse_plane(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, int plane, int highbd);
#if CONFIG_AV1_HIGHBITDEPTH
uint64_t aom_highbd_get_y_var(const YV12_BUFFER_CONFIG *a, int hstart,
int width, int vstart, int height);
uint64_t aom_highbd_get_u_var(const YV12_BUFFER_CONFIG *a, int hstart,
int width, int vstart, int height);
uint64_t aom_highbd_get_v_var(const YV12_BUFFER_CONFIG *a, int hstart,
int width, int vstart, int height);
int64_t aom_highbd_get_y_sse_part(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, int hstart,
int width, int vstart, int height);
@ -67,6 +80,7 @@ int64_t aom_highbd_get_v_sse(const YV12_BUFFER_CONFIG *a,
void aom_calc_highbd_psnr(const YV12_BUFFER_CONFIG *a,
const YV12_BUFFER_CONFIG *b, PSNR_STATS *psnr,
unsigned int bit_depth, unsigned int in_bit_depth);
#endif
void aom_calc_psnr(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b,
PSNR_STATS *psnr);

View file

@ -102,13 +102,8 @@ static const double csf_cr420[8][8] = {
0.478717061273, 0.393021669543, 0.330555063063, 0.285345396658 }
};
static double convert_score_db(double _score, double _weight, int bit_depth) {
int16_t pix_max = 255;
static double convert_score_db(double _score, double _weight, int16_t pix_max) {
assert(_score * _weight >= 0.0);
if (bit_depth == 10)
pix_max = 1023;
else if (bit_depth == 12)
pix_max = 4095;
if (_weight * _score < pix_max * pix_max * 1e-10) return MAX_PSNR;
return 10 * (log10(pix_max * pix_max) - log10(_weight * _score));
@ -117,7 +112,8 @@ static double convert_score_db(double _score, double _weight, int bit_depth) {
static double calc_psnrhvs(const unsigned char *src, int _systride,
const unsigned char *dst, int _dystride, double _par,
int _w, int _h, int _step, const double _csf[8][8],
uint32_t _shift, int buf_is_hbd) {
uint32_t _shift, int buf_is_hbd, int16_t pix_max,
int luma) {
double ret;
const uint8_t *_src8 = src;
const uint8_t *_dst8 = dst;
@ -131,8 +127,24 @@ static double calc_psnrhvs(const unsigned char *src, int _systride,
int pixels;
int x;
int y;
float sum1;
float sum2;
float delt;
(void)_par;
ret = pixels = 0;
sum1 = sum2 = delt = 0.0f;
for (y = 0; y < _h; y++) {
for (x = 0; x < _w; x++) {
if (!buf_is_hbd) {
sum1 += _src8[y * _systride + x];
sum2 += _dst8[y * _dystride + x];
} else {
sum1 += _src16[y * _systride + x] >> _shift;
sum2 += _dst16[y * _dystride + x] >> _shift;
}
}
}
if (luma) delt = (sum1 - sum2) / (_w * _h);
/*In the PSNR-HVS-M paper[1] the authors describe the construction of
their masking table as "we have used the quantization table for the
color component Y of JPEG [6] that has been also obtained on the
@ -140,7 +152,7 @@ static double calc_psnrhvs(const unsigned char *src, int _systride,
been normalized and then squared." Their CSF matrix (from PSNR-HVS)
was also constructed from the JPEG matrices. I can not find any obvious
scheme of normalizing to produce their table, but if I multiply their
CSF by 0.38857 and square the result I get their masking table.
CSF by 0.3885746225901003 and square the result I get their masking table.
I have no idea where this constant comes from, but deviating from it
too greatly hurts MOS agreement.
@ -148,30 +160,28 @@ static double calc_psnrhvs(const unsigned char *src, int _systride,
Jaakko Astola, Vladimir Lukin, "On between-coefficient contrast masking
of DCT basis functions", CD-ROM Proceedings of the Third
International Workshop on Video Processing and Quality Metrics for Consumer
Electronics VPQM-07, Scottsdale, Arizona, USA, 25-26 January, 2007, 4 p.*/
Electronics VPQM-07, Scottsdale, Arizona, USA, 25-26 January, 2007, 4 p.
Suggested in aomedia issue#2363:
0.3885746225901003 is a reciprocal of the maximum coefficient (2.573509)
of the old JPEG based matrix from the paper. Since you are not using that,
divide by actual maximum coefficient. */
for (x = 0; x < 8; x++)
for (y = 0; y < 8; y++)
mask[x][y] =
(_csf[x][y] * 0.3885746225901003) * (_csf[x][y] * 0.3885746225901003);
mask[x][y] = (_csf[x][y] / _csf[1][0]) * (_csf[x][y] / _csf[1][0]);
for (y = 0; y < _h - 7; y += _step) {
for (x = 0; x < _w - 7; x += _step) {
int i;
int j;
double s_means[4];
double d_means[4];
double s_vars[4];
double d_vars[4];
int n = 0;
double s_gx = 0;
double s_gy = 0;
double g = 0;
double s_gmean = 0;
double d_gmean = 0;
double s_gvar = 0;
double d_gvar = 0;
double s_mask = 0;
double d_mask = 0;
for (i = 0; i < 4; i++)
s_means[i] = d_means[i] = s_vars[i] = d_vars[i] = 0;
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
int sub = ((i & 12) >> 2) + ((j & 12) >> 1);
if (!buf_is_hbd) {
dct_s[i * 8 + j] = _src8[(y + i) * _systride + (j + x)];
dct_d[i * 8 + j] = _dst8[(y + i) * _dystride + (j + x)];
@ -179,35 +189,27 @@ static double calc_psnrhvs(const unsigned char *src, int _systride,
dct_s[i * 8 + j] = _src16[(y + i) * _systride + (j + x)] >> _shift;
dct_d[i * 8 + j] = _dst16[(y + i) * _dystride + (j + x)] >> _shift;
}
s_gmean += dct_s[i * 8 + j];
d_gmean += dct_d[i * 8 + j];
s_means[sub] += dct_s[i * 8 + j];
d_means[sub] += dct_d[i * 8 + j];
dct_d[i * 8 + j] += (int)(delt + 0.5f);
}
}
s_gmean /= 64.f;
d_gmean /= 64.f;
for (i = 0; i < 4; i++) s_means[i] /= 16.f;
for (i = 0; i < 4; i++) d_means[i] /= 16.f;
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
int sub = ((i & 12) >> 2) + ((j & 12) >> 1);
s_gvar += (dct_s[i * 8 + j] - s_gmean) * (dct_s[i * 8 + j] - s_gmean);
d_gvar += (dct_d[i * 8 + j] - d_gmean) * (dct_d[i * 8 + j] - d_gmean);
s_vars[sub] += (dct_s[i * 8 + j] - s_means[sub]) *
(dct_s[i * 8 + j] - s_means[sub]);
d_vars[sub] += (dct_d[i * 8 + j] - d_means[sub]) *
(dct_d[i * 8 + j] - d_means[sub]);
for (i = 1; i < 7; i++) {
for (j = 1; j < 7; j++) {
s_gx = (dct_s[(i - 1) * 8 + j - 1] * 3 -
dct_s[(i - 1) * 8 + j + 1] * 3 + dct_s[i * 8 + j - 1] * 10 -
dct_s[i * 8 + j + 1] * 10 + dct_s[(i + 1) * 8 + j - 1] * 3 -
dct_s[(i + 1) * 8 + j + 1] * 3) /
(pix_max * 16.f);
s_gy = (dct_s[(i - 1) * 8 + j - 1] * 3 -
dct_s[(i + 1) * 8 + j - 1] * 3 + dct_s[(i - 1) * 8 + j] * 10 -
dct_s[(i + 1) * 8 + j] * 10 + dct_s[(i - 1) * 8 + j + 1] * 3 -
dct_s[(i + 1) * 8 + j + 1] * 3) /
(pix_max * 16.f);
g = sqrt(s_gx * s_gx + s_gy * s_gy);
if (g > 0.1f) n++;
s_gmean += g;
}
}
s_gvar *= 1 / 63.f * 64;
d_gvar *= 1 / 63.f * 64;
for (i = 0; i < 4; i++) s_vars[i] *= 1 / 15.f * 16;
for (i = 0; i < 4; i++) d_vars[i] *= 1 / 15.f * 16;
if (s_gvar > 0)
s_gvar = (s_vars[0] + s_vars[1] + s_vars[2] + s_vars[3]) / s_gvar;
if (d_gvar > 0)
d_gvar = (d_vars[0] + d_vars[1] + d_vars[2] + d_vars[3]) / d_gvar;
s_gvar = 1.f / (36 - n + 1) * s_gmean / 36.f;
if (!buf_is_hbd) {
od_bin_fdct8x8(dct_s_coef, 8, dct_s, 8);
od_bin_fdct8x8(dct_d_coef, 8, dct_d, 8);
@ -218,12 +220,7 @@ static double calc_psnrhvs(const unsigned char *src, int _systride,
for (i = 0; i < 8; i++)
for (j = (i == 0); j < 8; j++)
s_mask += dct_s_coef[i * 8 + j] * dct_s_coef[i * 8 + j] * mask[i][j];
for (i = 0; i < 8; i++)
for (j = (i == 0); j < 8; j++)
d_mask += dct_d_coef[i * 8 + j] * dct_d_coef[i * 8 + j] * mask[i][j];
s_mask = sqrt(s_mask * s_gvar) / 32.f;
d_mask = sqrt(d_mask * d_gvar) / 32.f;
if (d_mask > s_mask) s_mask = d_mask;
s_mask = sqrt(s_mask * s_gvar) / 8.f;
for (i = 0; i < 8; i++) {
for (j = 0; j < 8; j++) {
double err;
@ -238,6 +235,7 @@ static double calc_psnrhvs(const unsigned char *src, int _systride,
}
if (pixels <= 0) return 0;
ret /= pixels;
ret += 0.04 * delt * delt;
return ret;
}
@ -254,19 +252,26 @@ double aom_psnrhvs(const YV12_BUFFER_CONFIG *src, const YV12_BUFFER_CONFIG *dst,
assert(src->flags == dst->flags);
const int buf_is_hbd = src->flags & YV12_FLAG_HIGHBITDEPTH;
int16_t pix_max = 255;
if (in_bd == 10)
pix_max = 1023;
else if (in_bd == 12)
pix_max = 4095;
bd_shift = bd - in_bd;
*y_psnrhvs = calc_psnrhvs(
src->y_buffer, src->y_stride, dst->y_buffer, dst->y_stride, par,
src->y_crop_width, src->y_crop_height, step, csf_y, bd_shift, buf_is_hbd);
*y_psnrhvs =
calc_psnrhvs(src->y_buffer, src->y_stride, dst->y_buffer, dst->y_stride,
par, src->y_crop_width, src->y_crop_height, step, csf_y,
bd_shift, buf_is_hbd, pix_max, 1);
*u_psnrhvs =
calc_psnrhvs(src->u_buffer, src->uv_stride, dst->u_buffer, dst->uv_stride,
par, src->uv_crop_width, src->uv_crop_height, step,
csf_cb420, bd_shift, buf_is_hbd);
csf_cb420, bd_shift, buf_is_hbd, pix_max, 0);
*v_psnrhvs =
calc_psnrhvs(src->v_buffer, src->uv_stride, dst->v_buffer, dst->uv_stride,
par, src->uv_crop_width, src->uv_crop_height, step,
csf_cr420, bd_shift, buf_is_hbd);
csf_cr420, bd_shift, buf_is_hbd, pix_max, 0);
psnrhvs = (*y_psnrhvs) * .8 + .1 * ((*u_psnrhvs) + (*v_psnrhvs));
return convert_score_db(psnrhvs, 1.0, in_bd);
return convert_score_db(psnrhvs, 1.0, pix_max);
}

View file

@ -11,15 +11,108 @@
#include "aom_dsp/quantize.h"
#include "aom_mem/aom_mem.h"
#include "av1/encoder/av1_quantize.h"
void quantize_b_helper_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr,
uint16_t *eob_ptr, const int16_t *scan,
const int16_t *iscan, const qm_val_t *qm_ptr,
const qm_val_t *iqm_ptr, const int log_scale) {
void aom_quantize_b_adaptive_helper_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan, const qm_val_t *qm_ptr,
const qm_val_t *iqm_ptr, const int log_scale) {
const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
const int nzbins[2] = { zbins[0] * -1, zbins[1] * -1 };
int i, non_zero_count = (int)n_coeffs, eob = -1;
(void)iscan;
memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr));
memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr));
int prescan_add[2];
for (i = 0; i < 2; ++i)
prescan_add[i] = ROUND_POWER_OF_TWO(dequant_ptr[i] * EOB_FACTOR, 7);
// Pre-scan pass
for (i = (int)n_coeffs - 1; i >= 0; i--) {
const int rc = scan[i];
const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
const int coeff = coeff_ptr[rc] * wt;
const int prescan_add_val = prescan_add[rc != 0];
if (coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val) &&
coeff > (nzbins[rc != 0] * (1 << AOM_QM_BITS) - prescan_add_val))
non_zero_count--;
else
break;
}
// Quantization pass: All coefficients with index >= zero_flag are
// skippable. Note: zero_flag can be zero.
#if SKIP_EOB_FACTOR_ADJUST
int first = -1;
#endif // SKIP_EOB_FACTOR_ADJUST
for (i = 0; i < non_zero_count; i++) {
const int rc = scan[i];
const int coeff = coeff_ptr[rc];
const int coeff_sign = AOMSIGN(coeff);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
int tmp32;
const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
if (abs_coeff * wt >= (zbins[rc != 0] << AOM_QM_BITS)) {
int64_t tmp =
clamp(abs_coeff + ROUND_POWER_OF_TWO(round_ptr[rc != 0], log_scale),
INT16_MIN, INT16_MAX);
tmp *= wt;
tmp32 = (int)(((((tmp * quant_ptr[rc != 0]) >> 16) + tmp) *
quant_shift_ptr[rc != 0]) >>
(16 - log_scale + AOM_QM_BITS)); // quantization
qcoeff_ptr[rc] = (tmp32 ^ coeff_sign) - coeff_sign;
const int iwt = iqm_ptr != NULL ? iqm_ptr[rc] : (1 << AOM_QM_BITS);
const int dequant =
(dequant_ptr[rc != 0] * iwt + (1 << (AOM_QM_BITS - 1))) >>
AOM_QM_BITS;
const tran_low_t abs_dqcoeff = (tmp32 * dequant) >> log_scale;
dqcoeff_ptr[rc] = (tran_low_t)((abs_dqcoeff ^ coeff_sign) - coeff_sign);
if (tmp32) {
eob = i;
#if SKIP_EOB_FACTOR_ADJUST
if (first == -1) first = i;
#endif // SKIP_EOB_FACTOR_ADJUST
}
}
}
#if SKIP_EOB_FACTOR_ADJUST
if (eob >= 0 && first == eob) {
const int rc = scan[eob];
if (qcoeff_ptr[rc] == 1 || qcoeff_ptr[rc] == -1) {
const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
const int coeff = coeff_ptr[rc] * wt;
const int factor = EOB_FACTOR + SKIP_EOB_FACTOR_ADJUST;
const int prescan_add_val =
ROUND_POWER_OF_TWO(dequant_ptr[rc != 0] * factor, 7);
if (coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val) &&
coeff > (nzbins[rc != 0] * (1 << AOM_QM_BITS) - prescan_add_val)) {
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
eob = -1;
}
}
}
#endif // SKIP_EOB_FACTOR_ADJUST
*eob_ptr = eob + 1;
}
void aom_quantize_b_helper_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
const int16_t *quant_ptr,
const int16_t *quant_shift_ptr,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan,
const qm_val_t *qm_ptr, const qm_val_t *iqm_ptr,
const int log_scale) {
const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
const int nzbins[2] = { zbins[0] * -1, zbins[1] * -1 };
@ -47,7 +140,7 @@ void quantize_b_helper_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
for (i = 0; i < non_zero_count; i++) {
const int rc = scan[i];
const int coeff = coeff_ptr[rc];
const int coeff_sign = (coeff >> 31);
const int coeff_sign = AOMSIGN(coeff);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
int tmp32;
@ -74,7 +167,95 @@ void quantize_b_helper_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
*eob_ptr = eob + 1;
}
void highbd_quantize_b_helper_c(
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_quantize_b_adaptive_helper_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan, const qm_val_t *qm_ptr,
const qm_val_t *iqm_ptr, const int log_scale) {
const int zbins[2] = { ROUND_POWER_OF_TWO(zbin_ptr[0], log_scale),
ROUND_POWER_OF_TWO(zbin_ptr[1], log_scale) };
const int nzbins[2] = { zbins[0] * -1, zbins[1] * -1 };
(void)iscan;
int i, non_zero_count = (int)n_coeffs, eob = -1;
memset(qcoeff_ptr, 0, n_coeffs * sizeof(*qcoeff_ptr));
memset(dqcoeff_ptr, 0, n_coeffs * sizeof(*dqcoeff_ptr));
int prescan_add[2];
for (i = 0; i < 2; ++i)
prescan_add[i] = ROUND_POWER_OF_TWO(dequant_ptr[i] * EOB_FACTOR, 7);
// Pre-scan pass
for (i = (int)n_coeffs - 1; i >= 0; i--) {
const int rc = scan[i];
const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
const int coeff = coeff_ptr[rc] * wt;
const int prescan_add_val = prescan_add[rc != 0];
if (coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val) &&
coeff > (nzbins[rc != 0] * (1 << AOM_QM_BITS) - prescan_add_val))
non_zero_count--;
else
break;
}
// Quantization pass: All coefficients with index >= zero_flag are
// skippable. Note: zero_flag can be zero.
#if SKIP_EOB_FACTOR_ADJUST
int first = -1;
#endif // SKIP_EOB_FACTOR_ADJUST
for (i = 0; i < non_zero_count; i++) {
const int rc = scan[i];
const int coeff = coeff_ptr[rc];
const int coeff_sign = AOMSIGN(coeff);
const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
if (abs_coeff * wt >= (zbins[rc != 0] << AOM_QM_BITS)) {
const int64_t tmp1 =
abs_coeff + ROUND_POWER_OF_TWO(round_ptr[rc != 0], log_scale);
const int64_t tmpw = tmp1 * wt;
const int64_t tmp2 = ((tmpw * quant_ptr[rc != 0]) >> 16) + tmpw;
const int abs_qcoeff = (int)((tmp2 * quant_shift_ptr[rc != 0]) >>
(16 - log_scale + AOM_QM_BITS));
qcoeff_ptr[rc] = (tran_low_t)((abs_qcoeff ^ coeff_sign) - coeff_sign);
const qm_val_t iwt = iqm_ptr != NULL ? iqm_ptr[rc] : (1 << AOM_QM_BITS);
const int dequant =
(dequant_ptr[rc != 0] * iwt + (1 << (AOM_QM_BITS - 1))) >>
AOM_QM_BITS;
const tran_low_t abs_dqcoeff = (abs_qcoeff * dequant) >> log_scale;
dqcoeff_ptr[rc] = (tran_low_t)((abs_dqcoeff ^ coeff_sign) - coeff_sign);
if (abs_qcoeff) {
eob = i;
#if SKIP_EOB_FACTOR_ADJUST
if (first == -1) first = eob;
#endif // SKIP_EOB_FACTOR_ADJUST
}
}
}
#if SKIP_EOB_FACTOR_ADJUST
if (eob >= 0 && first == eob) {
const int rc = scan[eob];
if (qcoeff_ptr[rc] == 1 || qcoeff_ptr[rc] == -1) {
const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
const int coeff = coeff_ptr[rc] * wt;
const int factor = EOB_FACTOR + SKIP_EOB_FACTOR_ADJUST;
const int prescan_add_val =
ROUND_POWER_OF_TWO(dequant_ptr[rc != 0] * factor, 7);
if (coeff < (zbins[rc != 0] * (1 << AOM_QM_BITS) + prescan_add_val) &&
coeff > (nzbins[rc != 0] * (1 << AOM_QM_BITS) - prescan_add_val)) {
qcoeff_ptr[rc] = 0;
dqcoeff_ptr[rc] = 0;
eob = -1;
}
}
}
#endif // SKIP_EOB_FACTOR_ADJUST
*eob_ptr = eob + 1;
}
void aom_highbd_quantize_b_helper_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
@ -111,7 +292,7 @@ void highbd_quantize_b_helper_c(
for (i = 0; i < idx; i++) {
const int rc = scan[idx_arr[i]];
const int coeff = coeff_ptr[rc];
const int coeff_sign = (coeff >> 31);
const int coeff_sign = AOMSIGN(coeff);
const qm_val_t wt = qm_ptr != NULL ? qm_ptr[rc] : (1 << AOM_QM_BITS);
const qm_val_t iwt = iqm_ptr != NULL ? iqm_ptr[rc] : (1 << AOM_QM_BITS);
const int abs_coeff = (coeff ^ coeff_sign) - coeff_sign;
@ -130,18 +311,95 @@ void highbd_quantize_b_helper_c(
}
*eob_ptr = eob + 1;
}
#endif // CONFIG_AV1_HIGHBITDEPTH
/* These functions should only be called when quantisation matrices
are not used. */
void aom_quantize_b_adaptive_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr,
const int16_t *round_ptr,
const int16_t *quant_ptr,
const int16_t *quant_shift_ptr,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
aom_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan,
iscan, NULL, NULL, 0);
}
void aom_quantize_b_32x32_adaptive_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
aom_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan,
iscan, NULL, NULL, 1);
}
void aom_quantize_b_64x64_adaptive_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
aom_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan,
iscan, NULL, NULL, 2);
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_quantize_b_adaptive_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
aom_highbd_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr,
round_ptr, quant_ptr, quant_shift_ptr,
qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 0);
}
void aom_highbd_quantize_b_32x32_adaptive_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
aom_highbd_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr,
round_ptr, quant_ptr, quant_shift_ptr,
qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 1);
}
void aom_highbd_quantize_b_64x64_adaptive_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
aom_highbd_quantize_b_adaptive_helper_c(coeff_ptr, n_coeffs, zbin_ptr,
round_ptr, quant_ptr, quant_shift_ptr,
qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 2);
}
#endif // CONFIG_AV1_HIGHBITDEPTH
void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
const int16_t *quant_ptr, const int16_t *quant_shift_ptr,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 0);
aom_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 0);
}
void aom_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
@ -151,9 +409,9 @@ void aom_quantize_b_32x32_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 1);
aom_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 1);
}
void aom_quantize_b_64x64_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
@ -163,11 +421,12 @@ void aom_quantize_b_64x64_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 2);
aom_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr, quant_ptr,
quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr, dequant_ptr,
eob_ptr, scan, iscan, NULL, NULL, 2);
}
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
const int16_t *quant_ptr,
@ -175,10 +434,10 @@ void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
NULL, NULL, 0);
aom_highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
NULL, NULL, 0);
}
void aom_highbd_quantize_b_32x32_c(
@ -187,10 +446,10 @@ void aom_highbd_quantize_b_32x32_c(
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
NULL, NULL, 1);
aom_highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
NULL, NULL, 1);
}
void aom_highbd_quantize_b_64x64_c(
@ -199,8 +458,9 @@ void aom_highbd_quantize_b_64x64_c(
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
NULL, NULL, 2);
aom_highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr,
dqcoeff_ptr, dequant_ptr, eob_ptr, scan, iscan,
NULL, NULL, 2);
}
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -20,14 +20,77 @@
extern "C" {
#endif
void quantize_b_helper_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr,
uint16_t *eob_ptr, const int16_t *scan,
const int16_t *iscan, const qm_val_t *qm_ptr,
const qm_val_t *iqm_ptr, const int log_scale);
void aom_quantize_b_adaptive_helper_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan, const qm_val_t *qm_ptr,
const qm_val_t *iqm_ptr, const int log_scale);
void aom_quantize_b_adaptive_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr,
const int16_t *round_ptr,
const int16_t *quant_ptr,
const int16_t *quant_shift_ptr,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan);
void aom_quantize_b_32x32_adaptive_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan);
void aom_quantize_b_64x64_adaptive_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan);
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_quantize_b_adaptive_helper_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan, const qm_val_t *qm_ptr,
const qm_val_t *iqm_ptr, const int log_scale);
void aom_highbd_quantize_b_adaptive_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan);
void aom_highbd_quantize_b_32x32_adaptive_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan);
void aom_highbd_quantize_b_64x64_adaptive_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
tran_low_t *dqcoeff_ptr, const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan);
#endif // CONFIG_AV1_HIGHBITDEPTH
void aom_quantize_b_helper_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
const int16_t *quant_ptr,
const int16_t *quant_shift_ptr,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan,
const qm_val_t *qm_ptr, const qm_val_t *iqm_ptr,
const int log_scale);
void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *zbin_ptr, const int16_t *round_ptr,
@ -36,7 +99,8 @@ void aom_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan);
void highbd_quantize_b_helper_c(
#if CONFIG_AV1_HIGHBITDEPTH
void aom_highbd_quantize_b_helper_c(
const tran_low_t *coeff_ptr, intptr_t n_coeffs, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, tran_low_t *qcoeff_ptr,
@ -51,6 +115,7 @@ void aom_highbd_quantize_b_c(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
const int16_t *dequant_ptr, uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan);
#endif // CONFIG_AV1_HIGHBITDEPTH
#ifdef __cplusplus
} // extern "C"

View file

@ -0,0 +1,61 @@
/*
* Copyright (c) 2018, 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_DSP_RECENTER_H_
#define AOM_AOM_DSP_RECENTER_H_
#include "config/aom_config.h"
#include "aom/aom_integer.h"
// Inverse recenters a non-negative literal v around a reference r
static INLINE uint16_t inv_recenter_nonneg(uint16_t r, uint16_t v) {
if (v > (r << 1))
return v;
else if ((v & 1) == 0)
return (v >> 1) + r;
else
return r - ((v + 1) >> 1);
}
// Inverse recenters a non-negative literal v in [0, n-1] around a
// reference r also in [0, n-1]
static INLINE uint16_t inv_recenter_finite_nonneg(uint16_t n, uint16_t r,
uint16_t v) {
if ((r << 1) <= n) {
return inv_recenter_nonneg(r, v);
} else {
return n - 1 - inv_recenter_nonneg(n - 1 - r, v);
}
}
// Recenters a non-negative literal v around a reference r
static INLINE uint16_t recenter_nonneg(uint16_t r, uint16_t v) {
if (v > (r << 1))
return v;
else if (v >= r)
return ((v - r) << 1);
else
return ((r - v) << 1) - 1;
}
// Recenters a non-negative literal v in [0, n-1] around a
// reference r also in [0, n-1]
static INLINE uint16_t recenter_finite_nonneg(uint16_t n, uint16_t r,
uint16_t v) {
if ((r << 1) <= n) {
return recenter_nonneg(r, v);
} else {
return recenter_nonneg(n - 1 - r, n - 1 - v);
}
}
#endif // AOM_AOM_DSP_RECENTER_H_

View file

@ -25,7 +25,9 @@ static INLINE unsigned int sad(const uint8_t *a, int a_stride, const uint8_t *b,
unsigned int sad = 0;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) sad += abs(a[x] - b[x]);
for (x = 0; x < width; x++) {
sad += abs(a[x] - b[x]);
}
a += a_stride;
b += b_stride;
@ -52,90 +54,99 @@ static INLINE unsigned int sad(const uint8_t *a, int a_stride, const uint8_t *b,
aom_comp_avg_pred(comp_pred, second_pred, m, n, ref, ref_stride); \
return sad(src, src_stride, comp_pred, m, m, n); \
} \
unsigned int aom_jnt_sad##m##x##n##_avg_c( \
unsigned int aom_dist_wtd_sad##m##x##n##_avg_c( \
const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, \
const uint8_t *second_pred, const JNT_COMP_PARAMS *jcp_param) { \
const uint8_t *second_pred, const DIST_WTD_COMP_PARAMS *jcp_param) { \
uint8_t comp_pred[m * n]; \
aom_jnt_comp_avg_pred_c(comp_pred, second_pred, m, n, ref, ref_stride, \
jcp_param); \
aom_dist_wtd_comp_avg_pred_c(comp_pred, second_pred, m, n, ref, \
ref_stride, jcp_param); \
return sad(src, src_stride, comp_pred, m, m, n); \
}
// Calculate sad against 4 reference locations and store each in sad_array
#define sadMxNx4D(m, n) \
void aom_sad##m##x##n##x4d_c(const uint8_t *src, int src_stride, \
const uint8_t *const ref_array[], \
int ref_stride, uint32_t *sad_array) { \
int i; \
for (i = 0; i < 4; ++i) \
sad_array[i] = \
aom_sad##m##x##n##_c(src, src_stride, ref_array[i], ref_stride); \
#define sadMxNx4D(m, n) \
void aom_sad##m##x##n##x4d_c(const uint8_t *src, int src_stride, \
const uint8_t *const ref_array[], \
int ref_stride, uint32_t *sad_array) { \
int i; \
for (i = 0; i < 4; ++i) { \
sad_array[i] = \
aom_sad##m##x##n##_c(src, src_stride, ref_array[i], ref_stride); \
} \
} \
void aom_sad##m##x##n##x4d_avg_c( \
const uint8_t *src, int src_stride, const uint8_t *const ref_array[], \
int ref_stride, const uint8_t *second_pred, uint32_t *sad_array) { \
int i; \
for (i = 0; i < 4; ++i) { \
sad_array[i] = aom_sad##m##x##n##_avg_c(src, src_stride, ref_array[i], \
ref_stride, second_pred); \
} \
}
/* clang-format off */
// 128x128
sadMxN(128, 128)
sadMxNx4D(128, 128)
sadMxN(128, 128);
sadMxNx4D(128, 128);
// 128x64
sadMxN(128, 64)
sadMxNx4D(128, 64)
sadMxN(128, 64);
sadMxNx4D(128, 64);
// 64x128
sadMxN(64, 128)
sadMxNx4D(64, 128)
sadMxN(64, 128);
sadMxNx4D(64, 128);
// 64x64
sadMxN(64, 64)
sadMxNx4D(64, 64)
sadMxN(64, 64);
sadMxNx4D(64, 64);
// 64x32
sadMxN(64, 32)
sadMxNx4D(64, 32)
sadMxN(64, 32);
sadMxNx4D(64, 32);
// 32x64
sadMxN(32, 64)
sadMxNx4D(32, 64)
sadMxN(32, 64);
sadMxNx4D(32, 64);
// 32x32
sadMxN(32, 32)
sadMxNx4D(32, 32)
sadMxN(32, 32);
sadMxNx4D(32, 32);
// 32x16
sadMxN(32, 16)
sadMxNx4D(32, 16)
sadMxN(32, 16);
sadMxNx4D(32, 16);
// 16x32
sadMxN(16, 32)
sadMxNx4D(16, 32)
sadMxN(16, 32);
sadMxNx4D(16, 32);
// 16x16
sadMxN(16, 16)
sadMxNx4D(16, 16)
sadMxN(16, 16);
sadMxNx4D(16, 16);
// 16x8
sadMxN(16, 8)
sadMxNx4D(16, 8)
sadMxN(16, 8);
sadMxNx4D(16, 8);
// 8x16
sadMxN(8, 16)
sadMxNx4D(8, 16)
sadMxN(8, 16);
sadMxNx4D(8, 16);
// 8x8
sadMxN(8, 8)
sadMxNx4D(8, 8)
sadMxN(8, 8);
sadMxNx4D(8, 8);
// 8x4
sadMxN(8, 4)
sadMxNx4D(8, 4)
sadMxN(8, 4);
sadMxNx4D(8, 4);
// 4x8
sadMxN(4, 8)
sadMxNx4D(4, 8)
sadMxN(4, 8);
sadMxNx4D(4, 8);
// 4x4
sadMxN(4, 4)
sadMxNx4D(4, 4)
sadMxN(4, 4);
sadMxNx4D(4, 4);
sadMxh(128);
sadMxh(64);
@ -144,30 +155,31 @@ sadMxh(16);
sadMxh(8);
sadMxh(4);
sadMxN(4, 16)
sadMxNx4D(4, 16)
sadMxN(16, 4)
sadMxNx4D(16, 4)
sadMxN(8, 32)
sadMxNx4D(8, 32)
sadMxN(32, 8)
sadMxNx4D(32, 8)
sadMxN(16, 64)
sadMxNx4D(16, 64)
sadMxN(64, 16)
sadMxNx4D(64, 16)
sadMxN(4, 16);
sadMxNx4D(4, 16);
sadMxN(16, 4);
sadMxNx4D(16, 4);
sadMxN(8, 32);
sadMxNx4D(8, 32);
sadMxN(32, 8);
sadMxNx4D(32, 8);
sadMxN(16, 64);
sadMxNx4D(16, 64);
sadMxN(64, 16);
sadMxNx4D(64, 16);
/* clang-format on */
static INLINE
unsigned int highbd_sad(const uint8_t *a8, int a_stride, const uint8_t *b8,
int b_stride, int width, int height) {
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE unsigned int highbd_sad(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride,
int width, int height) {
int y, x;
unsigned int sad = 0;
const uint16_t *a = CONVERT_TO_SHORTPTR(a8);
const uint16_t *b = CONVERT_TO_SHORTPTR(b8);
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) sad += abs(a[x] - b[x]);
for (x = 0; x < width; x++) {
sad += abs(a[x] - b[x]);
}
a += a_stride;
b += b_stride;
@ -176,13 +188,16 @@ sadMxNx4D(64, 16)
}
static INLINE unsigned int highbd_sadb(const uint8_t *a8, int a_stride,
const uint16_t *b, int b_stride,
const uint8_t *b8, int b_stride,
int width, int height) {
int y, x;
unsigned int sad = 0;
const uint16_t *a = CONVERT_TO_SHORTPTR(a8);
const uint16_t *b = CONVERT_TO_SHORTPTR(b8);
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) sad += abs(a[x] - b[x]);
for (x = 0; x < width; x++) {
sad += abs(a[x] - b[x]);
}
a += a_stride;
b += b_stride;
@ -200,17 +215,18 @@ static INLINE unsigned int highbd_sadb(const uint8_t *a8, int a_stride,
const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, \
const uint8_t *second_pred) { \
uint16_t comp_pred[m * n]; \
aom_highbd_comp_avg_pred(CONVERT_TO_BYTEPTR(comp_pred), second_pred, m, n, \
ref, ref_stride); \
return highbd_sadb(src, src_stride, comp_pred, m, m, n); \
uint8_t *const comp_pred8 = CONVERT_TO_BYTEPTR(comp_pred); \
aom_highbd_comp_avg_pred(comp_pred8, second_pred, m, n, ref, ref_stride); \
return highbd_sadb(src, src_stride, comp_pred8, m, m, n); \
} \
unsigned int aom_highbd_jnt_sad##m##x##n##_avg_c( \
unsigned int aom_highbd_dist_wtd_sad##m##x##n##_avg_c( \
const uint8_t *src, int src_stride, const uint8_t *ref, int ref_stride, \
const uint8_t *second_pred, const JNT_COMP_PARAMS *jcp_param) { \
const uint8_t *second_pred, const DIST_WTD_COMP_PARAMS *jcp_param) { \
uint16_t comp_pred[m * n]; \
aom_highbd_jnt_comp_avg_pred(CONVERT_TO_BYTEPTR(comp_pred), second_pred, \
m, n, ref, ref_stride, jcp_param); \
return highbd_sadb(src, src_stride, comp_pred, m, m, n); \
uint8_t *const comp_pred8 = CONVERT_TO_BYTEPTR(comp_pred); \
aom_highbd_dist_wtd_comp_avg_pred(comp_pred8, second_pred, m, n, ref, \
ref_stride, jcp_param); \
return highbd_sadb(src, src_stride, comp_pred8, m, m, n); \
}
#define highbd_sadMxNx4D(m, n) \
@ -224,81 +240,80 @@ static INLINE unsigned int highbd_sadb(const uint8_t *a8, int a_stride,
} \
}
/* clang-format off */
// 128x128
highbd_sadMxN(128, 128)
highbd_sadMxNx4D(128, 128)
highbd_sadMxN(128, 128);
highbd_sadMxNx4D(128, 128);
// 128x64
highbd_sadMxN(128, 64)
highbd_sadMxNx4D(128, 64)
highbd_sadMxN(128, 64);
highbd_sadMxNx4D(128, 64);
// 64x128
highbd_sadMxN(64, 128)
highbd_sadMxNx4D(64, 128)
highbd_sadMxN(64, 128);
highbd_sadMxNx4D(64, 128);
// 64x64
highbd_sadMxN(64, 64)
highbd_sadMxNx4D(64, 64)
highbd_sadMxN(64, 64);
highbd_sadMxNx4D(64, 64);
// 64x32
highbd_sadMxN(64, 32)
highbd_sadMxNx4D(64, 32)
highbd_sadMxN(64, 32);
highbd_sadMxNx4D(64, 32);
// 32x64
highbd_sadMxN(32, 64)
highbd_sadMxNx4D(32, 64)
highbd_sadMxN(32, 64);
highbd_sadMxNx4D(32, 64);
// 32x32
highbd_sadMxN(32, 32)
highbd_sadMxNx4D(32, 32)
highbd_sadMxN(32, 32);
highbd_sadMxNx4D(32, 32);
// 32x16
highbd_sadMxN(32, 16)
highbd_sadMxNx4D(32, 16)
highbd_sadMxN(32, 16);
highbd_sadMxNx4D(32, 16);
// 16x32
highbd_sadMxN(16, 32)
highbd_sadMxNx4D(16, 32)
highbd_sadMxN(16, 32);
highbd_sadMxNx4D(16, 32);
// 16x16
highbd_sadMxN(16, 16)
highbd_sadMxNx4D(16, 16)
highbd_sadMxN(16, 16);
highbd_sadMxNx4D(16, 16);
// 16x8
highbd_sadMxN(16, 8)
highbd_sadMxNx4D(16, 8)
highbd_sadMxN(16, 8);
highbd_sadMxNx4D(16, 8);
// 8x16
highbd_sadMxN(8, 16)
highbd_sadMxNx4D(8, 16)
highbd_sadMxN(8, 16);
highbd_sadMxNx4D(8, 16);
// 8x8
highbd_sadMxN(8, 8)
highbd_sadMxNx4D(8, 8)
highbd_sadMxN(8, 8);
highbd_sadMxNx4D(8, 8);
// 8x4
highbd_sadMxN(8, 4)
highbd_sadMxNx4D(8, 4)
highbd_sadMxN(8, 4);
highbd_sadMxNx4D(8, 4);
// 4x8
highbd_sadMxN(4, 8)
highbd_sadMxNx4D(4, 8)
highbd_sadMxN(4, 8);
highbd_sadMxNx4D(4, 8);
// 4x4
highbd_sadMxN(4, 4)
highbd_sadMxNx4D(4, 4)
highbd_sadMxN(4, 4);
highbd_sadMxNx4D(4, 4);
highbd_sadMxN(4, 16)
highbd_sadMxNx4D(4, 16)
highbd_sadMxN(16, 4)
highbd_sadMxNx4D(16, 4)
highbd_sadMxN(8, 32)
highbd_sadMxNx4D(8, 32)
highbd_sadMxN(32, 8)
highbd_sadMxNx4D(32, 8)
highbd_sadMxN(16, 64)
highbd_sadMxNx4D(16, 64)
highbd_sadMxN(64, 16)
highbd_sadMxNx4D(64, 16)
/* clang-format on */
highbd_sadMxN(4, 16);
highbd_sadMxNx4D(4, 16);
highbd_sadMxN(16, 4);
highbd_sadMxNx4D(16, 4);
highbd_sadMxN(8, 32);
highbd_sadMxNx4D(8, 32);
highbd_sadMxN(32, 8);
highbd_sadMxNx4D(32, 8);
highbd_sadMxN(16, 64);
highbd_sadMxNx4D(16, 64);
highbd_sadMxN(64, 16);
highbd_sadMxNx4D(64, 16);
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -35,7 +35,6 @@ static INLINE unsigned int masked_sad(const uint8_t *src, int src_stride,
b += b_stride;
m += m_stride;
}
sad = (sad + 31) >> 6;
return sad;
}
@ -50,6 +49,21 @@ static INLINE unsigned int masked_sad(const uint8_t *src, int src_stride,
else \
return masked_sad(src, src_stride, second_pred, m, ref, ref_stride, msk, \
msk_stride, m, n); \
} \
void aom_masked_sad##m##x##n##x4d_c( \
const uint8_t *src, int src_stride, const uint8_t *ref[], \
int ref_stride, const uint8_t *second_pred, const uint8_t *msk, \
int msk_stride, int invert_mask, unsigned sads[]) { \
if (!invert_mask) \
for (int i = 0; i < 4; i++) { \
sads[i] = masked_sad(src, src_stride, ref[i], ref_stride, second_pred, \
m, msk, msk_stride, m, n); \
} \
else \
for (int i = 0; i < 4; i++) { \
sads[i] = masked_sad(src, src_stride, second_pred, m, ref[i], \
ref_stride, msk, msk_stride, m, n); \
} \
}
/* clang-format off */
@ -75,10 +89,10 @@ MASKSADMxN(8, 32)
MASKSADMxN(32, 8)
MASKSADMxN(16, 64)
MASKSADMxN(64, 16)
/* clang-format on */
/* clang-format on */
static INLINE
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE
unsigned int highbd_masked_sad(const uint8_t *src8, int src_stride,
const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride,
@ -101,7 +115,6 @@ MASKSADMxN(64, 16)
b += b_stride;
m += m_stride;
}
sad = (sad + 31) >> 6;
return sad;
}
@ -141,6 +154,7 @@ HIGHBD_MASKSADMXN(8, 32)
HIGHBD_MASKSADMXN(32, 8)
HIGHBD_MASKSADMXN(16, 64)
HIGHBD_MASKSADMXN(64, 16)
#endif // CONFIG_AV1_HIGHBITDEPTH
// pre: predictor being evaluated
// wsrc: target weighted prediction (has been *4096 to keep precision)
@ -193,9 +207,10 @@ OBMCSADMxN(8, 32)
OBMCSADMxN(32, 8)
OBMCSADMxN(16, 64)
OBMCSADMxN(64, 16)
/* clang-format on */
/* clang-format on */
static INLINE
#if CONFIG_AV1_HIGHBITDEPTH
static INLINE
unsigned int highbd_obmc_sad(const uint8_t *pre8, int pre_stride,
const int32_t *wsrc, const int32_t *mask,
int width, int height) {
@ -246,3 +261,4 @@ HIGHBD_OBMCSADMXN(32, 8)
HIGHBD_OBMCSADMXN(16, 64)
HIGHBD_OBMCSADMXN(64, 16)
/* clang-format on */
#endif // CONFIG_AV1_HIGHBITDEPTH

View file

@ -54,26 +54,28 @@ SIMD_INLINE v128 v128_align(v128 a, v128 b, unsigned int c) {
return c_v128_align(a, b, c);
}
SIMD_INLINE v128 v128_zero() { return c_v128_zero(); }
SIMD_INLINE v128 v128_zero(void) { return c_v128_zero(); }
SIMD_INLINE v128 v128_dup_8(uint8_t x) { return c_v128_dup_8(x); }
SIMD_INLINE v128 v128_dup_16(uint16_t x) { return c_v128_dup_16(x); }
SIMD_INLINE v128 v128_dup_32(uint32_t x) { return c_v128_dup_32(x); }
SIMD_INLINE v128 v128_dup_64(uint64_t x) { return c_v128_dup_64(x); }
typedef uint32_t sad128_internal;
SIMD_INLINE sad128_internal v128_sad_u8_init() { return c_v128_sad_u8_init(); }
SIMD_INLINE sad128_internal v128_sad_u8(sad128_internal s, v128 a, v128 b) {
SIMD_INLINE c_sad128_internal v128_sad_u8_init(void) {
return c_v128_sad_u8_init();
}
SIMD_INLINE c_sad128_internal v128_sad_u8(c_sad128_internal s, v128 a, v128 b) {
return c_v128_sad_u8(s, a, b);
}
SIMD_INLINE uint32_t v128_sad_u8_sum(sad128_internal s) {
SIMD_INLINE uint32_t v128_sad_u8_sum(c_sad128_internal s) {
return c_v128_sad_u8_sum(s);
}
typedef uint32_t ssd128_internal;
SIMD_INLINE ssd128_internal v128_ssd_u8_init() { return c_v128_ssd_u8_init(); }
SIMD_INLINE ssd128_internal v128_ssd_u8(ssd128_internal s, v128 a, v128 b) {
SIMD_INLINE c_ssd128_internal v128_ssd_u8_init(void) {
return c_v128_ssd_u8_init();
}
SIMD_INLINE c_ssd128_internal v128_ssd_u8(c_ssd128_internal s, v128 a, v128 b) {
return c_v128_ssd_u8(s, a, b);
}
SIMD_INLINE uint32_t v128_ssd_u8_sum(ssd128_internal s) {
SIMD_INLINE uint32_t v128_ssd_u8_sum(c_ssd128_internal s) {
return c_v128_ssd_u8_sum(s);
}
SIMD_INLINE int64_t v128_dotp_su8(v128 a, v128 b) {
@ -318,7 +320,7 @@ SIMD_INLINE v128 v128_shr_n_s64(v128 a, unsigned int n) {
}
typedef uint32_t sad128_internal_u16;
SIMD_INLINE sad128_internal_u16 v128_sad_u16_init() {
SIMD_INLINE sad128_internal_u16 v128_sad_u16_init(void) {
return c_v128_sad_u16_init();
}
SIMD_INLINE sad128_internal_u16 v128_sad_u16(sad128_internal_u16 s, v128 a,
@ -330,7 +332,7 @@ SIMD_INLINE uint32_t v128_sad_u16_sum(sad128_internal_u16 s) {
}
typedef uint64_t ssd128_internal_s16;
SIMD_INLINE ssd128_internal_s16 v128_ssd_s16_init() {
SIMD_INLINE ssd128_internal_s16 v128_ssd_s16_init(void) {
return c_v128_ssd_s16_init();
}
SIMD_INLINE ssd128_internal_s16 v128_ssd_s16(ssd128_internal_s16 s, v128 a,

View file

@ -68,9 +68,11 @@ SIMD_INLINE v128 v128_align(v128 a, v128 b, unsigned int c) {
#endif
}
SIMD_INLINE v128 v128_zero() { return vreinterpretq_s64_u8(vdupq_n_u8(0)); }
SIMD_INLINE v128 v128_zero(void) { return vreinterpretq_s64_u8(vdupq_n_u8(0)); }
SIMD_INLINE v128 v128_ones() { return vreinterpretq_s64_u8(vdupq_n_u8(-1)); }
SIMD_INLINE v128 v128_ones(void) {
return vreinterpretq_s64_u8(vdupq_n_u8(-1));
}
SIMD_INLINE v128 v128_dup_8(uint8_t x) {
return vreinterpretq_s64_u8(vdupq_n_u8(x));
@ -136,7 +138,7 @@ typedef struct {
sad64_internal hi, lo;
} sad128_internal;
SIMD_INLINE sad128_internal v128_sad_u8_init() {
SIMD_INLINE sad128_internal v128_sad_u8_init(void) {
sad128_internal s;
s.hi = s.lo = vdupq_n_u16(0);
return s;
@ -165,7 +167,7 @@ typedef struct {
ssd64_internal hi, lo;
} ssd128_internal;
SIMD_INLINE ssd128_internal v128_ssd_u8_init() {
SIMD_INLINE ssd128_internal v128_ssd_u8_init(void) {
ssd128_internal s;
s.hi = s.lo = v64_ssd_u8_init();
return s;
@ -784,68 +786,79 @@ SIMD_INLINE v128 v128_shl_n_byte(v128 a, unsigned int n) {
}
SIMD_INLINE v128 v128_shr_n_byte(v128 a, unsigned int n) {
return n < 8
? v128_from_64(
(uint64_t)vshr_n_u64(vreinterpret_u64_s64(vget_high_s64(a)),
n * 8),
(uint64_t)vorr_u64(
vshr_n_u64(vreinterpret_u64_s64(vget_low_s64(a)), n * 8),
vshl_n_u64(vreinterpret_u64_s64(vget_high_s64(a)),
(8 - n) * 8)))
: (n == 8 ? v128_from_64(0, (uint64_t)vreinterpret_u64_s64(
vget_high_s64(a)))
: v128_from_64(
0, (uint64_t)vshr_n_u64(
vreinterpret_u64_s64(vget_high_s64(a)),
(n - 8) * 8)));
return n == 0
? a
: (n < 8
? v128_from_64(
(uint64_t)vshr_n_u64(
vreinterpret_u64_s64(vget_high_s64(a)), n * 8),
(uint64_t)vorr_u64(
vshr_n_u64(vreinterpret_u64_s64(vget_low_s64(a)),
n * 8),
vshl_n_u64(vreinterpret_u64_s64(vget_high_s64(a)),
(8 - n) * 8)))
: (n == 8 ? v128_from_64(0, (uint64_t)vreinterpret_u64_s64(
vget_high_s64(a)))
: v128_from_64(0, (uint64_t)vshr_n_u64(
vreinterpret_u64_s64(
vget_high_s64(a)),
(n - 8) * 8))));
}
SIMD_INLINE v128 v128_shl_n_8(v128 a, unsigned int c) {
return vreinterpretq_s64_u8(vshlq_n_u8(vreinterpretq_u8_s64(a), c));
return c ? vreinterpretq_s64_u8(vshlq_n_u8(vreinterpretq_u8_s64(a), c)) : a;
}
SIMD_INLINE v128 v128_shr_n_u8(v128 a, unsigned int c) {
return vreinterpretq_s64_u8(vshrq_n_u8(vreinterpretq_u8_s64(a), c));
return c ? vreinterpretq_s64_u8(vshrq_n_u8(vreinterpretq_u8_s64(a), c)) : a;
}
SIMD_INLINE v128 v128_shr_n_s8(v128 a, unsigned int c) {
return vreinterpretq_s64_s8(vshrq_n_s8(vreinterpretq_s8_s64(a), c));
return c ? vreinterpretq_s64_s8(vshrq_n_s8(vreinterpretq_s8_s64(a), c)) : a;
}
SIMD_INLINE v128 v128_shl_n_16(v128 a, unsigned int c) {
return vreinterpretq_s64_u16(vshlq_n_u16(vreinterpretq_u16_s64(a), c));
return c ? vreinterpretq_s64_u16(vshlq_n_u16(vreinterpretq_u16_s64(a), c))
: a;
}
SIMD_INLINE v128 v128_shr_n_u16(v128 a, unsigned int c) {
return vreinterpretq_s64_u16(vshrq_n_u16(vreinterpretq_u16_s64(a), c));
return c ? vreinterpretq_s64_u16(vshrq_n_u16(vreinterpretq_u16_s64(a), c))
: a;
}
SIMD_INLINE v128 v128_shr_n_s16(v128 a, unsigned int c) {
return vreinterpretq_s64_s16(vshrq_n_s16(vreinterpretq_s16_s64(a), c));
return c ? vreinterpretq_s64_s16(vshrq_n_s16(vreinterpretq_s16_s64(a), c))
: a;
}
SIMD_INLINE v128 v128_shl_n_32(v128 a, unsigned int c) {
return vreinterpretq_s64_u32(vshlq_n_u32(vreinterpretq_u32_s64(a), c));
return c ? vreinterpretq_s64_u32(vshlq_n_u32(vreinterpretq_u32_s64(a), c))
: a;
}
SIMD_INLINE v128 v128_shr_n_u32(v128 a, unsigned int c) {
return vreinterpretq_s64_u32(vshrq_n_u32(vreinterpretq_u32_s64(a), c));
return c ? vreinterpretq_s64_u32(vshrq_n_u32(vreinterpretq_u32_s64(a), c))
: a;
}
SIMD_INLINE v128 v128_shr_n_s32(v128 a, unsigned int c) {
return vreinterpretq_s64_s32(vshrq_n_s32(vreinterpretq_s32_s64(a), c));
return c ? vreinterpretq_s64_s32(vshrq_n_s32(vreinterpretq_s32_s64(a), c))
: a;
}
SIMD_INLINE v128 v128_shl_n_64(v128 a, unsigned int c) {
return vreinterpretq_s64_u64(vshlq_n_u64(vreinterpretq_u64_s64(a), c));
return c ? vreinterpretq_s64_u64(vshlq_n_u64(vreinterpretq_u64_s64(a), c))
: a;
}
SIMD_INLINE v128 v128_shr_n_u64(v128 a, unsigned int c) {
return vreinterpretq_s64_u64(vshrq_n_u64(vreinterpretq_u64_s64(a), c));
return c ? vreinterpretq_s64_u64(vshrq_n_u64(vreinterpretq_u64_s64(a), c))
: a;
}
SIMD_INLINE v128 v128_shr_n_s64(v128 a, unsigned int c) {
return vshrq_n_s64(a, c);
return c ? vshrq_n_s64(a, c) : a;
}
#else
@ -920,7 +933,9 @@ SIMD_INLINE v128 v128_shr_n_s64(v128 a, unsigned int c) {
typedef uint32x4_t sad128_internal_u16;
SIMD_INLINE sad128_internal_u16 v128_sad_u16_init() { return vdupq_n_u32(0); }
SIMD_INLINE sad128_internal_u16 v128_sad_u16_init(void) {
return vdupq_n_u32(0);
}
/* Implementation dependent return value. Result must be finalised with
* v128_sad_u16_sum(). */
@ -939,7 +954,7 @@ SIMD_INLINE uint32_t v128_sad_u16_sum(sad128_internal_u16 s) {
}
typedef v128 ssd128_internal_s16;
SIMD_INLINE ssd128_internal_s16 v128_ssd_s16_init() { return v128_zero(); }
SIMD_INLINE ssd128_internal_s16 v128_ssd_s16_init(void) { return v128_zero(); }
/* Implementation dependent return value. Result must be finalised with
* v128_ssd_s16_sum(). */

View file

@ -93,7 +93,7 @@ SIMD_INLINE void c_v128_store_aligned(void *p, c_v128 a) {
c_v128_store_unaligned(p, a);
}
SIMD_INLINE c_v128 c_v128_zero() {
SIMD_INLINE c_v128 c_v128_zero(void) {
c_v128 t;
t.u64[1] = t.u64[0] = 0;
return t;
@ -145,26 +145,39 @@ SIMD_INLINE uint64_t c_v128_hadd_u8(c_v128 a) {
return c_v64_hadd_u8(a.v64[1]) + c_v64_hadd_u8(a.v64[0]);
}
typedef uint32_t c_sad128_internal;
typedef struct {
uint32_t val;
int count;
} c_sad128_internal;
SIMD_INLINE c_sad128_internal c_v128_sad_u8_init() { return 0; }
SIMD_INLINE c_sad128_internal c_v128_sad_u8_init(void) {
c_sad128_internal t;
t.val = t.count = 0;
return t;
}
/* Implementation dependent return value. Result must be finalised with
v128_sad_u8_sum().
The result for more than 32 v128_sad_u8() calls is undefined. */
* v128_sad_u8_sum(). The result for more than 32 v128_sad_u8() calls is
* undefined. */
SIMD_INLINE c_sad128_internal c_v128_sad_u8(c_sad128_internal s, c_v128 a,
c_v128 b) {
int c;
for (c = 0; c < 16; c++)
s += a.u8[c] > b.u8[c] ? a.u8[c] - b.u8[c] : b.u8[c] - a.u8[c];
s.val += a.u8[c] > b.u8[c] ? a.u8[c] - b.u8[c] : b.u8[c] - a.u8[c];
s.count++;
if (SIMD_CHECK && s.count > 32) {
fprintf(stderr,
"Error: sad called 32 times returning an undefined result\n");
abort();
}
return s;
}
SIMD_INLINE uint32_t c_v128_sad_u8_sum(c_sad128_internal s) { return s; }
SIMD_INLINE uint32_t c_v128_sad_u8_sum(c_sad128_internal s) { return s.val; }
typedef uint32_t c_ssd128_internal;
SIMD_INLINE c_ssd128_internal c_v128_ssd_u8_init() { return 0; }
SIMD_INLINE c_ssd128_internal c_v128_ssd_u8_init(void) { return 0; }
/* Implementation dependent return value. Result must be finalised with
* v128_ssd_u8_sum(). */
@ -720,6 +733,7 @@ SIMD_INLINE c_v128 c_v128_cmpeq_32(c_v128 a, c_v128 b) {
}
SIMD_INLINE c_v128 c_v128_shl_n_byte(c_v128 a, const unsigned int n) {
if (n == 0) return a;
if (n < 8)
return c_v128_from_v64(c_v64_or(c_v64_shl_n_byte(a.v64[1], n),
c_v64_shr_n_byte(a.v64[0], 8 - n)),
@ -729,6 +743,7 @@ SIMD_INLINE c_v128 c_v128_shl_n_byte(c_v128 a, const unsigned int n) {
}
SIMD_INLINE c_v128 c_v128_shr_n_byte(c_v128 a, const unsigned int n) {
if (n == 0) return a;
if (n < 8)
return c_v128_from_v64(c_v64_shr_n_byte(a.v64[1], n),
c_v64_or(c_v64_shr_n_byte(a.v64[0], n),
@ -854,7 +869,7 @@ SIMD_INLINE c_v128 c_v128_shr_n_s64(c_v128 a, const unsigned int n) {
typedef uint32_t c_sad128_internal_u16;
SIMD_INLINE c_sad128_internal_u16 c_v128_sad_u16_init() { return 0; }
SIMD_INLINE c_sad128_internal_u16 c_v128_sad_u16_init(void) { return 0; }
/* Implementation dependent return value. Result must be finalised with
* v128_sad_u16_sum(). */
@ -870,7 +885,7 @@ SIMD_INLINE uint32_t c_v128_sad_u16_sum(c_sad128_internal_u16 s) { return s; }
typedef uint64_t c_ssd128_internal_s16;
SIMD_INLINE c_ssd128_internal_s16 c_v128_ssd_s16_init() { return 0; }
SIMD_INLINE c_ssd128_internal_s16 c_v128_ssd_s16_init(void) { return 0; }
/* Implementation dependent return value. Result must be finalised with
* v128_ssd_s16_sum(). */

View file

@ -45,7 +45,7 @@ SIMD_INLINE v128 v128_load_aligned(const void *p) {
SIMD_INLINE v128 v128_load_unaligned(const void *p) {
#if defined(__SSSE3__)
return (__m128i)_mm_lddqu_si128((__m128i *)p);
return _mm_lddqu_si128((__m128i *)p);
#else
return _mm_loadu_si128((__m128i *)p);
#endif
@ -89,7 +89,8 @@ SIMD_INLINE v128 v128_dup_32(uint32_t x) { return _mm_set1_epi32(x); }
SIMD_INLINE v128 v128_dup_64(uint64_t x) {
// _mm_set_pi64x and _mm_cvtsi64x_si64 missing in some compilers
return _mm_set_epi32(x >> 32, (uint32_t)x, x >> 32, (uint32_t)x);
return _mm_set_epi32((uint32_t)(x >> 32), (uint32_t)x, (uint32_t)(x >> 32),
(uint32_t)x);
}
SIMD_INLINE v128 v128_add_8(v128 a, v128 b) { return _mm_add_epi8(a, b); }
@ -538,7 +539,7 @@ SIMD_INLINE v128 v128_shl_8(v128 a, unsigned int c) {
}
SIMD_INLINE v128 v128_shr_u8(v128 a, unsigned int c) {
return _mm_and_si128(_mm_set1_epi8(0xff >> c),
return _mm_and_si128(_mm_set1_epi8((char)(0xff >> c)),
_mm_srl_epi16(a, _mm_cvtsi32_si128(c)));
}

View file

@ -57,29 +57,42 @@ SIMD_INLINE v256 v256_align(v256 a, v256 b, unsigned int c) {
return c_v256_align(a, b, c);
}
SIMD_INLINE v256 v256_zero() { return c_v256_zero(); }
SIMD_INLINE v256 v256_zero(void) { return c_v256_zero(); }
SIMD_INLINE v256 v256_dup_8(uint8_t x) { return c_v256_dup_8(x); }
SIMD_INLINE v256 v256_dup_16(uint16_t x) { return c_v256_dup_16(x); }
SIMD_INLINE v256 v256_dup_32(uint32_t x) { return c_v256_dup_32(x); }
SIMD_INLINE v256 v256_dup_64(uint64_t x) { return c_v256_dup_64(x); }
typedef uint32_t sad256_internal;
SIMD_INLINE sad256_internal v256_sad_u8_init() { return c_v256_sad_u8_init(); }
SIMD_INLINE sad256_internal v256_sad_u8(sad256_internal s, v256 a, v256 b) {
SIMD_INLINE c_sad256_internal v256_sad_u8_init(void) {
return c_v256_sad_u8_init();
}
SIMD_INLINE c_sad256_internal v256_sad_u8(c_sad256_internal s, v256 a, v256 b) {
return c_v256_sad_u8(s, a, b);
}
SIMD_INLINE uint32_t v256_sad_u8_sum(sad256_internal s) {
SIMD_INLINE uint32_t v256_sad_u8_sum(c_sad256_internal s) {
return c_v256_sad_u8_sum(s);
}
typedef uint32_t ssd256_internal;
SIMD_INLINE ssd256_internal v256_ssd_u8_init() { return c_v256_ssd_u8_init(); }
SIMD_INLINE ssd256_internal v256_ssd_u8(ssd256_internal s, v256 a, v256 b) {
SIMD_INLINE c_ssd256_internal v256_ssd_u8_init(void) {
return c_v256_ssd_u8_init();
}
SIMD_INLINE c_ssd256_internal v256_ssd_u8(c_ssd256_internal s, v256 a, v256 b) {
return c_v256_ssd_u8(s, a, b);
}
SIMD_INLINE uint32_t v256_ssd_u8_sum(ssd256_internal s) {
SIMD_INLINE uint32_t v256_ssd_u8_sum(c_ssd256_internal s) {
return c_v256_ssd_u8_sum(s);
}
SIMD_INLINE c_ssd256_internal_s16 v256_ssd_s16_init(void) {
return c_v256_ssd_s16_init();
}
SIMD_INLINE c_ssd256_internal_s16 v256_ssd_s16(c_ssd256_internal_s16 s, v256 a,
v256 b) {
return c_v256_ssd_s16(s, a, b);
}
SIMD_INLINE uint64_t v256_ssd_s16_sum(c_ssd256_internal_s16 s) {
return c_v256_ssd_s16_sum(s);
}
SIMD_INLINE int64_t v256_dotp_su8(v256 a, v256 b) {
return c_v256_dotp_su8(a, b);
}
@ -350,7 +363,7 @@ SIMD_INLINE v256 v256_shl_n_word(v256 a, unsigned int n) {
}
typedef uint32_t sad256_internal_u16;
SIMD_INLINE sad256_internal_u16 v256_sad_u16_init() {
SIMD_INLINE sad256_internal_u16 v256_sad_u16_init(void) {
return c_v256_sad_u16_init();
}
SIMD_INLINE sad256_internal_u16 v256_sad_u16(sad256_internal_u16 s, v256 a,
@ -361,16 +374,4 @@ SIMD_INLINE uint32_t v256_sad_u16_sum(sad256_internal_u16 s) {
return c_v256_sad_u16_sum(s);
}
typedef uint64_t ssd256_internal_s16;
SIMD_INLINE ssd256_internal_s16 v256_ssd_s16_init() {
return c_v256_ssd_s16_init();
}
SIMD_INLINE ssd256_internal_s16 v256_ssd_s16(ssd256_internal_s16 s, v256 a,
v256 b) {
return c_v256_ssd_s16(s, a, b);
}
SIMD_INLINE uint64_t v256_ssd_s16_sum(ssd256_internal_s16 s) {
return c_v256_ssd_s16_sum(s);
}
#endif // AOM_AOM_DSP_SIMD_V256_INTRINSICS_H_

View file

@ -149,9 +149,16 @@ SIMD_INLINE uint64_t c_v256_hadd_u8(c_v256 a) {
return c_v128_hadd_u8(a.v128[1]) + c_v128_hadd_u8(a.v128[0]);
}
typedef uint32_t c_sad256_internal;
typedef struct {
uint32_t val;
int count;
} c_sad256_internal;
SIMD_INLINE c_sad256_internal c_v256_sad_u8_init() { return 0; }
SIMD_INLINE c_sad256_internal c_v256_sad_u8_init(void) {
c_sad256_internal t;
t.val = t.count = 0;
return t;
}
/* Implementation dependent return value. Result must be finalised with
v256_sad_u8_sum().
@ -160,11 +167,17 @@ SIMD_INLINE c_sad256_internal c_v256_sad_u8(c_sad256_internal s, c_v256 a,
c_v256 b) {
int c;
for (c = 0; c < 32; c++)
s += a.u8[c] > b.u8[c] ? a.u8[c] - b.u8[c] : b.u8[c] - a.u8[c];
s.val += a.u8[c] > b.u8[c] ? a.u8[c] - b.u8[c] : b.u8[c] - a.u8[c];
s.count++;
if (SIMD_CHECK && s.count > 32) {
fprintf(stderr,
"Error: sad called 32 times returning an undefined result\n");
abort();
}
return s;
}
SIMD_INLINE uint32_t c_v256_sad_u8_sum(c_sad256_internal s) { return s; }
SIMD_INLINE uint32_t c_v256_sad_u8_sum(c_sad256_internal s) { return s.val; }
typedef uint32_t c_ssd256_internal;
@ -746,6 +759,7 @@ SIMD_INLINE c_v256 c_v256_cmpeq_32(c_v256 a, c_v256 b) {
}
SIMD_INLINE c_v256 c_v256_shl_n_byte(c_v256 a, unsigned int n) {
if (n == 0) return a;
if (n < 16)
return c_v256_from_v128(c_v128_or(c_v128_shl_n_byte(a.v128[1], n),
c_v128_shr_n_byte(a.v128[0], 16 - n)),
@ -758,6 +772,7 @@ SIMD_INLINE c_v256 c_v256_shl_n_byte(c_v256 a, unsigned int n) {
}
SIMD_INLINE c_v256 c_v256_shr_n_byte(c_v256 a, unsigned int n) {
if (n == 0) return a;
if (n < 16)
return c_v256_from_v128(c_v128_shr_n_byte(a.v128[1], n),
c_v128_or(c_v128_shr_n_byte(a.v128[0], n),

View file

@ -73,7 +73,7 @@ SIMD_INLINE void v256_store_aligned(void *p, v256 a) {
v128_store_aligned((uint8_t *)p + 16, a.val[1]);
}
SIMD_INLINE v256 v256_zero() {
SIMD_INLINE v256 v256_zero(void) {
return v256_from_v128(v128_zero(), v128_zero());
}
@ -117,7 +117,7 @@ typedef struct {
sad128_internal val[2];
} sad256_internal;
SIMD_INLINE sad256_internal v256_sad_u8_init() {
SIMD_INLINE sad256_internal v256_sad_u8_init(void) {
sad256_internal t;
t.val[1] = v128_sad_u8_init();
t.val[0] = v128_sad_u8_init();
@ -142,7 +142,7 @@ typedef struct {
ssd128_internal val[2];
} ssd256_internal;
SIMD_INLINE ssd256_internal v256_ssd_u8_init() {
SIMD_INLINE ssd256_internal v256_ssd_u8_init(void) {
ssd256_internal t;
t.val[1] = v128_ssd_u8_init();
t.val[0] = v128_ssd_u8_init();
@ -780,13 +780,16 @@ SIMD_INLINE v256 v256_shr_s64(v256 a, const unsigned int c) {
(n) > 16 ? v128_shl_n_byte(a.val[0], (n)-16) : a.val[0], \
v128_zero()))
#define v256_shr_n_byte(a, n) \
((n) < 16 ? v256_from_v128(v128_shr_n_byte(a.val[1], n), \
v128_or(v128_shr_n_byte(a.val[0], n), \
v128_shl_n_byte(a.val[1], 16 - (n)))) \
: v256_from_v128( \
v128_zero(), \
(n) > 16 ? v128_shr_n_byte(a.val[1], (n)-16) : a.val[1]))
#define v256_shr_n_byte(a, n) \
(n == 0 \
? a \
: ((n) < 16 \
? v256_from_v128(v128_shr_n_byte(a.val[1], n), \
v128_or(v128_shr_n_byte(a.val[0], n), \
v128_shl_n_byte(a.val[1], 16 - (n)))) \
: v256_from_v128( \
v128_zero(), \
(n) > 16 ? v128_shr_n_byte(a.val[1], (n)-16) : a.val[1])))
#define v256_align(a, b, c) \
((c) ? v256_or(v256_shr_n_byte(b, c), v256_shl_n_byte(a, 32 - (c))) : b)
@ -823,7 +826,7 @@ typedef struct {
sad128_internal_u16 val[2];
} sad256_internal_u16;
SIMD_INLINE sad256_internal_u16 v256_sad_u16_init() {
SIMD_INLINE sad256_internal_u16 v256_sad_u16_init(void) {
sad256_internal_u16 t;
t.val[1] = v128_sad_u16_init();
t.val[0] = v128_sad_u16_init();
@ -849,7 +852,7 @@ typedef struct {
ssd128_internal_s16 val[2];
} ssd256_internal_s16;
SIMD_INLINE ssd256_internal_s16 v256_ssd_s16_init() {
SIMD_INLINE ssd256_internal_s16 v256_ssd_s16_init(void) {
ssd256_internal_s16 t;
t.val[1] = v128_ssd_s16_init();
t.val[0] = v128_ssd_s16_init();

View file

@ -57,7 +57,7 @@ SIMD_INLINE v256 v256_from_v64(v64 a, v64 b, v64 c, v64 d) {
}
SIMD_INLINE v256 v256_from_64(uint64_t a, uint64_t b, uint64_t c, uint64_t d) {
return v256_from_v128(v128_from_64(a, b), v128_from_64(c, d));
return _mm256_set_epi64x(a, b, c, d);
}
SIMD_INLINE v256 v256_load_aligned(const void *p) {
@ -76,7 +76,7 @@ SIMD_INLINE void v256_store_unaligned(void *p, v256 a) {
_mm256_storeu_si256((__m256i *)p, a);
}
SIMD_INLINE v256 v256_zero() { return _mm256_setzero_si256(); }
SIMD_INLINE v256 v256_zero(void) { return _mm256_setzero_si256(); }
SIMD_INLINE v256 v256_dup_8(uint8_t x) { return _mm256_set1_epi8(x); }
@ -187,11 +187,11 @@ SIMD_INLINE v256 v256_ziphi_64(v256 a, v256 b) {
}
SIMD_INLINE v256 v256_ziplo_128(v256 a, v256 b) {
return v256_from_v128(v256_low_v128(a), v256_low_v128(b));
return _mm256_permute2x128_si256(a, b, 0x02);
}
SIMD_INLINE v256 v256_ziphi_128(v256 a, v256 b) {
return v256_from_v128(v256_high_v128(a), v256_high_v128(b));
return _mm256_permute2x128_si256(a, b, 0x13);
}
SIMD_INLINE v256 v256_zip_8(v128 a, v128 b) {
@ -256,9 +256,7 @@ SIMD_INLINE v256 v256_unziplo_64(v256 a, v256 b) {
_MM_SHUFFLE(3, 1, 2, 0));
}
SIMD_INLINE v256 v256_unpack_u8_s16(v128 a) {
return v256_from_v128(v128_unpackhi_u8_s16(a), v128_unpacklo_u8_s16(a));
}
SIMD_INLINE v256 v256_unpack_u8_s16(v128 a) { return _mm256_cvtepu8_epi16(a); }
SIMD_INLINE v256 v256_unpacklo_u8_s16(v256 a) {
return _mm256_unpacklo_epi8(
@ -311,11 +309,11 @@ SIMD_INLINE v256 v256_pack_s16_s8(v256 a, v256 b) {
}
SIMD_INLINE v256 v256_unpack_u16_s32(v128 a) {
return v256_from_v128(v128_unpackhi_u16_s32(a), v128_unpacklo_u16_s32(a));
return _mm256_cvtepu16_epi32(a);
}
SIMD_INLINE v256 v256_unpack_s16_s32(v128 a) {
return v256_from_v128(v128_unpackhi_s16_s32(a), v128_unpacklo_s16_s32(a));
return _mm256_cvtepi16_epi32(a);
}
SIMD_INLINE v256 v256_unpacklo_u16_s32(v256 a) {
@ -442,7 +440,7 @@ SIMD_INLINE uint64_t v256_hadd_u8(v256 a) {
typedef v256 sad256_internal;
SIMD_INLINE sad256_internal v256_sad_u8_init() {
SIMD_INLINE sad256_internal v256_sad_u8_init(void) {
return _mm256_setzero_si256();
}
@ -460,7 +458,7 @@ SIMD_INLINE uint32_t v256_sad_u8_sum(sad256_internal s) {
typedef v256 ssd256_internal;
SIMD_INLINE ssd256_internal v256_ssd_u8_init() {
SIMD_INLINE ssd256_internal v256_ssd_u8_init(void) {
return _mm256_setzero_si256();
}
@ -603,7 +601,7 @@ SIMD_INLINE v256 v256_shl_8(v256 a, unsigned int c) {
}
SIMD_INLINE v256 v256_shr_u8(v256 a, unsigned int c) {
return _mm256_and_si256(_mm256_set1_epi8(0xff >> c),
return _mm256_and_si256(_mm256_set1_epi8((char)(0xff >> c)),
_mm256_srl_epi16(a, _mm_cvtsi32_si128(c)));
}
@ -646,7 +644,7 @@ SIMD_INLINE v256 v256_shr_u64(v256 a, unsigned int c) {
}
SIMD_INLINE v256 v256_shr_s64(v256 a, unsigned int c) {
#if defined(__AVX512F__)
#if defined(__AVX512VL__)
return _mm256_sra_epi64(a, _mm_cvtsi32_si128(c));
#else
return v256_from_v128(v128_shr_s64(v256_high_v128(a), c),
@ -670,13 +668,15 @@ SIMD_INLINE v256 v256_shr_s64(v256 a, unsigned int c) {
((n) < 16 \
? _mm256_alignr_epi8( \
_mm256_permute2x128_si256(a, a, _MM_SHUFFLE(2, 0, 0, 1)), a, n) \
: _mm256_inserti128_si256( \
_mm256_setzero_si256(), \
v128_align(v256_high_v128(a), v256_high_v128(a), n), 0))
: ((n) == 16 \
? _mm256_permute2x128_si256(_mm256_setzero_si256(), a, 3) \
: _mm256_inserti128_si256( \
_mm256_setzero_si256(), \
v128_align(v256_high_v128(a), v256_high_v128(a), n), 0)))
// _mm256_alignr_epi8 works on two 128 bit lanes and can't be used
#define v256_align(a, b, c) \
((c) ? v256_or(v256_shr_n_byte(b, c), v256_shl_n_byte(a, 32 - c)) : b)
((c) ? v256_or(v256_shr_n_byte(b, c), v256_shl_n_byte(a, 32 - (c))) : b)
#define v256_shl_n_8(a, c) \
_mm256_and_si256(_mm256_set1_epi8((uint8_t)(0xff << (c))), \
@ -701,7 +701,7 @@ SIMD_INLINE v256 v256_shr_s64(v256 a, unsigned int c) {
typedef v256 sad256_internal_u16;
SIMD_INLINE sad256_internal_u16 v256_sad_u16_init() { return v256_zero(); }
SIMD_INLINE sad256_internal_u16 v256_sad_u16_init(void) { return v256_zero(); }
/* Implementation dependent return value. Result must be finalised with
* v256_sad_u16_sum(). */
@ -728,7 +728,7 @@ SIMD_INLINE uint32_t v256_sad_u16_sum(sad256_internal_u16 s) {
typedef v256 ssd256_internal_s16;
SIMD_INLINE ssd256_internal_s16 v256_ssd_s16_init() { return v256_zero(); }
SIMD_INLINE ssd256_internal_s16 v256_ssd_s16_init(void) { return v256_zero(); }
/* Implementation dependent return value. Result must be finalised with
* v256_ssd_s16_sum(). */

View file

@ -65,7 +65,7 @@ SIMD_INLINE v64 v64_align(v64 a, v64 b, unsigned int c) {
return c_v64_align(a, b, c);
}
SIMD_INLINE v64 v64_zero() { return c_v64_zero(); }
SIMD_INLINE v64 v64_zero(void) { return c_v64_zero(); }
SIMD_INLINE v64 v64_dup_8(uint8_t x) { return c_v64_dup_8(x); }
SIMD_INLINE v64 v64_dup_16(uint16_t x) { return c_v64_dup_16(x); }
SIMD_INLINE v64 v64_dup_32(uint32_t x) { return c_v64_dup_32(x); }
@ -128,20 +128,22 @@ SIMD_INLINE v64 v64_shuffle_8(v64 a, v64 pattern) {
return c_v64_shuffle_8(a, pattern);
}
typedef uint32_t sad64_internal;
SIMD_INLINE sad64_internal v64_sad_u8_init() { return c_v64_sad_u8_init(); }
SIMD_INLINE sad64_internal v64_sad_u8(sad64_internal s, v64 a, v64 b) {
SIMD_INLINE c_sad64_internal v64_sad_u8_init(void) {
return c_v64_sad_u8_init();
}
SIMD_INLINE c_sad64_internal v64_sad_u8(c_sad64_internal s, v64 a, v64 b) {
return c_v64_sad_u8(s, a, b);
}
SIMD_INLINE uint32_t v64_sad_u8_sum(sad64_internal s) {
SIMD_INLINE uint32_t v64_sad_u8_sum(c_sad64_internal s) {
return c_v64_sad_u8_sum(s);
}
typedef uint32_t ssd64_internal;
SIMD_INLINE ssd64_internal v64_ssd_u8_init() { return c_v64_ssd_u8_init(); }
SIMD_INLINE ssd64_internal v64_ssd_u8(ssd64_internal s, v64 a, v64 b) {
SIMD_INLINE c_ssd64_internal v64_ssd_u8_init(void) {
return c_v64_ssd_u8_init();
}
SIMD_INLINE c_ssd64_internal v64_ssd_u8(c_ssd64_internal s, v64 a, v64 b) {
return c_v64_ssd_u8(s, a, b);
}
SIMD_INLINE uint32_t v64_ssd_u8_sum(ssd64_internal s) {
SIMD_INLINE uint32_t v64_ssd_u8_sum(c_ssd64_internal s) {
return c_v64_ssd_u8_sum(s);
}
SIMD_INLINE int64_t v64_dotp_su8(v64 a, v64 b) { return c_v64_dotp_su8(a, b); }

View file

@ -71,7 +71,11 @@ SIMD_INLINE void u32_store_unaligned(void *p, uint32_t a) {
#elif defined(__CC_ARM)
*(__packed uint32_t *)p) = a;
#elif defined(__GNUC__)
*((__attribute((packed)) uint32_t *)p) = a;
struct Unaligned32Struct {
uint32_t value;
uint8_t dummy; // To make the size non-power-of-two.
} __attribute__((__packed__));
((struct Unaligned32Struct *)p)->value = a;
#else
vst1_lane_u32((uint32_t *)p, vreinterpret_u32_s64((uint64x1_t)(uint64_t)a),
0);
@ -107,7 +111,7 @@ SIMD_INLINE v64 v64_align(v64 a, v64 b, unsigned int c) {
#endif
}
SIMD_INLINE v64 v64_zero() { return vreinterpret_s64_u8(vdup_n_u8(0)); }
SIMD_INLINE v64 v64_zero(void) { return vreinterpret_s64_u8(vdup_n_u8(0)); }
SIMD_INLINE v64 v64_dup_8(uint8_t x) {
return vreinterpret_s64_u8(vdup_n_u8(x));
@ -158,7 +162,7 @@ SIMD_INLINE int64_t v64_hadd_s16(v64 a) {
typedef uint16x8_t sad64_internal;
SIMD_INLINE sad64_internal v64_sad_u8_init() { return vdupq_n_u16(0); }
SIMD_INLINE sad64_internal v64_sad_u8_init(void) { return vdupq_n_u16(0); }
// Implementation dependent return value. Result must be finalised with
// v64_sad_u8_sum().
@ -177,7 +181,7 @@ SIMD_INLINE uint32_t v64_sad_u8_sum(sad64_internal s) {
typedef uint32x4_t ssd64_internal;
SIMD_INLINE ssd64_internal v64_ssd_u8_init() { return vdupq_n_u32(0); }
SIMD_INLINE ssd64_internal v64_ssd_u8_init(void) { return vdupq_n_u32(0); }
// Implementation dependent return value. Result must be finalised with
// v64_ssd_u8_sum().
@ -604,39 +608,39 @@ SIMD_INLINE v64 v64_shr_n_byte(v64 a, unsigned int c) {
}
SIMD_INLINE v64 v64_shl_n_8(v64 a, unsigned int c) {
return vreinterpret_s64_u8(vshl_n_u8(vreinterpret_u8_s64(a), c));
return c ? vreinterpret_s64_u8(vshl_n_u8(vreinterpret_u8_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shr_n_u8(v64 a, unsigned int c) {
return vreinterpret_s64_u8(vshr_n_u8(vreinterpret_u8_s64(a), c));
return c ? vreinterpret_s64_u8(vshr_n_u8(vreinterpret_u8_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shr_n_s8(v64 a, unsigned int c) {
return vreinterpret_s64_s8(vshr_n_s8(vreinterpret_s8_s64(a), c));
return c ? vreinterpret_s64_s8(vshr_n_s8(vreinterpret_s8_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shl_n_16(v64 a, unsigned int c) {
return vreinterpret_s64_u16(vshl_n_u16(vreinterpret_u16_s64(a), c));
return c ? vreinterpret_s64_u16(vshl_n_u16(vreinterpret_u16_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shr_n_u16(v64 a, unsigned int c) {
return vreinterpret_s64_u16(vshr_n_u16(vreinterpret_u16_s64(a), c));
return c ? vreinterpret_s64_u16(vshr_n_u16(vreinterpret_u16_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shr_n_s16(v64 a, unsigned int c) {
return vreinterpret_s64_s16(vshr_n_s16(vreinterpret_s16_s64(a), c));
return c ? vreinterpret_s64_s16(vshr_n_s16(vreinterpret_s16_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shl_n_32(v64 a, unsigned int c) {
return vreinterpret_s64_u32(vshl_n_u32(vreinterpret_u32_s64(a), c));
return c ? vreinterpret_s64_u32(vshl_n_u32(vreinterpret_u32_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shr_n_u32(v64 a, unsigned int c) {
return vreinterpret_s64_u32(vshr_n_u32(vreinterpret_u32_s64(a), c));
return c ? vreinterpret_s64_u32(vshr_n_u32(vreinterpret_u32_s64(a), c)) : a;
}
SIMD_INLINE v64 v64_shr_n_s32(v64 a, unsigned int c) {
return vreinterpret_s64_s32(vshr_n_s32(vreinterpret_s32_s64(a), c));
return c ? vreinterpret_s64_s32(vshr_n_s32(vreinterpret_s32_s64(a), c)) : a;
}
#else

View file

@ -143,7 +143,7 @@ SIMD_INLINE void c_v64_store_aligned(void *p, c_v64 a) {
c_v64_store_unaligned(p, a);
}
SIMD_INLINE c_v64 c_v64_zero() {
SIMD_INLINE c_v64 c_v64_zero(void) {
c_v64 t;
t.u64 = 0;
return t;
@ -171,14 +171,14 @@ SIMD_INLINE c_v64 c_v64_dup_32(uint32_t x) {
SIMD_INLINE c_v64 c_v64_add_8(c_v64 a, c_v64 b) {
c_v64 t;
int c;
for (c = 0; c < 8; c++) t.u8[c] = a.u8[c] + b.u8[c];
for (c = 0; c < 8; c++) t.u8[c] = (uint8_t)(a.u8[c] + b.u8[c]);
return t;
}
SIMD_INLINE c_v64 c_v64_add_16(c_v64 a, c_v64 b) {
c_v64 t;
int c;
for (c = 0; c < 4; c++) t.u16[c] = a.u16[c] + b.u16[c];
for (c = 0; c < 4; c++) t.u16[c] = (uint16_t)(a.u16[c] + b.u16[c]);
return t;
}
@ -228,7 +228,7 @@ SIMD_INLINE c_v64 c_v64_add_32(c_v64 a, c_v64 b) {
SIMD_INLINE c_v64 c_v64_sub_8(c_v64 a, c_v64 b) {
c_v64 t;
int c;
for (c = 0; c < 8; c++) t.u8[c] = a.u8[c] - b.u8[c];
for (c = 0; c < 8; c++) t.u8[c] = (uint8_t)(a.u8[c] - b.u8[c]);
return t;
}
@ -252,7 +252,7 @@ SIMD_INLINE c_v64 c_v64_ssub_s8(c_v64 a, c_v64 b) {
SIMD_INLINE c_v64 c_v64_sub_16(c_v64 a, c_v64 b) {
c_v64 t;
int c;
for (c = 0; c < 4; c++) t.u16[c] = a.u16[c] - b.u16[c];
for (c = 0; c < 4; c++) t.u16[c] = (uint16_t)(a.u16[c] - b.u16[c]);
return t;
}
@ -288,14 +288,15 @@ SIMD_INLINE c_v64 c_v64_abs_s16(c_v64 a) {
c_v64 t;
int c;
for (c = 0; c < 4; c++)
t.u16[c] = (int16_t)a.u16[c] > 0 ? a.u16[c] : -a.u16[c];
t.u16[c] = (uint16_t)((int16_t)a.u16[c] > 0 ? a.u16[c] : -a.u16[c]);
return t;
}
SIMD_INLINE c_v64 c_v64_abs_s8(c_v64 a) {
c_v64 t;
int c;
for (c = 0; c < 8; c++) t.u8[c] = (int8_t)a.u8[c] > 0 ? a.u8[c] : -a.u8[c];
for (c = 0; c < 8; c++)
t.u8[c] = (uint8_t)((int8_t)a.u8[c] > 0 ? a.u8[c] : -a.u8[c]);
return t;
}
@ -526,14 +527,14 @@ SIMD_INLINE c_v64 c_v64_pack_s16_s8(c_v64 a, c_v64 b) {
a = b;
b = u;
}
t.u8[7] = a.s16[3] > 127 ? 127 : a.s16[3] < -128 ? 128 : a.s16[3];
t.u8[6] = a.s16[2] > 127 ? 127 : a.s16[2] < -128 ? 128 : a.s16[2];
t.u8[5] = a.s16[1] > 127 ? 127 : a.s16[1] < -128 ? 128 : a.s16[1];
t.u8[4] = a.s16[0] > 127 ? 127 : a.s16[0] < -128 ? 128 : a.s16[0];
t.u8[3] = b.s16[3] > 127 ? 127 : b.s16[3] < -128 ? 128 : b.s16[3];
t.u8[2] = b.s16[2] > 127 ? 127 : b.s16[2] < -128 ? 128 : b.s16[2];
t.u8[1] = b.s16[1] > 127 ? 127 : b.s16[1] < -128 ? 128 : b.s16[1];
t.u8[0] = b.s16[0] > 127 ? 127 : b.s16[0] < -128 ? 128 : b.s16[0];
t.u8[7] = (uint8_t)(a.s16[3] > 127 ? 127 : a.s16[3] < -128 ? 128 : a.s16[3]);
t.u8[6] = (uint8_t)(a.s16[2] > 127 ? 127 : a.s16[2] < -128 ? 128 : a.s16[2]);
t.u8[5] = (uint8_t)(a.s16[1] > 127 ? 127 : a.s16[1] < -128 ? 128 : a.s16[1]);
t.u8[4] = (uint8_t)(a.s16[0] > 127 ? 127 : a.s16[0] < -128 ? 128 : a.s16[0]);
t.u8[3] = (uint8_t)(b.s16[3] > 127 ? 127 : b.s16[3] < -128 ? 128 : b.s16[3]);
t.u8[2] = (uint8_t)(b.s16[2] > 127 ? 127 : b.s16[2] < -128 ? 128 : b.s16[2]);
t.u8[1] = (uint8_t)(b.s16[1] > 127 ? 127 : b.s16[1] < -128 ? 128 : b.s16[1]);
t.u8[0] = (uint8_t)(b.s16[0] > 127 ? 127 : b.s16[0] < -128 ? 128 : b.s16[0]);
return t;
}
@ -600,28 +601,41 @@ SIMD_INLINE int64_t c_v64_hadd_s16(c_v64 a) {
return a.s16[3] + a.s16[2] + a.s16[1] + a.s16[0];
}
typedef uint32_t c_sad64_internal;
typedef struct {
uint32_t val;
int count;
} c_sad64_internal;
SIMD_INLINE c_sad64_internal c_v64_sad_u8_init(void) {
c_sad64_internal t;
t.val = t.count = 0;
return t;
}
/* Implementation dependent return value. Result must be finalised with
v64_sad_u8_sum().
The result for more than 32 v64_sad_u8() calls is undefined. */
SIMD_INLINE c_sad64_internal c_v64_sad_u8_init() { return 0; }
v64_sad_u8_sum(). The result for more than 32 v64_sad_u8() calls is
undefined. */
SIMD_INLINE c_sad64_internal c_v64_sad_u8(c_sad64_internal s, c_v64 a,
c_v64 b) {
int c;
for (c = 0; c < 8; c++)
s += a.u8[c] > b.u8[c] ? a.u8[c] - b.u8[c] : b.u8[c] - a.u8[c];
s.val += a.u8[c] > b.u8[c] ? a.u8[c] - b.u8[c] : b.u8[c] - a.u8[c];
s.count++;
if (SIMD_CHECK && s.count > 32) {
fprintf(stderr,
"Error: sad called 32 times returning an undefined result\n");
abort();
}
return s;
}
SIMD_INLINE uint32_t c_v64_sad_u8_sum(c_sad64_internal s) { return s; }
SIMD_INLINE uint32_t c_v64_sad_u8_sum(c_sad64_internal s) { return s.val; }
typedef uint32_t c_ssd64_internal;
/* Implementation dependent return value. Result must be finalised with
* v64_ssd_u8_sum(). */
SIMD_INLINE c_ssd64_internal c_v64_ssd_u8_init() { return 0; }
SIMD_INLINE c_ssd64_internal c_v64_ssd_u8_init(void) { return 0; }
SIMD_INLINE c_ssd64_internal c_v64_ssd_u8(c_ssd64_internal s, c_v64 a,
c_v64 b) {
@ -817,7 +831,7 @@ SIMD_INLINE c_v64 c_v64_shl_8(c_v64 a, unsigned int n) {
fprintf(stderr, "Error: Undefined u8 shift left %d\n", n);
abort();
}
for (c = 0; c < 8; c++) t.s8[c] = a.u8[c] << n;
for (c = 0; c < 8; c++) t.s8[c] = (int8_t)(a.u8[c] << n);
return t;
}
@ -850,7 +864,7 @@ SIMD_INLINE c_v64 c_v64_shl_16(c_v64 a, unsigned int n) {
fprintf(stderr, "Error: Undefined u16 shift left %d\n", n);
abort();
}
for (c = 0; c < 4; c++) t.u16[c] = a.u16[c] << n;
for (c = 0; c < 4; c++) t.u16[c] = (uint16_t)(a.u16[c] << n);
return t;
}

View file

@ -99,7 +99,7 @@ SIMD_INLINE void v64_store_unaligned(void *p, v64 a) {
: (b))
#endif
SIMD_INLINE v64 v64_zero() { return _mm_setzero_si128(); }
SIMD_INLINE v64 v64_zero(void) { return _mm_setzero_si128(); }
SIMD_INLINE v64 v64_dup_8(uint8_t x) { return _mm_set1_epi8(x); }
@ -319,7 +319,7 @@ SIMD_INLINE int64_t v64_hadd_s16(v64 a) {
typedef v64 sad64_internal;
SIMD_INLINE sad64_internal v64_sad_u8_init() { return _mm_setzero_si128(); }
SIMD_INLINE sad64_internal v64_sad_u8_init(void) { return _mm_setzero_si128(); }
/* Implementation dependent return value. Result must be finalised with
v64_sad_u8_sum().
@ -332,7 +332,7 @@ SIMD_INLINE uint32_t v64_sad_u8_sum(sad64_internal s) { return v64_low_u32(s); }
typedef v64 ssd64_internal;
SIMD_INLINE ssd64_internal v64_ssd_u8_init() { return _mm_setzero_si128(); }
SIMD_INLINE ssd64_internal v64_ssd_u8_init(void) { return _mm_setzero_si128(); }
/* Implementation dependent return value. Result must be finalised with
* v64_ssd_u8_sum(). */
@ -438,7 +438,7 @@ SIMD_INLINE v64 v64_shl_8(v64 a, unsigned int c) {
}
SIMD_INLINE v64 v64_shr_u8(v64 a, unsigned int c) {
return _mm_and_si128(_mm_set1_epi8(0xff >> c),
return _mm_and_si128(_mm_set1_epi8((char)(0xff >> c)),
_mm_srl_epi16(a, _mm_cvtsi32_si128(c)));
}

View file

@ -33,6 +33,7 @@ int64_t aom_sse_c(const uint8_t *a, int a_stride, const uint8_t *b,
return sse;
}
#if CONFIG_AV1_HIGHBITDEPTH
int64_t aom_highbd_sse_c(const uint8_t *a8, int a_stride, const uint8_t *b8,
int b_stride, int width, int height) {
int y, x;
@ -50,3 +51,4 @@ int64_t aom_highbd_sse_c(const uint8_t *a8, int a_stride, const uint8_t *b8,
}
return sse;
}
#endif

Some files were not shown because too many files have changed in this diff Show more