зеркало из https://github.com/mozilla/gecko-dev.git
Merge mozilla-central to fx-team
This commit is contained in:
Коммит
26f471ed60
|
@ -74,6 +74,7 @@ StyleInfo::TextIndent(nsAString& aValue)
|
|||
case eStyleUnit_Grad:
|
||||
case eStyleUnit_Radian:
|
||||
case eStyleUnit_Turn:
|
||||
case eStyleUnit_FlexFraction:
|
||||
case eStyleUnit_Integer:
|
||||
case eStyleUnit_Enumerated:
|
||||
case eStyleUnit_Calc:
|
||||
|
|
|
@ -861,6 +861,7 @@ TextAttrsMgr::TextPosTextAttr::
|
|||
case eStyleUnit_Grad:
|
||||
case eStyleUnit_Radian:
|
||||
case eStyleUnit_Turn:
|
||||
case eStyleUnit_FlexFraction:
|
||||
case eStyleUnit_Integer:
|
||||
case eStyleUnit_Calc:
|
||||
break;
|
||||
|
|
|
@ -30,10 +30,11 @@
|
|||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/EventTarget.h"
|
||||
#include "nsIDOMDataContainerEvent.h"
|
||||
#include "nsIDOMCustomEvent.h"
|
||||
#include "nsIDOMXULMultSelectCntrlEl.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIPropertyBag2.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIWebBrowserChrome.h"
|
||||
|
@ -657,25 +658,30 @@ void
|
|||
RootAccessible::HandleTreeRowCountChangedEvent(nsIDOMEvent* aEvent,
|
||||
XULTreeAccessible* aAccessible)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDataContainerEvent> dataEvent(do_QueryInterface(aEvent));
|
||||
if (!dataEvent)
|
||||
nsCOMPtr<nsIDOMCustomEvent> customEvent(do_QueryInterface(aEvent));
|
||||
if (!customEvent)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIVariant> indexVariant;
|
||||
dataEvent->GetData(NS_LITERAL_STRING("index"),
|
||||
getter_AddRefs(indexVariant));
|
||||
if (!indexVariant)
|
||||
nsCOMPtr<nsIVariant> detailVariant;
|
||||
customEvent->GetDetail(getter_AddRefs(detailVariant));
|
||||
if (!detailVariant)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIVariant> countVariant;
|
||||
dataEvent->GetData(NS_LITERAL_STRING("count"),
|
||||
getter_AddRefs(countVariant));
|
||||
if (!countVariant)
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
detailVariant->GetAsISupports(getter_AddRefs(supports));
|
||||
nsCOMPtr<nsIPropertyBag2> propBag(do_QueryInterface(supports));
|
||||
if (!propBag)
|
||||
return;
|
||||
|
||||
nsresult rv;
|
||||
int32_t index, count;
|
||||
indexVariant->GetAsInt32(&index);
|
||||
countVariant->GetAsInt32(&count);
|
||||
rv = propBag->GetPropertyAsInt32(NS_LITERAL_STRING("index"), &index);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
rv = propBag->GetPropertyAsInt32(NS_LITERAL_STRING("count"), &count);
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
aAccessible->InvalidateCache(index, count);
|
||||
}
|
||||
|
@ -684,35 +690,30 @@ void
|
|||
RootAccessible::HandleTreeInvalidatedEvent(nsIDOMEvent* aEvent,
|
||||
XULTreeAccessible* aAccessible)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDataContainerEvent> dataEvent(do_QueryInterface(aEvent));
|
||||
if (!dataEvent)
|
||||
nsCOMPtr<nsIDOMCustomEvent> customEvent(do_QueryInterface(aEvent));
|
||||
if (!customEvent)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIVariant> detailVariant;
|
||||
customEvent->GetDetail(getter_AddRefs(detailVariant));
|
||||
if (!detailVariant)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
detailVariant->GetAsISupports(getter_AddRefs(supports));
|
||||
nsCOMPtr<nsIPropertyBag2> propBag(do_QueryInterface(supports));
|
||||
if (!propBag)
|
||||
return;
|
||||
|
||||
int32_t startRow = 0, endRow = -1, startCol = 0, endCol = -1;
|
||||
|
||||
nsCOMPtr<nsIVariant> startRowVariant;
|
||||
dataEvent->GetData(NS_LITERAL_STRING("startrow"),
|
||||
getter_AddRefs(startRowVariant));
|
||||
if (startRowVariant)
|
||||
startRowVariant->GetAsInt32(&startRow);
|
||||
|
||||
nsCOMPtr<nsIVariant> endRowVariant;
|
||||
dataEvent->GetData(NS_LITERAL_STRING("endrow"),
|
||||
getter_AddRefs(endRowVariant));
|
||||
if (endRowVariant)
|
||||
endRowVariant->GetAsInt32(&endRow);
|
||||
|
||||
nsCOMPtr<nsIVariant> startColVariant;
|
||||
dataEvent->GetData(NS_LITERAL_STRING("startcolumn"),
|
||||
getter_AddRefs(startColVariant));
|
||||
if (startColVariant)
|
||||
startColVariant->GetAsInt32(&startCol);
|
||||
|
||||
nsCOMPtr<nsIVariant> endColVariant;
|
||||
dataEvent->GetData(NS_LITERAL_STRING("endcolumn"),
|
||||
getter_AddRefs(endColVariant));
|
||||
if (endColVariant)
|
||||
endColVariant->GetAsInt32(&endCol);
|
||||
propBag->GetPropertyAsInt32(NS_LITERAL_STRING("startrow"),
|
||||
&startRow);
|
||||
propBag->GetPropertyAsInt32(NS_LITERAL_STRING("endrow"),
|
||||
&endRow);
|
||||
propBag->GetPropertyAsInt32(NS_LITERAL_STRING("startcolumn"),
|
||||
&startCol);
|
||||
propBag->GetPropertyAsInt32(NS_LITERAL_STRING("endcolumn"),
|
||||
&endCol);
|
||||
|
||||
aAccessible->TreeViewInvalidated(startRow, endRow, startCol, endCol);
|
||||
}
|
||||
|
|
|
@ -32,10 +32,11 @@
|
|||
this.target = gTree;
|
||||
this.check = function check(aEvent)
|
||||
{
|
||||
var index = aEvent.getData("index");
|
||||
var propBag = aEvent.detail.QueryInterface(Components.interfaces.nsIPropertyBag2);
|
||||
var index = propBag.getPropertyAsInt32("index");
|
||||
is(index, aIdx, "Wrong 'index' data of 'treeRowCountChanged' event.");
|
||||
|
||||
var count = aEvent.getData("count");
|
||||
var count = propBag.getPropertyAsInt32("count");
|
||||
is(count, aCount, "Wrong 'count' data of 'treeRowCountChanged' event.");
|
||||
}
|
||||
this.getID = function getID()
|
||||
|
@ -53,19 +54,36 @@
|
|||
this.target = gTree;
|
||||
this.check = function check(aEvent)
|
||||
{
|
||||
var startRow = aEvent.getData("startrow");
|
||||
var propBag = aEvent.detail.QueryInterface(Components.interfaces.nsIPropertyBag2);
|
||||
try {
|
||||
var startRow = propBag.getPropertyAsInt32("startrow");
|
||||
} catch (e if e.name == 'NS_ERROR_NOT_AVAILABLE') {
|
||||
startRow = null;
|
||||
}
|
||||
is(startRow, aStartRow,
|
||||
"Wrong 'startrow' of 'treeInvalidated' event on " + aMsg);
|
||||
|
||||
var endRow = aEvent.getData("endrow");
|
||||
try {
|
||||
var endRow = propBag.getPropertyAsInt32("endrow");
|
||||
} catch (e if e.name == 'NS_ERROR_NOT_AVAILABLE') {
|
||||
endRow = null;
|
||||
}
|
||||
is(endRow, aEndRow,
|
||||
"Wrong 'endrow' of 'treeInvalidated' event on " + aMsg);
|
||||
|
||||
var startCol = aEvent.getData("startcolumn");
|
||||
try {
|
||||
var startCol = propBag.getPropertyAsInt32("startcolumn");
|
||||
} catch (e if e.name == 'NS_ERROR_NOT_AVAILABLE') {
|
||||
startCol = null;
|
||||
}
|
||||
is(startCol, aStartCol,
|
||||
"Wrong 'startcolumn' of 'treeInvalidated' event on " + aMsg);
|
||||
|
||||
var endCol = aEvent.getData("endcolumn");
|
||||
try {
|
||||
var endCol = propBag.getPropertyAsInt32("endcolumn");
|
||||
} catch (e if e.name == 'NS_ERROR_NOT_AVAILABLE') {
|
||||
startCol = null;
|
||||
}
|
||||
is(endCol, aEndCol,
|
||||
"Wrong 'endcolumn' of 'treeInvalidated' event on " + aMsg);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ function Buffer(subject, encoding /*, bufferLength */) {
|
|||
case 'number':
|
||||
// Create typed array of the given size if number.
|
||||
try {
|
||||
let buffer = Uint8Array(subject > 0 ? Math.floor(subject) : 0);
|
||||
let buffer = new Uint8Array(subject > 0 ? Math.floor(subject) : 0);
|
||||
return buffer;
|
||||
} catch (e) {
|
||||
if (/size and count too large/.test(e.message) ||
|
||||
|
@ -58,19 +58,19 @@ function Buffer(subject, encoding /*, bufferLength */) {
|
|||
// If string encode it and use buffer for the returned Uint8Array
|
||||
// to create a local patched version that acts like node buffer.
|
||||
encoding = encoding || 'utf8';
|
||||
return Uint8Array(new TextEncoder(encoding).encode(subject).buffer);
|
||||
return new Uint8Array(new TextEncoder(encoding).encode(subject).buffer);
|
||||
case 'object':
|
||||
// This form of the constructor uses the form of
|
||||
// Uint8Array(buffer, offset, length);
|
||||
// new Uint8Array(buffer, offset, length);
|
||||
// So we can instantiate a typed array within the constructor
|
||||
// to inherit the appropriate properties, where both the
|
||||
// `subject` and newly instantiated buffer share the same underlying
|
||||
// data structure.
|
||||
if (arguments.length === 3)
|
||||
return Uint8Array(subject, encoding, arguments[2]);
|
||||
return new Uint8Array(subject, encoding, arguments[2]);
|
||||
// If array or alike just make a copy with a local patched prototype.
|
||||
else
|
||||
return Uint8Array(subject);
|
||||
return new Uint8Array(subject);
|
||||
default:
|
||||
throw new TypeError('must start with number, buffer, array or string');
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ Object.defineProperties(Buffer.prototype, {
|
|||
get: function () {
|
||||
let view = views.get(this, undefined);
|
||||
if (view) return view;
|
||||
view = DataView(this.buffer);
|
||||
view = new DataView(this.buffer);
|
||||
views.set(this, view);
|
||||
return view;
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ Object.defineProperties(Buffer.prototype, {
|
|||
if (end < start)
|
||||
end = start;
|
||||
|
||||
// This instantiation uses the Uint8Array(buffer, offset, length) version
|
||||
// This instantiation uses the new Uint8Array(buffer, offset, length) version
|
||||
// of construction to share the same underling data structure
|
||||
let buffer = new Buffer(this.buffer, start, end - start);
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="2c06eb8cfc7eee1021c868a6a8b030242007b684"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="cc13cdff437c3df45374f5622094a3565a414d5b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d11f524d00cacf5ba0dfbf25e4aa2158b1c3a036"/>
|
||||
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="456499c44d1ef39b602ea02e9ed460b6aab85b44"/>
|
||||
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="0f9f3d948d6ba25c47fbec29e2eff02c8590e2e2"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="cb16958e41105d7c551d9941f522db97b8312538"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="485846b2a40d8ac7d6c1c5f8af6d15b0c10af19d"/>
|
||||
<!-- Stock Android things -->
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="2c06eb8cfc7eee1021c868a6a8b030242007b684"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="cc13cdff437c3df45374f5622094a3565a414d5b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="cb16958e41105d7c551d9941f522db97b8312538"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="485846b2a40d8ac7d6c1c5f8af6d15b0c10af19d"/>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<project name="platform_build" path="build" remote="b2g" revision="a9e08b91e9cd1f0930f16cfc49ec72f63575d5fe">
|
||||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="2c06eb8cfc7eee1021c868a6a8b030242007b684"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="cc13cdff437c3df45374f5622094a3565a414d5b"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="cb16958e41105d7c551d9941f522db97b8312538"/>
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="2c06eb8cfc7eee1021c868a6a8b030242007b684"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="cc13cdff437c3df45374f5622094a3565a414d5b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="d11f524d00cacf5ba0dfbf25e4aa2158b1c3a036"/>
|
||||
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="456499c44d1ef39b602ea02e9ed460b6aab85b44"/>
|
||||
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="0f9f3d948d6ba25c47fbec29e2eff02c8590e2e2"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="cb16958e41105d7c551d9941f522db97b8312538"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="485846b2a40d8ac7d6c1c5f8af6d15b0c10af19d"/>
|
||||
<!-- Stock Android things -->
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
"branch": "",
|
||||
"revision": ""
|
||||
},
|
||||
"revision": "a9008fd903e2b258d481ef072353b5219f74c158",
|
||||
"revision": "3045bf73d5cc752ba8c548d82ea567987743c3bd",
|
||||
"repo_path": "/integration/gaia-central"
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="2c06eb8cfc7eee1021c868a6a8b030242007b684"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="cc13cdff437c3df45374f5622094a3565a414d5b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="2c06eb8cfc7eee1021c868a6a8b030242007b684"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="cc13cdff437c3df45374f5622094a3565a414d5b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="2c06eb8cfc7eee1021c868a6a8b030242007b684"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="cc13cdff437c3df45374f5622094a3565a414d5b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="2c06eb8cfc7eee1021c868a6a8b030242007b684"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="cc13cdff437c3df45374f5622094a3565a414d5b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</project>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="2c06eb8cfc7eee1021c868a6a8b030242007b684"/>
|
||||
<project name="gaia" path="gaia" remote="mozillaorg" revision="cc13cdff437c3df45374f5622094a3565a414d5b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="moztt" path="external/moztt" remote="b2g" revision="cb16958e41105d7c551d9941f522db97b8312538"/>
|
||||
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="485846b2a40d8ac7d6c1c5f8af6d15b0c10af19d"/>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<copyfile dest="Makefile" src="core/root.mk"/>
|
||||
</project>
|
||||
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="2c06eb8cfc7eee1021c868a6a8b030242007b684"/>
|
||||
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="cc13cdff437c3df45374f5622094a3565a414d5b"/>
|
||||
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="266bca6e60dad43e395f38b66edabe8bdc882334"/>
|
||||
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
|
||||
<project name="librecovery" path="librecovery" remote="b2g" revision="1f6a1fe07f81c5bc5e1d079c9b60f7f78ca2bf4f"/>
|
||||
|
|
|
@ -1142,15 +1142,16 @@ var gPluginHandler = {
|
|||
// plugin in content.
|
||||
pluginInstanceCrashed: function (plugin, aEvent) {
|
||||
// Ensure the plugin and event are of the right type.
|
||||
if (!(aEvent instanceof Ci.nsIDOMDataContainerEvent))
|
||||
if (!(aEvent instanceof Ci.nsIDOMCustomEvent))
|
||||
return;
|
||||
|
||||
let submittedReport = aEvent.getData("submittedCrashReport");
|
||||
let doPrompt = true; // XXX followup for .getData("doPrompt");
|
||||
let submitReports = true; // XXX followup for .getData("submitReports");
|
||||
let pluginName = aEvent.getData("pluginName");
|
||||
let pluginDumpID = aEvent.getData("pluginDumpID");
|
||||
let browserDumpID = aEvent.getData("browserDumpID");
|
||||
let propBag = aEvent.detail.QueryInterface(Ci.nsIPropertyBag2);
|
||||
let submittedReport = propBag.getPropertyAsBool("submittedCrashReport");
|
||||
let doPrompt = true; // XXX followup for .getPropertyAsBool("doPrompt");
|
||||
let submitReports = true; // XXX followup for .getPropertyAsBool("submitReports");
|
||||
let pluginName = propBag.getPropertyAsAString("pluginName");
|
||||
let pluginDumpID = propBag.getPropertyAsAString("pluginDumpID");
|
||||
let browserDumpID = propBag.getPropertyAsAString("browserDumpID");
|
||||
|
||||
// Remap the plugin name to a more user-presentable form.
|
||||
pluginName = this.makeNicePluginName(pluginName);
|
||||
|
|
|
@ -433,7 +433,7 @@ var gPopupBlockerObserver = {
|
|||
if (!this._reportButton && gURLBar)
|
||||
this._reportButton = document.getElementById("page-report-button");
|
||||
|
||||
if (!gBrowser.pageReport) {
|
||||
if (!gBrowser.selectedBrowser.blockedPopups) {
|
||||
// Hide the icon in the location bar (if the location bar exists)
|
||||
if (gURLBar)
|
||||
this._reportButton.hidden = true;
|
||||
|
@ -446,11 +446,11 @@ var gPopupBlockerObserver = {
|
|||
// Only show the notification again if we've not already shown it. Since
|
||||
// notifications are per-browser, we don't need to worry about re-adding
|
||||
// it.
|
||||
if (!gBrowser.pageReport.reported) {
|
||||
if (!gBrowser.selectedBrowser.blockedPopups.reported) {
|
||||
if (gPrefService.getBoolPref("privacy.popups.showBrowserMessage")) {
|
||||
var brandBundle = document.getElementById("bundle_brand");
|
||||
var brandShortName = brandBundle.getString("brandShortName");
|
||||
var popupCount = gBrowser.pageReport.length;
|
||||
var popupCount = gBrowser.selectedBrowser.blockedPopups.length;
|
||||
#ifdef XP_WIN
|
||||
var popupButtonText = gNavigatorBundle.getString("popupWarningButton");
|
||||
var popupButtonAccesskey = gNavigatorBundle.getString("popupWarningButton.accesskey");
|
||||
|
@ -485,7 +485,7 @@ var gPopupBlockerObserver = {
|
|||
|
||||
// Record the fact that we've reported this blocked popup, so we don't
|
||||
// show it again.
|
||||
gBrowser.pageReport.reported = true;
|
||||
gBrowser.selectedBrowser.blockedPopups.reported = true;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -502,7 +502,7 @@ var gPopupBlockerObserver = {
|
|||
fillPopupList: function (aEvent)
|
||||
{
|
||||
// XXXben - rather than using |currentURI| here, which breaks down on multi-framed sites
|
||||
// we should really walk the pageReport and create a list of "allow for <host>"
|
||||
// we should really walk the blockedPopups and create a list of "allow for <host>"
|
||||
// menuitems for the common subset of hosts present in the report, this will
|
||||
// make us frame-safe.
|
||||
//
|
||||
|
@ -510,7 +510,8 @@ var gPopupBlockerObserver = {
|
|||
// also back out the fix for bug 343772 where
|
||||
// nsGlobalWindow::CheckOpenAllow() was changed to also
|
||||
// check if the top window's location is whitelisted.
|
||||
var uri = gBrowser.currentURI;
|
||||
let browser = gBrowser.selectedBrowser;
|
||||
var uri = browser.currentURI;
|
||||
var blockedPopupAllowSite = document.getElementById("blockedPopupAllowSite");
|
||||
try {
|
||||
blockedPopupAllowSite.removeAttribute("hidden");
|
||||
|
@ -540,16 +541,18 @@ var gPopupBlockerObserver = {
|
|||
blockedPopupAllowSite.removeAttribute("disabled");
|
||||
|
||||
var foundUsablePopupURI = false;
|
||||
var pageReports = gBrowser.pageReport;
|
||||
if (pageReports) {
|
||||
for (let pageReport of pageReports) {
|
||||
var blockedPopups = browser.blockedPopups;
|
||||
if (blockedPopups) {
|
||||
for (let i = 0; i < blockedPopups.length; i++) {
|
||||
let blockedPopup = blockedPopups[i];
|
||||
|
||||
// popupWindowURI will be null if the file picker popup is blocked.
|
||||
// xxxdz this should make the option say "Show file picker" and do it (Bug 590306)
|
||||
if (!pageReport.popupWindowURI)
|
||||
if (!blockedPopup.popupWindowURI)
|
||||
continue;
|
||||
var popupURIspec = pageReport.popupWindowURI.spec;
|
||||
var popupURIspec = blockedPopup.popupWindowURI;
|
||||
|
||||
// Sometimes the popup URI that we get back from the pageReport
|
||||
// Sometimes the popup URI that we get back from the blockedPopup
|
||||
// isn't useful (for instance, netscape.com's popup URI ends up
|
||||
// being "http://www.netscape.com", which isn't really the URI of
|
||||
// the popup they're trying to show). This isn't going to be
|
||||
|
@ -570,11 +573,11 @@ var gPopupBlockerObserver = {
|
|||
[popupURIspec]);
|
||||
menuitem.setAttribute("label", label);
|
||||
menuitem.setAttribute("popupWindowURI", popupURIspec);
|
||||
menuitem.setAttribute("popupWindowFeatures", pageReport.popupWindowFeatures);
|
||||
menuitem.setAttribute("popupWindowName", pageReport.popupWindowName);
|
||||
menuitem.setAttribute("popupWindowFeatures", blockedPopup.popupWindowFeatures);
|
||||
menuitem.setAttribute("popupWindowName", blockedPopup.popupWindowName);
|
||||
menuitem.setAttribute("oncommand", "gPopupBlockerObserver.showBlockedPopup(event);");
|
||||
menuitem.requestingWindow = pageReport.requestingWindow;
|
||||
menuitem.requestingDocument = pageReport.requestingDocument;
|
||||
menuitem.setAttribute("popupReportIndex", i);
|
||||
menuitem.popupReportBrowser = browser;
|
||||
aEvent.target.appendChild(menuitem);
|
||||
}
|
||||
}
|
||||
|
@ -613,17 +616,9 @@ var gPopupBlockerObserver = {
|
|||
showBlockedPopup: function (aEvent)
|
||||
{
|
||||
var target = aEvent.target;
|
||||
var popupWindowURI = target.getAttribute("popupWindowURI");
|
||||
var features = target.getAttribute("popupWindowFeatures");
|
||||
var name = target.getAttribute("popupWindowName");
|
||||
|
||||
var dwi = target.requestingWindow;
|
||||
|
||||
// If we have a requesting window and the requesting document is
|
||||
// still the current document, open the popup.
|
||||
if (dwi && dwi.document == target.requestingDocument) {
|
||||
dwi.open(popupWindowURI, name, features);
|
||||
}
|
||||
var popupReportIndex = target.getAttribute("popupReportIndex");
|
||||
let browser = target.popupReportBrowser;
|
||||
browser.unblockPopup(popupReportIndex);
|
||||
},
|
||||
|
||||
editPopupSettings: function ()
|
||||
|
|
|
@ -996,11 +996,11 @@
|
|||
oldBrowser.docShellIsActive = false;
|
||||
}
|
||||
|
||||
var updatePageReport = false;
|
||||
var updateBlockedPopups = false;
|
||||
if (!oldBrowser ||
|
||||
(oldBrowser.pageReport && !newBrowser.pageReport) ||
|
||||
(!oldBrowser.pageReport && newBrowser.pageReport))
|
||||
updatePageReport = true;
|
||||
(oldBrowser.blockedPopups && !newBrowser.blockedPopups) ||
|
||||
(!oldBrowser.blockedPopups && newBrowser.blockedPopups))
|
||||
updateBlockedPopups = true;
|
||||
|
||||
newBrowser.setAttribute("type", "content-primary");
|
||||
newBrowser.docShellIsActive =
|
||||
|
@ -1020,8 +1020,8 @@
|
|||
|
||||
this._appendStatusPanel();
|
||||
|
||||
if (updatePageReport)
|
||||
this.mCurrentBrowser.updatePageReport();
|
||||
if (updateBlockedPopups)
|
||||
this.mCurrentBrowser.updateBlockedPopups(false);
|
||||
|
||||
// Update the URL bar.
|
||||
var loc = this.mCurrentBrowser.currentURI;
|
||||
|
@ -2795,10 +2795,6 @@
|
|||
]]></body>
|
||||
</method>
|
||||
|
||||
<property name="pageReport"
|
||||
onget="return this.mCurrentBrowser.pageReport;"
|
||||
readonly="true"/>
|
||||
|
||||
<property name="currentURI"
|
||||
onget="return this.mCurrentBrowser.currentURI;"
|
||||
readonly="true"/>
|
||||
|
|
|
@ -304,7 +304,7 @@ MainPreferencesPropertyList.prototype = {
|
|||
binaryStream.setInputStream(inputStream);
|
||||
let bytes = binaryStream.readByteArray(inputStream.available());
|
||||
this._dict = PropertyListUtils._readFromArrayBufferSync(
|
||||
Uint8Array(bytes).buffer);
|
||||
new Uint8Array(bytes).buffer);
|
||||
return this._dict;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -81,7 +81,7 @@ DEBUGGER_INFO = {
|
|||
"interactive": False,
|
||||
"args": " ".join(["--leak-check=full",
|
||||
"--show-possibly-lost=no",
|
||||
"--smc-check=all-non-file,"
|
||||
"--smc-check=all-non-file",
|
||||
"--vex-iropt-register-updates=allregs-at-mem-access"])
|
||||
}
|
||||
}
|
||||
|
|
21
configure.in
21
configure.in
|
@ -3948,6 +3948,7 @@ MOZ_GSTREAMER=
|
|||
MOZ_DIRECTSHOW=
|
||||
MOZ_WMF=
|
||||
MOZ_FMP4=
|
||||
MOZ_FFMPEG=
|
||||
MOZ_WEBRTC=1
|
||||
MOZ_PEERCONNECTION=
|
||||
MOZ_SRTP=
|
||||
|
@ -5266,10 +5267,27 @@ if test -n "$MOZ_WMF"; then
|
|||
AC_DEFINE(MOZ_WMF)
|
||||
fi;
|
||||
|
||||
dnl ========================================================
|
||||
dnl FFmpeg H264/AAC Decoding Support
|
||||
dnl ========================================================
|
||||
if test "$OS_TARGET" = "Linux"; then
|
||||
MOZ_FFMPEG=1
|
||||
fi
|
||||
|
||||
MOZ_ARG_DISABLE_BOOL(ffmpeg,
|
||||
[ --disable-ffmpeg Disable FFmpeg for fragmented H264/AAC decoding],
|
||||
MOZ_FFMPEG=,
|
||||
MOZ_FFMPEG=1
|
||||
)
|
||||
|
||||
if test -n "$MOZ_FFMPEG"; then
|
||||
AC_DEFINE(MOZ_FFMPEG)
|
||||
fi;
|
||||
|
||||
dnl ========================================================
|
||||
dnl = Built-in fragmented MP4 support.
|
||||
dnl ========================================================
|
||||
if test -n "$MOZ_WMF"; then
|
||||
if test -n "$MOZ_WMF" -o -n "$MOZ_FFMPEG"; then
|
||||
dnl Enable fragmented MP4 parser on Windows by default.
|
||||
dnl We will also need to enable it on other platforms as we implement
|
||||
dnl platform decoder support there too.
|
||||
|
@ -8693,6 +8711,7 @@ AC_SUBST(MOZ_TREMOR)
|
|||
AC_SUBST(MOZ_OPUS)
|
||||
AC_SUBST(MOZ_WEBM)
|
||||
AC_SUBST(MOZ_WMF)
|
||||
AC_SUBST(MOZ_FFMPEG)
|
||||
AC_SUBST(MOZ_FMP4)
|
||||
AC_SUBST(MOZ_DIRECTSHOW)
|
||||
AC_SUBST(MOZ_MEDIA_PLUGINS)
|
||||
|
|
|
@ -65,10 +65,17 @@ inline bool IsSpaceCharacter(char aChar) {
|
|||
return aChar == ' ' || aChar == '\t' || aChar == '\n' || aChar == '\r' ||
|
||||
aChar == '\f';
|
||||
}
|
||||
struct BoxQuadOptions;
|
||||
struct ConvertCoordinateOptions;
|
||||
class DOMPoint;
|
||||
class DOMQuad;
|
||||
class DOMRectReadOnly;
|
||||
class Element;
|
||||
class EventHandlerNonNull;
|
||||
class OnErrorEventHandlerNonNull;
|
||||
template<typename T> class Optional;
|
||||
class TextOrElementOrDocument;
|
||||
struct DOMPointInit;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -279,6 +286,15 @@ private:
|
|||
class nsINode : public mozilla::dom::EventTarget
|
||||
{
|
||||
public:
|
||||
typedef mozilla::dom::BoxQuadOptions BoxQuadOptions;
|
||||
typedef mozilla::dom::ConvertCoordinateOptions ConvertCoordinateOptions;
|
||||
typedef mozilla::dom::DOMPoint DOMPoint;
|
||||
typedef mozilla::dom::DOMPointInit DOMPointInit;
|
||||
typedef mozilla::dom::DOMQuad DOMQuad;
|
||||
typedef mozilla::dom::DOMRectReadOnly DOMRectReadOnly;
|
||||
typedef mozilla::dom::TextOrElementOrDocument TextOrElementOrDocument;
|
||||
typedef mozilla::ErrorResult ErrorResult;
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODE_IID)
|
||||
|
||||
// Among the sub-classes that inherit (directly or indirectly) from nsINode,
|
||||
|
@ -1610,6 +1626,23 @@ public:
|
|||
mozilla::dom::Element* GetFirstElementChild() const;
|
||||
mozilla::dom::Element* GetLastElementChild() const;
|
||||
|
||||
void GetBoxQuads(const BoxQuadOptions& aOptions,
|
||||
nsTArray<nsRefPtr<DOMQuad> >& aResult,
|
||||
mozilla::ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<DOMQuad> ConvertQuadFromNode(DOMQuad& aQuad,
|
||||
const TextOrElementOrDocument& aFrom,
|
||||
const ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
already_AddRefed<DOMQuad> ConvertRectFromNode(DOMRectReadOnly& aRect,
|
||||
const TextOrElementOrDocument& aFrom,
|
||||
const ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
already_AddRefed<DOMPoint> ConvertPointFromNode(const DOMPointInit& aPoint,
|
||||
const TextOrElementOrDocument& aFrom,
|
||||
const ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
|
||||
protected:
|
||||
|
||||
// Override this function to create a custom slots class.
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/DOMPoint.h"
|
||||
|
||||
#include "mozilla/dom/DOMPointBinding.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DOMPoint, mParent)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMPoint, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMPoint, Release)
|
||||
|
||||
already_AddRefed<DOMPoint>
|
||||
DOMPoint::Constructor(const GlobalObject& aGlobal, const DOMPointInit& aParams,
|
||||
ErrorResult& aRV)
|
||||
{
|
||||
nsRefPtr<DOMPoint> obj =
|
||||
new DOMPoint(aGlobal.GetAsSupports(), aParams.mX, aParams.mY,
|
||||
aParams.mZ, aParams.mW);
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMPoint>
|
||||
DOMPoint::Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
||||
double aZ, double aW, ErrorResult& aRV)
|
||||
{
|
||||
nsRefPtr<DOMPoint> obj =
|
||||
new DOMPoint(aGlobal.GetAsSupports(), aX, aY, aZ, aW);
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
JSObject*
|
||||
DOMPoint::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
return DOMPointBinding::Wrap(aCx, aScope, this);
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef MOZILLA_DOMPOINT_H_
|
||||
#define MOZILLA_DOMPOINT_H_
|
||||
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class GlobalObject;
|
||||
class DOMPointInit;
|
||||
|
||||
class DOMPointReadOnly : public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
DOMPointReadOnly(nsISupports* aParent, double aX, double aY,
|
||||
double aZ, double aW)
|
||||
: mParent(aParent)
|
||||
, mX(aX)
|
||||
, mY(aY)
|
||||
, mZ(aZ)
|
||||
, mW(aW)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
double X() const { return mX; }
|
||||
double Y() const { return mY; }
|
||||
double Z() const { return mZ; }
|
||||
double W() const { return mW; }
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
double mX, mY, mZ, mW;
|
||||
};
|
||||
|
||||
class DOMPoint MOZ_FINAL : public DOMPointReadOnly
|
||||
{
|
||||
public:
|
||||
DOMPoint(nsISupports* aParent, double aX = 0.0, double aY = 0.0,
|
||||
double aZ = 0.0, double aW = 1.0)
|
||||
: DOMPointReadOnly(aParent, aX, aY, aZ, aW)
|
||||
{}
|
||||
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMPoint)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMPoint)
|
||||
|
||||
static already_AddRefed<DOMPoint>
|
||||
Constructor(const GlobalObject& aGlobal, const DOMPointInit& aParams,
|
||||
ErrorResult& aRV);
|
||||
static already_AddRefed<DOMPoint>
|
||||
Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
||||
double aZ, double aW, ErrorResult& aRV);
|
||||
|
||||
nsISupports* GetParentObject() const { return mParent; }
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
void SetX(double aX) { mX = aX; }
|
||||
void SetY(double aY) { mY = aY; }
|
||||
void SetZ(double aZ) { mZ = aZ; }
|
||||
void SetW(double aW) { mW = aW; }
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*MOZILLA_DOMPOINT_H_*/
|
|
@ -0,0 +1,159 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/DOMQuad.h"
|
||||
|
||||
#include "mozilla/dom/DOMQuadBinding.h"
|
||||
#include "mozilla/dom/DOMPoint.h"
|
||||
#include "mozilla/dom/DOMRect.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::gfx;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_6(DOMQuad, mParent, mBounds, mPoints[0],
|
||||
mPoints[1], mPoints[2], mPoints[3])
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMQuad, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMQuad, Release)
|
||||
|
||||
DOMQuad::DOMQuad(nsISupports* aParent, CSSPoint aPoints[4])
|
||||
: mParent(aParent)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
for (uint32_t i = 0; i < 4; ++i) {
|
||||
mPoints[i] = new DOMPoint(aParent, aPoints[i].x, aPoints[i].y);
|
||||
}
|
||||
}
|
||||
|
||||
DOMQuad::DOMQuad(nsISupports* aParent)
|
||||
: mParent(aParent)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
DOMQuad::~DOMQuad()
|
||||
{
|
||||
}
|
||||
|
||||
JSObject*
|
||||
DOMQuad::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
return DOMQuadBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMQuad>
|
||||
DOMQuad::Constructor(const GlobalObject& aGlobal,
|
||||
const DOMPointInit& aP1,
|
||||
const DOMPointInit& aP2,
|
||||
const DOMPointInit& aP3,
|
||||
const DOMPointInit& aP4,
|
||||
ErrorResult& aRV)
|
||||
{
|
||||
nsRefPtr<DOMQuad> obj = new DOMQuad(aGlobal.GetAsSupports());
|
||||
obj->mPoints[0] = DOMPoint::Constructor(aGlobal, aP1, aRV);
|
||||
obj->mPoints[1] = DOMPoint::Constructor(aGlobal, aP2, aRV);
|
||||
obj->mPoints[2] = DOMPoint::Constructor(aGlobal, aP3, aRV);
|
||||
obj->mPoints[3] = DOMPoint::Constructor(aGlobal, aP4, aRV);
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMQuad>
|
||||
DOMQuad::Constructor(const GlobalObject& aGlobal, const DOMRectReadOnly& aRect,
|
||||
ErrorResult& aRV)
|
||||
{
|
||||
CSSPoint points[4];
|
||||
Float x = aRect.X(), y = aRect.Y(), w = aRect.Width(), h = aRect.Height();
|
||||
points[0] = CSSPoint(x, y);
|
||||
points[1] = CSSPoint(x + w, y);
|
||||
points[2] = CSSPoint(x + w, y + h);
|
||||
points[3] = CSSPoint(x, y + h);
|
||||
nsRefPtr<DOMQuad> obj = new DOMQuad(aGlobal.GetAsSupports(), points);
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
class DOMQuad::QuadBounds MOZ_FINAL : public DOMRectReadOnly
|
||||
{
|
||||
public:
|
||||
QuadBounds(DOMQuad* aQuad)
|
||||
: DOMRectReadOnly(aQuad->GetParentObject())
|
||||
, mQuad(aQuad)
|
||||
{}
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(QuadBounds, DOMRectReadOnly)
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
virtual double X() const
|
||||
{
|
||||
double x1, x2;
|
||||
GetHorizontalMinMax(&x1, &x2);
|
||||
return x1;
|
||||
}
|
||||
virtual double Y() const
|
||||
{
|
||||
double y1, y2;
|
||||
GetVerticalMinMax(&y1, &y2);
|
||||
return y1;
|
||||
}
|
||||
virtual double Width() const
|
||||
{
|
||||
double x1, x2;
|
||||
GetHorizontalMinMax(&x1, &x2);
|
||||
return x2 - x1;
|
||||
}
|
||||
virtual double Height() const
|
||||
{
|
||||
double y1, y2;
|
||||
GetVerticalMinMax(&y1, &y2);
|
||||
return y2 - y1;
|
||||
}
|
||||
|
||||
void GetHorizontalMinMax(double* aX1, double* aX2) const
|
||||
{
|
||||
double x1, x2;
|
||||
x1 = x2 = mQuad->Point(0)->X();
|
||||
for (uint32_t i = 1; i < 4; ++i) {
|
||||
double x = mQuad->Point(i)->X();
|
||||
x1 = std::min(x1, x);
|
||||
x2 = std::max(x2, x);
|
||||
}
|
||||
*aX1 = x1;
|
||||
*aX2 = x2;
|
||||
}
|
||||
|
||||
void GetVerticalMinMax(double* aY1, double* aY2) const
|
||||
{
|
||||
double y1, y2;
|
||||
y1 = y2 = mQuad->Point(0)->Y();
|
||||
for (uint32_t i = 1; i < 4; ++i) {
|
||||
double y = mQuad->Point(i)->Y();
|
||||
y1 = std::min(y1, y);
|
||||
y2 = std::max(y2, y);
|
||||
}
|
||||
*aY1 = y1;
|
||||
*aY2 = y2;
|
||||
}
|
||||
|
||||
protected:
|
||||
nsRefPtr<DOMQuad> mQuad;
|
||||
};
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(DOMQuad::QuadBounds, DOMRectReadOnly, mQuad)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DOMQuad::QuadBounds)
|
||||
NS_INTERFACE_MAP_END_INHERITING(DOMRectReadOnly)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(DOMQuad::QuadBounds, DOMRectReadOnly)
|
||||
NS_IMPL_RELEASE_INHERITED(DOMQuad::QuadBounds, DOMRectReadOnly)
|
||||
|
||||
DOMRectReadOnly*
|
||||
DOMQuad::Bounds() const
|
||||
{
|
||||
if (!mBounds) {
|
||||
mBounds = new QuadBounds(const_cast<DOMQuad*>(this));
|
||||
}
|
||||
return mBounds;
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef MOZILLA_DOMQUAD_H_
|
||||
#define MOZILLA_DOMQUAD_H_
|
||||
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "Units.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class DOMRectReadOnly;
|
||||
class DOMPoint;
|
||||
struct DOMPointInit;
|
||||
|
||||
class DOMQuad MOZ_FINAL : public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
DOMQuad(nsISupports* aParent, CSSPoint aPoints[4]);
|
||||
DOMQuad(nsISupports* aParent);
|
||||
~DOMQuad();
|
||||
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMQuad)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMQuad)
|
||||
|
||||
nsISupports* GetParentObject() const { return mParent; }
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
static already_AddRefed<DOMQuad>
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
const DOMPointInit& aP1,
|
||||
const DOMPointInit& aP2,
|
||||
const DOMPointInit& aP3,
|
||||
const DOMPointInit& aP4,
|
||||
ErrorResult& aRV);
|
||||
static already_AddRefed<DOMQuad>
|
||||
Constructor(const GlobalObject& aGlobal, const DOMRectReadOnly& aRect,
|
||||
ErrorResult& aRV);
|
||||
|
||||
DOMRectReadOnly* Bounds() const;
|
||||
DOMPoint* P1() const { return mPoints[0]; }
|
||||
DOMPoint* P2() const { return mPoints[1]; }
|
||||
DOMPoint* P3() const { return mPoints[2]; }
|
||||
DOMPoint* P4() const { return mPoints[3]; }
|
||||
|
||||
DOMPoint* Point(uint32_t aIndex) { return mPoints[aIndex]; }
|
||||
|
||||
protected:
|
||||
class QuadBounds;
|
||||
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
nsRefPtr<DOMPoint> mPoints[4];
|
||||
mutable nsRefPtr<QuadBounds> mBounds; // allocated lazily
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*MOZILLA_DOMRECT_H_*/
|
|
@ -3,7 +3,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DOMRect.h"
|
||||
#include "mozilla/dom/DOMRect.h"
|
||||
|
||||
#include "nsPresContext.h"
|
||||
#include "mozilla/dom/DOMRectListBinding.h"
|
||||
|
@ -12,20 +12,30 @@
|
|||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DOMRect, mParent)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMRect)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMRect)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMRect)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DOMRectReadOnly, mParent)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMRectReadOnly)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMRectReadOnly)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMRectReadOnly)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMClientRect)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
JSObject*
|
||||
DOMRectReadOnly::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
MOZ_ASSERT(mParent);
|
||||
return DOMRectReadOnlyBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(DOMRect, DOMRectReadOnly, nsIDOMClientRect)
|
||||
|
||||
#define FORWARD_GETTER(_name) \
|
||||
NS_IMETHODIMP \
|
||||
DOMRect::Get ## _name(float* aResult) \
|
||||
{ \
|
||||
*aResult = _name(); \
|
||||
*aResult = float(_name()); \
|
||||
return NS_OK; \
|
||||
}
|
||||
|
||||
|
@ -43,6 +53,23 @@ DOMRect::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
|||
return DOMRectBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRect>
|
||||
DOMRect::Constructor(const GlobalObject& aGlobal, ErrorResult& aRV)
|
||||
{
|
||||
nsRefPtr<DOMRect> obj =
|
||||
new DOMRect(aGlobal.GetAsSupports(), 0.0, 0.0, 0.0, 0.0);
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<DOMRect>
|
||||
DOMRect::Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
||||
double aWidth, double aHeight, ErrorResult& aRV)
|
||||
{
|
||||
nsRefPtr<DOMRect> obj =
|
||||
new DOMRect(aGlobal.GetAsSupports(), aX, aY, aWidth, aHeight);
|
||||
return obj.forget();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(DOMRectList, mParent, mArray)
|
||||
|
@ -57,7 +84,7 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMRectList)
|
|||
NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMRectList)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
NS_IMETHODIMP
|
||||
DOMRectList::GetLength(uint32_t* aLength)
|
||||
{
|
||||
*aLength = Length();
|
||||
|
|
|
@ -14,33 +14,29 @@
|
|||
#include "nsWrapperCache.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include <algorithm>
|
||||
|
||||
struct nsRect;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class DOMRect MOZ_FINAL : public nsIDOMClientRect
|
||||
, public nsWrapperCache
|
||||
class DOMRectReadOnly : public nsISupports
|
||||
, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
DOMRect(nsISupports* aParent)
|
||||
: mParent(aParent), mX(0.0), mY(0.0), mWidth(0.0), mHeight(0.0)
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMRectReadOnly)
|
||||
|
||||
virtual ~DOMRectReadOnly() {}
|
||||
|
||||
DOMRectReadOnly(nsISupports* aParent)
|
||||
: mParent(aParent)
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
virtual ~DOMRect() {}
|
||||
|
||||
void SetRect(float aX, float aY, float aWidth, float aHeight) {
|
||||
mX = aX; mY = aY; mWidth = aWidth; mHeight = aHeight;
|
||||
}
|
||||
void SetLayoutRect(const nsRect& aLayoutRect);
|
||||
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMRect)
|
||||
NS_DECL_NSIDOMCLIENTRECT
|
||||
|
||||
|
||||
nsISupports* GetParentObject() const
|
||||
{
|
||||
|
@ -50,40 +46,103 @@ public:
|
|||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
virtual double X() const = 0;
|
||||
virtual double Y() const = 0;
|
||||
virtual double Width() const = 0;
|
||||
virtual double Height() const = 0;
|
||||
|
||||
float Left() const
|
||||
double Left() const
|
||||
{
|
||||
return mX;
|
||||
double x = X(), w = Width();
|
||||
return std::min(x, x + w);
|
||||
}
|
||||
|
||||
float Top() const
|
||||
double Top() const
|
||||
{
|
||||
return mY;
|
||||
double y = Y(), h = Height();
|
||||
return std::min(y, y + h);
|
||||
}
|
||||
|
||||
float Right() const
|
||||
double Right() const
|
||||
{
|
||||
return mX + mWidth;
|
||||
double x = X(), w = Width();
|
||||
return std::max(x, x + w);
|
||||
}
|
||||
|
||||
float Bottom() const
|
||||
double Bottom() const
|
||||
{
|
||||
return mY + mHeight;
|
||||
}
|
||||
|
||||
float Width() const
|
||||
{
|
||||
return mWidth;
|
||||
}
|
||||
|
||||
float Height() const
|
||||
{
|
||||
return mHeight;
|
||||
double y = Y(), h = Height();
|
||||
return std::max(y, y + h);
|
||||
}
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
float mX, mY, mWidth, mHeight;
|
||||
};
|
||||
|
||||
class DOMRect MOZ_FINAL : public DOMRectReadOnly
|
||||
, public nsIDOMClientRect
|
||||
{
|
||||
public:
|
||||
DOMRect(nsISupports* aParent, double aX = 0, double aY = 0,
|
||||
double aWidth = 0, double aHeight = 0)
|
||||
: DOMRectReadOnly(aParent)
|
||||
, mX(aX)
|
||||
, mY(aY)
|
||||
, mWidth(aWidth)
|
||||
, mHeight(aHeight)
|
||||
{
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMCLIENTRECT
|
||||
|
||||
static already_AddRefed<DOMRect>
|
||||
Constructor(const GlobalObject& aGlobal, ErrorResult& aRV);
|
||||
static already_AddRefed<DOMRect>
|
||||
Constructor(const GlobalObject& aGlobal, double aX, double aY,
|
||||
double aWidth, double aHeight, ErrorResult& aRV);
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
void SetRect(float aX, float aY, float aWidth, float aHeight) {
|
||||
mX = aX; mY = aY; mWidth = aWidth; mHeight = aHeight;
|
||||
}
|
||||
void SetLayoutRect(const nsRect& aLayoutRect);
|
||||
|
||||
virtual double X() const MOZ_OVERRIDE
|
||||
{
|
||||
return mX;
|
||||
}
|
||||
virtual double Y() const MOZ_OVERRIDE
|
||||
{
|
||||
return mY;
|
||||
}
|
||||
virtual double Width() const MOZ_OVERRIDE
|
||||
{
|
||||
return mWidth;
|
||||
}
|
||||
virtual double Height() const MOZ_OVERRIDE
|
||||
{
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
void SetX(double aX)
|
||||
{
|
||||
mX = aX;
|
||||
}
|
||||
void SetY(double aY)
|
||||
{
|
||||
mY = aY;
|
||||
}
|
||||
void SetWidth(double aWidth)
|
||||
{
|
||||
mWidth = aWidth;
|
||||
}
|
||||
void SetHeight(double aHeight)
|
||||
{
|
||||
mHeight = aHeight;
|
||||
}
|
||||
|
||||
protected:
|
||||
double mX, mY, mWidth, mHeight;
|
||||
};
|
||||
|
||||
class DOMRectList MOZ_FINAL : public nsIDOMClientRectList,
|
||||
|
@ -145,9 +204,7 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
virtual ~DOMRectList() {}
|
||||
|
||||
nsTArray< nsRefPtr<DOMRect> > mArray;
|
||||
nsTArray<nsRefPtr<DOMRect> > mArray;
|
||||
nsCOMPtr<nsISupports> mParent;
|
||||
};
|
||||
|
||||
|
|
|
@ -60,6 +60,8 @@ EXPORTS.mozilla.dom += [
|
|||
'DocumentType.h',
|
||||
'DOMImplementation.h',
|
||||
'DOMParser.h',
|
||||
'DOMPoint.h',
|
||||
'DOMQuad.h',
|
||||
'DOMRect.h',
|
||||
'DOMStringList.h',
|
||||
'EventSource.h',
|
||||
|
@ -79,6 +81,8 @@ UNIFIED_SOURCES += [
|
|||
'DocumentType.cpp',
|
||||
'DOMImplementation.cpp',
|
||||
'DOMParser.cpp',
|
||||
'DOMPoint.cpp',
|
||||
'DOMQuad.cpp',
|
||||
'DOMRect.cpp',
|
||||
'DOMStringList.cpp',
|
||||
'Element.cpp',
|
||||
|
|
|
@ -103,6 +103,7 @@
|
|||
#include <algorithm>
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsDOMMutationObserver.h"
|
||||
#include "GeometryUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
@ -1140,6 +1141,41 @@ nsINode::PreHandleEvent(EventChainPreVisitor& aVisitor)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void
|
||||
nsINode::GetBoxQuads(const BoxQuadOptions& aOptions,
|
||||
nsTArray<nsRefPtr<DOMQuad> >& aResult,
|
||||
mozilla::ErrorResult& aRv)
|
||||
{
|
||||
mozilla::GetBoxQuads(this, aOptions, aResult, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMQuad>
|
||||
nsINode::ConvertQuadFromNode(DOMQuad& aQuad,
|
||||
const GeometryNode& aFrom,
|
||||
const ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
return mozilla::ConvertQuadFromNode(this, aQuad, aFrom, aOptions, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMQuad>
|
||||
nsINode::ConvertRectFromNode(DOMRectReadOnly& aRect,
|
||||
const GeometryNode& aFrom,
|
||||
const ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
return mozilla::ConvertRectFromNode(this, aRect, aFrom, aOptions, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<DOMPoint>
|
||||
nsINode::ConvertPointFromNode(const DOMPointInit& aPoint,
|
||||
const GeometryNode& aFrom,
|
||||
const ConvertCoordinateOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
return mozilla::ConvertPointFromNode(this, aPoint, aFrom, aOptions, aRv);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsINode::DispatchEvent(nsIDOMEvent *aEvent, bool* aRetVal)
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
|
||||
#if defined(XP_WIN)
|
||||
#ifdef LoadImage
|
||||
// Undefine LoadImage to prevent naming conflict with Windows.
|
||||
#undef LoadImage
|
||||
#endif
|
||||
|
|
|
@ -31,6 +31,11 @@ class nsPresContext;
|
|||
class nsIContent;
|
||||
class imgRequestProxy;
|
||||
|
||||
#ifdef LoadImage
|
||||
// Undefine LoadImage to prevent naming conflict with Windows.
|
||||
#undef LoadImage
|
||||
#endif
|
||||
|
||||
class nsImageLoadingContent : public nsIImageLoadingContent,
|
||||
public imgIOnloadBlocker
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "nsIContent.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDataContainerEvent.h"
|
||||
#include "nsIDOMCustomEvent.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMHTMLObjectElement.h"
|
||||
#include "nsIDOMHTMLAppletElement.h"
|
||||
|
@ -318,63 +318,52 @@ nsPluginCrashedEvent::Run()
|
|||
|
||||
ErrorResult rv;
|
||||
nsRefPtr<Event> event =
|
||||
doc->CreateEvent(NS_LITERAL_STRING("datacontainerevents"), rv);
|
||||
nsCOMPtr<nsIDOMDataContainerEvent> containerEvent(do_QueryObject(event));
|
||||
if (!containerEvent) {
|
||||
doc->CreateEvent(NS_LITERAL_STRING("customevent"), rv);
|
||||
nsCOMPtr<nsIDOMCustomEvent> customEvent(do_QueryObject(event));
|
||||
if (!customEvent) {
|
||||
NS_WARNING("Couldn't QI event for PluginCrashed event!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
event->InitEvent(NS_LITERAL_STRING("PluginCrashed"), true, true);
|
||||
nsCOMPtr<nsIWritableVariant> variant;
|
||||
variant = do_CreateInstance("@mozilla.org/variant;1");
|
||||
if (!variant) {
|
||||
NS_WARNING("Couldn't create detail variant for PluginCrashed event!");
|
||||
return NS_OK;
|
||||
}
|
||||
customEvent->InitCustomEvent(NS_LITERAL_STRING("PluginCrashed"),
|
||||
true, true, variant);
|
||||
event->SetTrusted(true);
|
||||
event->GetInternalNSEvent()->mFlags.mOnlyChromeDispatch = true;
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> variant;
|
||||
nsCOMPtr<nsIWritablePropertyBag2> propBag;
|
||||
propBag = do_CreateInstance("@mozilla.org/hash-property-bag;1");
|
||||
if (!propBag) {
|
||||
NS_WARNING("Couldn't create a property bag for PluginCrashed event!");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// add a "pluginDumpID" property to this event
|
||||
variant = do_CreateInstance("@mozilla.org/variant;1");
|
||||
if (!variant) {
|
||||
NS_WARNING("Couldn't create pluginDumpID variant for PluginCrashed event!");
|
||||
return NS_OK;
|
||||
}
|
||||
variant->SetAsAString(mPluginDumpID);
|
||||
containerEvent->SetData(NS_LITERAL_STRING("pluginDumpID"), variant);
|
||||
propBag->SetPropertyAsAString(NS_LITERAL_STRING("pluginDumpID"),
|
||||
mPluginDumpID);
|
||||
|
||||
// add a "browserDumpID" property to this event
|
||||
variant = do_CreateInstance("@mozilla.org/variant;1");
|
||||
if (!variant) {
|
||||
NS_WARNING("Couldn't create browserDumpID variant for PluginCrashed event!");
|
||||
return NS_OK;
|
||||
}
|
||||
variant->SetAsAString(mBrowserDumpID);
|
||||
containerEvent->SetData(NS_LITERAL_STRING("browserDumpID"), variant);
|
||||
propBag->SetPropertyAsAString(NS_LITERAL_STRING("browserDumpID"),
|
||||
mBrowserDumpID);
|
||||
|
||||
// add a "pluginName" property to this event
|
||||
variant = do_CreateInstance("@mozilla.org/variant;1");
|
||||
if (!variant) {
|
||||
NS_WARNING("Couldn't create pluginName variant for PluginCrashed event!");
|
||||
return NS_OK;
|
||||
}
|
||||
variant->SetAsAString(mPluginName);
|
||||
containerEvent->SetData(NS_LITERAL_STRING("pluginName"), variant);
|
||||
propBag->SetPropertyAsAString(NS_LITERAL_STRING("pluginName"),
|
||||
mPluginName);
|
||||
|
||||
// add a "pluginFilename" property to this event
|
||||
variant = do_CreateInstance("@mozilla.org/variant;1");
|
||||
if (!variant) {
|
||||
NS_WARNING("Couldn't create pluginFilename variant for PluginCrashed event!");
|
||||
return NS_OK;
|
||||
}
|
||||
variant->SetAsAString(mPluginFilename);
|
||||
containerEvent->SetData(NS_LITERAL_STRING("pluginFilename"), variant);
|
||||
propBag->SetPropertyAsAString(NS_LITERAL_STRING("pluginFilename"),
|
||||
mPluginFilename);
|
||||
|
||||
// add a "submittedCrashReport" property to this event
|
||||
variant = do_CreateInstance("@mozilla.org/variant;1");
|
||||
if (!variant) {
|
||||
NS_WARNING("Couldn't create crashSubmit variant for PluginCrashed event!");
|
||||
return NS_OK;
|
||||
}
|
||||
variant->SetAsBool(mSubmittedCrashReport);
|
||||
containerEvent->SetData(NS_LITERAL_STRING("submittedCrashReport"), variant);
|
||||
propBag->SetPropertyAsBool(NS_LITERAL_STRING("submittedCrashReport"),
|
||||
mSubmittedCrashReport);
|
||||
|
||||
variant->SetAsISupports(propBag);
|
||||
|
||||
EventDispatcher::DispatchDOMEvent(mContent, nullptr, event, nullptr, nullptr);
|
||||
return NS_OK;
|
||||
|
|
|
@ -62,7 +62,7 @@ void main(void) {
|
|||
|
||||
function isScreenBlack() {
|
||||
var pixels = gl.drawingBufferWidth * gl.drawingBufferHeight;
|
||||
var data = Uint8Array(4 * pixels);
|
||||
var data = new Uint8Array(4 * pixels);
|
||||
gl.readPixels(0, 0,
|
||||
gl.drawingBufferWidth, gl.drawingBufferHeight,
|
||||
gl.RGBA, gl.UNSIGNED_BYTE,
|
||||
|
@ -98,11 +98,11 @@ void main(void) {
|
|||
|
||||
var indexType = gl.UNSIGNED_SHORT;
|
||||
var indexStride = 2;
|
||||
var indexArr = Uint16Array([0, 1, Math.min(hugeIndex, UINT16_MAX)]);
|
||||
var indexArr = new Uint16Array([0, 1, Math.min(hugeIndex, UINT16_MAX)]);
|
||||
if (gl.getExtension('OES_element_index_uint')) {
|
||||
indexType = gl.UNSIGNED_INT;
|
||||
indexStride = 4;
|
||||
indexArr = Uint32Array([0, 1, hugeIndex]);
|
||||
indexArr = new Uint32Array([0, 1, hugeIndex]);
|
||||
}
|
||||
|
||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
|
|
|
@ -74,6 +74,13 @@ static const uint32_t LOW_AUDIO_USECS = 300000;
|
|||
// less than the low audio threshold.
|
||||
const int64_t AMPLE_AUDIO_USECS = 1000000;
|
||||
|
||||
// When we're only playing audio and we don't have a video stream, we divide
|
||||
// AMPLE_AUDIO_USECS and LOW_AUDIO_USECS by the following value. This reduces
|
||||
// the amount of decoded audio we buffer, reducing our memory usage. We only
|
||||
// need to decode far ahead when we're decoding video using software decoding,
|
||||
// as otherwise a long video decode could cause an audio underrun.
|
||||
const int64_t NO_VIDEO_AMPLE_AUDIO_DIVISOR = 8;
|
||||
|
||||
// Maximum number of bytes we'll allocate and write at once to the audio
|
||||
// hardware when the audio stream contains missing frames and we're
|
||||
// writing silence in order to fill the gap. We limit our silence-writes
|
||||
|
@ -1856,6 +1863,14 @@ nsresult MediaDecoderStateMachine::DecodeMetadata()
|
|||
mDecoder.get(), mStartTime, mEndTime, GetDuration(),
|
||||
mTransportSeekable, mMediaSeekable));
|
||||
|
||||
if (HasAudio() && !HasVideo()) {
|
||||
// We're playing audio only. We don't need to worry about slow video
|
||||
// decodes causing audio underruns, so don't buffer so much audio in
|
||||
// order to reduce memory usage.
|
||||
mAmpleAudioThresholdUsecs /= NO_VIDEO_AMPLE_AUDIO_DIVISOR;
|
||||
mLowAudioThresholdUsecs /= NO_VIDEO_AMPLE_AUDIO_DIVISOR;
|
||||
}
|
||||
|
||||
// Inform the element that we've loaded the metadata and the first frame,
|
||||
// setting the default framebuffer size for audioavailable events. Also,
|
||||
// if there is audio, let the MozAudioAvailable event manager know about
|
||||
|
|
|
@ -45,8 +45,8 @@ public:
|
|||
MediaDataDecoderCallback* aCallback,
|
||||
BlankMediaDataCreator* aCreator)
|
||||
: mSample(aSample)
|
||||
, mCallback(aCallback)
|
||||
, mCreator(aCreator)
|
||||
, mCallback(aCallback)
|
||||
{
|
||||
}
|
||||
NS_IMETHOD Run() MOZ_OVERRIDE
|
||||
|
@ -161,10 +161,9 @@ public:
|
|||
BlankAudioDataCreator(uint32_t aChannelCount,
|
||||
uint32_t aSampleRate,
|
||||
uint16_t aBitsPerSample)
|
||||
: mFrameSum(0),
|
||||
mChannelCount(aChannelCount),
|
||||
mSampleRate(aSampleRate),
|
||||
mBitsPerSample(aBitsPerSample)
|
||||
: mFrameSum(0)
|
||||
, mChannelCount(aChannelCount)
|
||||
, mSampleRate(aSampleRate)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -204,7 +203,6 @@ private:
|
|||
int64_t mFrameSum;
|
||||
uint32_t mChannelCount;
|
||||
uint32_t mSampleRate;
|
||||
uint16_t mBitsPerSample;
|
||||
};
|
||||
|
||||
class BlankDecoderModule : public PlatformDecoderModule {
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
#ifdef XP_WIN
|
||||
#include "mozilla/WindowsVersion.h"
|
||||
#endif
|
||||
#ifdef MOZ_FFMPEG
|
||||
#include "FFmpegDecoderModule.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -64,17 +67,33 @@ MP4Decoder::GetSupportedCodecs(const nsACString& aType,
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
IsFFmpegAvailable()
|
||||
{
|
||||
#ifndef MOZ_FFMPEG
|
||||
return false;
|
||||
#else
|
||||
if (!Preferences::GetBool("media.fragmented-mp4.ffmpeg.enabled", false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we can link to FFmpeg, then we can almost certainly play H264 and AAC
|
||||
// with it.
|
||||
return FFmpegDecoderModule::Link();
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool
|
||||
HavePlatformMPEGDecoders()
|
||||
{
|
||||
return
|
||||
Preferences::GetBool("media.fragmented-mp4.use-blank-decoder") ||
|
||||
return Preferences::GetBool("media.fragmented-mp4.use-blank-decoder") ||
|
||||
#ifdef XP_WIN
|
||||
// We have H.264/AAC platform decoders on Windows Vista and up.
|
||||
IsVistaOrLater() ||
|
||||
// We have H.264/AAC platform decoders on Windows Vista and up.
|
||||
IsVistaOrLater() ||
|
||||
#endif
|
||||
// TODO: Other platforms...
|
||||
false;
|
||||
IsFFmpegAvailable() ||
|
||||
// TODO: Other platforms...
|
||||
false;
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
MOZ_COUNT_CTOR(MP4Stream);
|
||||
MOZ_ASSERT(aResource);
|
||||
}
|
||||
~MP4Stream() {
|
||||
virtual ~MP4Stream() {
|
||||
MOZ_COUNT_DTOR(MP4Stream);
|
||||
}
|
||||
|
||||
|
@ -83,10 +83,10 @@ private:
|
|||
|
||||
MP4Reader::MP4Reader(AbstractMediaDecoder* aDecoder)
|
||||
: MediaDecoderReader(aDecoder)
|
||||
, mLayersBackendType(layers::LayersBackend::LAYERS_NONE)
|
||||
, mAudio("MP4 audio decoder data", Preferences::GetUint("media.mp4-audio-decode-ahead", 2))
|
||||
, mVideo("MP4 video decoder data", Preferences::GetUint("media.mp4-video-decode-ahead", 2))
|
||||
, mLastReportedNumDecodedFrames(0)
|
||||
, mLayersBackendType(layers::LayersBackend::LAYERS_NONE)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread.");
|
||||
MOZ_COUNT_CTOR(MP4Reader);
|
||||
|
@ -371,6 +371,7 @@ MP4Reader::Decode(TrackType aTrack)
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifdef LOG_SAMPLE_DECODE
|
||||
static const char*
|
||||
TrackTypeToStr(TrackType aTrack)
|
||||
{
|
||||
|
@ -381,6 +382,7 @@ TrackTypeToStr(TrackType aTrack)
|
|||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
MP4Reader::Output(mp4_demuxer::TrackType aTrack, MediaData* aSample)
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
#ifdef XP_WIN
|
||||
#include "WMFDecoderModule.h"
|
||||
#endif
|
||||
#ifdef MOZ_FFMPEG
|
||||
#include "FFmpegDecoderModule.h"
|
||||
#endif
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -15,6 +18,7 @@ namespace mozilla {
|
|||
extern PlatformDecoderModule* CreateBlankDecoderModule();
|
||||
|
||||
bool PlatformDecoderModule::sUseBlankDecoder = false;
|
||||
bool PlatformDecoderModule::sFFmpegDecoderEnabled = false;
|
||||
|
||||
/* static */
|
||||
void
|
||||
|
@ -26,7 +30,12 @@ PlatformDecoderModule::Init()
|
|||
return;
|
||||
}
|
||||
alreadyInitialized = true;
|
||||
sUseBlankDecoder = Preferences::GetBool("media.fragmented-mp4.use-blank-decoder");
|
||||
|
||||
Preferences::AddBoolVarCache(&sUseBlankDecoder,
|
||||
"media.fragmented-mp4.use-blank-decoder");
|
||||
Preferences::AddBoolVarCache(&sFFmpegDecoderEnabled,
|
||||
"media.fragmented-mp4.ffmpeg.enabled", false);
|
||||
|
||||
#ifdef XP_WIN
|
||||
WMFDecoderModule::Init();
|
||||
#endif
|
||||
|
@ -44,6 +53,11 @@ PlatformDecoderModule::Create()
|
|||
if (NS_SUCCEEDED(m->Startup())) {
|
||||
return m.forget();
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_FFMPEG
|
||||
if (sFFmpegDecoderEnabled) {
|
||||
return new FFmpegDecoderModule();
|
||||
}
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -109,6 +109,7 @@ protected:
|
|||
PlatformDecoderModule() {}
|
||||
// Caches pref media.fragmented-mp4.use-blank-decoder
|
||||
static bool sUseBlankDecoder;
|
||||
static bool sFFmpegDecoderEnabled;
|
||||
};
|
||||
|
||||
// A callback used by MediaDataDecoder to return output/errors to the
|
||||
|
|
|
@ -61,12 +61,12 @@ namespace mp4_demuxer {
|
|||
#ifdef PR_LOGGING
|
||||
#define DMX_LOG(...) PR_LOG(GetDemuxerLog(), PR_LOG_DEBUG, (__VA_ARGS__))
|
||||
#else
|
||||
#define DMX_LOG(...) 0
|
||||
#define DMX_LOG(...) (void)0
|
||||
#endif
|
||||
#else
|
||||
// define DMX_LOG as 0, so that if(condition){DMX_LOG(...)} branches don't elicit
|
||||
// a warning-as-error.
|
||||
#define DMX_LOG(...) 0
|
||||
#define DMX_LOG(...) (void)0
|
||||
#endif
|
||||
|
||||
// A macro to disallow the evil copy constructor and operator= functions
|
||||
|
|
|
@ -27,7 +27,7 @@ struct Box {
|
|||
class StreamReader {
|
||||
public:
|
||||
StreamReader(Stream* stream, int64_t offset, int64_t size)
|
||||
: stream_(stream), start_(offset), pos_(0), size_(size) {}
|
||||
: start_(offset), size_(size), pos_(0), stream_(stream) {}
|
||||
|
||||
bool HasBytes(int count) { return (pos() + count <= size()); }
|
||||
|
||||
|
|
|
@ -97,8 +97,6 @@ bool MP4Demuxer::Init()
|
|||
void MP4Demuxer::Reset() {
|
||||
moov_ = nullptr;
|
||||
runs_ = nullptr;
|
||||
stream_offset_; // TODO; Not sure if this needs to be reset?
|
||||
DMX_LOG("Warning: resetting stream_offset_\n");
|
||||
moof_head_ = 0;
|
||||
mdat_tail_ = 0;
|
||||
}
|
||||
|
@ -303,15 +301,7 @@ bool MP4Demuxer::ParseBox() {
|
|||
}
|
||||
|
||||
bool MP4Demuxer::EmitSample(nsAutoPtr<MP4Sample>* sample) {
|
||||
bool ok = true;
|
||||
if (!runs_->IsRunValid()) {
|
||||
|
||||
// Flush any buffers we've gotten in this chunk so that buffers don't
|
||||
// cross NewSegment() calls
|
||||
//ok = SendAndFlushSamples(/*audio_buffers, video_buffers*/);
|
||||
//if (!ok)
|
||||
// return false;
|
||||
|
||||
ChangeState(kParsingBoxes);
|
||||
//end_of_segment_cb_.Run();
|
||||
return true;
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "MediaTaskQueue.h"
|
||||
#include "FFmpegRuntimeLinker.h"
|
||||
|
||||
#include "FFmpegAACDecoder.h"
|
||||
|
||||
#define MAX_CHANNELS 16
|
||||
|
||||
typedef mp4_demuxer::MP4Sample MP4Sample;
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
|
||||
FFmpegAACDecoder::FFmpegAACDecoder(
|
||||
MediaTaskQueue* aTaskQueue, MediaDataDecoderCallback* aCallback,
|
||||
const mp4_demuxer::AudioDecoderConfig &aConfig)
|
||||
: FFmpegDataDecoder(aTaskQueue, AV_CODEC_ID_AAC)
|
||||
, mCallback(aCallback)
|
||||
, mConfig(aConfig)
|
||||
{
|
||||
MOZ_COUNT_CTOR(FFmpegAACDecoder);
|
||||
}
|
||||
|
||||
nsresult
|
||||
FFmpegAACDecoder::Init()
|
||||
{
|
||||
nsresult rv = FFmpegDataDecoder::Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static AudioDataValue*
|
||||
CopyAndPackAudio(AVFrame* aFrame, uint32_t aNumChannels, uint32_t aNumSamples)
|
||||
{
|
||||
// These are the only two valid AAC packet sizes.
|
||||
NS_ASSERTION(aNumSamples == 960 || aNumSamples == 1024,
|
||||
"Should have exactly one AAC audio packet.");
|
||||
MOZ_ASSERT(aNumChannels <= MAX_CHANNELS);
|
||||
|
||||
nsAutoArrayPtr<AudioDataValue> audio(
|
||||
new AudioDataValue[aNumChannels * aNumSamples]);
|
||||
|
||||
AudioDataValue** data = reinterpret_cast<AudioDataValue**>(aFrame->data);
|
||||
|
||||
if (aFrame->format == AV_SAMPLE_FMT_FLT) {
|
||||
// Audio data already packed. No need to do anything other than copy it
|
||||
// into a buffer we own.
|
||||
memcpy(audio, data[0], aNumChannels * aNumSamples * sizeof(AudioDataValue));
|
||||
} else if (aFrame->format == AV_SAMPLE_FMT_FLTP) {
|
||||
// Planar audio data. Pack it into something we can understand.
|
||||
for (uint32_t channel = 0; channel < aNumChannels; channel++) {
|
||||
for (uint32_t sample = 0; sample < aNumSamples; sample++) {
|
||||
audio[sample * aNumChannels + channel] = data[channel][sample];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return audio.forget();
|
||||
}
|
||||
|
||||
void
|
||||
FFmpegAACDecoder::DecodePacket(MP4Sample* aSample)
|
||||
{
|
||||
nsAutoPtr<AVFrame> frame(avcodec_alloc_frame());
|
||||
avcodec_get_frame_defaults(frame);
|
||||
|
||||
AVPacket packet;
|
||||
av_init_packet(&packet);
|
||||
|
||||
packet.data = &(*aSample->data)[0];
|
||||
packet.size = aSample->data->size();
|
||||
packet.pos = aSample->byte_offset;
|
||||
packet.dts = aSample->decode_timestamp;
|
||||
|
||||
int decoded;
|
||||
int bytesConsumed =
|
||||
avcodec_decode_audio4(&mCodecContext, frame.get(), &decoded, &packet);
|
||||
|
||||
if (bytesConsumed < 0 || !decoded) {
|
||||
NS_WARNING("FFmpeg audio decoder error.");
|
||||
mCallback->Error();
|
||||
return;
|
||||
}
|
||||
|
||||
NS_ASSERTION(bytesConsumed == (int)aSample->data->size(),
|
||||
"Only one audio packet should be received at a time.");
|
||||
|
||||
uint32_t numChannels = mCodecContext.channels;
|
||||
|
||||
nsAutoArrayPtr<AudioDataValue> audio(
|
||||
CopyAndPackAudio(frame.get(), numChannels, frame->nb_samples));
|
||||
|
||||
nsAutoPtr<AudioData> data(new AudioData(packet.pos, aSample->decode_timestamp,
|
||||
aSample->duration, frame->nb_samples,
|
||||
audio.forget(), numChannels));
|
||||
|
||||
mCallback->Output(data.forget());
|
||||
|
||||
if (mTaskQueue->IsEmpty()) {
|
||||
mCallback->InputExhausted();
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
FFmpegAACDecoder::Input(MP4Sample* aSample)
|
||||
{
|
||||
mTaskQueue->Dispatch(NS_NewRunnableMethodWithArg<nsAutoPtr<MP4Sample> >(
|
||||
this, &FFmpegAACDecoder::DecodePacket, nsAutoPtr<MP4Sample>(aSample)));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
FFmpegAACDecoder::Drain()
|
||||
{
|
||||
// AAC is never delayed; nothing to do here.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
FFmpegAACDecoder::~FFmpegAACDecoder() {
|
||||
MOZ_COUNT_DTOR(FFmpegAACDecoder);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,36 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __FFmpegAACDecoder_h__
|
||||
#define __FFmpegAACDecoder_h__
|
||||
|
||||
#include "FFmpegDataDecoder.h"
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
|
||||
class FFmpegAACDecoder : public FFmpegDataDecoder
|
||||
{
|
||||
public:
|
||||
FFmpegAACDecoder(MediaTaskQueue* aTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback,
|
||||
const mp4_demuxer::AudioDecoderConfig &aConfig);
|
||||
virtual ~FFmpegAACDecoder();
|
||||
|
||||
virtual nsresult Init() MOZ_OVERRIDE;
|
||||
virtual nsresult Input(mp4_demuxer::MP4Sample* aSample) MOZ_OVERRIDE;
|
||||
virtual nsresult Drain() MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
void DecodePacket(mp4_demuxer::MP4Sample* aSample);
|
||||
|
||||
MediaDataDecoderCallback* mCallback;
|
||||
mp4_demuxer::AudioDecoderConfig mConfig;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // __FFmpegAACDecoder_h__
|
|
@ -0,0 +1,18 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __FFmpegCompat_h__
|
||||
#define __FFmpegCompat_h__
|
||||
|
||||
#include <libavcodec/version.h>
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 55
|
||||
#define AV_CODEC_ID_H264 CODEC_ID_H264
|
||||
#define AV_CODEC_ID_AAC CODEC_ID_AAC
|
||||
typedef CodecID AVCodecID;
|
||||
#endif
|
||||
|
||||
#endif // __FFmpegCompat_h__
|
|
@ -0,0 +1,124 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "MediaTaskQueue.h"
|
||||
#include "mp4_demuxer/mp4_demuxer.h"
|
||||
#include "FFmpegRuntimeLinker.h"
|
||||
|
||||
#include "FFmpegDataDecoder.h"
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
|
||||
bool FFmpegDataDecoder::sFFmpegInitDone = false;
|
||||
|
||||
FFmpegDataDecoder::FFmpegDataDecoder(MediaTaskQueue* aTaskQueue,
|
||||
AVCodecID aCodecID)
|
||||
: mTaskQueue(aTaskQueue), mCodecID(aCodecID)
|
||||
{
|
||||
MOZ_COUNT_CTOR(FFmpegDataDecoder);
|
||||
}
|
||||
|
||||
FFmpegDataDecoder::~FFmpegDataDecoder() {
|
||||
MOZ_COUNT_DTOR(FFmpegDataDecoder);
|
||||
}
|
||||
|
||||
/**
|
||||
* FFmpeg calls back to this function with a list of pixel formats it supports.
|
||||
* We choose a pixel format that we support and return it.
|
||||
* For now, we just look for YUV420P as it is the only non-HW accelerated format
|
||||
* supported by FFmpeg's H264 decoder.
|
||||
*/
|
||||
static PixelFormat
|
||||
ChoosePixelFormat(AVCodecContext* aCodecContext, const PixelFormat* aFormats)
|
||||
{
|
||||
FFMPEG_LOG("Choosing FFmpeg pixel format for video decoding.");
|
||||
for (; *aFormats > -1; aFormats++) {
|
||||
if (*aFormats == PIX_FMT_YUV420P) {
|
||||
FFMPEG_LOG("Requesting pixel format YUV420P.");
|
||||
return PIX_FMT_YUV420P;
|
||||
}
|
||||
}
|
||||
|
||||
NS_WARNING("FFmpeg does not share any supported pixel formats.");
|
||||
return PIX_FMT_NONE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
FFmpegDataDecoder::Init()
|
||||
{
|
||||
FFMPEG_LOG("Initialising FFmpeg decoder.");
|
||||
|
||||
if (!FFmpegRuntimeLinker::Link()) {
|
||||
NS_WARNING("Failed to link FFmpeg shared libraries.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (!sFFmpegInitDone) {
|
||||
av_register_all();
|
||||
#ifdef DEBUG
|
||||
av_log_set_level(AV_LOG_DEBUG);
|
||||
#endif
|
||||
sFFmpegInitDone = true;
|
||||
}
|
||||
|
||||
AVCodec* codec = avcodec_find_decoder(mCodecID);
|
||||
if (!codec) {
|
||||
NS_WARNING("Couldn't find ffmpeg decoder");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (avcodec_get_context_defaults3(&mCodecContext, codec) < 0) {
|
||||
NS_WARNING("Couldn't init ffmpeg context");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mCodecContext.opaque = this;
|
||||
|
||||
// FFmpeg takes this as a suggestion for what format to use for audio samples.
|
||||
mCodecContext.request_sample_fmt = AV_SAMPLE_FMT_FLT;
|
||||
|
||||
// FFmpeg will call back to this to negotiate a video pixel format.
|
||||
mCodecContext.get_format = ChoosePixelFormat;
|
||||
|
||||
AVDictionary* opts = nullptr;
|
||||
if (avcodec_open2(&mCodecContext, codec, &opts) < 0) {
|
||||
NS_WARNING("Couldn't initialise ffmpeg decoder");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mCodecContext.codec_type == AVMEDIA_TYPE_AUDIO &&
|
||||
mCodecContext.sample_fmt != AV_SAMPLE_FMT_FLT &&
|
||||
mCodecContext.sample_fmt != AV_SAMPLE_FMT_FLTP) {
|
||||
NS_WARNING("FFmpeg AAC decoder outputs unsupported audio format.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
FFMPEG_LOG("FFmpeg init successful.");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
FFmpegDataDecoder::Flush()
|
||||
{
|
||||
mTaskQueue->Flush();
|
||||
avcodec_flush_buffers(&mCodecContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
FFmpegDataDecoder::Shutdown()
|
||||
{
|
||||
if (sFFmpegInitDone) {
|
||||
avcodec_close(&mCodecContext);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,45 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __FFmpegDataDecoder_h__
|
||||
#define __FFmpegDataDecoder_h__
|
||||
|
||||
#include "mp4_demuxer/mp4_demuxer.h"
|
||||
|
||||
#include "FFmpegDecoderModule.h"
|
||||
#include "FFmpegRuntimeLinker.h"
|
||||
#include "FFmpegCompat.h"
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
|
||||
class FFmpegDataDecoder : public MediaDataDecoder
|
||||
{
|
||||
public:
|
||||
FFmpegDataDecoder(MediaTaskQueue* aTaskQueue, AVCodecID aCodecID);
|
||||
virtual ~FFmpegDataDecoder();
|
||||
|
||||
static bool Link();
|
||||
|
||||
virtual nsresult Init() MOZ_OVERRIDE;
|
||||
virtual nsresult Input(mp4_demuxer::MP4Sample* aSample) = 0;
|
||||
virtual nsresult Flush() MOZ_OVERRIDE;
|
||||
virtual nsresult Drain() = 0;
|
||||
virtual nsresult Shutdown() MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
MediaTaskQueue* mTaskQueue;
|
||||
AVCodecContext mCodecContext;
|
||||
|
||||
private:
|
||||
static bool sFFmpegInitDone;
|
||||
|
||||
AVCodecID mCodecID;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // __FFmpegDataDecoder_h__
|
|
@ -0,0 +1,81 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "FFmpegRuntimeLinker.h"
|
||||
#include "FFmpegAACDecoder.h"
|
||||
#include "FFmpegH264Decoder.h"
|
||||
|
||||
#include "FFmpegDecoderModule.h"
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
|
||||
PRLogModuleInfo* GetFFmpegDecoderLog()
|
||||
{
|
||||
static PRLogModuleInfo* sFFmpegDecoderLog = nullptr;
|
||||
if (!sFFmpegDecoderLog) {
|
||||
sFFmpegDecoderLog = PR_NewLogModule("FFmpegDecoderModule");
|
||||
}
|
||||
return sFFmpegDecoderLog;
|
||||
}
|
||||
|
||||
bool FFmpegDecoderModule::sFFmpegLinkDone = false;
|
||||
|
||||
FFmpegDecoderModule::FFmpegDecoderModule()
|
||||
{
|
||||
MOZ_COUNT_CTOR(FFmpegDecoderModule);
|
||||
}
|
||||
|
||||
FFmpegDecoderModule::~FFmpegDecoderModule() {
|
||||
MOZ_COUNT_DTOR(FFmpegDecoderModule);
|
||||
}
|
||||
|
||||
bool
|
||||
FFmpegDecoderModule::Link()
|
||||
{
|
||||
if (sFFmpegLinkDone) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!FFmpegRuntimeLinker::Link()) {
|
||||
NS_WARNING("Failed to link FFmpeg shared libraries.");
|
||||
return false;
|
||||
}
|
||||
|
||||
sFFmpegLinkDone = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nsresult
|
||||
FFmpegDecoderModule::Shutdown()
|
||||
{
|
||||
// Nothing to do here.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MediaDataDecoder*
|
||||
FFmpegDecoderModule::CreateH264Decoder(
|
||||
const mp4_demuxer::VideoDecoderConfig& aConfig,
|
||||
mozilla::layers::LayersBackend aLayersBackend,
|
||||
mozilla::layers::ImageContainer* aImageContainer,
|
||||
MediaTaskQueue* aVideoTaskQueue, MediaDataDecoderCallback* aCallback)
|
||||
{
|
||||
FFMPEG_LOG("Creating FFmpeg H264 decoder.");
|
||||
return new FFmpegH264Decoder(aVideoTaskQueue, aCallback, aConfig,
|
||||
aImageContainer);
|
||||
}
|
||||
|
||||
MediaDataDecoder*
|
||||
FFmpegDecoderModule::CreateAACDecoder(
|
||||
const mp4_demuxer::AudioDecoderConfig& aConfig,
|
||||
MediaTaskQueue* aAudioTaskQueue, MediaDataDecoderCallback* aCallback)
|
||||
{
|
||||
FFMPEG_LOG("Creating FFmpeg AAC decoder.");
|
||||
return new FFmpegAACDecoder(aAudioTaskQueue, aCallback, aConfig);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __FFmpegDecoderModule_h__
|
||||
#define __FFmpegDecoderModule_h__
|
||||
|
||||
#include "PlatformDecoderModule.h"
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
extern PRLogModuleInfo* GetFFmpegDecoderLog();
|
||||
#define FFMPEG_LOG(...) PR_LOG(GetFFmpegDecoderLog(), PR_LOG_DEBUG, (__VA_ARGS__))
|
||||
#else
|
||||
#define FFMPEG_LOG(...)
|
||||
#endif
|
||||
|
||||
class FFmpegDecoderModule : public PlatformDecoderModule
|
||||
{
|
||||
public:
|
||||
FFmpegDecoderModule();
|
||||
virtual ~FFmpegDecoderModule();
|
||||
|
||||
static bool Link();
|
||||
|
||||
virtual nsresult Shutdown() MOZ_OVERRIDE;
|
||||
|
||||
virtual MediaDataDecoder* CreateH264Decoder(
|
||||
const mp4_demuxer::VideoDecoderConfig& aConfig,
|
||||
mozilla::layers::LayersBackend aLayersBackend,
|
||||
mozilla::layers::ImageContainer* aImageContainer,
|
||||
MediaTaskQueue* aVideoTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
|
||||
|
||||
virtual MediaDataDecoder* CreateAACDecoder(
|
||||
const mp4_demuxer::AudioDecoderConfig& aConfig,
|
||||
MediaTaskQueue* aAudioTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
static bool sFFmpegLinkDone;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // __FFmpegDecoderModule_h__
|
|
@ -0,0 +1,25 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
AV_FUNC(LIBAVCODEC, avcodec_align_dimensions2)
|
||||
AV_FUNC(LIBAVCODEC, avcodec_alloc_frame)
|
||||
AV_FUNC(LIBAVCODEC, avcodec_close)
|
||||
AV_FUNC(LIBAVCODEC, avcodec_decode_audio4)
|
||||
AV_FUNC(LIBAVCODEC, avcodec_decode_video2)
|
||||
AV_FUNC(LIBAVCODEC, avcodec_default_get_buffer)
|
||||
AV_FUNC(LIBAVCODEC, avcodec_default_release_buffer)
|
||||
AV_FUNC(LIBAVCODEC, avcodec_find_decoder)
|
||||
AV_FUNC(LIBAVCODEC, avcodec_flush_buffers)
|
||||
AV_FUNC(LIBAVCODEC, avcodec_get_context_defaults3)
|
||||
AV_FUNC(LIBAVCODEC, avcodec_get_edge_width)
|
||||
AV_FUNC(LIBAVCODEC, avcodec_get_frame_defaults)
|
||||
AV_FUNC(LIBAVCODEC, avcodec_open2)
|
||||
AV_FUNC(LIBAVCODEC, av_init_packet)
|
||||
AV_FUNC(LIBAVCODEC, av_dict_get)
|
||||
|
||||
AV_FUNC(LIBAVFORMAT, av_register_all)
|
||||
|
||||
AV_FUNC(LIBAVUTIL, av_image_fill_linesizes)
|
||||
AV_FUNC(LIBAVUTIL, av_image_fill_pointers)
|
||||
AV_FUNC(LIBAVUTIL, av_log_set_level)
|
|
@ -0,0 +1,271 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "MediaTaskQueue.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "ImageContainer.h"
|
||||
|
||||
#include "mp4_demuxer/mp4_demuxer.h"
|
||||
#include "FFmpegRuntimeLinker.h"
|
||||
|
||||
#include "FFmpegH264Decoder.h"
|
||||
|
||||
#define GECKO_FRAME_TYPE 0x00093CC0
|
||||
|
||||
typedef mozilla::layers::Image Image;
|
||||
typedef mozilla::layers::PlanarYCbCrImage PlanarYCbCrImage;
|
||||
|
||||
typedef mp4_demuxer::MP4Sample MP4Sample;
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
|
||||
FFmpegH264Decoder::FFmpegH264Decoder(
|
||||
MediaTaskQueue* aTaskQueue, MediaDataDecoderCallback* aCallback,
|
||||
const mp4_demuxer::VideoDecoderConfig &aConfig,
|
||||
ImageContainer* aImageContainer)
|
||||
: FFmpegDataDecoder(aTaskQueue, AV_CODEC_ID_H264)
|
||||
, mConfig(aConfig)
|
||||
, mCallback(aCallback)
|
||||
, mImageContainer(aImageContainer)
|
||||
{
|
||||
MOZ_COUNT_CTOR(FFmpegH264Decoder);
|
||||
}
|
||||
|
||||
nsresult
|
||||
FFmpegH264Decoder::Init()
|
||||
{
|
||||
nsresult rv = FFmpegDataDecoder::Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mCodecContext.get_buffer = AllocateBufferCb;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
FFmpegH264Decoder::DecodeFrame(mp4_demuxer::MP4Sample* aSample)
|
||||
{
|
||||
AVPacket packet;
|
||||
av_init_packet(&packet);
|
||||
|
||||
packet.data = &(*aSample->data)[0];
|
||||
packet.size = aSample->data->size();
|
||||
packet.dts = aSample->decode_timestamp;
|
||||
packet.pts = aSample->composition_timestamp;
|
||||
packet.flags = aSample->is_sync_point ? AV_PKT_FLAG_KEY : 0;
|
||||
packet.pos = aSample->byte_offset;
|
||||
|
||||
nsAutoPtr<AVFrame> frame(avcodec_alloc_frame());
|
||||
avcodec_get_frame_defaults(frame);
|
||||
|
||||
int decoded;
|
||||
int bytesConsumed =
|
||||
avcodec_decode_video2(&mCodecContext, frame, &decoded, &packet);
|
||||
|
||||
if (bytesConsumed < 0) {
|
||||
NS_WARNING("FFmpeg video decoder error.");
|
||||
mCallback->Error();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!decoded) {
|
||||
// The decoder doesn't have enough data to decode a frame yet.
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoPtr<VideoData> data;
|
||||
|
||||
VideoInfo info;
|
||||
info.mDisplay = nsIntSize(mCodecContext.width, mCodecContext.height);
|
||||
info.mStereoMode = StereoMode::MONO;
|
||||
info.mHasVideo = true;
|
||||
|
||||
data = VideoData::CreateFromImage(
|
||||
info, mImageContainer, aSample->byte_offset, aSample->composition_timestamp,
|
||||
aSample->duration, mCurrentImage, aSample->is_sync_point, -1,
|
||||
gfx::IntRect(0, 0, mCodecContext.width, mCodecContext.height));
|
||||
|
||||
// Insert the frame into the heap for reordering.
|
||||
mDelayedFrames.Push(data.forget());
|
||||
|
||||
// Reorder video frames from decode order to presentation order. The minimum
|
||||
// size of the heap comes from one P frame + |max_b_frames| B frames, which
|
||||
// is the maximum number of frames in a row which will be out-of-order.
|
||||
if (mDelayedFrames.Length() > (uint32_t)mCodecContext.max_b_frames + 1) {
|
||||
VideoData* d = mDelayedFrames.Pop();
|
||||
mCallback->Output(d);
|
||||
}
|
||||
|
||||
if (mTaskQueue->IsEmpty()) {
|
||||
mCallback->InputExhausted();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
PlanarYCbCrDataFromAVFrame(mozilla::layers::PlanarYCbCrData &aData,
|
||||
AVFrame* aFrame)
|
||||
{
|
||||
aData.mPicX = aData.mPicY = 0;
|
||||
aData.mPicSize = mozilla::gfx::IntSize(aFrame->width, aFrame->height);
|
||||
aData.mStereoMode = StereoMode::MONO;
|
||||
|
||||
aData.mYChannel = aFrame->data[0];
|
||||
aData.mYStride = aFrame->linesize[0];
|
||||
aData.mYSize = aData.mPicSize;
|
||||
aData.mYSkip = 0;
|
||||
|
||||
aData.mCbChannel = aFrame->data[1];
|
||||
aData.mCrChannel = aFrame->data[2];
|
||||
aData.mCbCrStride = aFrame->linesize[1];
|
||||
aData.mCbSkip = aData.mCrSkip = 0;
|
||||
aData.mCbCrSize =
|
||||
mozilla::gfx::IntSize((aFrame->width + 1) / 2, (aFrame->height + 1) / 2);
|
||||
}
|
||||
|
||||
/* static */ int
|
||||
FFmpegH264Decoder::AllocateBufferCb(AVCodecContext* aCodecContext,
|
||||
AVFrame* aFrame)
|
||||
{
|
||||
MOZ_ASSERT(aCodecContext->codec_type == AVMEDIA_TYPE_VIDEO);
|
||||
|
||||
FFmpegH264Decoder* self =
|
||||
reinterpret_cast<FFmpegH264Decoder*>(aCodecContext->opaque);
|
||||
|
||||
switch (aCodecContext->pix_fmt) {
|
||||
case PIX_FMT_YUV420P:
|
||||
return self->AllocateYUV420PVideoBuffer(aCodecContext, aFrame);
|
||||
default:
|
||||
return avcodec_default_get_buffer(aCodecContext, aFrame);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
FFmpegH264Decoder::AllocateYUV420PVideoBuffer(AVCodecContext* aCodecContext,
|
||||
AVFrame* aFrame)
|
||||
{
|
||||
// Older versions of ffmpeg require that edges be allocated* around* the
|
||||
// actual image.
|
||||
int edgeWidth = avcodec_get_edge_width();
|
||||
int decodeWidth = aCodecContext->width + edgeWidth * 2;
|
||||
int decodeHeight = aCodecContext->height + edgeWidth * 2;
|
||||
|
||||
// Align width and height to possibly speed up decode.
|
||||
int stride_align[AV_NUM_DATA_POINTERS];
|
||||
avcodec_align_dimensions2(aCodecContext, &decodeWidth, &decodeHeight,
|
||||
stride_align);
|
||||
|
||||
// Get strides for each plane.
|
||||
av_image_fill_linesizes(aFrame->linesize, aCodecContext->pix_fmt,
|
||||
decodeWidth);
|
||||
|
||||
// Let FFmpeg set up its YUV plane pointers and tell us how much memory we
|
||||
// need.
|
||||
// Note that we're passing |nullptr| here as the base address as we haven't
|
||||
// allocated our image yet. We will adjust |aFrame->data| below.
|
||||
size_t allocSize =
|
||||
av_image_fill_pointers(aFrame->data, aCodecContext->pix_fmt, decodeHeight,
|
||||
nullptr /* base address */, aFrame->linesize);
|
||||
|
||||
nsRefPtr<Image> image =
|
||||
mImageContainer->CreateImage(ImageFormat::PLANAR_YCBCR);
|
||||
PlanarYCbCrImage* ycbcr = reinterpret_cast<PlanarYCbCrImage*>(image.get());
|
||||
uint8_t* buffer = ycbcr->AllocateAndGetNewBuffer(allocSize);
|
||||
|
||||
if (!buffer) {
|
||||
NS_WARNING("Failed to allocate buffer for FFmpeg video decoding");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Now that we've allocated our image, we can add its address to the offsets
|
||||
// set by |av_image_fill_pointers| above. We also have to add |edgeWidth|
|
||||
// pixels of padding here.
|
||||
for (uint32_t i = 0; i < AV_NUM_DATA_POINTERS; i++) {
|
||||
// The C planes are half the resolution of the Y plane, so we need to halve
|
||||
// the edge width here.
|
||||
uint32_t planeEdgeWidth = edgeWidth / (i ? 2 : 1);
|
||||
|
||||
// Add buffer offset, plus a horizontal bar |edgeWidth| pixels high at the
|
||||
// top of the frame, plus |edgeWidth| pixels from the left of the frame.
|
||||
aFrame->data[i] += reinterpret_cast<ptrdiff_t>(
|
||||
buffer + planeEdgeWidth * aFrame->linesize[i] + planeEdgeWidth);
|
||||
}
|
||||
|
||||
// Unused, but needs to be non-zero to keep ffmpeg happy.
|
||||
aFrame->type = GECKO_FRAME_TYPE;
|
||||
|
||||
aFrame->extended_data = aFrame->data;
|
||||
aFrame->width = aCodecContext->width;
|
||||
aFrame->height = aCodecContext->height;
|
||||
|
||||
mozilla::layers::PlanarYCbCrData data;
|
||||
PlanarYCbCrDataFromAVFrame(data, aFrame);
|
||||
ycbcr->SetDataNoCopy(data);
|
||||
|
||||
mCurrentImage.swap(image);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsresult
|
||||
FFmpegH264Decoder::Input(mp4_demuxer::MP4Sample* aSample)
|
||||
{
|
||||
mTaskQueue->Dispatch(
|
||||
NS_NewRunnableMethodWithArg<nsAutoPtr<mp4_demuxer::MP4Sample> >(
|
||||
this, &FFmpegH264Decoder::DecodeFrame,
|
||||
nsAutoPtr<mp4_demuxer::MP4Sample>(aSample)));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
FFmpegH264Decoder::OutputDelayedFrames()
|
||||
{
|
||||
while (!mDelayedFrames.IsEmpty()) {
|
||||
mCallback->Output(mDelayedFrames.Pop());
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
FFmpegH264Decoder::Drain()
|
||||
{
|
||||
// The maximum number of frames that can be waiting to be decoded is
|
||||
// max_b_frames + 1: One P frame and max_b_frames B frames.
|
||||
for (int32_t i = 0; i <= mCodecContext.max_b_frames; i++) {
|
||||
// An empty frame tells FFmpeg to decode the next delayed frame it has in
|
||||
// its queue, if it has any.
|
||||
nsAutoPtr<MP4Sample> empty(new MP4Sample(0 /* dts */, 0 /* cts */,
|
||||
0 /* duration */, 0 /* offset */,
|
||||
new std::vector<uint8_t>(),
|
||||
mp4_demuxer::kVideo, nullptr,
|
||||
false));
|
||||
|
||||
nsresult rv = Input(empty.forget());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
mTaskQueue->Dispatch(
|
||||
NS_NewRunnableMethod(this, &FFmpegH264Decoder::OutputDelayedFrames));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
FFmpegH264Decoder::Flush()
|
||||
{
|
||||
nsresult rv = FFmpegDataDecoder::Flush();
|
||||
// Even if the above fails we may as well clear our frame queue.
|
||||
mDelayedFrames.Clear();
|
||||
return rv;
|
||||
}
|
||||
|
||||
FFmpegH264Decoder::~FFmpegH264Decoder() {
|
||||
MOZ_COUNT_DTOR(FFmpegH264Decoder);
|
||||
MOZ_ASSERT(mDelayedFrames.IsEmpty());
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,84 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __FFmpegH264Decoder_h__
|
||||
#define __FFmpegH264Decoder_h__
|
||||
|
||||
#include "nsTPriorityQueue.h"
|
||||
|
||||
#include "FFmpegDataDecoder.h"
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
|
||||
class FFmpegH264Decoder : public FFmpegDataDecoder
|
||||
{
|
||||
typedef mozilla::layers::Image Image;
|
||||
typedef mozilla::layers::ImageContainer ImageContainer;
|
||||
|
||||
public:
|
||||
FFmpegH264Decoder(MediaTaskQueue* aTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback,
|
||||
const mp4_demuxer::VideoDecoderConfig &aConfig,
|
||||
ImageContainer* aImageContainer);
|
||||
virtual ~FFmpegH264Decoder();
|
||||
|
||||
virtual nsresult Init() MOZ_OVERRIDE;
|
||||
virtual nsresult Input(mp4_demuxer::MP4Sample* aSample) MOZ_OVERRIDE;
|
||||
virtual nsresult Drain() MOZ_OVERRIDE;
|
||||
virtual nsresult Flush() MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
void DecodeFrame(mp4_demuxer::MP4Sample* aSample);
|
||||
void OutputDelayedFrames();
|
||||
|
||||
/**
|
||||
* This method allocates a buffer for FFmpeg's decoder, wrapped in an Image.
|
||||
* Currently it only supports Planar YUV420, which appears to be the only
|
||||
* non-hardware accelerated image format that FFmpeg's H264 decoder is
|
||||
* capable of outputting.
|
||||
*/
|
||||
int AllocateYUV420PVideoBuffer(AVCodecContext* aCodecContext,
|
||||
AVFrame* aFrame);
|
||||
|
||||
static int AllocateBufferCb(AVCodecContext* aCodecContext, AVFrame* aFrame);
|
||||
|
||||
mp4_demuxer::VideoDecoderConfig mConfig;
|
||||
MediaDataDecoderCallback* mCallback;
|
||||
nsRefPtr<ImageContainer> mImageContainer;
|
||||
|
||||
/**
|
||||
* Pass Image back from the allocator to our DoDecode method.
|
||||
* We *should* return the image back through ffmpeg wrapped in an AVFrame like
|
||||
* we're meant to. However, if avcodec_decode_video2 fails, it returns a
|
||||
* completely different frame from the one holding our image and it will be
|
||||
* leaked.
|
||||
* This could be handled in the future by wrapping our Image in a reference
|
||||
* counted AVBuffer and letting ffmpeg hold the nsAutoPtr<Image>, but
|
||||
* currently we have to support older versions of ffmpeg which lack
|
||||
* refcounting.
|
||||
*/
|
||||
nsRefPtr<Image> mCurrentImage;
|
||||
|
||||
struct VideoDataComparator
|
||||
{
|
||||
bool LessThan(VideoData* const &a, VideoData* const &b) const
|
||||
{
|
||||
return a->mTime < b->mTime;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* FFmpeg returns frames in DTS order, so we need to keep a heap of the
|
||||
* previous MAX_B_FRAMES + 1 frames (all B frames in a GOP + one P frame)
|
||||
* ordered by PTS to make sure we present video frames in the intended order.
|
||||
*/
|
||||
nsTPriorityQueue<VideoData*, VideoDataComparator> mDelayedFrames;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // __FFmpegH264Decoder_h__
|
|
@ -0,0 +1,85 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "nsDebug.h"
|
||||
|
||||
#include "FFmpegRuntimeLinker.h"
|
||||
|
||||
// For FFMPEG_LOG
|
||||
#include "FFmpegDecoderModule.h"
|
||||
|
||||
#define NUM_ELEMENTS(X) (sizeof(X) / sizeof((X)[0]))
|
||||
|
||||
#define LIBAVCODEC 0
|
||||
#define LIBAVFORMAT 1
|
||||
#define LIBAVUTIL 2
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
|
||||
FFmpegRuntimeLinker::LinkStatus FFmpegRuntimeLinker::sLinkStatus =
|
||||
LinkStatus_INIT;
|
||||
|
||||
static const char * const sLibNames[] = {
|
||||
"libavcodec.so.53", "libavformat.so.53", "libavutil.so.51",
|
||||
};
|
||||
|
||||
void* FFmpegRuntimeLinker::sLinkedLibs[NUM_ELEMENTS(sLibNames)] = {
|
||||
nullptr, nullptr, nullptr
|
||||
};
|
||||
|
||||
#define AV_FUNC(lib, func) typeof(func) func;
|
||||
#include "FFmpegFunctionList.h"
|
||||
#undef AV_FUNC
|
||||
|
||||
/* static */ bool
|
||||
FFmpegRuntimeLinker::Link()
|
||||
{
|
||||
if (sLinkStatus) {
|
||||
return sLinkStatus == LinkStatus_SUCCEEDED;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < NUM_ELEMENTS(sLinkedLibs); i++) {
|
||||
if (!(sLinkedLibs[i] = dlopen(sLibNames[i], RTLD_NOW | RTLD_LOCAL))) {
|
||||
NS_WARNING("Couldn't link ffmpeg libraries.");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
#define AV_FUNC(lib, func) \
|
||||
func = (typeof(func))dlsym(sLinkedLibs[lib], #func); \
|
||||
if (!func) { \
|
||||
NS_WARNING("Couldn't load FFmpeg function " #func "."); \
|
||||
goto fail; \
|
||||
}
|
||||
#include "FFmpegFunctionList.h"
|
||||
#undef AV_FUNC
|
||||
|
||||
sLinkStatus = LinkStatus_SUCCEEDED;
|
||||
return true;
|
||||
|
||||
fail:
|
||||
Unlink();
|
||||
|
||||
sLinkStatus = LinkStatus_FAILED;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* static */ void
|
||||
FFmpegRuntimeLinker::Unlink()
|
||||
{
|
||||
FFMPEG_LOG("Unlinking ffmpeg libraries.");
|
||||
for (uint32_t i = 0; i < NUM_ELEMENTS(sLinkedLibs); i++) {
|
||||
if (sLinkedLibs[i]) {
|
||||
dlclose(sLinkedLibs[i]);
|
||||
sLinkedLibs[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
|
@ -0,0 +1,44 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __FFmpegRuntimeLinker_h__
|
||||
#define __FFmpegRuntimeLinker_h__
|
||||
|
||||
extern "C" {
|
||||
#pragma GCC visibility push(default)
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavutil/imgutils.h>
|
||||
#pragma GCC visibility pop
|
||||
}
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
|
||||
class FFmpegRuntimeLinker
|
||||
{
|
||||
public:
|
||||
static bool Link();
|
||||
static void Unlink();
|
||||
|
||||
private:
|
||||
static void* sLinkedLibs[];
|
||||
|
||||
static enum LinkStatus {
|
||||
LinkStatus_INIT = 0,
|
||||
LinkStatus_FAILED,
|
||||
LinkStatus_SUCCEEDED
|
||||
} sLinkStatus;
|
||||
};
|
||||
|
||||
#define AV_FUNC(lib, func) extern typeof(func)* func;
|
||||
#include "FFmpegFunctionList.h"
|
||||
#undef AV_FUNC
|
||||
}
|
||||
|
||||
#endif // __FFmpegRuntimeLinker_h__
|
|
@ -0,0 +1,504 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
These headers are taken from Libav version 0.8.9.
|
||||
|
||||
These headers are licensed under the GNU Lesser General Public License version
|
||||
2.1. For more information see the file COPYING.LGPLv2.1
|
||||
|
||||
While the function ABIs of FFmpeg/Libav tend to be stable between even major
|
||||
versions, the class layouts can change considerably. This can lead to major
|
||||
crashes if we build against the wrong headers. We include these headers to make
|
||||
sure we have the same version every time we build, and to ease the pain of
|
||||
acquiring the correct libraries for a build, especially for those distributions
|
||||
who oppose distributing such packages.
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_AVFFT_H
|
||||
#define AVCODEC_AVFFT_H
|
||||
|
||||
typedef float FFTSample;
|
||||
|
||||
typedef struct FFTComplex {
|
||||
FFTSample re, im;
|
||||
} FFTComplex;
|
||||
|
||||
typedef struct FFTContext FFTContext;
|
||||
|
||||
/**
|
||||
* Set up a complex FFT.
|
||||
* @param nbits log2 of the length of the input array
|
||||
* @param inverse if 0 perform the forward transform, if 1 perform the inverse
|
||||
*/
|
||||
FFTContext *av_fft_init(int nbits, int inverse);
|
||||
|
||||
/**
|
||||
* Do the permutation needed BEFORE calling ff_fft_calc().
|
||||
*/
|
||||
void av_fft_permute(FFTContext *s, FFTComplex *z);
|
||||
|
||||
/**
|
||||
* Do a complex FFT with the parameters defined in av_fft_init(). The
|
||||
* input data must be permuted before. No 1.0/sqrt(n) normalization is done.
|
||||
*/
|
||||
void av_fft_calc(FFTContext *s, FFTComplex *z);
|
||||
|
||||
void av_fft_end(FFTContext *s);
|
||||
|
||||
FFTContext *av_mdct_init(int nbits, int inverse, double scale);
|
||||
void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
void av_mdct_end(FFTContext *s);
|
||||
|
||||
/* Real Discrete Fourier Transform */
|
||||
|
||||
enum RDFTransformType {
|
||||
DFT_R2C,
|
||||
IDFT_C2R,
|
||||
IDFT_R2C,
|
||||
DFT_C2R,
|
||||
};
|
||||
|
||||
typedef struct RDFTContext RDFTContext;
|
||||
|
||||
/**
|
||||
* Set up a real FFT.
|
||||
* @param nbits log2 of the length of the input array
|
||||
* @param trans the type of transform
|
||||
*/
|
||||
RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans);
|
||||
void av_rdft_calc(RDFTContext *s, FFTSample *data);
|
||||
void av_rdft_end(RDFTContext *s);
|
||||
|
||||
/* Discrete Cosine Transform */
|
||||
|
||||
typedef struct DCTContext DCTContext;
|
||||
|
||||
enum DCTTransformType {
|
||||
DCT_II = 0,
|
||||
DCT_III,
|
||||
DCT_I,
|
||||
DST_I,
|
||||
};
|
||||
|
||||
/**
|
||||
* Set up DCT.
|
||||
* @param nbits size of the input array:
|
||||
* (1 << nbits) for DCT-II, DCT-III and DST-I
|
||||
* (1 << nbits) + 1 for DCT-I
|
||||
*
|
||||
* @note the first element of the input of DST-I is ignored
|
||||
*/
|
||||
DCTContext *av_dct_init(int nbits, enum DCTTransformType type);
|
||||
void av_dct_calc(DCTContext *s, FFTSample *data);
|
||||
void av_dct_end (DCTContext *s);
|
||||
|
||||
#endif /* AVCODEC_AVFFT_H */
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* DXVA2 HW acceleration
|
||||
*
|
||||
* copyright (c) 2009 Laurent Aimar
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_DXVA_H
|
||||
#define AVCODEC_DXVA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <dxva2api.h>
|
||||
|
||||
#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards
|
||||
|
||||
/**
|
||||
* This structure is used to provides the necessary configurations and data
|
||||
* to the DXVA2 Libav HWAccel implementation.
|
||||
*
|
||||
* The application must make it available as AVCodecContext.hwaccel_context.
|
||||
*/
|
||||
struct dxva_context {
|
||||
/**
|
||||
* DXVA2 decoder object
|
||||
*/
|
||||
IDirectXVideoDecoder *decoder;
|
||||
|
||||
/**
|
||||
* DXVA2 configuration used to create the decoder
|
||||
*/
|
||||
const DXVA2_ConfigPictureDecode *cfg;
|
||||
|
||||
/**
|
||||
* The number of surface in the surface array
|
||||
*/
|
||||
unsigned surface_count;
|
||||
|
||||
/**
|
||||
* The array of Direct3D surfaces used to create the decoder
|
||||
*/
|
||||
LPDIRECT3DSURFACE9 *surface;
|
||||
|
||||
/**
|
||||
* A bit field configuring the workarounds needed for using the decoder
|
||||
*/
|
||||
uint64_t workaround;
|
||||
|
||||
/**
|
||||
* Private to the Libav AVHWAccel implementation
|
||||
*/
|
||||
unsigned report_id;
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_DXVA_H */
|
|
@ -0,0 +1,398 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_OLD_CODEC_IDS_H
|
||||
#define AVCODEC_OLD_CODEC_IDS_H
|
||||
|
||||
#include "libavutil/common.h"
|
||||
|
||||
/*
|
||||
* This header exists to prevent new codec IDs from being accidentally added to
|
||||
* the deprecated list.
|
||||
* Do not include it directly. It will be removed on next major bump
|
||||
*
|
||||
* Do not add new items to this list. Use the AVCodecID enum instead.
|
||||
*/
|
||||
|
||||
CODEC_ID_NONE = AV_CODEC_ID_NONE,
|
||||
|
||||
/* video codecs */
|
||||
CODEC_ID_MPEG1VIDEO,
|
||||
CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
|
||||
CODEC_ID_MPEG2VIDEO_XVMC,
|
||||
CODEC_ID_H261,
|
||||
CODEC_ID_H263,
|
||||
CODEC_ID_RV10,
|
||||
CODEC_ID_RV20,
|
||||
CODEC_ID_MJPEG,
|
||||
CODEC_ID_MJPEGB,
|
||||
CODEC_ID_LJPEG,
|
||||
CODEC_ID_SP5X,
|
||||
CODEC_ID_JPEGLS,
|
||||
CODEC_ID_MPEG4,
|
||||
CODEC_ID_RAWVIDEO,
|
||||
CODEC_ID_MSMPEG4V1,
|
||||
CODEC_ID_MSMPEG4V2,
|
||||
CODEC_ID_MSMPEG4V3,
|
||||
CODEC_ID_WMV1,
|
||||
CODEC_ID_WMV2,
|
||||
CODEC_ID_H263P,
|
||||
CODEC_ID_H263I,
|
||||
CODEC_ID_FLV1,
|
||||
CODEC_ID_SVQ1,
|
||||
CODEC_ID_SVQ3,
|
||||
CODEC_ID_DVVIDEO,
|
||||
CODEC_ID_HUFFYUV,
|
||||
CODEC_ID_CYUV,
|
||||
CODEC_ID_H264,
|
||||
CODEC_ID_INDEO3,
|
||||
CODEC_ID_VP3,
|
||||
CODEC_ID_THEORA,
|
||||
CODEC_ID_ASV1,
|
||||
CODEC_ID_ASV2,
|
||||
CODEC_ID_FFV1,
|
||||
CODEC_ID_4XM,
|
||||
CODEC_ID_VCR1,
|
||||
CODEC_ID_CLJR,
|
||||
CODEC_ID_MDEC,
|
||||
CODEC_ID_ROQ,
|
||||
CODEC_ID_INTERPLAY_VIDEO,
|
||||
CODEC_ID_XAN_WC3,
|
||||
CODEC_ID_XAN_WC4,
|
||||
CODEC_ID_RPZA,
|
||||
CODEC_ID_CINEPAK,
|
||||
CODEC_ID_WS_VQA,
|
||||
CODEC_ID_MSRLE,
|
||||
CODEC_ID_MSVIDEO1,
|
||||
CODEC_ID_IDCIN,
|
||||
CODEC_ID_8BPS,
|
||||
CODEC_ID_SMC,
|
||||
CODEC_ID_FLIC,
|
||||
CODEC_ID_TRUEMOTION1,
|
||||
CODEC_ID_VMDVIDEO,
|
||||
CODEC_ID_MSZH,
|
||||
CODEC_ID_ZLIB,
|
||||
CODEC_ID_QTRLE,
|
||||
CODEC_ID_SNOW,
|
||||
CODEC_ID_TSCC,
|
||||
CODEC_ID_ULTI,
|
||||
CODEC_ID_QDRAW,
|
||||
CODEC_ID_VIXL,
|
||||
CODEC_ID_QPEG,
|
||||
CODEC_ID_PNG,
|
||||
CODEC_ID_PPM,
|
||||
CODEC_ID_PBM,
|
||||
CODEC_ID_PGM,
|
||||
CODEC_ID_PGMYUV,
|
||||
CODEC_ID_PAM,
|
||||
CODEC_ID_FFVHUFF,
|
||||
CODEC_ID_RV30,
|
||||
CODEC_ID_RV40,
|
||||
CODEC_ID_VC1,
|
||||
CODEC_ID_WMV3,
|
||||
CODEC_ID_LOCO,
|
||||
CODEC_ID_WNV1,
|
||||
CODEC_ID_AASC,
|
||||
CODEC_ID_INDEO2,
|
||||
CODEC_ID_FRAPS,
|
||||
CODEC_ID_TRUEMOTION2,
|
||||
CODEC_ID_BMP,
|
||||
CODEC_ID_CSCD,
|
||||
CODEC_ID_MMVIDEO,
|
||||
CODEC_ID_ZMBV,
|
||||
CODEC_ID_AVS,
|
||||
CODEC_ID_SMACKVIDEO,
|
||||
CODEC_ID_NUV,
|
||||
CODEC_ID_KMVC,
|
||||
CODEC_ID_FLASHSV,
|
||||
CODEC_ID_CAVS,
|
||||
CODEC_ID_JPEG2000,
|
||||
CODEC_ID_VMNC,
|
||||
CODEC_ID_VP5,
|
||||
CODEC_ID_VP6,
|
||||
CODEC_ID_VP6F,
|
||||
CODEC_ID_TARGA,
|
||||
CODEC_ID_DSICINVIDEO,
|
||||
CODEC_ID_TIERTEXSEQVIDEO,
|
||||
CODEC_ID_TIFF,
|
||||
CODEC_ID_GIF,
|
||||
CODEC_ID_DXA,
|
||||
CODEC_ID_DNXHD,
|
||||
CODEC_ID_THP,
|
||||
CODEC_ID_SGI,
|
||||
CODEC_ID_C93,
|
||||
CODEC_ID_BETHSOFTVID,
|
||||
CODEC_ID_PTX,
|
||||
CODEC_ID_TXD,
|
||||
CODEC_ID_VP6A,
|
||||
CODEC_ID_AMV,
|
||||
CODEC_ID_VB,
|
||||
CODEC_ID_PCX,
|
||||
CODEC_ID_SUNRAST,
|
||||
CODEC_ID_INDEO4,
|
||||
CODEC_ID_INDEO5,
|
||||
CODEC_ID_MIMIC,
|
||||
CODEC_ID_RL2,
|
||||
CODEC_ID_ESCAPE124,
|
||||
CODEC_ID_DIRAC,
|
||||
CODEC_ID_BFI,
|
||||
CODEC_ID_CMV,
|
||||
CODEC_ID_MOTIONPIXELS,
|
||||
CODEC_ID_TGV,
|
||||
CODEC_ID_TGQ,
|
||||
CODEC_ID_TQI,
|
||||
CODEC_ID_AURA,
|
||||
CODEC_ID_AURA2,
|
||||
CODEC_ID_V210X,
|
||||
CODEC_ID_TMV,
|
||||
CODEC_ID_V210,
|
||||
CODEC_ID_DPX,
|
||||
CODEC_ID_MAD,
|
||||
CODEC_ID_FRWU,
|
||||
CODEC_ID_FLASHSV2,
|
||||
CODEC_ID_CDGRAPHICS,
|
||||
CODEC_ID_R210,
|
||||
CODEC_ID_ANM,
|
||||
CODEC_ID_BINKVIDEO,
|
||||
CODEC_ID_IFF_ILBM,
|
||||
CODEC_ID_IFF_BYTERUN1,
|
||||
CODEC_ID_KGV1,
|
||||
CODEC_ID_YOP,
|
||||
CODEC_ID_VP8,
|
||||
CODEC_ID_PICTOR,
|
||||
CODEC_ID_ANSI,
|
||||
CODEC_ID_A64_MULTI,
|
||||
CODEC_ID_A64_MULTI5,
|
||||
CODEC_ID_R10K,
|
||||
CODEC_ID_MXPEG,
|
||||
CODEC_ID_LAGARITH,
|
||||
CODEC_ID_PRORES,
|
||||
CODEC_ID_JV,
|
||||
CODEC_ID_DFA,
|
||||
CODEC_ID_WMV3IMAGE,
|
||||
CODEC_ID_VC1IMAGE,
|
||||
CODEC_ID_UTVIDEO,
|
||||
CODEC_ID_BMV_VIDEO,
|
||||
CODEC_ID_VBLE,
|
||||
CODEC_ID_DXTORY,
|
||||
CODEC_ID_V410,
|
||||
CODEC_ID_XWD,
|
||||
CODEC_ID_CDXL,
|
||||
CODEC_ID_XBM,
|
||||
CODEC_ID_ZEROCODEC,
|
||||
CODEC_ID_MSS1,
|
||||
CODEC_ID_MSA1,
|
||||
CODEC_ID_TSCC2,
|
||||
CODEC_ID_MTS2,
|
||||
CODEC_ID_CLLC,
|
||||
CODEC_ID_Y41P = MKBETAG('Y','4','1','P'),
|
||||
CODEC_ID_ESCAPE130 = MKBETAG('E','1','3','0'),
|
||||
CODEC_ID_EXR = MKBETAG('0','E','X','R'),
|
||||
CODEC_ID_AVRP = MKBETAG('A','V','R','P'),
|
||||
|
||||
CODEC_ID_G2M = MKBETAG( 0 ,'G','2','M'),
|
||||
CODEC_ID_AVUI = MKBETAG('A','V','U','I'),
|
||||
CODEC_ID_AYUV = MKBETAG('A','Y','U','V'),
|
||||
CODEC_ID_V308 = MKBETAG('V','3','0','8'),
|
||||
CODEC_ID_V408 = MKBETAG('V','4','0','8'),
|
||||
CODEC_ID_YUV4 = MKBETAG('Y','U','V','4'),
|
||||
CODEC_ID_SANM = MKBETAG('S','A','N','M'),
|
||||
CODEC_ID_PAF_VIDEO = MKBETAG('P','A','F','V'),
|
||||
|
||||
/* various PCM "codecs" */
|
||||
CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
|
||||
CODEC_ID_PCM_S16LE = 0x10000,
|
||||
CODEC_ID_PCM_S16BE,
|
||||
CODEC_ID_PCM_U16LE,
|
||||
CODEC_ID_PCM_U16BE,
|
||||
CODEC_ID_PCM_S8,
|
||||
CODEC_ID_PCM_U8,
|
||||
CODEC_ID_PCM_MULAW,
|
||||
CODEC_ID_PCM_ALAW,
|
||||
CODEC_ID_PCM_S32LE,
|
||||
CODEC_ID_PCM_S32BE,
|
||||
CODEC_ID_PCM_U32LE,
|
||||
CODEC_ID_PCM_U32BE,
|
||||
CODEC_ID_PCM_S24LE,
|
||||
CODEC_ID_PCM_S24BE,
|
||||
CODEC_ID_PCM_U24LE,
|
||||
CODEC_ID_PCM_U24BE,
|
||||
CODEC_ID_PCM_S24DAUD,
|
||||
CODEC_ID_PCM_ZORK,
|
||||
CODEC_ID_PCM_S16LE_PLANAR,
|
||||
CODEC_ID_PCM_DVD,
|
||||
CODEC_ID_PCM_F32BE,
|
||||
CODEC_ID_PCM_F32LE,
|
||||
CODEC_ID_PCM_F64BE,
|
||||
CODEC_ID_PCM_F64LE,
|
||||
CODEC_ID_PCM_BLURAY,
|
||||
CODEC_ID_PCM_LXF,
|
||||
CODEC_ID_S302M,
|
||||
CODEC_ID_PCM_S8_PLANAR,
|
||||
|
||||
/* various ADPCM codecs */
|
||||
CODEC_ID_ADPCM_IMA_QT = 0x11000,
|
||||
CODEC_ID_ADPCM_IMA_WAV,
|
||||
CODEC_ID_ADPCM_IMA_DK3,
|
||||
CODEC_ID_ADPCM_IMA_DK4,
|
||||
CODEC_ID_ADPCM_IMA_WS,
|
||||
CODEC_ID_ADPCM_IMA_SMJPEG,
|
||||
CODEC_ID_ADPCM_MS,
|
||||
CODEC_ID_ADPCM_4XM,
|
||||
CODEC_ID_ADPCM_XA,
|
||||
CODEC_ID_ADPCM_ADX,
|
||||
CODEC_ID_ADPCM_EA,
|
||||
CODEC_ID_ADPCM_G726,
|
||||
CODEC_ID_ADPCM_CT,
|
||||
CODEC_ID_ADPCM_SWF,
|
||||
CODEC_ID_ADPCM_YAMAHA,
|
||||
CODEC_ID_ADPCM_SBPRO_4,
|
||||
CODEC_ID_ADPCM_SBPRO_3,
|
||||
CODEC_ID_ADPCM_SBPRO_2,
|
||||
CODEC_ID_ADPCM_THP,
|
||||
CODEC_ID_ADPCM_IMA_AMV,
|
||||
CODEC_ID_ADPCM_EA_R1,
|
||||
CODEC_ID_ADPCM_EA_R3,
|
||||
CODEC_ID_ADPCM_EA_R2,
|
||||
CODEC_ID_ADPCM_IMA_EA_SEAD,
|
||||
CODEC_ID_ADPCM_IMA_EA_EACS,
|
||||
CODEC_ID_ADPCM_EA_XAS,
|
||||
CODEC_ID_ADPCM_EA_MAXIS_XA,
|
||||
CODEC_ID_ADPCM_IMA_ISS,
|
||||
CODEC_ID_ADPCM_G722,
|
||||
CODEC_ID_ADPCM_IMA_APC,
|
||||
CODEC_ID_VIMA = MKBETAG('V','I','M','A'),
|
||||
|
||||
/* AMR */
|
||||
CODEC_ID_AMR_NB = 0x12000,
|
||||
CODEC_ID_AMR_WB,
|
||||
|
||||
/* RealAudio codecs*/
|
||||
CODEC_ID_RA_144 = 0x13000,
|
||||
CODEC_ID_RA_288,
|
||||
|
||||
/* various DPCM codecs */
|
||||
CODEC_ID_ROQ_DPCM = 0x14000,
|
||||
CODEC_ID_INTERPLAY_DPCM,
|
||||
CODEC_ID_XAN_DPCM,
|
||||
CODEC_ID_SOL_DPCM,
|
||||
|
||||
/* audio codecs */
|
||||
CODEC_ID_MP2 = 0x15000,
|
||||
CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
|
||||
CODEC_ID_AAC,
|
||||
CODEC_ID_AC3,
|
||||
CODEC_ID_DTS,
|
||||
CODEC_ID_VORBIS,
|
||||
CODEC_ID_DVAUDIO,
|
||||
CODEC_ID_WMAV1,
|
||||
CODEC_ID_WMAV2,
|
||||
CODEC_ID_MACE3,
|
||||
CODEC_ID_MACE6,
|
||||
CODEC_ID_VMDAUDIO,
|
||||
CODEC_ID_FLAC,
|
||||
CODEC_ID_MP3ADU,
|
||||
CODEC_ID_MP3ON4,
|
||||
CODEC_ID_SHORTEN,
|
||||
CODEC_ID_ALAC,
|
||||
CODEC_ID_WESTWOOD_SND1,
|
||||
CODEC_ID_GSM, ///< as in Berlin toast format
|
||||
CODEC_ID_QDM2,
|
||||
CODEC_ID_COOK,
|
||||
CODEC_ID_TRUESPEECH,
|
||||
CODEC_ID_TTA,
|
||||
CODEC_ID_SMACKAUDIO,
|
||||
CODEC_ID_QCELP,
|
||||
CODEC_ID_WAVPACK,
|
||||
CODEC_ID_DSICINAUDIO,
|
||||
CODEC_ID_IMC,
|
||||
CODEC_ID_MUSEPACK7,
|
||||
CODEC_ID_MLP,
|
||||
CODEC_ID_GSM_MS, /* as found in WAV */
|
||||
CODEC_ID_ATRAC3,
|
||||
CODEC_ID_VOXWARE,
|
||||
CODEC_ID_APE,
|
||||
CODEC_ID_NELLYMOSER,
|
||||
CODEC_ID_MUSEPACK8,
|
||||
CODEC_ID_SPEEX,
|
||||
CODEC_ID_WMAVOICE,
|
||||
CODEC_ID_WMAPRO,
|
||||
CODEC_ID_WMALOSSLESS,
|
||||
CODEC_ID_ATRAC3P,
|
||||
CODEC_ID_EAC3,
|
||||
CODEC_ID_SIPR,
|
||||
CODEC_ID_MP1,
|
||||
CODEC_ID_TWINVQ,
|
||||
CODEC_ID_TRUEHD,
|
||||
CODEC_ID_MP4ALS,
|
||||
CODEC_ID_ATRAC1,
|
||||
CODEC_ID_BINKAUDIO_RDFT,
|
||||
CODEC_ID_BINKAUDIO_DCT,
|
||||
CODEC_ID_AAC_LATM,
|
||||
CODEC_ID_QDMC,
|
||||
CODEC_ID_CELT,
|
||||
CODEC_ID_G723_1,
|
||||
CODEC_ID_G729,
|
||||
CODEC_ID_8SVX_EXP,
|
||||
CODEC_ID_8SVX_FIB,
|
||||
CODEC_ID_BMV_AUDIO,
|
||||
CODEC_ID_RALF,
|
||||
CODEC_ID_IAC,
|
||||
CODEC_ID_ILBC,
|
||||
CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),
|
||||
CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'),
|
||||
CODEC_ID_SONIC = MKBETAG('S','O','N','C'),
|
||||
CODEC_ID_SONIC_LS = MKBETAG('S','O','N','L'),
|
||||
CODEC_ID_PAF_AUDIO = MKBETAG('P','A','F','A'),
|
||||
CODEC_ID_OPUS = MKBETAG('O','P','U','S'),
|
||||
|
||||
/* subtitle codecs */
|
||||
CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
|
||||
CODEC_ID_DVD_SUBTITLE = 0x17000,
|
||||
CODEC_ID_DVB_SUBTITLE,
|
||||
CODEC_ID_TEXT, ///< raw UTF-8 text
|
||||
CODEC_ID_XSUB,
|
||||
CODEC_ID_SSA,
|
||||
CODEC_ID_MOV_TEXT,
|
||||
CODEC_ID_HDMV_PGS_SUBTITLE,
|
||||
CODEC_ID_DVB_TELETEXT,
|
||||
CODEC_ID_SRT,
|
||||
CODEC_ID_MICRODVD = MKBETAG('m','D','V','D'),
|
||||
CODEC_ID_EIA_608 = MKBETAG('c','6','0','8'),
|
||||
CODEC_ID_JACOSUB = MKBETAG('J','S','U','B'),
|
||||
CODEC_ID_SAMI = MKBETAG('S','A','M','I'),
|
||||
CODEC_ID_REALTEXT = MKBETAG('R','T','X','T'),
|
||||
CODEC_ID_SUBVIEWER = MKBETAG('S','u','b','V'),
|
||||
|
||||
/* other specific kind of codecs (generally used for attachments) */
|
||||
CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
|
||||
CODEC_ID_TTF = 0x18000,
|
||||
CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'),
|
||||
CODEC_ID_XBIN = MKBETAG('X','B','I','N'),
|
||||
CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'),
|
||||
CODEC_ID_OTF = MKBETAG( 0 ,'O','T','F'),
|
||||
|
||||
CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it
|
||||
|
||||
CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
|
||||
* stream (only used by libavformat) */
|
||||
CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
|
||||
* stream (only used by libavformat) */
|
||||
CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
|
||||
|
||||
#endif /* AVCODEC_OLD_CODEC_IDS_H */
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This header is provided for compatibility only and will be removed
|
||||
* on next major bump
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_OPT_H
|
||||
#define AVCODEC_OPT_H
|
||||
|
||||
#include "libavcodec/version.h"
|
||||
|
||||
#if FF_API_OPT_H
|
||||
#include "libavutil/opt.h"
|
||||
#endif
|
||||
|
||||
#endif /* AVCODEC_OPT_H */
|
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
* Video Acceleration API (shared data between Libav and the video player)
|
||||
* HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1
|
||||
*
|
||||
* Copyright (C) 2008-2009 Splitted-Desktop Systems
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VAAPI_H
|
||||
#define AVCODEC_VAAPI_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup VAAPI_Decoding VA API Decoding
|
||||
* @ingroup Decoder
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* This structure is used to share data between the Libav library and
|
||||
* the client video application.
|
||||
* This shall be zero-allocated and available as
|
||||
* AVCodecContext.hwaccel_context. All user members can be set once
|
||||
* during initialization or through each AVCodecContext.get_buffer()
|
||||
* function call. In any case, they must be valid prior to calling
|
||||
* decoding functions.
|
||||
*/
|
||||
struct vaapi_context {
|
||||
/**
|
||||
* Window system dependent data
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by user
|
||||
*/
|
||||
void *display;
|
||||
|
||||
/**
|
||||
* Configuration ID
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by user
|
||||
*/
|
||||
uint32_t config_id;
|
||||
|
||||
/**
|
||||
* Context ID (video decode pipeline)
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by user
|
||||
*/
|
||||
uint32_t context_id;
|
||||
|
||||
/**
|
||||
* VAPictureParameterBuffer ID
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
uint32_t pic_param_buf_id;
|
||||
|
||||
/**
|
||||
* VAIQMatrixBuffer ID
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
uint32_t iq_matrix_buf_id;
|
||||
|
||||
/**
|
||||
* VABitPlaneBuffer ID (for VC-1 decoding)
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
uint32_t bitplane_buf_id;
|
||||
|
||||
/**
|
||||
* Slice parameter/data buffer IDs
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
uint32_t *slice_buf_ids;
|
||||
|
||||
/**
|
||||
* Number of effective slice buffer IDs to send to the HW
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
unsigned int n_slice_buf_ids;
|
||||
|
||||
/**
|
||||
* Size of pre-allocated slice_buf_ids
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
unsigned int slice_buf_ids_alloc;
|
||||
|
||||
/**
|
||||
* Pointer to VASliceParameterBuffers
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
void *slice_params;
|
||||
|
||||
/**
|
||||
* Size of a VASliceParameterBuffer element
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
unsigned int slice_param_size;
|
||||
|
||||
/**
|
||||
* Size of pre-allocated slice_params
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
unsigned int slice_params_alloc;
|
||||
|
||||
/**
|
||||
* Number of slices currently filled in
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
unsigned int slice_count;
|
||||
|
||||
/**
|
||||
* Pointer to slice data buffer base
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
const uint8_t *slice_data;
|
||||
|
||||
/**
|
||||
* Current size of slice data
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
uint32_t slice_data_size;
|
||||
};
|
||||
|
||||
/* @} */
|
||||
|
||||
#endif /* AVCODEC_VAAPI_H */
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* VDA HW acceleration
|
||||
*
|
||||
* copyright (c) 2011 Sebastien Zwickert
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VDA_H
|
||||
#define AVCODEC_VDA_H
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
|
||||
// http://openradar.appspot.com/8026390
|
||||
#undef __GNUC_STDC_INLINE__
|
||||
|
||||
#define Picture QuickdrawPicture
|
||||
#include <VideoDecodeAcceleration/VDADecoder.h>
|
||||
#undef Picture
|
||||
|
||||
/**
|
||||
* This structure is used to store a decoded frame information and data.
|
||||
*/
|
||||
typedef struct vda_frame {
|
||||
/**
|
||||
* The PTS of the frame.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
int64_t pts;
|
||||
|
||||
/**
|
||||
* The CoreVideo buffer that contains the decoded data.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
CVPixelBufferRef cv_buffer;
|
||||
|
||||
/**
|
||||
* A pointer to the next frame.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
struct vda_frame *next_frame;
|
||||
} vda_frame;
|
||||
|
||||
/**
|
||||
* This structure is used to provide the necessary configurations and data
|
||||
* to the VDA Libav HWAccel implementation.
|
||||
*
|
||||
* The application must make it available as AVCodecContext.hwaccel_context.
|
||||
*/
|
||||
struct vda_context {
|
||||
/**
|
||||
* VDA decoder object.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
VDADecoder decoder;
|
||||
|
||||
/**
|
||||
* VDA frames queue ordered by presentation timestamp.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
vda_frame *queue;
|
||||
|
||||
/**
|
||||
* Mutex for locking queue operations.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
pthread_mutex_t queue_mutex;
|
||||
|
||||
/**
|
||||
* The frame width.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
int width;
|
||||
|
||||
/**
|
||||
* The frame height.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
int height;
|
||||
|
||||
/**
|
||||
* The frame format.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
int format;
|
||||
|
||||
/**
|
||||
* The pixel format for output image buffers.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
OSType cv_pix_fmt_type;
|
||||
};
|
||||
|
||||
/** Create the video decoder. */
|
||||
int ff_vda_create_decoder(struct vda_context *vda_ctx,
|
||||
uint8_t *extradata,
|
||||
int extradata_size);
|
||||
|
||||
/** Destroy the video decoder. */
|
||||
int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
|
||||
|
||||
/** Return the top frame of the queue. */
|
||||
vda_frame *ff_vda_queue_pop(struct vda_context *vda_ctx);
|
||||
|
||||
/** Release the given frame. */
|
||||
void ff_vda_release_vda_frame(vda_frame *frame);
|
||||
|
||||
#endif /* AVCODEC_VDA_H */
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* The Video Decode and Presentation API for UNIX (VDPAU) is used for
|
||||
* hardware-accelerated decoding of MPEG-1/2, H.264 and VC-1.
|
||||
*
|
||||
* Copyright (C) 2008 NVIDIA
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VDPAU_H
|
||||
#define AVCODEC_VDPAU_H
|
||||
|
||||
/**
|
||||
* @defgroup Decoder VDPAU Decoder and Renderer
|
||||
*
|
||||
* VDPAU hardware acceleration has two modules
|
||||
* - VDPAU decoding
|
||||
* - VDPAU presentation
|
||||
*
|
||||
* The VDPAU decoding module parses all headers using Libav
|
||||
* parsing mechanisms and uses VDPAU for the actual decoding.
|
||||
*
|
||||
* As per the current implementation, the actual decoding
|
||||
* and rendering (API calls) are done as part of the VDPAU
|
||||
* presentation (vo_vdpau.c) module.
|
||||
*
|
||||
* @defgroup VDPAU_Decoding VDPAU Decoding
|
||||
* @ingroup Decoder
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <vdpau/vdpau.h>
|
||||
#include <vdpau/vdpau_x11.h>
|
||||
|
||||
/** @brief The videoSurface is used for rendering. */
|
||||
#define FF_VDPAU_STATE_USED_FOR_RENDER 1
|
||||
|
||||
/**
|
||||
* @brief The videoSurface is needed for reference/prediction.
|
||||
* The codec manipulates this.
|
||||
*/
|
||||
#define FF_VDPAU_STATE_USED_FOR_REFERENCE 2
|
||||
|
||||
/**
|
||||
* @brief This structure is used as a callback between the Libav
|
||||
* decoder (vd_) and presentation (vo_) module.
|
||||
* This is used for defining a video frame containing surface,
|
||||
* picture parameter, bitstream information etc which are passed
|
||||
* between the Libav decoder and its clients.
|
||||
*/
|
||||
struct vdpau_render_state {
|
||||
VdpVideoSurface surface; ///< Used as rendered surface, never changed.
|
||||
|
||||
int state; ///< Holds FF_VDPAU_STATE_* values.
|
||||
|
||||
/** picture parameter information for all supported codecs */
|
||||
union VdpPictureInfo {
|
||||
VdpPictureInfoH264 h264;
|
||||
VdpPictureInfoMPEG1Or2 mpeg;
|
||||
VdpPictureInfoVC1 vc1;
|
||||
VdpPictureInfoMPEG4Part2 mpeg4;
|
||||
} info;
|
||||
|
||||
/** Describe size/location of the compressed video data.
|
||||
Set to 0 when freeing bitstream_buffers. */
|
||||
int bitstream_buffers_allocated;
|
||||
int bitstream_buffers_used;
|
||||
/** The user is responsible for freeing this buffer using av_freep(). */
|
||||
VdpBitstreamBuffer *bitstream_buffers;
|
||||
};
|
||||
|
||||
/* @}*/
|
||||
|
||||
#endif /* AVCODEC_VDPAU_H */
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VERSION_H
|
||||
#define AVCODEC_VERSION_H
|
||||
|
||||
#define LIBAVCODEC_VERSION_MAJOR 53
|
||||
#define LIBAVCODEC_VERSION_MINOR 35
|
||||
#define LIBAVCODEC_VERSION_MICRO 0
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
LIBAVCODEC_VERSION_MINOR, \
|
||||
LIBAVCODEC_VERSION_MICRO)
|
||||
#define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \
|
||||
LIBAVCODEC_VERSION_MINOR, \
|
||||
LIBAVCODEC_VERSION_MICRO)
|
||||
#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
|
||||
|
||||
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
|
||||
|
||||
/**
|
||||
* Those FF_API_* defines are not part of public API.
|
||||
* They may change, break or disappear at any time.
|
||||
*/
|
||||
#ifndef FF_API_PALETTE_CONTROL
|
||||
#define FF_API_PALETTE_CONTROL (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_SAMPLE_FMT
|
||||
#define FF_API_OLD_SAMPLE_FMT (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_AUDIOCONVERT
|
||||
#define FF_API_OLD_AUDIOCONVERT (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_ANTIALIAS_ALGO
|
||||
#define FF_API_ANTIALIAS_ALGO (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_REQUEST_CHANNELS
|
||||
#define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_OPT_H
|
||||
#define FF_API_OPT_H (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_THREAD_INIT
|
||||
#define FF_API_THREAD_INIT (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_FF_PICT_TYPES
|
||||
#define FF_API_OLD_FF_PICT_TYPES (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_FLAC_GLOBAL_OPTS
|
||||
#define FF_API_FLAC_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_GET_PIX_FMT_NAME
|
||||
#define FF_API_GET_PIX_FMT_NAME (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_ALLOC_CONTEXT
|
||||
#define FF_API_ALLOC_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_AVCODEC_OPEN
|
||||
#define FF_API_AVCODEC_OPEN (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_DRC_SCALE
|
||||
#define FF_API_DRC_SCALE (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_ER
|
||||
#define FF_API_ER (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_AVCODEC_INIT
|
||||
#define FF_API_AVCODEC_INIT (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_X264_GLOBAL_OPTS
|
||||
#define FF_API_X264_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_MPEGVIDEO_GLOBAL_OPTS
|
||||
#define FF_API_MPEGVIDEO_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_LAME_GLOBAL_OPTS
|
||||
#define FF_API_LAME_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_SNOW_GLOBAL_OPTS
|
||||
#define FF_API_SNOW_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_MJPEG_GLOBAL_OPTS
|
||||
#define FF_API_MJPEG_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_GET_ALPHA_INFO
|
||||
#define FF_API_GET_ALPHA_INFO (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_PARSE_FRAME
|
||||
#define FF_API_PARSE_FRAME (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_INTERNAL_CONTEXT
|
||||
#define FF_API_INTERNAL_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_TIFFENC_COMPLEVEL
|
||||
#define FF_API_TIFFENC_COMPLEVEL (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_DATA_POINTERS
|
||||
#define FF_API_DATA_POINTERS (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_DECODE_AUDIO
|
||||
#define FF_API_OLD_DECODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_AVFRAME_AGE
|
||||
#define FF_API_AVFRAME_AGE (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_ENCODE_AUDIO
|
||||
#define FF_API_OLD_ENCODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
|
||||
#endif /* AVCODEC_VERSION_H */
|
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
* Copyright (C) 2003 Ivan Kalvachev
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_XVMC_H
|
||||
#define AVCODEC_XVMC_H
|
||||
|
||||
#include <X11/extensions/XvMC.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
|
||||
#define AV_XVMC_ID 0x1DC711C0 /**< special value to ensure that regular pixel routines haven't corrupted the struct
|
||||
the number is 1337 speak for the letters IDCT MCo (motion compensation) */
|
||||
|
||||
struct xvmc_pix_fmt {
|
||||
/** The field contains the special constant value AV_XVMC_ID.
|
||||
It is used as a test that the application correctly uses the API,
|
||||
and that there is no corruption caused by pixel routines.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int xvmc_id;
|
||||
|
||||
/** Pointer to the block array allocated by XvMCCreateBlocks().
|
||||
The array has to be freed by XvMCDestroyBlocks().
|
||||
Each group of 64 values represents one data block of differential
|
||||
pixel information (in MoCo mode) or coefficients for IDCT.
|
||||
- application - set the pointer during initialization
|
||||
- libavcodec - fills coefficients/pixel data into the array
|
||||
*/
|
||||
short* data_blocks;
|
||||
|
||||
/** Pointer to the macroblock description array allocated by
|
||||
XvMCCreateMacroBlocks() and freed by XvMCDestroyMacroBlocks().
|
||||
- application - set the pointer during initialization
|
||||
- libavcodec - fills description data into the array
|
||||
*/
|
||||
XvMCMacroBlock* mv_blocks;
|
||||
|
||||
/** Number of macroblock descriptions that can be stored in the mv_blocks
|
||||
array.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int allocated_mv_blocks;
|
||||
|
||||
/** Number of blocks that can be stored at once in the data_blocks array.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int allocated_data_blocks;
|
||||
|
||||
/** Indicate that the hardware would interpret data_blocks as IDCT
|
||||
coefficients and perform IDCT on them.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int idct;
|
||||
|
||||
/** In MoCo mode it indicates that intra macroblocks are assumed to be in
|
||||
unsigned format; same as the XVMC_INTRA_UNSIGNED flag.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int unsigned_intra;
|
||||
|
||||
/** Pointer to the surface allocated by XvMCCreateSurface().
|
||||
It has to be freed by XvMCDestroySurface() on application exit.
|
||||
It identifies the frame and its state on the video hardware.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
XvMCSurface* p_surface;
|
||||
|
||||
/** Set by the decoder before calling ff_draw_horiz_band(),
|
||||
needed by the XvMCRenderSurface function. */
|
||||
//@{
|
||||
/** Pointer to the surface used as past reference
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
XvMCSurface* p_past_surface;
|
||||
|
||||
/** Pointer to the surface used as future reference
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
XvMCSurface* p_future_surface;
|
||||
|
||||
/** top/bottom field or frame
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
unsigned int picture_structure;
|
||||
|
||||
/** XVMC_SECOND_FIELD - 1st or 2nd field in the sequence
|
||||
- application - unchanged
|
||||
- libavcodec - set
|
||||
*/
|
||||
unsigned int flags;
|
||||
//}@
|
||||
|
||||
/** Number of macroblock descriptions in the mv_blocks array
|
||||
that have already been passed to the hardware.
|
||||
- application - zeroes it on get_buffer().
|
||||
A successful ff_draw_horiz_band() may increment it
|
||||
with filled_mb_block_num or zero both.
|
||||
- libavcodec - unchanged
|
||||
*/
|
||||
int start_mv_blocks_num;
|
||||
|
||||
/** Number of new macroblock descriptions in the mv_blocks array (after
|
||||
start_mv_blocks_num) that are filled by libavcodec and have to be
|
||||
passed to the hardware.
|
||||
- application - zeroes it on get_buffer() or after successful
|
||||
ff_draw_horiz_band().
|
||||
- libavcodec - increment with one of each stored MB
|
||||
*/
|
||||
int filled_mv_blocks_num;
|
||||
|
||||
/** Number of the the next free data block; one data block consists of
|
||||
64 short values in the data_blocks array.
|
||||
All blocks before this one have already been claimed by placing their
|
||||
position into the corresponding block description structure field,
|
||||
that are part of the mv_blocks array.
|
||||
- application - zeroes it on get_buffer().
|
||||
A successful ff_draw_horiz_band() may zero it together
|
||||
with start_mb_blocks_num.
|
||||
- libavcodec - each decoded macroblock increases it by the number
|
||||
of coded blocks it contains.
|
||||
*/
|
||||
int next_free_data_block_num;
|
||||
};
|
||||
|
||||
#endif /* AVCODEC_XVMC_H */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,688 @@
|
|||
/*
|
||||
* copyright (c) 2001 Fabrice Bellard
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef AVFORMAT_AVIO_H
|
||||
#define AVFORMAT_AVIO_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavf_io
|
||||
* Buffered I/O operations
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/dict.h"
|
||||
#include "libavutil/log.h"
|
||||
|
||||
#include "libavformat/version.h"
|
||||
|
||||
|
||||
#define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */
|
||||
|
||||
/**
|
||||
* Callback for checking whether to abort blocking functions.
|
||||
* AVERROR_EXIT is returned in this case by the interrupted
|
||||
* function. During blocking operations, callback is called with
|
||||
* opaque as parameter. If the callback returns 1, the
|
||||
* blocking operation will be aborted.
|
||||
*
|
||||
* No members can be added to this struct without a major bump, if
|
||||
* new elements have been added after this struct in AVFormatContext
|
||||
* or AVIOContext.
|
||||
*/
|
||||
typedef struct {
|
||||
int (*callback)(void*);
|
||||
void *opaque;
|
||||
} AVIOInterruptCB;
|
||||
|
||||
/**
|
||||
* Bytestream IO Context.
|
||||
* New fields can be added to the end with minor version bumps.
|
||||
* Removal, reordering and changes to existing fields require a major
|
||||
* version bump.
|
||||
* sizeof(AVIOContext) must not be used outside libav*.
|
||||
*
|
||||
* @note None of the function pointers in AVIOContext should be called
|
||||
* directly, they should only be set by the client application
|
||||
* when implementing custom I/O. Normally these are set to the
|
||||
* function pointers specified in avio_alloc_context()
|
||||
*/
|
||||
typedef struct {
|
||||
#if !FF_API_OLD_AVIO
|
||||
/**
|
||||
* A class for private options.
|
||||
*
|
||||
* If this AVIOContext is created by avio_open2(), av_class is set and
|
||||
* passes the options down to protocols.
|
||||
*
|
||||
* If this AVIOContext is manually allocated, then av_class may be set by
|
||||
* the caller.
|
||||
*
|
||||
* warning -- this field can be NULL, be sure to not pass this AVIOContext
|
||||
* to any av_opt_* functions in that case.
|
||||
*/
|
||||
AVClass *av_class;
|
||||
#endif
|
||||
unsigned char *buffer; /**< Start of the buffer. */
|
||||
int buffer_size; /**< Maximum buffer size */
|
||||
unsigned char *buf_ptr; /**< Current position in the buffer */
|
||||
unsigned char *buf_end; /**< End of the data, may be less than
|
||||
buffer+buffer_size if the read function returned
|
||||
less data than requested, e.g. for streams where
|
||||
no more data has been received yet. */
|
||||
void *opaque; /**< A private pointer, passed to the read/write/seek/...
|
||||
functions. */
|
||||
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
|
||||
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
|
||||
int64_t (*seek)(void *opaque, int64_t offset, int whence);
|
||||
int64_t pos; /**< position in the file of the current buffer */
|
||||
int must_flush; /**< true if the next seek should flush */
|
||||
int eof_reached; /**< true if eof reached */
|
||||
int write_flag; /**< true if open for writing */
|
||||
#if FF_API_OLD_AVIO
|
||||
attribute_deprecated int is_streamed;
|
||||
#endif
|
||||
int max_packet_size;
|
||||
unsigned long checksum;
|
||||
unsigned char *checksum_ptr;
|
||||
unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
|
||||
int error; /**< contains the error code or 0 if no error happened */
|
||||
/**
|
||||
* Pause or resume playback for network streaming protocols - e.g. MMS.
|
||||
*/
|
||||
int (*read_pause)(void *opaque, int pause);
|
||||
/**
|
||||
* Seek to a given timestamp in stream with the specified stream_index.
|
||||
* Needed for some network streaming protocols which don't support seeking
|
||||
* to byte position.
|
||||
*/
|
||||
int64_t (*read_seek)(void *opaque, int stream_index,
|
||||
int64_t timestamp, int flags);
|
||||
/**
|
||||
* A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
|
||||
*/
|
||||
int seekable;
|
||||
} AVIOContext;
|
||||
|
||||
/* unbuffered I/O */
|
||||
|
||||
#if FF_API_OLD_AVIO
|
||||
/**
|
||||
* URL Context.
|
||||
* New fields can be added to the end with minor version bumps.
|
||||
* Removal, reordering and changes to existing fields require a major
|
||||
* version bump.
|
||||
* sizeof(URLContext) must not be used outside libav*.
|
||||
* @deprecated This struct will be made private
|
||||
*/
|
||||
typedef struct URLContext {
|
||||
const AVClass *av_class; ///< information for av_log(). Set by url_open().
|
||||
struct URLProtocol *prot;
|
||||
int flags;
|
||||
int is_streamed; /**< true if streamed (no seek possible), default = false */
|
||||
int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */
|
||||
void *priv_data;
|
||||
char *filename; /**< specified URL */
|
||||
int is_connected;
|
||||
AVIOInterruptCB interrupt_callback;
|
||||
} URLContext;
|
||||
|
||||
#define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */
|
||||
#define URL_PROTOCOL_FLAG_NETWORK 2 /*< The protocol uses network */
|
||||
|
||||
/**
|
||||
* @deprecated This struct is to be made private. Use the higher-level
|
||||
* AVIOContext-based API instead.
|
||||
*/
|
||||
typedef struct URLProtocol {
|
||||
const char *name;
|
||||
int (*url_open)(URLContext *h, const char *url, int flags);
|
||||
int (*url_read)(URLContext *h, unsigned char *buf, int size);
|
||||
int (*url_write)(URLContext *h, const unsigned char *buf, int size);
|
||||
int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
|
||||
int (*url_close)(URLContext *h);
|
||||
struct URLProtocol *next;
|
||||
int (*url_read_pause)(URLContext *h, int pause);
|
||||
int64_t (*url_read_seek)(URLContext *h, int stream_index,
|
||||
int64_t timestamp, int flags);
|
||||
int (*url_get_file_handle)(URLContext *h);
|
||||
int priv_data_size;
|
||||
const AVClass *priv_data_class;
|
||||
int flags;
|
||||
int (*url_check)(URLContext *h, int mask);
|
||||
} URLProtocol;
|
||||
|
||||
typedef struct URLPollEntry {
|
||||
URLContext *handle;
|
||||
int events;
|
||||
int revents;
|
||||
} URLPollEntry;
|
||||
|
||||
/* not implemented */
|
||||
attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout);
|
||||
|
||||
/**
|
||||
* @name URL open modes
|
||||
* The flags argument to url_open and cosins must be one of the following
|
||||
* constants, optionally ORed with other flags.
|
||||
* @{
|
||||
*/
|
||||
#define URL_RDONLY 1 /**< read-only */
|
||||
#define URL_WRONLY 2 /**< write-only */
|
||||
#define URL_RDWR (URL_RDONLY|URL_WRONLY) /**< read-write */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Use non-blocking mode.
|
||||
* If this flag is set, operations on the context will return
|
||||
* AVERROR(EAGAIN) if they can not be performed immediately.
|
||||
* If this flag is not set, operations on the context will never return
|
||||
* AVERROR(EAGAIN).
|
||||
* Note that this flag does not affect the opening/connecting of the
|
||||
* context. Connecting a protocol will always block if necessary (e.g. on
|
||||
* network protocols) but never hang (e.g. on busy devices).
|
||||
* Warning: non-blocking protocols is work-in-progress; this flag may be
|
||||
* silently ignored.
|
||||
*/
|
||||
#define URL_FLAG_NONBLOCK 8
|
||||
|
||||
typedef int URLInterruptCB(void);
|
||||
extern URLInterruptCB *url_interrupt_cb;
|
||||
|
||||
/**
|
||||
* @defgroup old_url_funcs Old url_* functions
|
||||
* The following functions are deprecated. Use the buffered API based on #AVIOContext instead.
|
||||
* @{
|
||||
* @ingroup lavf_io
|
||||
*/
|
||||
attribute_deprecated int url_open_protocol (URLContext **puc, struct URLProtocol *up,
|
||||
const char *url, int flags);
|
||||
attribute_deprecated int url_alloc(URLContext **h, const char *url, int flags);
|
||||
attribute_deprecated int url_connect(URLContext *h);
|
||||
attribute_deprecated int url_open(URLContext **h, const char *url, int flags);
|
||||
attribute_deprecated int url_read(URLContext *h, unsigned char *buf, int size);
|
||||
attribute_deprecated int url_read_complete(URLContext *h, unsigned char *buf, int size);
|
||||
attribute_deprecated int url_write(URLContext *h, const unsigned char *buf, int size);
|
||||
attribute_deprecated int64_t url_seek(URLContext *h, int64_t pos, int whence);
|
||||
attribute_deprecated int url_close(URLContext *h);
|
||||
attribute_deprecated int64_t url_filesize(URLContext *h);
|
||||
attribute_deprecated int url_get_file_handle(URLContext *h);
|
||||
attribute_deprecated int url_get_max_packet_size(URLContext *h);
|
||||
attribute_deprecated void url_get_filename(URLContext *h, char *buf, int buf_size);
|
||||
attribute_deprecated int av_url_read_pause(URLContext *h, int pause);
|
||||
attribute_deprecated int64_t av_url_read_seek(URLContext *h, int stream_index,
|
||||
int64_t timestamp, int flags);
|
||||
attribute_deprecated void url_set_interrupt_cb(int (*interrupt_cb)(void));
|
||||
/**
|
||||
* If protocol is NULL, returns the first registered protocol,
|
||||
* if protocol is non-NULL, returns the next registered protocol after protocol,
|
||||
* or NULL if protocol is the last one.
|
||||
*/
|
||||
attribute_deprecated URLProtocol *av_protocol_next(URLProtocol *p);
|
||||
/**
|
||||
* Register the URLProtocol protocol.
|
||||
*
|
||||
* @param size the size of the URLProtocol struct referenced
|
||||
*/
|
||||
attribute_deprecated int av_register_protocol2(URLProtocol *protocol, int size);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
typedef attribute_deprecated AVIOContext ByteIOContext;
|
||||
|
||||
attribute_deprecated int init_put_byte(AVIOContext *s,
|
||||
unsigned char *buffer,
|
||||
int buffer_size,
|
||||
int write_flag,
|
||||
void *opaque,
|
||||
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
|
||||
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
|
||||
int64_t (*seek)(void *opaque, int64_t offset, int whence));
|
||||
attribute_deprecated AVIOContext *av_alloc_put_byte(
|
||||
unsigned char *buffer,
|
||||
int buffer_size,
|
||||
int write_flag,
|
||||
void *opaque,
|
||||
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
|
||||
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
|
||||
int64_t (*seek)(void *opaque, int64_t offset, int whence));
|
||||
|
||||
/**
|
||||
* @defgroup old_avio_funcs Old put_/get_*() functions
|
||||
* The following functions are deprecated. Use the "avio_"-prefixed functions instead.
|
||||
* @{
|
||||
* @ingroup lavf_io
|
||||
*/
|
||||
attribute_deprecated int get_buffer(AVIOContext *s, unsigned char *buf, int size);
|
||||
attribute_deprecated int get_partial_buffer(AVIOContext *s, unsigned char *buf, int size);
|
||||
attribute_deprecated int get_byte(AVIOContext *s);
|
||||
attribute_deprecated unsigned int get_le16(AVIOContext *s);
|
||||
attribute_deprecated unsigned int get_le24(AVIOContext *s);
|
||||
attribute_deprecated unsigned int get_le32(AVIOContext *s);
|
||||
attribute_deprecated uint64_t get_le64(AVIOContext *s);
|
||||
attribute_deprecated unsigned int get_be16(AVIOContext *s);
|
||||
attribute_deprecated unsigned int get_be24(AVIOContext *s);
|
||||
attribute_deprecated unsigned int get_be32(AVIOContext *s);
|
||||
attribute_deprecated uint64_t get_be64(AVIOContext *s);
|
||||
|
||||
attribute_deprecated void put_byte(AVIOContext *s, int b);
|
||||
attribute_deprecated void put_nbyte(AVIOContext *s, int b, int count);
|
||||
attribute_deprecated void put_buffer(AVIOContext *s, const unsigned char *buf, int size);
|
||||
attribute_deprecated void put_le64(AVIOContext *s, uint64_t val);
|
||||
attribute_deprecated void put_be64(AVIOContext *s, uint64_t val);
|
||||
attribute_deprecated void put_le32(AVIOContext *s, unsigned int val);
|
||||
attribute_deprecated void put_be32(AVIOContext *s, unsigned int val);
|
||||
attribute_deprecated void put_le24(AVIOContext *s, unsigned int val);
|
||||
attribute_deprecated void put_be24(AVIOContext *s, unsigned int val);
|
||||
attribute_deprecated void put_le16(AVIOContext *s, unsigned int val);
|
||||
attribute_deprecated void put_be16(AVIOContext *s, unsigned int val);
|
||||
attribute_deprecated void put_tag(AVIOContext *s, const char *tag);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
attribute_deprecated int av_url_read_fpause(AVIOContext *h, int pause);
|
||||
attribute_deprecated int64_t av_url_read_fseek (AVIOContext *h, int stream_index,
|
||||
int64_t timestamp, int flags);
|
||||
|
||||
/**
|
||||
* @defgroup old_url_f_funcs Old url_f* functions
|
||||
* The following functions are deprecated, use the "avio_"-prefixed functions instead.
|
||||
* @{
|
||||
* @ingroup lavf_io
|
||||
*/
|
||||
attribute_deprecated int url_fopen( AVIOContext **s, const char *url, int flags);
|
||||
attribute_deprecated int url_fclose(AVIOContext *s);
|
||||
attribute_deprecated int64_t url_fseek(AVIOContext *s, int64_t offset, int whence);
|
||||
attribute_deprecated int url_fskip(AVIOContext *s, int64_t offset);
|
||||
attribute_deprecated int64_t url_ftell(AVIOContext *s);
|
||||
attribute_deprecated int64_t url_fsize(AVIOContext *s);
|
||||
#define URL_EOF (-1)
|
||||
attribute_deprecated int url_fgetc(AVIOContext *s);
|
||||
attribute_deprecated int url_setbufsize(AVIOContext *s, int buf_size);
|
||||
attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
|
||||
attribute_deprecated void put_flush_packet(AVIOContext *s);
|
||||
attribute_deprecated int url_open_dyn_buf(AVIOContext **s);
|
||||
attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
|
||||
attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
|
||||
attribute_deprecated int url_fdopen(AVIOContext **s, URLContext *h);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated use AVIOContext.eof_reached
|
||||
*/
|
||||
attribute_deprecated int url_feof(AVIOContext *s);
|
||||
attribute_deprecated int url_ferror(AVIOContext *s);
|
||||
|
||||
attribute_deprecated int udp_set_remote_url(URLContext *h, const char *uri);
|
||||
attribute_deprecated int udp_get_local_port(URLContext *h);
|
||||
|
||||
attribute_deprecated void init_checksum(AVIOContext *s,
|
||||
unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
|
||||
unsigned long checksum);
|
||||
attribute_deprecated unsigned long get_checksum(AVIOContext *s);
|
||||
attribute_deprecated void put_strz(AVIOContext *s, const char *buf);
|
||||
/** @note unlike fgets, the EOL character is not returned and a whole
|
||||
line is parsed. return NULL if first char read was EOF */
|
||||
attribute_deprecated char *url_fgets(AVIOContext *s, char *buf, int buf_size);
|
||||
/**
|
||||
* @deprecated use avio_get_str instead
|
||||
*/
|
||||
attribute_deprecated char *get_strz(AVIOContext *s, char *buf, int maxlen);
|
||||
/**
|
||||
* @deprecated Use AVIOContext.seekable field directly.
|
||||
*/
|
||||
attribute_deprecated static inline int url_is_streamed(AVIOContext *s)
|
||||
{
|
||||
return !s->seekable;
|
||||
}
|
||||
attribute_deprecated URLContext *url_fileno(AVIOContext *s);
|
||||
|
||||
/**
|
||||
* @deprecated use AVIOContext.max_packet_size directly.
|
||||
*/
|
||||
attribute_deprecated int url_fget_max_packet_size(AVIOContext *s);
|
||||
|
||||
attribute_deprecated int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags);
|
||||
|
||||
/** return the written or read size */
|
||||
attribute_deprecated int url_close_buf(AVIOContext *s);
|
||||
|
||||
/**
|
||||
* Return a non-zero value if the resource indicated by url
|
||||
* exists, 0 otherwise.
|
||||
* @deprecated Use avio_check instead.
|
||||
*/
|
||||
attribute_deprecated int url_exist(const char *url);
|
||||
#endif // FF_API_OLD_AVIO
|
||||
|
||||
/**
|
||||
* Return AVIO_FLAG_* access flags corresponding to the access permissions
|
||||
* of the resource in url, or a negative value corresponding to an
|
||||
* AVERROR code in case of failure. The returned access flags are
|
||||
* masked by the value in flags.
|
||||
*
|
||||
* @note This function is intrinsically unsafe, in the sense that the
|
||||
* checked resource may change its existence or permission status from
|
||||
* one call to another. Thus you should not trust the returned value,
|
||||
* unless you are sure that no other processes are accessing the
|
||||
* checked resource.
|
||||
*/
|
||||
int avio_check(const char *url, int flags);
|
||||
|
||||
#if FF_API_OLD_INTERRUPT_CB
|
||||
/**
|
||||
* The callback is called in blocking functions to test regulary if
|
||||
* asynchronous interruption is needed. AVERROR_EXIT is returned
|
||||
* in this case by the interrupted function. 'NULL' means no interrupt
|
||||
* callback is given.
|
||||
* @deprecated Use interrupt_callback in AVFormatContext/avio_open2
|
||||
* instead.
|
||||
*/
|
||||
attribute_deprecated void avio_set_interrupt_cb(int (*interrupt_cb)(void));
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Allocate and initialize an AVIOContext for buffered I/O. It must be later
|
||||
* freed with av_free().
|
||||
*
|
||||
* @param buffer Memory block for input/output operations via AVIOContext.
|
||||
* The buffer must be allocated with av_malloc() and friends.
|
||||
* @param buffer_size The buffer size is very important for performance.
|
||||
* For protocols with fixed blocksize it should be set to this blocksize.
|
||||
* For others a typical size is a cache page, e.g. 4kb.
|
||||
* @param write_flag Set to 1 if the buffer should be writable, 0 otherwise.
|
||||
* @param opaque An opaque pointer to user-specific data.
|
||||
* @param read_packet A function for refilling the buffer, may be NULL.
|
||||
* @param write_packet A function for writing the buffer contents, may be NULL.
|
||||
* @param seek A function for seeking to specified byte position, may be NULL.
|
||||
*
|
||||
* @return Allocated AVIOContext or NULL on failure.
|
||||
*/
|
||||
AVIOContext *avio_alloc_context(
|
||||
unsigned char *buffer,
|
||||
int buffer_size,
|
||||
int write_flag,
|
||||
void *opaque,
|
||||
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
|
||||
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
|
||||
int64_t (*seek)(void *opaque, int64_t offset, int whence));
|
||||
|
||||
void avio_w8(AVIOContext *s, int b);
|
||||
void avio_write(AVIOContext *s, const unsigned char *buf, int size);
|
||||
void avio_wl64(AVIOContext *s, uint64_t val);
|
||||
void avio_wb64(AVIOContext *s, uint64_t val);
|
||||
void avio_wl32(AVIOContext *s, unsigned int val);
|
||||
void avio_wb32(AVIOContext *s, unsigned int val);
|
||||
void avio_wl24(AVIOContext *s, unsigned int val);
|
||||
void avio_wb24(AVIOContext *s, unsigned int val);
|
||||
void avio_wl16(AVIOContext *s, unsigned int val);
|
||||
void avio_wb16(AVIOContext *s, unsigned int val);
|
||||
|
||||
/**
|
||||
* Write a NULL-terminated string.
|
||||
* @return number of bytes written.
|
||||
*/
|
||||
int avio_put_str(AVIOContext *s, const char *str);
|
||||
|
||||
/**
|
||||
* Convert an UTF-8 string to UTF-16LE and write it.
|
||||
* @return number of bytes written.
|
||||
*/
|
||||
int avio_put_str16le(AVIOContext *s, const char *str);
|
||||
|
||||
/**
|
||||
* Passing this as the "whence" parameter to a seek function causes it to
|
||||
* return the filesize without seeking anywhere. Supporting this is optional.
|
||||
* If it is not supported then the seek function will return <0.
|
||||
*/
|
||||
#define AVSEEK_SIZE 0x10000
|
||||
|
||||
/**
|
||||
* Oring this flag as into the "whence" parameter to a seek function causes it to
|
||||
* seek by any means (like reopening and linear reading) or other normally unreasonble
|
||||
* means that can be extreemly slow.
|
||||
* This may be ignored by the seek code.
|
||||
*/
|
||||
#define AVSEEK_FORCE 0x20000
|
||||
|
||||
/**
|
||||
* fseek() equivalent for AVIOContext.
|
||||
* @return new position or AVERROR.
|
||||
*/
|
||||
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
|
||||
|
||||
/**
|
||||
* Skip given number of bytes forward
|
||||
* @return new position or AVERROR.
|
||||
*/
|
||||
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
|
||||
{
|
||||
return avio_seek(s, offset, SEEK_CUR);
|
||||
}
|
||||
|
||||
/**
|
||||
* ftell() equivalent for AVIOContext.
|
||||
* @return position or AVERROR.
|
||||
*/
|
||||
static av_always_inline int64_t avio_tell(AVIOContext *s)
|
||||
{
|
||||
return avio_seek(s, 0, SEEK_CUR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filesize.
|
||||
* @return filesize or AVERROR
|
||||
*/
|
||||
int64_t avio_size(AVIOContext *s);
|
||||
|
||||
/** @warning currently size is limited */
|
||||
int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
|
||||
|
||||
void avio_flush(AVIOContext *s);
|
||||
|
||||
|
||||
/**
|
||||
* Read size bytes from AVIOContext into buf.
|
||||
* @return number of bytes read or AVERROR
|
||||
*/
|
||||
int avio_read(AVIOContext *s, unsigned char *buf, int size);
|
||||
|
||||
/**
|
||||
* @name Functions for reading from AVIOContext
|
||||
* @{
|
||||
*
|
||||
* @note return 0 if EOF, so you cannot use it if EOF handling is
|
||||
* necessary
|
||||
*/
|
||||
int avio_r8 (AVIOContext *s);
|
||||
unsigned int avio_rl16(AVIOContext *s);
|
||||
unsigned int avio_rl24(AVIOContext *s);
|
||||
unsigned int avio_rl32(AVIOContext *s);
|
||||
uint64_t avio_rl64(AVIOContext *s);
|
||||
unsigned int avio_rb16(AVIOContext *s);
|
||||
unsigned int avio_rb24(AVIOContext *s);
|
||||
unsigned int avio_rb32(AVIOContext *s);
|
||||
uint64_t avio_rb64(AVIOContext *s);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Read a string from pb into buf. The reading will terminate when either
|
||||
* a NULL character was encountered, maxlen bytes have been read, or nothing
|
||||
* more can be read from pb. The result is guaranteed to be NULL-terminated, it
|
||||
* will be truncated if buf is too small.
|
||||
* Note that the string is not interpreted or validated in any way, it
|
||||
* might get truncated in the middle of a sequence for multi-byte encodings.
|
||||
*
|
||||
* @return number of bytes read (is always <= maxlen).
|
||||
* If reading ends on EOF or error, the return value will be one more than
|
||||
* bytes actually read.
|
||||
*/
|
||||
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
|
||||
|
||||
/**
|
||||
* Read a UTF-16 string from pb and convert it to UTF-8.
|
||||
* The reading will terminate when either a null or invalid character was
|
||||
* encountered or maxlen bytes have been read.
|
||||
* @return number of bytes read (is always <= maxlen)
|
||||
*/
|
||||
int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
|
||||
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
|
||||
|
||||
|
||||
/**
|
||||
* @name URL open modes
|
||||
* The flags argument to avio_open must be one of the following
|
||||
* constants, optionally ORed with other flags.
|
||||
* @{
|
||||
*/
|
||||
#define AVIO_FLAG_READ 1 /**< read-only */
|
||||
#define AVIO_FLAG_WRITE 2 /**< write-only */
|
||||
#define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE) /**< read-write pseudo flag */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Use non-blocking mode.
|
||||
* If this flag is set, operations on the context will return
|
||||
* AVERROR(EAGAIN) if they can not be performed immediately.
|
||||
* If this flag is not set, operations on the context will never return
|
||||
* AVERROR(EAGAIN).
|
||||
* Note that this flag does not affect the opening/connecting of the
|
||||
* context. Connecting a protocol will always block if necessary (e.g. on
|
||||
* network protocols) but never hang (e.g. on busy devices).
|
||||
* Warning: non-blocking protocols is work-in-progress; this flag may be
|
||||
* silently ignored.
|
||||
*/
|
||||
#define AVIO_FLAG_NONBLOCK 8
|
||||
|
||||
/**
|
||||
* Create and initialize a AVIOContext for accessing the
|
||||
* resource indicated by url.
|
||||
* @note When the resource indicated by url has been opened in
|
||||
* read+write mode, the AVIOContext can be used only for writing.
|
||||
*
|
||||
* @param s Used to return the pointer to the created AVIOContext.
|
||||
* In case of failure the pointed to value is set to NULL.
|
||||
* @param flags flags which control how the resource indicated by url
|
||||
* is to be opened
|
||||
* @return 0 in case of success, a negative value corresponding to an
|
||||
* AVERROR code in case of failure
|
||||
*/
|
||||
int avio_open(AVIOContext **s, const char *url, int flags);
|
||||
|
||||
/**
|
||||
* Create and initialize a AVIOContext for accessing the
|
||||
* resource indicated by url.
|
||||
* @note When the resource indicated by url has been opened in
|
||||
* read+write mode, the AVIOContext can be used only for writing.
|
||||
*
|
||||
* @param s Used to return the pointer to the created AVIOContext.
|
||||
* In case of failure the pointed to value is set to NULL.
|
||||
* @param flags flags which control how the resource indicated by url
|
||||
* is to be opened
|
||||
* @param int_cb an interrupt callback to be used at the protocols level
|
||||
* @param options A dictionary filled with protocol-private options. On return
|
||||
* this parameter will be destroyed and replaced with a dict containing options
|
||||
* that were not found. May be NULL.
|
||||
* @return 0 in case of success, a negative value corresponding to an
|
||||
* AVERROR code in case of failure
|
||||
*/
|
||||
int avio_open2(AVIOContext **s, const char *url, int flags,
|
||||
const AVIOInterruptCB *int_cb, AVDictionary **options);
|
||||
|
||||
/**
|
||||
* Close the resource accessed by the AVIOContext s and free it.
|
||||
* This function can only be used if s was opened by avio_open().
|
||||
*
|
||||
* @return 0 on success, an AVERROR < 0 on error.
|
||||
*/
|
||||
int avio_close(AVIOContext *s);
|
||||
|
||||
/**
|
||||
* Open a write only memory stream.
|
||||
*
|
||||
* @param s new IO context
|
||||
* @return zero if no error.
|
||||
*/
|
||||
int avio_open_dyn_buf(AVIOContext **s);
|
||||
|
||||
/**
|
||||
* Return the written size and a pointer to the buffer. The buffer
|
||||
* must be freed with av_free().
|
||||
* Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer.
|
||||
*
|
||||
* @param s IO context
|
||||
* @param pbuffer pointer to a byte buffer
|
||||
* @return the length of the byte buffer
|
||||
*/
|
||||
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
|
||||
|
||||
/**
|
||||
* Iterate through names of available protocols.
|
||||
*
|
||||
* @param opaque A private pointer representing current protocol.
|
||||
* It must be a pointer to NULL on first iteration and will
|
||||
* be updated by successive calls to avio_enum_protocols.
|
||||
* @param output If set to 1, iterate over output protocols,
|
||||
* otherwise over input protocols.
|
||||
*
|
||||
* @return A static string containing the name of current protocol or NULL
|
||||
*/
|
||||
const char *avio_enum_protocols(void **opaque, int output);
|
||||
|
||||
/**
|
||||
* Pause and resume playing - only meaningful if using a network streaming
|
||||
* protocol (e.g. MMS).
|
||||
* @param pause 1 for pause, 0 for resume
|
||||
*/
|
||||
int avio_pause(AVIOContext *h, int pause);
|
||||
|
||||
/**
|
||||
* Seek to a given timestamp relative to some component stream.
|
||||
* Only meaningful if using a network streaming protocol (e.g. MMS.).
|
||||
* @param stream_index The stream index that the timestamp is relative to.
|
||||
* If stream_index is (-1) the timestamp should be in AV_TIME_BASE
|
||||
* units from the beginning of the presentation.
|
||||
* If a stream_index >= 0 is used and the protocol does not support
|
||||
* seeking based on component streams, the call will fail with ENOTSUP.
|
||||
* @param timestamp timestamp in AVStream.time_base units
|
||||
* or if there is no stream specified then in AV_TIME_BASE units.
|
||||
* @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE
|
||||
* and AVSEEK_FLAG_ANY. The protocol may silently ignore
|
||||
* AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will
|
||||
* fail with ENOTSUP if used and not supported.
|
||||
* @return >= 0 on success
|
||||
* @see AVInputFormat::read_seek
|
||||
*/
|
||||
int64_t avio_seek_time(AVIOContext *h, int stream_index,
|
||||
int64_t timestamp, int flags);
|
||||
|
||||
#endif /* AVFORMAT_AVIO_H */
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* Version macros.
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVFORMAT_VERSION_H
|
||||
#define AVFORMAT_VERSION_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup libavf
|
||||
* Libavformat version macros
|
||||
*/
|
||||
|
||||
#include "libavutil/avutil.h"
|
||||
|
||||
#define LIBAVFORMAT_VERSION_MAJOR 53
|
||||
#define LIBAVFORMAT_VERSION_MINOR 21
|
||||
#define LIBAVFORMAT_VERSION_MICRO 1
|
||||
|
||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
||||
LIBAVFORMAT_VERSION_MINOR, \
|
||||
LIBAVFORMAT_VERSION_MICRO)
|
||||
#define LIBAVFORMAT_VERSION AV_VERSION(LIBAVFORMAT_VERSION_MAJOR, \
|
||||
LIBAVFORMAT_VERSION_MINOR, \
|
||||
LIBAVFORMAT_VERSION_MICRO)
|
||||
#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
|
||||
|
||||
#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
|
||||
|
||||
/**
|
||||
* Those FF_API_* defines are not part of public API.
|
||||
* They may change, break or disappear at any time.
|
||||
*/
|
||||
#ifndef FF_API_OLD_METADATA2
|
||||
#define FF_API_OLD_METADATA2 (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_AVIO
|
||||
#define FF_API_OLD_AVIO (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_DUMP_FORMAT
|
||||
#define FF_API_DUMP_FORMAT (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_PARSE_DATE
|
||||
#define FF_API_PARSE_DATE (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_FIND_INFO_TAG
|
||||
#define FF_API_FIND_INFO_TAG (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_PKT_DUMP
|
||||
#define FF_API_PKT_DUMP (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_GUESS_IMG2_CODEC
|
||||
#define FF_API_GUESS_IMG2_CODEC (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_SDP_CREATE
|
||||
#define FF_API_SDP_CREATE (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_FORMAT_PARAMETERS
|
||||
#define FF_API_FORMAT_PARAMETERS (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_FLAG_RTP_HINT
|
||||
#define FF_API_FLAG_RTP_HINT (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_AVSTREAM_QUALITY
|
||||
#define FF_API_AVSTREAM_QUALITY (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_LOOP_INPUT
|
||||
#define FF_API_LOOP_INPUT (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_LOOP_OUTPUT
|
||||
#define FF_API_LOOP_OUTPUT (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_TIMESTAMP
|
||||
#define FF_API_TIMESTAMP (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_FILESIZE
|
||||
#define FF_API_FILESIZE (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_MUXRATE
|
||||
#define FF_API_MUXRATE (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_RTSP_URL_OPTIONS
|
||||
#define FF_API_RTSP_URL_OPTIONS (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_NEW_STREAM
|
||||
#define FF_API_NEW_STREAM (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_PRELOAD
|
||||
#define FF_API_PRELOAD (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_STREAM_COPY
|
||||
#define FF_API_STREAM_COPY (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_SEEK_PUBLIC
|
||||
#define FF_API_SEEK_PUBLIC (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_REORDER_PRIVATE
|
||||
#define FF_API_REORDER_PRIVATE (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_INTERRUPT_CB
|
||||
#define FF_API_OLD_INTERRUPT_CB (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_SET_PTS_INFO
|
||||
#define FF_API_SET_PTS_INFO (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_CLOSE_INPUT_FILE
|
||||
#define FF_API_CLOSE_INPUT_FILE (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
|
||||
#endif /* AVFORMAT_VERSION_H */
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* copyright (c) 2006 Mans Rullgard
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_ADLER32_H
|
||||
#define AVUTIL_ADLER32_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "attributes.h"
|
||||
|
||||
/**
|
||||
* @ingroup lavu_crypto
|
||||
* Calculate the Adler32 checksum of a buffer.
|
||||
*
|
||||
* Passing the return value to a subsequent av_adler32_update() call
|
||||
* allows the checksum of multiple buffers to be calculated as though
|
||||
* they were concatenated.
|
||||
*
|
||||
* @param adler initial checksum value
|
||||
* @param buf pointer to input buffer
|
||||
* @param len size of input buffer
|
||||
* @return updated checksum
|
||||
*/
|
||||
unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf,
|
||||
unsigned int len) av_pure;
|
||||
|
||||
#endif /* AVUTIL_ADLER32_H */
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* copyright (c) 2007 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AES_H
|
||||
#define AVUTIL_AES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavu_aes AES
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern const int av_aes_size;
|
||||
|
||||
struct AVAES;
|
||||
|
||||
/**
|
||||
* Initialize an AVAES context.
|
||||
* @param key_bits 128, 192 or 256
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context.
|
||||
* @param count number of 16 byte blocks
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param iv initialization vector for CBC mode, if NULL then ECB will be used
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_aes_crypt(struct AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AES_H */
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Macro definitions for various function/variable attributes
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_ATTRIBUTES_H
|
||||
#define AVUTIL_ATTRIBUTES_H
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y)
|
||||
#else
|
||||
# define AV_GCC_VERSION_AT_LEAST(x,y) 0
|
||||
#endif
|
||||
|
||||
#ifndef av_always_inline
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
# define av_always_inline __attribute__((always_inline)) inline
|
||||
#else
|
||||
# define av_always_inline inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef av_noinline
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
# define av_noinline __attribute__((noinline))
|
||||
#else
|
||||
# define av_noinline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef av_pure
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
# define av_pure __attribute__((pure))
|
||||
#else
|
||||
# define av_pure
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef av_const
|
||||
#if AV_GCC_VERSION_AT_LEAST(2,6)
|
||||
# define av_const __attribute__((const))
|
||||
#else
|
||||
# define av_const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef av_cold
|
||||
#if AV_GCC_VERSION_AT_LEAST(4,3)
|
||||
# define av_cold __attribute__((cold))
|
||||
#else
|
||||
# define av_cold
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef av_flatten
|
||||
#if AV_GCC_VERSION_AT_LEAST(4,1)
|
||||
# define av_flatten __attribute__((flatten))
|
||||
#else
|
||||
# define av_flatten
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef attribute_deprecated
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
# define attribute_deprecated __attribute__((deprecated))
|
||||
#else
|
||||
# define attribute_deprecated
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef av_unused
|
||||
#if defined(__GNUC__)
|
||||
# define av_unused __attribute__((unused))
|
||||
#else
|
||||
# define av_unused
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Mark a variable as used and prevent the compiler from optimizing it
|
||||
* away. This is useful for variables accessed only from inline
|
||||
* assembler without the compiler being aware.
|
||||
*/
|
||||
#ifndef av_used
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
# define av_used __attribute__((used))
|
||||
#else
|
||||
# define av_used
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef av_alias
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,3)
|
||||
# define av_alias __attribute__((may_alias))
|
||||
#else
|
||||
# define av_alias
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef av_uninit
|
||||
#if defined(__GNUC__) && !defined(__ICC)
|
||||
# define av_uninit(x) x=x
|
||||
#else
|
||||
# define av_uninit(x) x
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define av_builtin_constant_p __builtin_constant_p
|
||||
# define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
|
||||
#else
|
||||
# define av_builtin_constant_p(x) 0
|
||||
# define av_printf_format(fmtpos, attrpos)
|
||||
#endif
|
||||
|
||||
#endif /* AVUTIL_ATTRIBUTES_H */
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Audio FIFO
|
||||
* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Audio FIFO Buffer
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AUDIO_FIFO_H
|
||||
#define AVUTIL_AUDIO_FIFO_H
|
||||
|
||||
#include "avutil.h"
|
||||
#include "fifo.h"
|
||||
#include "samplefmt.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_audio
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Context for an Audio FIFO Buffer.
|
||||
*
|
||||
* - Operates at the sample level rather than the byte level.
|
||||
* - Supports multiple channels with either planar or packed sample format.
|
||||
* - Automatic reallocation when writing to a full buffer.
|
||||
*/
|
||||
typedef struct AVAudioFifo AVAudioFifo;
|
||||
|
||||
/**
|
||||
* Free an AVAudioFifo.
|
||||
*
|
||||
* @param af AVAudioFifo to free
|
||||
*/
|
||||
void av_audio_fifo_free(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* Allocate an AVAudioFifo.
|
||||
*
|
||||
* @param sample_fmt sample format
|
||||
* @param channels number of channels
|
||||
* @param nb_samples initial allocation size, in samples
|
||||
* @return newly allocated AVAudioFifo, or NULL on error
|
||||
*/
|
||||
AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels,
|
||||
int nb_samples);
|
||||
|
||||
/**
|
||||
* Reallocate an AVAudioFifo.
|
||||
*
|
||||
* @param af AVAudioFifo to reallocate
|
||||
* @param nb_samples new allocation size, in samples
|
||||
* @return 0 if OK, or negative AVERROR code on failure
|
||||
*/
|
||||
int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples);
|
||||
|
||||
/**
|
||||
* Write data to an AVAudioFifo.
|
||||
*
|
||||
* The AVAudioFifo will be reallocated automatically if the available space
|
||||
* is less than nb_samples.
|
||||
*
|
||||
* @see enum AVSampleFormat
|
||||
* The documentation for AVSampleFormat describes the data layout.
|
||||
*
|
||||
* @param af AVAudioFifo to write to
|
||||
* @param data audio data plane pointers
|
||||
* @param nb_samples number of samples to write
|
||||
* @return number of samples actually written, or negative AVERROR
|
||||
* code on failure.
|
||||
*/
|
||||
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples);
|
||||
|
||||
/**
|
||||
* Read data from an AVAudioFifo.
|
||||
*
|
||||
* @see enum AVSampleFormat
|
||||
* The documentation for AVSampleFormat describes the data layout.
|
||||
*
|
||||
* @param af AVAudioFifo to read from
|
||||
* @param data audio data plane pointers
|
||||
* @param nb_samples number of samples to read
|
||||
* @return number of samples actually read, or negative AVERROR code
|
||||
* on failure.
|
||||
*/
|
||||
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples);
|
||||
|
||||
/**
|
||||
* Drain data from an AVAudioFifo.
|
||||
*
|
||||
* Removes the data without reading it.
|
||||
*
|
||||
* @param af AVAudioFifo to drain
|
||||
* @param nb_samples number of samples to drain
|
||||
* @return 0 if OK, or negative AVERROR code on failure
|
||||
*/
|
||||
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples);
|
||||
|
||||
/**
|
||||
* Reset the AVAudioFifo buffer.
|
||||
*
|
||||
* This empties all data in the buffer.
|
||||
*
|
||||
* @param af AVAudioFifo to reset
|
||||
*/
|
||||
void av_audio_fifo_reset(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* Get the current number of samples in the AVAudioFifo available for reading.
|
||||
*
|
||||
* @param af the AVAudioFifo to query
|
||||
* @return number of samples available for reading
|
||||
*/
|
||||
int av_audio_fifo_size(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* Get the current number of samples in the AVAudioFifo available for writing.
|
||||
*
|
||||
* @param af the AVAudioFifo to query
|
||||
* @return number of samples available for writing
|
||||
*/
|
||||
int av_audio_fifo_space(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AUDIO_FIFO_H */
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
* Copyright (c) 2008 Peter Ross
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AUDIOCONVERT_H
|
||||
#define AVUTIL_AUDIOCONVERT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @file
|
||||
* audio conversion routines
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_audio
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup channel_masks Audio channel masks
|
||||
* @{
|
||||
*/
|
||||
#define AV_CH_FRONT_LEFT 0x00000001
|
||||
#define AV_CH_FRONT_RIGHT 0x00000002
|
||||
#define AV_CH_FRONT_CENTER 0x00000004
|
||||
#define AV_CH_LOW_FREQUENCY 0x00000008
|
||||
#define AV_CH_BACK_LEFT 0x00000010
|
||||
#define AV_CH_BACK_RIGHT 0x00000020
|
||||
#define AV_CH_FRONT_LEFT_OF_CENTER 0x00000040
|
||||
#define AV_CH_FRONT_RIGHT_OF_CENTER 0x00000080
|
||||
#define AV_CH_BACK_CENTER 0x00000100
|
||||
#define AV_CH_SIDE_LEFT 0x00000200
|
||||
#define AV_CH_SIDE_RIGHT 0x00000400
|
||||
#define AV_CH_TOP_CENTER 0x00000800
|
||||
#define AV_CH_TOP_FRONT_LEFT 0x00001000
|
||||
#define AV_CH_TOP_FRONT_CENTER 0x00002000
|
||||
#define AV_CH_TOP_FRONT_RIGHT 0x00004000
|
||||
#define AV_CH_TOP_BACK_LEFT 0x00008000
|
||||
#define AV_CH_TOP_BACK_CENTER 0x00010000
|
||||
#define AV_CH_TOP_BACK_RIGHT 0x00020000
|
||||
#define AV_CH_STEREO_LEFT 0x20000000 ///< Stereo downmix.
|
||||
#define AV_CH_STEREO_RIGHT 0x40000000 ///< See AV_CH_STEREO_LEFT.
|
||||
#define AV_CH_WIDE_LEFT 0x0000000080000000ULL
|
||||
#define AV_CH_WIDE_RIGHT 0x0000000100000000ULL
|
||||
#define AV_CH_SURROUND_DIRECT_LEFT 0x0000000200000000ULL
|
||||
#define AV_CH_SURROUND_DIRECT_RIGHT 0x0000000400000000ULL
|
||||
|
||||
/** Channel mask value used for AVCodecContext.request_channel_layout
|
||||
to indicate that the user requests the channel order of the decoder output
|
||||
to be the native codec channel order. */
|
||||
#define AV_CH_LAYOUT_NATIVE 0x8000000000000000ULL
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @defgroup channel_mask_c Audio channel convenience macros
|
||||
* @{
|
||||
* */
|
||||
#define AV_CH_LAYOUT_MONO (AV_CH_FRONT_CENTER)
|
||||
#define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT)
|
||||
#define AV_CH_LAYOUT_2POINT1 (AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_2_1 (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_SURROUND (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER)
|
||||
#define AV_CH_LAYOUT_3POINT1 (AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_4POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_4POINT1 (AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_2_2 (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
|
||||
#define AV_CH_LAYOUT_QUAD (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_5POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
|
||||
#define AV_CH_LAYOUT_5POINT1 (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_5POINT0_BACK (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_5POINT1_BACK (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_6POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_6POINT0_FRONT (AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
#define AV_CH_LAYOUT_HEXAGONAL (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_6POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_6POINT1_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_6POINT1_FRONT (AV_CH_LAYOUT_6POINT0_FRONT|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_7POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_7POINT0_FRONT (AV_CH_LAYOUT_5POINT0|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
#define AV_CH_LAYOUT_7POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
#define AV_CH_LAYOUT_OCTAGONAL (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return a channel layout id that matches name, 0 if no match.
|
||||
*/
|
||||
uint64_t av_get_channel_layout(const char *name);
|
||||
|
||||
/**
|
||||
* Return a description of a channel layout.
|
||||
* If nb_channels is <= 0, it is guessed from the channel_layout.
|
||||
*
|
||||
* @param buf put here the string containing the channel layout
|
||||
* @param buf_size size in bytes of the buffer
|
||||
*/
|
||||
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout);
|
||||
|
||||
/**
|
||||
* Return the number of channels in the channel layout.
|
||||
*/
|
||||
int av_get_channel_layout_nb_channels(uint64_t channel_layout);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AUDIOCONVERT_H */
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* copyright (c) 2010 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* simple assert() macros that are a bit more flexible than ISO C assert().
|
||||
* @author Michael Niedermayer <michaelni@gmx.at>
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AVASSERT_H
|
||||
#define AVUTIL_AVASSERT_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "avutil.h"
|
||||
#include "log.h"
|
||||
|
||||
/**
|
||||
* assert() equivalent, that is always enabled.
|
||||
*/
|
||||
#define av_assert0(cond) do { \
|
||||
if (!(cond)) { \
|
||||
av_log(NULL, AV_LOG_FATAL, "Assertion %s failed at %s:%d\n", \
|
||||
AV_STRINGIFY(cond), __FILE__, __LINE__); \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
* assert() equivalent, that does not lie in speed critical code.
|
||||
* These asserts() thus can be enabled without fearing speedloss.
|
||||
*/
|
||||
#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 0
|
||||
#define av_assert1(cond) av_assert0(cond)
|
||||
#else
|
||||
#define av_assert1(cond) ((void)0)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* assert() equivalent, that does lie in speed critical code.
|
||||
*/
|
||||
#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1
|
||||
#define av_assert2(cond) av_assert0(cond)
|
||||
#else
|
||||
#define av_assert2(cond) ((void)0)
|
||||
#endif
|
||||
|
||||
#endif /* AVUTIL_AVASSERT_H */
|
|
@ -0,0 +1,6 @@
|
|||
/* Generated by ffconf */
|
||||
#ifndef AVUTIL_AVCONFIG_H
|
||||
#define AVUTIL_AVCONFIG_H
|
||||
#define AV_HAVE_BIGENDIAN 0
|
||||
#define AV_HAVE_FAST_UNALIGNED 1
|
||||
#endif /* AVUTIL_AVCONFIG_H */
|
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Mans Rullgard
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AVSTRING_H
|
||||
#define AVUTIL_AVSTRING_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "attributes.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_string
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return non-zero if pfx is a prefix of str. If it is, *ptr is set to
|
||||
* the address of the first character in str after the prefix.
|
||||
*
|
||||
* @param str input string
|
||||
* @param pfx prefix to test
|
||||
* @param ptr updated if the prefix is matched inside str
|
||||
* @return non-zero if the prefix matches, zero otherwise
|
||||
*/
|
||||
int av_strstart(const char *str, const char *pfx, const char **ptr);
|
||||
|
||||
/**
|
||||
* Return non-zero if pfx is a prefix of str independent of case. If
|
||||
* it is, *ptr is set to the address of the first character in str
|
||||
* after the prefix.
|
||||
*
|
||||
* @param str input string
|
||||
* @param pfx prefix to test
|
||||
* @param ptr updated if the prefix is matched inside str
|
||||
* @return non-zero if the prefix matches, zero otherwise
|
||||
*/
|
||||
int av_stristart(const char *str, const char *pfx, const char **ptr);
|
||||
|
||||
/**
|
||||
* Locate the first case-independent occurrence in the string haystack
|
||||
* of the string needle. A zero-length string needle is considered to
|
||||
* match at the start of haystack.
|
||||
*
|
||||
* This function is a case-insensitive version of the standard strstr().
|
||||
*
|
||||
* @param haystack string to search in
|
||||
* @param needle string to search for
|
||||
* @return pointer to the located match within haystack
|
||||
* or a null pointer if no match
|
||||
*/
|
||||
char *av_stristr(const char *haystack, const char *needle);
|
||||
|
||||
/**
|
||||
* Copy the string src to dst, but no more than size - 1 bytes, and
|
||||
* null-terminate dst.
|
||||
*
|
||||
* This function is the same as BSD strlcpy().
|
||||
*
|
||||
* @param dst destination buffer
|
||||
* @param src source string
|
||||
* @param size size of destination buffer
|
||||
* @return the length of src
|
||||
*
|
||||
* @warning since the return value is the length of src, src absolutely
|
||||
* _must_ be a properly 0-terminated string, otherwise this will read beyond
|
||||
* the end of the buffer and possibly crash.
|
||||
*/
|
||||
size_t av_strlcpy(char *dst, const char *src, size_t size);
|
||||
|
||||
/**
|
||||
* Append the string src to the string dst, but to a total length of
|
||||
* no more than size - 1 bytes, and null-terminate dst.
|
||||
*
|
||||
* This function is similar to BSD strlcat(), but differs when
|
||||
* size <= strlen(dst).
|
||||
*
|
||||
* @param dst destination buffer
|
||||
* @param src source string
|
||||
* @param size size of destination buffer
|
||||
* @return the total length of src and dst
|
||||
*
|
||||
* @warning since the return value use the length of src and dst, these
|
||||
* absolutely _must_ be a properly 0-terminated strings, otherwise this
|
||||
* will read beyond the end of the buffer and possibly crash.
|
||||
*/
|
||||
size_t av_strlcat(char *dst, const char *src, size_t size);
|
||||
|
||||
/**
|
||||
* Append output to a string, according to a format. Never write out of
|
||||
* the destination buffer, and always put a terminating 0 within
|
||||
* the buffer.
|
||||
* @param dst destination buffer (string to which the output is
|
||||
* appended)
|
||||
* @param size total size of the destination buffer
|
||||
* @param fmt printf-compatible format string, specifying how the
|
||||
* following parameters are used
|
||||
* @return the length of the string that would have been generated
|
||||
* if enough space had been available
|
||||
*/
|
||||
size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_format(3, 4);
|
||||
|
||||
/**
|
||||
* Convert a number to a av_malloced string.
|
||||
*/
|
||||
char *av_d2str(double d);
|
||||
|
||||
/**
|
||||
* Unescape the given string until a non escaped terminating char,
|
||||
* and return the token corresponding to the unescaped string.
|
||||
*
|
||||
* The normal \ and ' escaping is supported. Leading and trailing
|
||||
* whitespaces are removed, unless they are escaped with '\' or are
|
||||
* enclosed between ''.
|
||||
*
|
||||
* @param buf the buffer to parse, buf will be updated to point to the
|
||||
* terminating char
|
||||
* @param term a 0-terminated list of terminating chars
|
||||
* @return the malloced unescaped string, which must be av_freed by
|
||||
* the user, NULL in case of allocation failure
|
||||
*/
|
||||
char *av_get_token(const char **buf, const char *term);
|
||||
|
||||
/**
|
||||
* Locale-independent conversion of ASCII characters to uppercase.
|
||||
*/
|
||||
static inline int av_toupper(int c)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
c ^= 0x20;
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locale-independent conversion of ASCII characters to lowercase.
|
||||
*/
|
||||
static inline int av_tolower(int c)
|
||||
{
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
c ^= 0x20;
|
||||
return c;
|
||||
}
|
||||
|
||||
/*
|
||||
* Locale-independent case-insensitive compare.
|
||||
* @note This means only ASCII-range characters are case-insensitive
|
||||
*/
|
||||
int av_strcasecmp(const char *a, const char *b);
|
||||
|
||||
/**
|
||||
* Locale-independent case-insensitive compare.
|
||||
* @note This means only ASCII-range characters are case-insensitive
|
||||
*/
|
||||
int av_strncasecmp(const char *a, const char *b, size_t n);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AVSTRING_H */
|
|
@ -0,0 +1,326 @@
|
|||
/*
|
||||
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AVUTIL_H
|
||||
#define AVUTIL_AVUTIL_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* external API header
|
||||
*/
|
||||
|
||||
/**
|
||||
* @mainpage
|
||||
*
|
||||
* @section libav_intro Introduction
|
||||
*
|
||||
* This document describe the usage of the different libraries
|
||||
* provided by Libav.
|
||||
*
|
||||
* @li @ref libavc "libavcodec" encoding/decoding library
|
||||
* @li @subpage libavfilter graph based frame editing library
|
||||
* @li @ref libavf "libavformat" I/O and muxing/demuxing library
|
||||
* @li @ref lavd "libavdevice" special devices muxing/demuxing library
|
||||
* @li @ref lavu "libavutil" common utility library
|
||||
* @li @subpage libpostproc post processing library
|
||||
* @li @subpage libswscale color conversion and scaling library
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lavu Common utility functions
|
||||
*
|
||||
* @brief
|
||||
* libavutil contains the code shared across all the other Libav
|
||||
* libraries
|
||||
*
|
||||
* @note In order to use the functions provided by avutil you must include
|
||||
* the specific header.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavu_crypto Crypto and Hashing
|
||||
*
|
||||
* @{
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_math Maths
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_string String Manipulation
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_mem Memory Management
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_data Data Structures
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_audio Audio related
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_error Error Codes
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_misc Other
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavu_internal Internal
|
||||
*
|
||||
* Not exported functions, for internal usage only
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup preproc_misc Preprocessor String Macros
|
||||
*
|
||||
* String manipulation macros
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AV_STRINGIFY(s) AV_TOSTRING(s)
|
||||
#define AV_TOSTRING(s) #s
|
||||
|
||||
#define AV_GLUE(a, b) a ## b
|
||||
#define AV_JOIN(a, b) AV_GLUE(a, b)
|
||||
|
||||
#define AV_PRAGMA(s) _Pragma(#s)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup version_utils Library Version Macros
|
||||
*
|
||||
* Useful to check and match library version in order to maintain
|
||||
* backward compatibility.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c)
|
||||
#define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c
|
||||
#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_ver Version and Build diagnostics
|
||||
*
|
||||
* Macros and function useful to check at compiletime and at runtime
|
||||
* which version of libavutil is in use.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define LIBAVUTIL_VERSION_MAJOR 51
|
||||
#define LIBAVUTIL_VERSION_MINOR 22
|
||||
#define LIBAVUTIL_VERSION_MICRO 1
|
||||
|
||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||
LIBAVUTIL_VERSION_MINOR, \
|
||||
LIBAVUTIL_VERSION_MICRO)
|
||||
#define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \
|
||||
LIBAVUTIL_VERSION_MINOR, \
|
||||
LIBAVUTIL_VERSION_MICRO)
|
||||
#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
|
||||
|
||||
#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
* @defgroup depr_guards Deprecation guards
|
||||
* Those FF_API_* defines are not part of public API.
|
||||
* They may change, break or disappear at any time.
|
||||
*
|
||||
* They are used mostly internally to mark code that will be removed
|
||||
* on the next major version.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#ifndef FF_API_GET_BITS_PER_SAMPLE_FMT
|
||||
#define FF_API_GET_BITS_PER_SAMPLE_FMT (LIBAVUTIL_VERSION_MAJOR < 52)
|
||||
#endif
|
||||
#ifndef FF_API_FIND_OPT
|
||||
#define FF_API_FIND_OPT (LIBAVUTIL_VERSION_MAJOR < 52)
|
||||
#endif
|
||||
#ifndef FF_API_AV_FIFO_PEEK
|
||||
#define FF_API_AV_FIFO_PEEK (LIBAVUTIL_VERSION_MAJOR < 52)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_AVOPTIONS
|
||||
#define FF_API_OLD_AVOPTIONS (LIBAVUTIL_VERSION_MAJOR < 52)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_ver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return the LIBAVUTIL_VERSION_INT constant.
|
||||
*/
|
||||
unsigned avutil_version(void);
|
||||
|
||||
/**
|
||||
* Return the libavutil build-time configuration.
|
||||
*/
|
||||
const char *avutil_configuration(void);
|
||||
|
||||
/**
|
||||
* Return the libavutil license.
|
||||
*/
|
||||
const char *avutil_license(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_media Media Type
|
||||
* @brief Media Type
|
||||
*/
|
||||
|
||||
enum AVMediaType {
|
||||
AVMEDIA_TYPE_UNKNOWN = -1, ///< Usually treated as AVMEDIA_TYPE_DATA
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_AUDIO,
|
||||
AVMEDIA_TYPE_DATA, ///< Opaque data information usually continuous
|
||||
AVMEDIA_TYPE_SUBTITLE,
|
||||
AVMEDIA_TYPE_ATTACHMENT, ///< Opaque data information usually sparse
|
||||
AVMEDIA_TYPE_NB
|
||||
};
|
||||
|
||||
/**
|
||||
* @defgroup lavu_const Constants
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavu_enc Encoding specific
|
||||
*
|
||||
* @note those definition should move to avcodec
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define FF_LAMBDA_SHIFT 7
|
||||
#define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
|
||||
#define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
|
||||
#define FF_LAMBDA_MAX (256*128-1)
|
||||
|
||||
#define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @defgroup lavu_time Timestamp specific
|
||||
*
|
||||
* Libav internal timebase and timestamp definitions
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Undefined timestamp value
|
||||
*
|
||||
* Usually reported by demuxer that work on containers that do not provide
|
||||
* either pts or dts.
|
||||
*/
|
||||
|
||||
#define AV_NOPTS_VALUE INT64_C(0x8000000000000000)
|
||||
|
||||
/**
|
||||
* Internal time base represented as integer
|
||||
*/
|
||||
|
||||
#define AV_TIME_BASE 1000000
|
||||
|
||||
/**
|
||||
* Internal time base represented as fractional value
|
||||
*/
|
||||
|
||||
#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @defgroup lavu_picture Image related
|
||||
*
|
||||
* AVPicture types, pixel formats and basic image planes manipulation.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
enum AVPictureType {
|
||||
AV_PICTURE_TYPE_I = 1, ///< Intra
|
||||
AV_PICTURE_TYPE_P, ///< Predicted
|
||||
AV_PICTURE_TYPE_B, ///< Bi-dir predicted
|
||||
AV_PICTURE_TYPE_S, ///< S(GMC)-VOP MPEG4
|
||||
AV_PICTURE_TYPE_SI, ///< Switching Intra
|
||||
AV_PICTURE_TYPE_SP, ///< Switching Predicted
|
||||
AV_PICTURE_TYPE_BI, ///< BI type
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a single letter to describe the given picture type
|
||||
* pict_type.
|
||||
*
|
||||
* @param[in] pict_type the picture type @return a single character
|
||||
* representing the picture type, '?' if pict_type is unknown
|
||||
*/
|
||||
char av_get_picture_type_char(enum AVPictureType pict_type);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "error.h"
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AVUTIL_H */
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright (c) 2006 Ryan Martell. (rdm4@martellventures.com)
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_BASE64_H
|
||||
#define AVUTIL_BASE64_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavu_base64 Base64
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Decode a base64-encoded string.
|
||||
*
|
||||
* @param out buffer for decoded data
|
||||
* @param in null-terminated input string
|
||||
* @param out_size size in bytes of the out buffer, must be at
|
||||
* least 3/4 of the length of in
|
||||
* @return number of bytes written, or a negative value in case of
|
||||
* invalid input
|
||||
*/
|
||||
int av_base64_decode(uint8_t *out, const char *in, int out_size);
|
||||
|
||||
/**
|
||||
* Encode data to base64 and null-terminate.
|
||||
*
|
||||
* @param out buffer for encoded data
|
||||
* @param out_size size in bytes of the output buffer, must be at
|
||||
* least AV_BASE64_SIZE(in_size)
|
||||
* @param in_size size in bytes of the 'in' buffer
|
||||
* @return 'out' or NULL in case of error
|
||||
*/
|
||||
char *av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size);
|
||||
|
||||
/**
|
||||
* Calculate the output size needed to base64-encode x bytes.
|
||||
*/
|
||||
#define AV_BASE64_SIZE(x) (((x)+2) / 3 * 4 + 1)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_BASE64_H */
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Blowfish algorithm
|
||||
* Copyright (c) 2012 Samuel Pitoiset
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_BLOWFISH_H
|
||||
#define AVUTIL_BLOWFISH_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavu_blowfish Blowfish
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AV_BF_ROUNDS 16
|
||||
|
||||
typedef struct AVBlowfish {
|
||||
uint32_t p[AV_BF_ROUNDS + 2];
|
||||
uint32_t s[4][256];
|
||||
} AVBlowfish;
|
||||
|
||||
/**
|
||||
* Initialize an AVBlowfish context.
|
||||
*
|
||||
* @param ctx an AVBlowfish context
|
||||
* @param key a key
|
||||
* @param key_len length of the key
|
||||
*/
|
||||
void av_blowfish_init(struct AVBlowfish *ctx, const uint8_t *key, int key_len);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context.
|
||||
*
|
||||
* @param ctx an AVBlowfish context
|
||||
* @param xl left four bytes halves of input to be encrypted
|
||||
* @param xr right four bytes halves of input to be encrypted
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_blowfish_crypt_ecb(struct AVBlowfish *ctx, uint32_t *xl, uint32_t *xr,
|
||||
int decrypt);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context.
|
||||
*
|
||||
* @param ctx an AVBlowfish context
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param count number of 8 byte blocks
|
||||
* @param iv initialization vector for CBC mode, if NULL ECB will be used
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_blowfish_crypt(struct AVBlowfish *ctx, uint8_t *dst, const uint8_t *src,
|
||||
int count, uint8_t *iv, int decrypt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_BLOWFISH_H */
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* Copyright (c) 2012 Nicolas George
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_BPRINT_H
|
||||
#define AVUTIL_BPRINT_H
|
||||
|
||||
#include "attributes.h"
|
||||
|
||||
/**
|
||||
* Define a structure with extra padding to a fixed size
|
||||
* This helps ensuring binary compatibility with future versions.
|
||||
*/
|
||||
#define FF_PAD_STRUCTURE(size, ...) \
|
||||
__VA_ARGS__ \
|
||||
char reserved_padding[size - sizeof(struct { __VA_ARGS__ })];
|
||||
|
||||
/**
|
||||
* Buffer to print data progressively
|
||||
*
|
||||
* The string buffer grows as necessary and is always 0-terminated.
|
||||
* The content of the string is never accessed, and thus is
|
||||
* encoding-agnostic and can even hold binary data.
|
||||
*
|
||||
* Small buffers are kept in the structure itself, and thus require no
|
||||
* memory allocation at all (unless the contents of the buffer is needed
|
||||
* after the structure goes out of scope). This is almost as lightweight as
|
||||
* declaring a local "char buf[512]".
|
||||
*
|
||||
* The length of the string can go beyond the allocated size: the buffer is
|
||||
* then truncated, but the functions still keep account of the actual total
|
||||
* length.
|
||||
*
|
||||
* In other words, buf->len can be greater than buf->size and records the
|
||||
* total length of what would have been to the buffer if there had been
|
||||
* enough memory.
|
||||
*
|
||||
* Append operations do not need to be tested for failure: if a memory
|
||||
* allocation fails, data stop being appended to the buffer, but the length
|
||||
* is still updated. This situation can be tested with
|
||||
* av_bprint_is_complete().
|
||||
*
|
||||
* The size_max field determines several possible behaviours:
|
||||
*
|
||||
* size_max = -1 (= UINT_MAX) or any large value will let the buffer be
|
||||
* reallocated as necessary, with an amortized linear cost.
|
||||
*
|
||||
* size_max = 0 prevents writing anything to the buffer: only the total
|
||||
* length is computed. The write operations can then possibly be repeated in
|
||||
* a buffer with exactly the necessary size
|
||||
* (using size_init = size_max = len + 1).
|
||||
*
|
||||
* size_max = 1 is automatically replaced by the exact size available in the
|
||||
* structure itself, thus ensuring no dynamic memory allocation. The
|
||||
* internal buffer is large enough to hold a reasonable paragraph of text,
|
||||
* such as the current paragraph.
|
||||
*/
|
||||
typedef struct AVBPrint {
|
||||
FF_PAD_STRUCTURE(1024,
|
||||
char *str; /** string so far */
|
||||
unsigned len; /** length so far */
|
||||
unsigned size; /** allocated memory */
|
||||
unsigned size_max; /** maximum allocated memory */
|
||||
char reserved_internal_buffer[1];
|
||||
)
|
||||
} AVBPrint;
|
||||
|
||||
/**
|
||||
* Convenience macros for special values for av_bprint_init() size_max
|
||||
* parameter.
|
||||
*/
|
||||
#define AV_BPRINT_SIZE_UNLIMITED ((unsigned)-1)
|
||||
#define AV_BPRINT_SIZE_AUTOMATIC 1
|
||||
#define AV_BPRINT_SIZE_COUNT_ONLY 0
|
||||
|
||||
/**
|
||||
* Init a print buffer.
|
||||
*
|
||||
* @param buf buffer to init
|
||||
* @param size_init initial size (including the final 0)
|
||||
* @param size_max maximum size;
|
||||
* 0 means do not write anything, just count the length;
|
||||
* 1 is replaced by the maximum value for automatic storage;
|
||||
* any large value means that the internal buffer will be
|
||||
* reallocated as needed up to that limit; -1 is converted to
|
||||
* UINT_MAX, the largest limit possible.
|
||||
* Check also AV_BPRINT_SIZE_* macros.
|
||||
*/
|
||||
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max);
|
||||
|
||||
/**
|
||||
* Init a print buffer using a pre-existing buffer.
|
||||
*
|
||||
* The buffer will not be reallocated.
|
||||
*
|
||||
* @param buf buffer structure to init
|
||||
* @param buffer byte buffer to use for the string data
|
||||
* @param size size of buffer
|
||||
*/
|
||||
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size);
|
||||
|
||||
/**
|
||||
* Append a formated string to a print buffer.
|
||||
*/
|
||||
void av_bprintf(AVBPrint *buf, const char *fmt, ...) av_printf_format(2, 3);
|
||||
|
||||
/**
|
||||
* Append char c n times to a print buffer.
|
||||
*/
|
||||
void av_bprint_chars(AVBPrint *buf, char c, unsigned n);
|
||||
|
||||
/**
|
||||
* Allocate bytes in the buffer for external use.
|
||||
*
|
||||
* @param[in] buf buffer structure
|
||||
* @param[in] size required size
|
||||
* @param[out] mem pointer to the memory area
|
||||
* @param[out] actual_size size of the memory area after allocation;
|
||||
* can be larger or smaller than size
|
||||
*/
|
||||
void av_bprint_get_buffer(AVBPrint *buf, unsigned size,
|
||||
unsigned char **mem, unsigned *actual_size);
|
||||
|
||||
/**
|
||||
* Reset the string to "" but keep internal allocated data.
|
||||
*/
|
||||
void av_bprint_clear(AVBPrint *buf);
|
||||
|
||||
/**
|
||||
* Test if the print buffer is complete (not truncated).
|
||||
*
|
||||
* It may have been truncated due to a memory allocation failure
|
||||
* or the size_max limit (compare size and size_max if necessary).
|
||||
*/
|
||||
static inline int av_bprint_is_complete(AVBPrint *buf)
|
||||
{
|
||||
return buf->len < buf->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalize a print buffer.
|
||||
*
|
||||
* The print buffer can no longer be used afterwards,
|
||||
* but the len and size fields are still valid.
|
||||
*
|
||||
* @arg[out] ret_str if not NULL, used to return a permanent copy of the
|
||||
* buffer contents, or NULL if memory allocation fails;
|
||||
* if NULL, the buffer is discarded and freed
|
||||
* @return 0 for success or error code (probably AVERROR(ENOMEM))
|
||||
*/
|
||||
int av_bprint_finalize(AVBPrint *buf, char **ret_str);
|
||||
|
||||
#endif /* AVUTIL_BPRINT_H */
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* byte swapping routines
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_BSWAP_H
|
||||
#define AVUTIL_BSWAP_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "libavutil/avconfig.h"
|
||||
#include "attributes.h"
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if ARCH_ARM
|
||||
# include "arm/bswap.h"
|
||||
#elif ARCH_AVR32
|
||||
# include "avr32/bswap.h"
|
||||
#elif ARCH_BFIN
|
||||
# include "bfin/bswap.h"
|
||||
#elif ARCH_SH4
|
||||
# include "sh4/bswap.h"
|
||||
#elif ARCH_X86
|
||||
# include "x86/bswap.h"
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_AV_CONFIG_H */
|
||||
|
||||
#define AV_BSWAP16C(x) (((x) << 8 & 0xff00) | ((x) >> 8 & 0x00ff))
|
||||
#define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C((x) >> 16))
|
||||
#define AV_BSWAP64C(x) (AV_BSWAP32C(x) << 32 | AV_BSWAP32C((x) >> 32))
|
||||
|
||||
#define AV_BSWAPC(s, x) AV_BSWAP##s##C(x)
|
||||
|
||||
#ifndef av_bswap16
|
||||
static av_always_inline av_const uint16_t av_bswap16(uint16_t x)
|
||||
{
|
||||
x= (x>>8) | (x<<8);
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef av_bswap32
|
||||
static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
|
||||
{
|
||||
return AV_BSWAP32C(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef av_bswap64
|
||||
static inline uint64_t av_const av_bswap64(uint64_t x)
|
||||
{
|
||||
return (uint64_t)av_bswap32(x) << 32 | av_bswap32(x >> 32);
|
||||
}
|
||||
#endif
|
||||
|
||||
// be2ne ... big-endian to native-endian
|
||||
// le2ne ... little-endian to native-endian
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
#define av_be2ne16(x) (x)
|
||||
#define av_be2ne32(x) (x)
|
||||
#define av_be2ne64(x) (x)
|
||||
#define av_le2ne16(x) av_bswap16(x)
|
||||
#define av_le2ne32(x) av_bswap32(x)
|
||||
#define av_le2ne64(x) av_bswap64(x)
|
||||
#define AV_BE2NEC(s, x) (x)
|
||||
#define AV_LE2NEC(s, x) AV_BSWAPC(s, x)
|
||||
#else
|
||||
#define av_be2ne16(x) av_bswap16(x)
|
||||
#define av_be2ne32(x) av_bswap32(x)
|
||||
#define av_be2ne64(x) av_bswap64(x)
|
||||
#define av_le2ne16(x) (x)
|
||||
#define av_le2ne32(x) (x)
|
||||
#define av_le2ne64(x) (x)
|
||||
#define AV_BE2NEC(s, x) AV_BSWAPC(s, x)
|
||||
#define AV_LE2NEC(s, x) (x)
|
||||
#endif
|
||||
|
||||
#define AV_BE2NE16C(x) AV_BE2NEC(16, x)
|
||||
#define AV_BE2NE32C(x) AV_BE2NEC(32, x)
|
||||
#define AV_BE2NE64C(x) AV_BE2NEC(64, x)
|
||||
#define AV_LE2NE16C(x) AV_LE2NEC(16, x)
|
||||
#define AV_LE2NE32C(x) AV_LE2NEC(32, x)
|
||||
#define AV_LE2NE64C(x) AV_LE2NEC(64, x)
|
||||
|
||||
#endif /* AVUTIL_BSWAP_H */
|
|
@ -0,0 +1,398 @@
|
|||
/*
|
||||
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* common internal and external API header
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_COMMON_H
|
||||
#define AVUTIL_COMMON_H
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "attributes.h"
|
||||
#include "libavutil/avconfig.h"
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
# define AV_NE(be, le) (be)
|
||||
#else
|
||||
# define AV_NE(be, le) (le)
|
||||
#endif
|
||||
|
||||
//rounded division & shift
|
||||
#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
|
||||
/* assume b>0 */
|
||||
#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
|
||||
#define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
|
||||
#define FFSIGN(a) ((a) > 0 ? 1 : -1)
|
||||
|
||||
#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c)
|
||||
#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
|
||||
#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c)
|
||||
|
||||
#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
|
||||
#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
|
||||
#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
|
||||
|
||||
/* misc math functions */
|
||||
extern const uint8_t ff_log2_tab[256];
|
||||
|
||||
extern const uint8_t av_reverse[256];
|
||||
|
||||
static av_always_inline av_const int av_log2_c(unsigned int v)
|
||||
{
|
||||
int n = 0;
|
||||
if (v & 0xffff0000) {
|
||||
v >>= 16;
|
||||
n += 16;
|
||||
}
|
||||
if (v & 0xff00) {
|
||||
v >>= 8;
|
||||
n += 8;
|
||||
}
|
||||
n += ff_log2_tab[v];
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static av_always_inline av_const int av_log2_16bit_c(unsigned int v)
|
||||
{
|
||||
int n = 0;
|
||||
if (v & 0xff00) {
|
||||
v >>= 8;
|
||||
n += 8;
|
||||
}
|
||||
n += ff_log2_tab[v];
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
# include "config.h"
|
||||
# include "intmath.h"
|
||||
#endif
|
||||
|
||||
/* Pull in unguarded fallback defines at the end of this file. */
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the amin-amax range.
|
||||
* @param a value to clip
|
||||
* @param amin minimum value of the clip range
|
||||
* @param amax maximum value of the clip range
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int av_clip_c(int a, int amin, int amax)
|
||||
{
|
||||
if (a < amin) return amin;
|
||||
else if (a > amax) return amax;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the 0-255 range.
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const uint8_t av_clip_uint8_c(int a)
|
||||
{
|
||||
if (a&(~0xFF)) return (-a)>>31;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the -128,127 range.
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int8_t av_clip_int8_c(int a)
|
||||
{
|
||||
if ((a+0x80) & ~0xFF) return (a>>31) ^ 0x7F;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the 0-65535 range.
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const uint16_t av_clip_uint16_c(int a)
|
||||
{
|
||||
if (a&(~0xFFFF)) return (-a)>>31;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the -32768,32767 range.
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int16_t av_clip_int16_c(int a)
|
||||
{
|
||||
if ((a+0x8000) & ~0xFFFF) return (a>>31) ^ 0x7FFF;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed 64-bit integer value into the -2147483648,2147483647 range.
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a)
|
||||
{
|
||||
if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (a>>63) ^ 0x7FFFFFFF;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer to an unsigned power of two range.
|
||||
* @param a value to clip
|
||||
* @param p bit position to clip at
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
|
||||
{
|
||||
if (a & ~((1<<p) - 1)) return -a >> 31 & ((1<<p) - 1);
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a float value into the amin-amax range.
|
||||
* @param a value to clip
|
||||
* @param amin minimum value of the clip range
|
||||
* @param amax maximum value of the clip range
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const float av_clipf_c(float a, float amin, float amax)
|
||||
{
|
||||
if (a < amin) return amin;
|
||||
else if (a > amax) return amax;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/** Compute ceil(log2(x)).
|
||||
* @param x value used to compute ceil(log2(x))
|
||||
* @return computed ceiling of log2(x)
|
||||
*/
|
||||
static av_always_inline av_const int av_ceil_log2_c(int x)
|
||||
{
|
||||
return av_log2((x - 1) << 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Count number of bits set to one in x
|
||||
* @param x value to count bits of
|
||||
* @return the number of bits set to one in x
|
||||
*/
|
||||
static av_always_inline av_const int av_popcount_c(uint32_t x)
|
||||
{
|
||||
x -= (x >> 1) & 0x55555555;
|
||||
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
|
||||
x = (x + (x >> 4)) & 0x0F0F0F0F;
|
||||
x += x >> 8;
|
||||
return (x + (x >> 16)) & 0x3F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count number of bits set to one in x
|
||||
* @param x value to count bits of
|
||||
* @return the number of bits set to one in x
|
||||
*/
|
||||
static av_always_inline av_const int av_popcount64_c(uint64_t x)
|
||||
{
|
||||
return av_popcount(x) + av_popcount(x >> 32);
|
||||
}
|
||||
|
||||
#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24))
|
||||
#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24))
|
||||
|
||||
/**
|
||||
* Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
|
||||
*
|
||||
* @param val Output value, must be an lvalue of type uint32_t.
|
||||
* @param GET_BYTE Expression reading one byte from the input.
|
||||
* Evaluated up to 7 times (4 for the currently
|
||||
* assigned Unicode range). With a memory buffer
|
||||
* input, this could be *ptr++.
|
||||
* @param ERROR Expression to be evaluated on invalid input,
|
||||
* typically a goto statement.
|
||||
*/
|
||||
#define GET_UTF8(val, GET_BYTE, ERROR)\
|
||||
val= GET_BYTE;\
|
||||
{\
|
||||
int ones= 7 - av_log2(val ^ 255);\
|
||||
if(ones==1)\
|
||||
ERROR\
|
||||
val&= 127>>ones;\
|
||||
while(--ones > 0){\
|
||||
int tmp= GET_BYTE - 128;\
|
||||
if(tmp>>6)\
|
||||
ERROR\
|
||||
val= (val<<6) + tmp;\
|
||||
}\
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form.
|
||||
*
|
||||
* @param val Output value, must be an lvalue of type uint32_t.
|
||||
* @param GET_16BIT Expression returning two bytes of UTF-16 data converted
|
||||
* to native byte order. Evaluated one or two times.
|
||||
* @param ERROR Expression to be evaluated on invalid input,
|
||||
* typically a goto statement.
|
||||
*/
|
||||
#define GET_UTF16(val, GET_16BIT, ERROR)\
|
||||
val = GET_16BIT;\
|
||||
{\
|
||||
unsigned int hi = val - 0xD800;\
|
||||
if (hi < 0x800) {\
|
||||
val = GET_16BIT - 0xDC00;\
|
||||
if (val > 0x3FFU || hi > 0x3FFU)\
|
||||
ERROR\
|
||||
val += (hi<<10) + 0x10000;\
|
||||
}\
|
||||
}\
|
||||
|
||||
/**
|
||||
* @def PUT_UTF8(val, tmp, PUT_BYTE)
|
||||
* Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
|
||||
* @param val is an input-only argument and should be of type uint32_t. It holds
|
||||
* a UCS-4 encoded Unicode character that is to be converted to UTF-8. If
|
||||
* val is given as a function it is executed only once.
|
||||
* @param tmp is a temporary variable and should be of type uint8_t. It
|
||||
* represents an intermediate value during conversion that is to be
|
||||
* output by PUT_BYTE.
|
||||
* @param PUT_BYTE writes the converted UTF-8 bytes to any proper destination.
|
||||
* It could be a function or a statement, and uses tmp as the input byte.
|
||||
* For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be
|
||||
* executed up to 4 times for values in the valid UTF-8 range and up to
|
||||
* 7 times in the general case, depending on the length of the converted
|
||||
* Unicode character.
|
||||
*/
|
||||
#define PUT_UTF8(val, tmp, PUT_BYTE)\
|
||||
{\
|
||||
int bytes, shift;\
|
||||
uint32_t in = val;\
|
||||
if (in < 0x80) {\
|
||||
tmp = in;\
|
||||
PUT_BYTE\
|
||||
} else {\
|
||||
bytes = (av_log2(in) + 4) / 5;\
|
||||
shift = (bytes - 1) * 6;\
|
||||
tmp = (256 - (256 >> bytes)) | (in >> shift);\
|
||||
PUT_BYTE\
|
||||
while (shift >= 6) {\
|
||||
shift -= 6;\
|
||||
tmp = 0x80 | ((in >> shift) & 0x3f);\
|
||||
PUT_BYTE\
|
||||
}\
|
||||
}\
|
||||
}
|
||||
|
||||
/**
|
||||
* @def PUT_UTF16(val, tmp, PUT_16BIT)
|
||||
* Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes).
|
||||
* @param val is an input-only argument and should be of type uint32_t. It holds
|
||||
* a UCS-4 encoded Unicode character that is to be converted to UTF-16. If
|
||||
* val is given as a function it is executed only once.
|
||||
* @param tmp is a temporary variable and should be of type uint16_t. It
|
||||
* represents an intermediate value during conversion that is to be
|
||||
* output by PUT_16BIT.
|
||||
* @param PUT_16BIT writes the converted UTF-16 data to any proper destination
|
||||
* in desired endianness. It could be a function or a statement, and uses tmp
|
||||
* as the input byte. For example, PUT_BYTE could be "*output++ = tmp;"
|
||||
* PUT_BYTE will be executed 1 or 2 times depending on input character.
|
||||
*/
|
||||
#define PUT_UTF16(val, tmp, PUT_16BIT)\
|
||||
{\
|
||||
uint32_t in = val;\
|
||||
if (in < 0x10000) {\
|
||||
tmp = in;\
|
||||
PUT_16BIT\
|
||||
} else {\
|
||||
tmp = 0xD800 | ((in - 0x10000) >> 10);\
|
||||
PUT_16BIT\
|
||||
tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\
|
||||
PUT_16BIT\
|
||||
}\
|
||||
}\
|
||||
|
||||
|
||||
|
||||
#include "mem.h"
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
# include "internal.h"
|
||||
#endif /* HAVE_AV_CONFIG_H */
|
||||
|
||||
#endif /* AVUTIL_COMMON_H */
|
||||
|
||||
/*
|
||||
* The following definitions are outside the multiple inclusion guard
|
||||
* to ensure they are immediately available in intmath.h.
|
||||
*/
|
||||
|
||||
#ifndef av_log2
|
||||
# define av_log2 av_log2_c
|
||||
#endif
|
||||
#ifndef av_log2_16bit
|
||||
# define av_log2_16bit av_log2_16bit_c
|
||||
#endif
|
||||
#ifndef av_ceil_log2
|
||||
# define av_ceil_log2 av_ceil_log2_c
|
||||
#endif
|
||||
#ifndef av_clip
|
||||
# define av_clip av_clip_c
|
||||
#endif
|
||||
#ifndef av_clip_uint8
|
||||
# define av_clip_uint8 av_clip_uint8_c
|
||||
#endif
|
||||
#ifndef av_clip_int8
|
||||
# define av_clip_int8 av_clip_int8_c
|
||||
#endif
|
||||
#ifndef av_clip_uint16
|
||||
# define av_clip_uint16 av_clip_uint16_c
|
||||
#endif
|
||||
#ifndef av_clip_int16
|
||||
# define av_clip_int16 av_clip_int16_c
|
||||
#endif
|
||||
#ifndef av_clipl_int32
|
||||
# define av_clipl_int32 av_clipl_int32_c
|
||||
#endif
|
||||
#ifndef av_clip_uintp2
|
||||
# define av_clip_uintp2 av_clip_uintp2_c
|
||||
#endif
|
||||
#ifndef av_clipf
|
||||
# define av_clipf av_clipf_c
|
||||
#endif
|
||||
#ifndef av_popcount
|
||||
# define av_popcount av_popcount_c
|
||||
#endif
|
||||
#ifndef av_popcount64
|
||||
# define av_popcount64 av_popcount64_c
|
||||
#endif
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_CPU_H
|
||||
#define AVUTIL_CPU_H
|
||||
|
||||
#define AV_CPU_FLAG_FORCE 0x80000000 /* force usage of selected flags (OR) */
|
||||
|
||||
/* lower 16 bits - CPU features */
|
||||
#define AV_CPU_FLAG_MMX 0x0001 ///< standard MMX
|
||||
#define AV_CPU_FLAG_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext
|
||||
#define AV_CPU_FLAG_3DNOW 0x0004 ///< AMD 3DNOW
|
||||
#define AV_CPU_FLAG_SSE 0x0008 ///< SSE functions
|
||||
#define AV_CPU_FLAG_SSE2 0x0010 ///< PIV SSE2 functions
|
||||
#define AV_CPU_FLAG_SSE2SLOW 0x40000000 ///< SSE2 supported, but usually not faster
|
||||
#define AV_CPU_FLAG_3DNOWEXT 0x0020 ///< AMD 3DNowExt
|
||||
#define AV_CPU_FLAG_SSE3 0x0040 ///< Prescott SSE3 functions
|
||||
#define AV_CPU_FLAG_SSE3SLOW 0x20000000 ///< SSE3 supported, but usually not faster
|
||||
#define AV_CPU_FLAG_SSSE3 0x0080 ///< Conroe SSSE3 functions
|
||||
#define AV_CPU_FLAG_ATOM 0x10000000 ///< Atom processor, some SSSE3 instructions are slower
|
||||
#define AV_CPU_FLAG_SSE4 0x0100 ///< Penryn SSE4.1 functions
|
||||
#define AV_CPU_FLAG_SSE42 0x0200 ///< Nehalem SSE4.2 functions
|
||||
#define AV_CPU_FLAG_AVX 0x4000 ///< AVX functions: requires OS support even if YMM registers aren't used
|
||||
#define AV_CPU_FLAG_XOP 0x0400 ///< Bulldozer XOP functions
|
||||
#define AV_CPU_FLAG_FMA4 0x0800 ///< Bulldozer FMA4 functions
|
||||
#define AV_CPU_FLAG_IWMMXT 0x0100 ///< XScale IWMMXT
|
||||
#define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard
|
||||
|
||||
/**
|
||||
* Return the flags which specify extensions supported by the CPU.
|
||||
*/
|
||||
int av_get_cpu_flags(void);
|
||||
|
||||
/* The following CPU-specific functions shall not be called directly. */
|
||||
int ff_get_cpu_flags_arm(void);
|
||||
int ff_get_cpu_flags_ppc(void);
|
||||
int ff_get_cpu_flags_x86(void);
|
||||
|
||||
#endif /* AVUTIL_CPU_H */
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_CRC_H
|
||||
#define AVUTIL_CRC_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "attributes.h"
|
||||
|
||||
typedef uint32_t AVCRC;
|
||||
|
||||
typedef enum {
|
||||
AV_CRC_8_ATM,
|
||||
AV_CRC_16_ANSI,
|
||||
AV_CRC_16_CCITT,
|
||||
AV_CRC_32_IEEE,
|
||||
AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */
|
||||
AV_CRC_MAX, /*< Not part of public API! Do not use outside libavutil. */
|
||||
}AVCRCId;
|
||||
|
||||
int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size);
|
||||
const AVCRC *av_crc_get_table(AVCRCId crc_id);
|
||||
uint32_t av_crc(const AVCRC *ctx, uint32_t start_crc, const uint8_t *buffer, size_t length) av_pure;
|
||||
|
||||
#endif /* AVUTIL_CRC_H */
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Public dictionary API.
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_DICT_H
|
||||
#define AVUTIL_DICT_H
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_dict AVDictionary
|
||||
* @ingroup lavu_data
|
||||
*
|
||||
* @brief Simple key:value store
|
||||
*
|
||||
* @{
|
||||
* Dictionaries are used for storing key:value pairs. To create
|
||||
* an AVDictionary, simply pass an address of a NULL pointer to
|
||||
* av_dict_set(). NULL can be used as an empty dictionary wherever
|
||||
* a pointer to an AVDictionary is required.
|
||||
* Use av_dict_get() to retrieve an entry or iterate over all
|
||||
* entries and finally av_dict_free() to free the dictionary
|
||||
* and all its contents.
|
||||
*
|
||||
* @code
|
||||
* AVDictionary *d = NULL; // "create" an empty dictionary
|
||||
* av_dict_set(&d, "foo", "bar", 0); // add an entry
|
||||
*
|
||||
* char *k = av_strdup("key"); // if your strings are already allocated,
|
||||
* char *v = av_strdup("value"); // you can avoid copying them like this
|
||||
* av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
|
||||
*
|
||||
* AVDictionaryEntry *t = NULL;
|
||||
* while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) {
|
||||
* <....> // iterate over all entries in d
|
||||
* }
|
||||
*
|
||||
* av_dict_free(&d);
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
|
||||
#define AV_DICT_MATCH_CASE 1
|
||||
#define AV_DICT_IGNORE_SUFFIX 2
|
||||
#define AV_DICT_DONT_STRDUP_KEY 4 /**< Take ownership of a key that's been
|
||||
allocated with av_malloc() and children. */
|
||||
#define AV_DICT_DONT_STRDUP_VAL 8 /**< Take ownership of a value that's been
|
||||
allocated with av_malloc() and chilren. */
|
||||
#define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries.
|
||||
#define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no
|
||||
delimiter is added, the strings are simply concatenated. */
|
||||
|
||||
typedef struct {
|
||||
char *key;
|
||||
char *value;
|
||||
} AVDictionaryEntry;
|
||||
|
||||
typedef struct AVDictionary AVDictionary;
|
||||
|
||||
/**
|
||||
* Get a dictionary entry with matching key.
|
||||
*
|
||||
* @param prev Set to the previous matching element to find the next.
|
||||
* If set to NULL the first matching element is returned.
|
||||
* @param flags Allows case as well as suffix-insensitive comparisons.
|
||||
* @return Found entry or NULL, changing key or value leads to undefined behavior.
|
||||
*/
|
||||
AVDictionaryEntry *
|
||||
av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
|
||||
|
||||
/**
|
||||
* Set the given entry in *pm, overwriting an existing entry.
|
||||
*
|
||||
* @param pm pointer to a pointer to a dictionary struct. If *pm is NULL
|
||||
* a dictionary struct is allocated and put in *pm.
|
||||
* @param key entry key to add to *pm (will be av_strduped depending on flags)
|
||||
* @param value entry value to add to *pm (will be av_strduped depending on flags).
|
||||
* Passing a NULL value will cause an existing tag to be deleted.
|
||||
* @return >= 0 on success otherwise an error code <0
|
||||
*/
|
||||
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags);
|
||||
|
||||
/**
|
||||
* Copy entries from one AVDictionary struct into another.
|
||||
* @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL,
|
||||
* this function will allocate a struct for you and put it in *dst
|
||||
* @param src pointer to source AVDictionary struct
|
||||
* @param flags flags to use when setting entries in *dst
|
||||
* @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
|
||||
*/
|
||||
void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags);
|
||||
|
||||
/**
|
||||
* Free all the memory allocated for an AVDictionary struct
|
||||
* and all keys and values.
|
||||
*/
|
||||
void av_dict_free(AVDictionary **m);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif // AVUTIL_DICT_H
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* error code definitions
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_ERROR_H
|
||||
#define AVUTIL_ERROR_H
|
||||
|
||||
#include <errno.h>
|
||||
#include "avutil.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_error
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/* error handling */
|
||||
#if EDOM > 0
|
||||
#define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions.
|
||||
#define AVUNERROR(e) (-(e)) ///< Returns a POSIX error code from a library function error return value.
|
||||
#else
|
||||
/* Some platforms have E* and errno already negated. */
|
||||
#define AVERROR(e) (e)
|
||||
#define AVUNERROR(e) (e)
|
||||
#endif
|
||||
|
||||
#define AVERROR_BSF_NOT_FOUND (-MKTAG(0xF8,'B','S','F')) ///< Bitstream filter not found
|
||||
#define AVERROR_DECODER_NOT_FOUND (-MKTAG(0xF8,'D','E','C')) ///< Decoder not found
|
||||
#define AVERROR_DEMUXER_NOT_FOUND (-MKTAG(0xF8,'D','E','M')) ///< Demuxer not found
|
||||
#define AVERROR_ENCODER_NOT_FOUND (-MKTAG(0xF8,'E','N','C')) ///< Encoder not found
|
||||
#define AVERROR_EOF (-MKTAG( 'E','O','F',' ')) ///< End of file
|
||||
#define AVERROR_EXIT (-MKTAG( 'E','X','I','T')) ///< Immediate exit was requested; the called function should not be restarted
|
||||
#define AVERROR_FILTER_NOT_FOUND (-MKTAG(0xF8,'F','I','L')) ///< Filter not found
|
||||
#define AVERROR_INVALIDDATA (-MKTAG( 'I','N','D','A')) ///< Invalid data found when processing input
|
||||
#define AVERROR_MUXER_NOT_FOUND (-MKTAG(0xF8,'M','U','X')) ///< Muxer not found
|
||||
#define AVERROR_OPTION_NOT_FOUND (-MKTAG(0xF8,'O','P','T')) ///< Option not found
|
||||
#define AVERROR_PATCHWELCOME (-MKTAG( 'P','A','W','E')) ///< Not yet implemented in Libav, patches welcome
|
||||
#define AVERROR_PROTOCOL_NOT_FOUND (-MKTAG(0xF8,'P','R','O')) ///< Protocol not found
|
||||
#define AVERROR_STREAM_NOT_FOUND (-MKTAG(0xF8,'S','T','R')) ///< Stream not found
|
||||
#define AVERROR_BUG (-MKTAG( 'B','U','G',' ')) ///< Bug detected, please report the issue
|
||||
#define AVERROR_UNKNOWN (-MKTAG( 'U','N','K','N')) ///< Unknown error, typically from an external library
|
||||
|
||||
/**
|
||||
* Put a description of the AVERROR code errnum in errbuf.
|
||||
* In case of failure the global variable errno is set to indicate the
|
||||
* error. Even in case of failure av_strerror() will print a generic
|
||||
* error message indicating the errnum provided to errbuf.
|
||||
*
|
||||
* @param errnum error code to describe
|
||||
* @param errbuf buffer to which description is written
|
||||
* @param errbuf_size the size in bytes of errbuf
|
||||
* @return 0 on success, a negative value if a description for errnum
|
||||
* cannot be found
|
||||
*/
|
||||
int av_strerror(int errnum, char *errbuf, size_t errbuf_size);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_ERROR_H */
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* Copyright (c) 2002 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* simple arithmetic expression evaluator
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_EVAL_H
|
||||
#define AVUTIL_EVAL_H
|
||||
|
||||
#include "avutil.h"
|
||||
|
||||
typedef struct AVExpr AVExpr;
|
||||
|
||||
/**
|
||||
* Parse and evaluate an expression.
|
||||
* Note, this is significantly slower than av_expr_eval().
|
||||
*
|
||||
* @param res a pointer to a double where is put the result value of
|
||||
* the expression, or NAN in case of error
|
||||
* @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
|
||||
* @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
|
||||
* @param const_values a zero terminated array of values for the identifiers from const_names
|
||||
* @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers
|
||||
* @param funcs1 NULL terminated array of function pointers for functions which take 1 argument
|
||||
* @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
|
||||
* @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
|
||||
* @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
|
||||
* @param log_ctx parent logging context
|
||||
* @return 0 in case of success, a negative value corresponding to an
|
||||
* AVERROR code otherwise
|
||||
*/
|
||||
int av_expr_parse_and_eval(double *res, const char *s,
|
||||
const char * const *const_names, const double *const_values,
|
||||
const char * const *func1_names, double (* const *funcs1)(void *, double),
|
||||
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
|
||||
void *opaque, int log_offset, void *log_ctx);
|
||||
|
||||
/**
|
||||
* Parse an expression.
|
||||
*
|
||||
* @param expr a pointer where is put an AVExpr containing the parsed
|
||||
* value in case of successful parsing, or NULL otherwise.
|
||||
* The pointed to AVExpr must be freed with av_expr_free() by the user
|
||||
* when it is not needed anymore.
|
||||
* @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
|
||||
* @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
|
||||
* @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers
|
||||
* @param funcs1 NULL terminated array of function pointers for functions which take 1 argument
|
||||
* @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
|
||||
* @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
|
||||
* @param log_ctx parent logging context
|
||||
* @return 0 in case of success, a negative value corresponding to an
|
||||
* AVERROR code otherwise
|
||||
*/
|
||||
int av_expr_parse(AVExpr **expr, const char *s,
|
||||
const char * const *const_names,
|
||||
const char * const *func1_names, double (* const *funcs1)(void *, double),
|
||||
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
|
||||
int log_offset, void *log_ctx);
|
||||
|
||||
/**
|
||||
* Evaluate a previously parsed expression.
|
||||
*
|
||||
* @param const_values a zero terminated array of values for the identifiers from av_expr_parse() const_names
|
||||
* @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
|
||||
* @return the value of the expression
|
||||
*/
|
||||
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque);
|
||||
|
||||
/**
|
||||
* Free a parsed expression previously created with av_expr_parse().
|
||||
*/
|
||||
void av_expr_free(AVExpr *e);
|
||||
|
||||
/**
|
||||
* Parse the string in numstr and return its value as a double. If
|
||||
* the string is empty, contains only whitespaces, or does not contain
|
||||
* an initial substring that has the expected syntax for a
|
||||
* floating-point number, no conversion is performed. In this case,
|
||||
* returns a value of zero and the value returned in tail is the value
|
||||
* of numstr.
|
||||
*
|
||||
* @param numstr a string representing a number, may contain one of
|
||||
* the International System number postfixes, for example 'K', 'M',
|
||||
* 'G'. If 'i' is appended after the postfix, powers of 2 are used
|
||||
* instead of powers of 10. The 'B' postfix multiplies the value for
|
||||
* 8, and can be appended after another postfix or used alone. This
|
||||
* allows using for example 'KB', 'MiB', 'G' and 'B' as postfix.
|
||||
* @param tail if non-NULL puts here the pointer to the char next
|
||||
* after the last parsed character
|
||||
*/
|
||||
double av_strtod(const char *numstr, char **tail);
|
||||
|
||||
#endif /* AVUTIL_EVAL_H */
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* a very simple circular buffer FIFO implementation
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_FIFO_H
|
||||
#define AVUTIL_FIFO_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "avutil.h"
|
||||
|
||||
typedef struct AVFifoBuffer {
|
||||
uint8_t *buffer;
|
||||
uint8_t *rptr, *wptr, *end;
|
||||
uint32_t rndx, wndx;
|
||||
} AVFifoBuffer;
|
||||
|
||||
/**
|
||||
* Initialize an AVFifoBuffer.
|
||||
* @param size of FIFO
|
||||
* @return AVFifoBuffer or NULL in case of memory allocation failure
|
||||
*/
|
||||
AVFifoBuffer *av_fifo_alloc(unsigned int size);
|
||||
|
||||
/**
|
||||
* Free an AVFifoBuffer.
|
||||
* @param f AVFifoBuffer to free
|
||||
*/
|
||||
void av_fifo_free(AVFifoBuffer *f);
|
||||
|
||||
/**
|
||||
* Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
|
||||
* @param f AVFifoBuffer to reset
|
||||
*/
|
||||
void av_fifo_reset(AVFifoBuffer *f);
|
||||
|
||||
/**
|
||||
* Return the amount of data in bytes in the AVFifoBuffer, that is the
|
||||
* amount of data you can read from it.
|
||||
* @param f AVFifoBuffer to read from
|
||||
* @return size
|
||||
*/
|
||||
int av_fifo_size(AVFifoBuffer *f);
|
||||
|
||||
/**
|
||||
* Return the amount of space in bytes in the AVFifoBuffer, that is the
|
||||
* amount of data you can write into it.
|
||||
* @param f AVFifoBuffer to write into
|
||||
* @return size
|
||||
*/
|
||||
int av_fifo_space(AVFifoBuffer *f);
|
||||
|
||||
/**
|
||||
* Feed data from an AVFifoBuffer to a user-supplied callback.
|
||||
* @param f AVFifoBuffer to read from
|
||||
* @param buf_size number of bytes to read
|
||||
* @param func generic read function
|
||||
* @param dest data destination
|
||||
*/
|
||||
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
|
||||
|
||||
/**
|
||||
* Feed data from a user-supplied callback to an AVFifoBuffer.
|
||||
* @param f AVFifoBuffer to write to
|
||||
* @param src data source; non-const since it may be used as a
|
||||
* modifiable context by the function defined in func
|
||||
* @param size number of bytes to write
|
||||
* @param func generic write function; the first parameter is src,
|
||||
* the second is dest_buf, the third is dest_buf_size.
|
||||
* func must return the number of bytes written to dest_buf, or <= 0 to
|
||||
* indicate no more data available to write.
|
||||
* If func is NULL, src is interpreted as a simple byte array for source data.
|
||||
* @return the number of bytes written to the FIFO
|
||||
*/
|
||||
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int));
|
||||
|
||||
/**
|
||||
* Resize an AVFifoBuffer.
|
||||
* @param f AVFifoBuffer to resize
|
||||
* @param size new AVFifoBuffer size in bytes
|
||||
* @return <0 for failure, >=0 otherwise
|
||||
*/
|
||||
int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size);
|
||||
|
||||
/**
|
||||
* Read and discard the specified amount of data from an AVFifoBuffer.
|
||||
* @param f AVFifoBuffer to read from
|
||||
* @param size amount of data to read in bytes
|
||||
*/
|
||||
void av_fifo_drain(AVFifoBuffer *f, int size);
|
||||
|
||||
/**
|
||||
* Return a pointer to the data stored in a FIFO buffer at a certain offset.
|
||||
* The FIFO buffer is not modified.
|
||||
*
|
||||
* @param f AVFifoBuffer to peek at, f must be non-NULL
|
||||
* @param offs an offset in bytes, its absolute value must be less
|
||||
* than the used buffer size or the returned pointer will
|
||||
* point outside to the buffer data.
|
||||
* The used buffer size can be checked with av_fifo_size().
|
||||
*/
|
||||
static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs)
|
||||
{
|
||||
uint8_t *ptr = f->rptr + offs;
|
||||
if (ptr >= f->end)
|
||||
ptr = f->buffer + (ptr - f->end);
|
||||
else if (ptr < f->buffer)
|
||||
ptr = f->end - (f->buffer - ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#if FF_API_AV_FIFO_PEEK
|
||||
/**
|
||||
* @deprecated Use av_fifo_peek2() instead.
|
||||
*/
|
||||
attribute_deprecated
|
||||
static inline uint8_t av_fifo_peek(AVFifoBuffer *f, int offs)
|
||||
{
|
||||
return *av_fifo_peek2(f, offs);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* AVUTIL_FIFO_H */
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_FILE_H
|
||||
#define AVUTIL_FILE_H
|
||||
|
||||
#include "avutil.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Misc file utilities.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Read the file with name filename, and put its content in a newly
|
||||
* allocated buffer or map it with mmap() when available.
|
||||
* In case of success set *bufptr to the read or mmapped buffer, and
|
||||
* *size to the size in bytes of the buffer in *bufptr.
|
||||
* The returned buffer must be released with av_file_unmap().
|
||||
*
|
||||
* @param log_offset loglevel offset used for logging
|
||||
* @param log_ctx context used for logging
|
||||
* @return a non negative number in case of success, a negative value
|
||||
* corresponding to an AVERROR error code in case of failure
|
||||
*/
|
||||
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
|
||||
int log_offset, void *log_ctx);
|
||||
|
||||
/**
|
||||
* Unmap or free the buffer bufptr created by av_file_map().
|
||||
*
|
||||
* @param size size in bytes of bufptr, must be the same as returned
|
||||
* by av_file_map()
|
||||
*/
|
||||
void av_file_unmap(uint8_t *bufptr, size_t size);
|
||||
|
||||
#endif /* AVUTIL_FILE_H */
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_IMGUTILS_H
|
||||
#define AVUTIL_IMGUTILS_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* misc image utilities
|
||||
*
|
||||
* @addtogroup lavu_picture
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "avutil.h"
|
||||
#include "pixdesc.h"
|
||||
|
||||
/**
|
||||
* Compute the max pixel step for each plane of an image with a
|
||||
* format described by pixdesc.
|
||||
*
|
||||
* The pixel step is the distance in bytes between the first byte of
|
||||
* the group of bytes which describe a pixel component and the first
|
||||
* byte of the successive group in the same plane for the same
|
||||
* component.
|
||||
*
|
||||
* @param max_pixsteps an array which is filled with the max pixel step
|
||||
* for each plane. Since a plane may contain different pixel
|
||||
* components, the computed max_pixsteps[plane] is relative to the
|
||||
* component in the plane with the max pixel step.
|
||||
* @param max_pixstep_comps an array which is filled with the component
|
||||
* for each plane which has the max pixel step. May be NULL.
|
||||
*/
|
||||
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
|
||||
const AVPixFmtDescriptor *pixdesc);
|
||||
|
||||
/**
|
||||
* Compute the size of an image line with format pix_fmt and width
|
||||
* width for the plane plane.
|
||||
*
|
||||
* @return the computed size in bytes
|
||||
*/
|
||||
int av_image_get_linesize(enum PixelFormat pix_fmt, int width, int plane);
|
||||
|
||||
/**
|
||||
* Fill plane linesizes for an image with pixel format pix_fmt and
|
||||
* width width.
|
||||
*
|
||||
* @param linesizes array to be filled with the linesize for each plane
|
||||
* @return >= 0 in case of success, a negative error code otherwise
|
||||
*/
|
||||
int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width);
|
||||
|
||||
/**
|
||||
* Fill plane data pointers for an image with pixel format pix_fmt and
|
||||
* height height.
|
||||
*
|
||||
* @param data pointers array to be filled with the pointer for each image plane
|
||||
* @param ptr the pointer to a buffer which will contain the image
|
||||
* @param linesizes the array containing the linesize for each
|
||||
* plane, should be filled by av_image_fill_linesizes()
|
||||
* @return the size in bytes required for the image buffer, a negative
|
||||
* error code in case of failure
|
||||
*/
|
||||
int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height,
|
||||
uint8_t *ptr, const int linesizes[4]);
|
||||
|
||||
/**
|
||||
* Allocate an image with size w and h and pixel format pix_fmt, and
|
||||
* fill pointers and linesizes accordingly.
|
||||
* The allocated image buffer has to be freed by using
|
||||
* av_freep(&pointers[0]).
|
||||
*
|
||||
* @param align the value to use for buffer size alignment
|
||||
* @return the size in bytes required for the image buffer, a negative
|
||||
* error code in case of failure
|
||||
*/
|
||||
int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
|
||||
int w, int h, enum PixelFormat pix_fmt, int align);
|
||||
|
||||
/**
|
||||
* Copy image plane from src to dst.
|
||||
* That is, copy "height" number of lines of "bytewidth" bytes each.
|
||||
* The first byte of each successive line is separated by *_linesize
|
||||
* bytes.
|
||||
*
|
||||
* @param dst_linesize linesize for the image plane in dst
|
||||
* @param src_linesize linesize for the image plane in src
|
||||
*/
|
||||
void av_image_copy_plane(uint8_t *dst, int dst_linesize,
|
||||
const uint8_t *src, int src_linesize,
|
||||
int bytewidth, int height);
|
||||
|
||||
/**
|
||||
* Copy image in src_data to dst_data.
|
||||
*
|
||||
* @param dst_linesizes linesizes for the image in dst_data
|
||||
* @param src_linesizes linesizes for the image in src_data
|
||||
*/
|
||||
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
|
||||
const uint8_t *src_data[4], const int src_linesizes[4],
|
||||
enum PixelFormat pix_fmt, int width, int height);
|
||||
|
||||
/**
|
||||
* Check if the given dimension of an image is valid, meaning that all
|
||||
* bytes of the image can be addressed with a signed int.
|
||||
*
|
||||
* @param w the width of the picture
|
||||
* @param h the height of the picture
|
||||
* @param log_offset the offset to sum to the log level for logging with log_ctx
|
||||
* @param log_ctx the parent logging context, it may be NULL
|
||||
* @return >= 0 if valid, a negative error code otherwise
|
||||
*/
|
||||
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
|
||||
|
||||
int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#endif /* AVUTIL_IMGUTILS_H */
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Mans Rullgard
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_INTFLOAT_H
|
||||
#define AVUTIL_INTFLOAT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "attributes.h"
|
||||
|
||||
union av_intfloat32 {
|
||||
uint32_t i;
|
||||
float f;
|
||||
};
|
||||
|
||||
union av_intfloat64 {
|
||||
uint64_t i;
|
||||
double f;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reinterpret a 32-bit integer as a float.
|
||||
*/
|
||||
static av_always_inline float av_int2float(uint32_t i)
|
||||
{
|
||||
union av_intfloat32 v = { .i = i };
|
||||
return v.f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reinterpret a float as a 32-bit integer.
|
||||
*/
|
||||
static av_always_inline uint32_t av_float2int(float f)
|
||||
{
|
||||
union av_intfloat32 v = { .f = f };
|
||||
return v.i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reinterpret a 64-bit integer as a double.
|
||||
*/
|
||||
static av_always_inline double av_int2double(uint64_t i)
|
||||
{
|
||||
union av_intfloat64 v = { .i = i };
|
||||
return v.f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reinterpret a double as a 64-bit integer.
|
||||
*/
|
||||
static av_always_inline uint64_t av_double2int(double f)
|
||||
{
|
||||
union av_intfloat64 v = { .f = f };
|
||||
return v.i;
|
||||
}
|
||||
|
||||
#endif /* AVUTIL_INTFLOAT_H */
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_INTFLOAT_READWRITE_H
|
||||
#define AVUTIL_INTFLOAT_READWRITE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "attributes.h"
|
||||
|
||||
/* IEEE 80 bits extended float */
|
||||
typedef struct AVExtFloat {
|
||||
uint8_t exponent[2];
|
||||
uint8_t mantissa[8];
|
||||
} AVExtFloat;
|
||||
|
||||
attribute_deprecated double av_int2dbl(int64_t v) av_const;
|
||||
attribute_deprecated float av_int2flt(int32_t v) av_const;
|
||||
attribute_deprecated double av_ext2dbl(const AVExtFloat ext) av_const;
|
||||
attribute_deprecated int64_t av_dbl2int(double d) av_const;
|
||||
attribute_deprecated int32_t av_flt2int(float d) av_const;
|
||||
attribute_deprecated AVExtFloat av_dbl2ext(double d) av_const;
|
||||
|
||||
#endif /* AVUTIL_INTFLOAT_READWRITE_H */
|
|
@ -0,0 +1,522 @@
|
|||
/*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_INTREADWRITE_H
|
||||
#define AVUTIL_INTREADWRITE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "libavutil/avconfig.h"
|
||||
#include "attributes.h"
|
||||
#include "bswap.h"
|
||||
|
||||
typedef union {
|
||||
uint64_t u64;
|
||||
uint32_t u32[2];
|
||||
uint16_t u16[4];
|
||||
uint8_t u8 [8];
|
||||
double f64;
|
||||
float f32[2];
|
||||
} av_alias av_alias64;
|
||||
|
||||
typedef union {
|
||||
uint32_t u32;
|
||||
uint16_t u16[2];
|
||||
uint8_t u8 [4];
|
||||
float f32;
|
||||
} av_alias av_alias32;
|
||||
|
||||
typedef union {
|
||||
uint16_t u16;
|
||||
uint8_t u8 [2];
|
||||
} av_alias av_alias16;
|
||||
|
||||
/*
|
||||
* Arch-specific headers can provide any combination of
|
||||
* AV_[RW][BLN](16|24|32|64) and AV_(COPY|SWAP|ZERO)(64|128) macros.
|
||||
* Preprocessor symbols must be defined, even if these are implemented
|
||||
* as inline functions.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if ARCH_ARM
|
||||
# include "arm/intreadwrite.h"
|
||||
#elif ARCH_AVR32
|
||||
# include "avr32/intreadwrite.h"
|
||||
#elif ARCH_MIPS
|
||||
# include "mips/intreadwrite.h"
|
||||
#elif ARCH_PPC
|
||||
# include "ppc/intreadwrite.h"
|
||||
#elif ARCH_TOMI
|
||||
# include "tomi/intreadwrite.h"
|
||||
#elif ARCH_X86
|
||||
# include "x86/intreadwrite.h"
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_AV_CONFIG_H */
|
||||
|
||||
/*
|
||||
* Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers.
|
||||
*/
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
|
||||
# if defined(AV_RN16) && !defined(AV_RB16)
|
||||
# define AV_RB16(p) AV_RN16(p)
|
||||
# elif !defined(AV_RN16) && defined(AV_RB16)
|
||||
# define AV_RN16(p) AV_RB16(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN16) && !defined(AV_WB16)
|
||||
# define AV_WB16(p, v) AV_WN16(p, v)
|
||||
# elif !defined(AV_WN16) && defined(AV_WB16)
|
||||
# define AV_WN16(p, v) AV_WB16(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN24) && !defined(AV_RB24)
|
||||
# define AV_RB24(p) AV_RN24(p)
|
||||
# elif !defined(AV_RN24) && defined(AV_RB24)
|
||||
# define AV_RN24(p) AV_RB24(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN24) && !defined(AV_WB24)
|
||||
# define AV_WB24(p, v) AV_WN24(p, v)
|
||||
# elif !defined(AV_WN24) && defined(AV_WB24)
|
||||
# define AV_WN24(p, v) AV_WB24(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN32) && !defined(AV_RB32)
|
||||
# define AV_RB32(p) AV_RN32(p)
|
||||
# elif !defined(AV_RN32) && defined(AV_RB32)
|
||||
# define AV_RN32(p) AV_RB32(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN32) && !defined(AV_WB32)
|
||||
# define AV_WB32(p, v) AV_WN32(p, v)
|
||||
# elif !defined(AV_WN32) && defined(AV_WB32)
|
||||
# define AV_WN32(p, v) AV_WB32(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN64) && !defined(AV_RB64)
|
||||
# define AV_RB64(p) AV_RN64(p)
|
||||
# elif !defined(AV_RN64) && defined(AV_RB64)
|
||||
# define AV_RN64(p) AV_RB64(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN64) && !defined(AV_WB64)
|
||||
# define AV_WB64(p, v) AV_WN64(p, v)
|
||||
# elif !defined(AV_WN64) && defined(AV_WB64)
|
||||
# define AV_WN64(p, v) AV_WB64(p, v)
|
||||
# endif
|
||||
|
||||
#else /* AV_HAVE_BIGENDIAN */
|
||||
|
||||
# if defined(AV_RN16) && !defined(AV_RL16)
|
||||
# define AV_RL16(p) AV_RN16(p)
|
||||
# elif !defined(AV_RN16) && defined(AV_RL16)
|
||||
# define AV_RN16(p) AV_RL16(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN16) && !defined(AV_WL16)
|
||||
# define AV_WL16(p, v) AV_WN16(p, v)
|
||||
# elif !defined(AV_WN16) && defined(AV_WL16)
|
||||
# define AV_WN16(p, v) AV_WL16(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN24) && !defined(AV_RL24)
|
||||
# define AV_RL24(p) AV_RN24(p)
|
||||
# elif !defined(AV_RN24) && defined(AV_RL24)
|
||||
# define AV_RN24(p) AV_RL24(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN24) && !defined(AV_WL24)
|
||||
# define AV_WL24(p, v) AV_WN24(p, v)
|
||||
# elif !defined(AV_WN24) && defined(AV_WL24)
|
||||
# define AV_WN24(p, v) AV_WL24(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN32) && !defined(AV_RL32)
|
||||
# define AV_RL32(p) AV_RN32(p)
|
||||
# elif !defined(AV_RN32) && defined(AV_RL32)
|
||||
# define AV_RN32(p) AV_RL32(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN32) && !defined(AV_WL32)
|
||||
# define AV_WL32(p, v) AV_WN32(p, v)
|
||||
# elif !defined(AV_WN32) && defined(AV_WL32)
|
||||
# define AV_WN32(p, v) AV_WL32(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN64) && !defined(AV_RL64)
|
||||
# define AV_RL64(p) AV_RN64(p)
|
||||
# elif !defined(AV_RN64) && defined(AV_RL64)
|
||||
# define AV_RN64(p) AV_RL64(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN64) && !defined(AV_WL64)
|
||||
# define AV_WL64(p, v) AV_WN64(p, v)
|
||||
# elif !defined(AV_WN64) && defined(AV_WL64)
|
||||
# define AV_WN64(p, v) AV_WL64(p, v)
|
||||
# endif
|
||||
|
||||
#endif /* !AV_HAVE_BIGENDIAN */
|
||||
|
||||
/*
|
||||
* Define AV_[RW]N helper macros to simplify definitions not provided
|
||||
* by per-arch headers.
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__) && !defined(__TI_COMPILER_VERSION__)
|
||||
|
||||
union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias;
|
||||
union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias;
|
||||
union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
|
||||
|
||||
# define AV_RN(s, p) (((const union unaligned_##s *) (p))->l)
|
||||
# define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v))
|
||||
|
||||
#elif defined(__DECC)
|
||||
|
||||
# define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p)))
|
||||
# define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v))
|
||||
|
||||
#elif AV_HAVE_FAST_UNALIGNED
|
||||
|
||||
# define AV_RN(s, p) (((const av_alias##s*)(p))->u##s)
|
||||
# define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v))
|
||||
|
||||
#else
|
||||
|
||||
#ifndef AV_RB16
|
||||
# define AV_RB16(x) \
|
||||
((((const uint8_t*)(x))[0] << 8) | \
|
||||
((const uint8_t*)(x))[1])
|
||||
#endif
|
||||
#ifndef AV_WB16
|
||||
# define AV_WB16(p, d) do { \
|
||||
((uint8_t*)(p))[1] = (d); \
|
||||
((uint8_t*)(p))[0] = (d)>>8; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL16
|
||||
# define AV_RL16(x) \
|
||||
((((const uint8_t*)(x))[1] << 8) | \
|
||||
((const uint8_t*)(x))[0])
|
||||
#endif
|
||||
#ifndef AV_WL16
|
||||
# define AV_WL16(p, d) do { \
|
||||
((uint8_t*)(p))[0] = (d); \
|
||||
((uint8_t*)(p))[1] = (d)>>8; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RB32
|
||||
# define AV_RB32(x) \
|
||||
(((uint32_t)((const uint8_t*)(x))[0] << 24) | \
|
||||
(((const uint8_t*)(x))[1] << 16) | \
|
||||
(((const uint8_t*)(x))[2] << 8) | \
|
||||
((const uint8_t*)(x))[3])
|
||||
#endif
|
||||
#ifndef AV_WB32
|
||||
# define AV_WB32(p, d) do { \
|
||||
((uint8_t*)(p))[3] = (d); \
|
||||
((uint8_t*)(p))[2] = (d)>>8; \
|
||||
((uint8_t*)(p))[1] = (d)>>16; \
|
||||
((uint8_t*)(p))[0] = (d)>>24; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL32
|
||||
# define AV_RL32(x) \
|
||||
(((uint32_t)((const uint8_t*)(x))[3] << 24) | \
|
||||
(((const uint8_t*)(x))[2] << 16) | \
|
||||
(((const uint8_t*)(x))[1] << 8) | \
|
||||
((const uint8_t*)(x))[0])
|
||||
#endif
|
||||
#ifndef AV_WL32
|
||||
# define AV_WL32(p, d) do { \
|
||||
((uint8_t*)(p))[0] = (d); \
|
||||
((uint8_t*)(p))[1] = (d)>>8; \
|
||||
((uint8_t*)(p))[2] = (d)>>16; \
|
||||
((uint8_t*)(p))[3] = (d)>>24; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RB64
|
||||
# define AV_RB64(x) \
|
||||
(((uint64_t)((const uint8_t*)(x))[0] << 56) | \
|
||||
((uint64_t)((const uint8_t*)(x))[1] << 48) | \
|
||||
((uint64_t)((const uint8_t*)(x))[2] << 40) | \
|
||||
((uint64_t)((const uint8_t*)(x))[3] << 32) | \
|
||||
((uint64_t)((const uint8_t*)(x))[4] << 24) | \
|
||||
((uint64_t)((const uint8_t*)(x))[5] << 16) | \
|
||||
((uint64_t)((const uint8_t*)(x))[6] << 8) | \
|
||||
(uint64_t)((const uint8_t*)(x))[7])
|
||||
#endif
|
||||
#ifndef AV_WB64
|
||||
# define AV_WB64(p, d) do { \
|
||||
((uint8_t*)(p))[7] = (d); \
|
||||
((uint8_t*)(p))[6] = (d)>>8; \
|
||||
((uint8_t*)(p))[5] = (d)>>16; \
|
||||
((uint8_t*)(p))[4] = (d)>>24; \
|
||||
((uint8_t*)(p))[3] = (d)>>32; \
|
||||
((uint8_t*)(p))[2] = (d)>>40; \
|
||||
((uint8_t*)(p))[1] = (d)>>48; \
|
||||
((uint8_t*)(p))[0] = (d)>>56; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL64
|
||||
# define AV_RL64(x) \
|
||||
(((uint64_t)((const uint8_t*)(x))[7] << 56) | \
|
||||
((uint64_t)((const uint8_t*)(x))[6] << 48) | \
|
||||
((uint64_t)((const uint8_t*)(x))[5] << 40) | \
|
||||
((uint64_t)((const uint8_t*)(x))[4] << 32) | \
|
||||
((uint64_t)((const uint8_t*)(x))[3] << 24) | \
|
||||
((uint64_t)((const uint8_t*)(x))[2] << 16) | \
|
||||
((uint64_t)((const uint8_t*)(x))[1] << 8) | \
|
||||
(uint64_t)((const uint8_t*)(x))[0])
|
||||
#endif
|
||||
#ifndef AV_WL64
|
||||
# define AV_WL64(p, d) do { \
|
||||
((uint8_t*)(p))[0] = (d); \
|
||||
((uint8_t*)(p))[1] = (d)>>8; \
|
||||
((uint8_t*)(p))[2] = (d)>>16; \
|
||||
((uint8_t*)(p))[3] = (d)>>24; \
|
||||
((uint8_t*)(p))[4] = (d)>>32; \
|
||||
((uint8_t*)(p))[5] = (d)>>40; \
|
||||
((uint8_t*)(p))[6] = (d)>>48; \
|
||||
((uint8_t*)(p))[7] = (d)>>56; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
# define AV_RN(s, p) AV_RB##s(p)
|
||||
# define AV_WN(s, p, v) AV_WB##s(p, v)
|
||||
#else
|
||||
# define AV_RN(s, p) AV_RL##s(p)
|
||||
# define AV_WN(s, p, v) AV_WL##s(p, v)
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_FAST_UNALIGNED */
|
||||
|
||||
#ifndef AV_RN16
|
||||
# define AV_RN16(p) AV_RN(16, p)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RN32
|
||||
# define AV_RN32(p) AV_RN(32, p)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RN64
|
||||
# define AV_RN64(p) AV_RN(64, p)
|
||||
#endif
|
||||
|
||||
#ifndef AV_WN16
|
||||
# define AV_WN16(p, v) AV_WN(16, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_WN32
|
||||
# define AV_WN32(p, v) AV_WN(32, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_WN64
|
||||
# define AV_WN64(p, v) AV_WN(64, p, v)
|
||||
#endif
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
# define AV_RB(s, p) AV_RN##s(p)
|
||||
# define AV_WB(s, p, v) AV_WN##s(p, v)
|
||||
# define AV_RL(s, p) av_bswap##s(AV_RN##s(p))
|
||||
# define AV_WL(s, p, v) AV_WN##s(p, av_bswap##s(v))
|
||||
#else
|
||||
# define AV_RB(s, p) av_bswap##s(AV_RN##s(p))
|
||||
# define AV_WB(s, p, v) AV_WN##s(p, av_bswap##s(v))
|
||||
# define AV_RL(s, p) AV_RN##s(p)
|
||||
# define AV_WL(s, p, v) AV_WN##s(p, v)
|
||||
#endif
|
||||
|
||||
#define AV_RB8(x) (((const uint8_t*)(x))[0])
|
||||
#define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0)
|
||||
|
||||
#define AV_RL8(x) AV_RB8(x)
|
||||
#define AV_WL8(p, d) AV_WB8(p, d)
|
||||
|
||||
#ifndef AV_RB16
|
||||
# define AV_RB16(p) AV_RB(16, p)
|
||||
#endif
|
||||
#ifndef AV_WB16
|
||||
# define AV_WB16(p, v) AV_WB(16, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL16
|
||||
# define AV_RL16(p) AV_RL(16, p)
|
||||
#endif
|
||||
#ifndef AV_WL16
|
||||
# define AV_WL16(p, v) AV_WL(16, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RB32
|
||||
# define AV_RB32(p) AV_RB(32, p)
|
||||
#endif
|
||||
#ifndef AV_WB32
|
||||
# define AV_WB32(p, v) AV_WB(32, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL32
|
||||
# define AV_RL32(p) AV_RL(32, p)
|
||||
#endif
|
||||
#ifndef AV_WL32
|
||||
# define AV_WL32(p, v) AV_WL(32, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RB64
|
||||
# define AV_RB64(p) AV_RB(64, p)
|
||||
#endif
|
||||
#ifndef AV_WB64
|
||||
# define AV_WB64(p, v) AV_WB(64, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL64
|
||||
# define AV_RL64(p) AV_RL(64, p)
|
||||
#endif
|
||||
#ifndef AV_WL64
|
||||
# define AV_WL64(p, v) AV_WL(64, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RB24
|
||||
# define AV_RB24(x) \
|
||||
((((const uint8_t*)(x))[0] << 16) | \
|
||||
(((const uint8_t*)(x))[1] << 8) | \
|
||||
((const uint8_t*)(x))[2])
|
||||
#endif
|
||||
#ifndef AV_WB24
|
||||
# define AV_WB24(p, d) do { \
|
||||
((uint8_t*)(p))[2] = (d); \
|
||||
((uint8_t*)(p))[1] = (d)>>8; \
|
||||
((uint8_t*)(p))[0] = (d)>>16; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL24
|
||||
# define AV_RL24(x) \
|
||||
((((const uint8_t*)(x))[2] << 16) | \
|
||||
(((const uint8_t*)(x))[1] << 8) | \
|
||||
((const uint8_t*)(x))[0])
|
||||
#endif
|
||||
#ifndef AV_WL24
|
||||
# define AV_WL24(p, d) do { \
|
||||
((uint8_t*)(p))[0] = (d); \
|
||||
((uint8_t*)(p))[1] = (d)>>8; \
|
||||
((uint8_t*)(p))[2] = (d)>>16; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The AV_[RW]NA macros access naturally aligned data
|
||||
* in a type-safe way.
|
||||
*/
|
||||
|
||||
#define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s)
|
||||
#define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v))
|
||||
|
||||
#ifndef AV_RN16A
|
||||
# define AV_RN16A(p) AV_RNA(16, p)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RN32A
|
||||
# define AV_RN32A(p) AV_RNA(32, p)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RN64A
|
||||
# define AV_RN64A(p) AV_RNA(64, p)
|
||||
#endif
|
||||
|
||||
#ifndef AV_WN16A
|
||||
# define AV_WN16A(p, v) AV_WNA(16, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_WN32A
|
||||
# define AV_WN32A(p, v) AV_WNA(32, p, v)
|
||||
#endif
|
||||
|
||||
#ifndef AV_WN64A
|
||||
# define AV_WN64A(p, v) AV_WNA(64, p, v)
|
||||
#endif
|
||||
|
||||
/* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be
|
||||
* naturally aligned. They may be implemented using MMX,
|
||||
* so emms_c() must be called before using any float code
|
||||
* afterwards.
|
||||
*/
|
||||
|
||||
#define AV_COPY(n, d, s) \
|
||||
(((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n)
|
||||
|
||||
#ifndef AV_COPY16
|
||||
# define AV_COPY16(d, s) AV_COPY(16, d, s)
|
||||
#endif
|
||||
|
||||
#ifndef AV_COPY32
|
||||
# define AV_COPY32(d, s) AV_COPY(32, d, s)
|
||||
#endif
|
||||
|
||||
#ifndef AV_COPY64
|
||||
# define AV_COPY64(d, s) AV_COPY(64, d, s)
|
||||
#endif
|
||||
|
||||
#ifndef AV_COPY128
|
||||
# define AV_COPY128(d, s) \
|
||||
do { \
|
||||
AV_COPY64(d, s); \
|
||||
AV_COPY64((char*)(d)+8, (char*)(s)+8); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b))
|
||||
|
||||
#ifndef AV_SWAP64
|
||||
# define AV_SWAP64(a, b) AV_SWAP(64, a, b)
|
||||
#endif
|
||||
|
||||
#define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0)
|
||||
|
||||
#ifndef AV_ZERO16
|
||||
# define AV_ZERO16(d) AV_ZERO(16, d)
|
||||
#endif
|
||||
|
||||
#ifndef AV_ZERO32
|
||||
# define AV_ZERO32(d) AV_ZERO(32, d)
|
||||
#endif
|
||||
|
||||
#ifndef AV_ZERO64
|
||||
# define AV_ZERO64(d) AV_ZERO(64, d)
|
||||
#endif
|
||||
|
||||
#ifndef AV_ZERO128
|
||||
# define AV_ZERO128(d) \
|
||||
do { \
|
||||
AV_ZERO64(d); \
|
||||
AV_ZERO64((char*)(d)+8); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#endif /* AVUTIL_INTREADWRITE_H */
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Lagged Fibonacci PRNG
|
||||
* Copyright (c) 2008 Michael Niedermayer
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_LFG_H
|
||||
#define AVUTIL_LFG_H
|
||||
|
||||
typedef struct {
|
||||
unsigned int state[64];
|
||||
int index;
|
||||
} AVLFG;
|
||||
|
||||
void av_lfg_init(AVLFG *c, unsigned int seed);
|
||||
|
||||
/**
|
||||
* Get the next random unsigned 32-bit number using an ALFG.
|
||||
*
|
||||
* Please also consider a simple LCG like state= state*1664525+1013904223,
|
||||
* it may be good enough and faster for your specific use case.
|
||||
*/
|
||||
static inline unsigned int av_lfg_get(AVLFG *c){
|
||||
c->state[c->index & 63] = c->state[(c->index-24) & 63] + c->state[(c->index-55) & 63];
|
||||
return c->state[c->index++ & 63];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next random unsigned 32-bit number using a MLFG.
|
||||
*
|
||||
* Please also consider av_lfg_get() above, it is faster.
|
||||
*/
|
||||
static inline unsigned int av_mlfg_get(AVLFG *c){
|
||||
unsigned int a= c->state[(c->index-55) & 63];
|
||||
unsigned int b= c->state[(c->index-24) & 63];
|
||||
return c->state[c->index++ & 63] = 2*a*b+a+b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next two numbers generated by a Box-Muller Gaussian
|
||||
* generator using the random numbers issued by lfg.
|
||||
*
|
||||
* @param out array where the two generated numbers are placed
|
||||
*/
|
||||
void av_bmg_get(AVLFG *lfg, double out[2]);
|
||||
|
||||
#endif /* AVUTIL_LFG_H */
|
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_LOG_H
|
||||
#define AVUTIL_LOG_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "avutil.h"
|
||||
#include "attributes.h"
|
||||
|
||||
/**
|
||||
* Describe the class of an AVClass context structure. That is an
|
||||
* arbitrary struct of which the first field is a pointer to an
|
||||
* AVClass struct (e.g. AVCodecContext, AVFormatContext etc.).
|
||||
*/
|
||||
typedef struct AVClass {
|
||||
/**
|
||||
* The name of the class; usually it is the same name as the
|
||||
* context structure type to which the AVClass is associated.
|
||||
*/
|
||||
const char* class_name;
|
||||
|
||||
/**
|
||||
* A pointer to a function which returns the name of a context
|
||||
* instance ctx associated with the class.
|
||||
*/
|
||||
const char* (*item_name)(void* ctx);
|
||||
|
||||
/**
|
||||
* a pointer to the first option specified in the class if any or NULL
|
||||
*
|
||||
* @see av_set_default_options()
|
||||
*/
|
||||
const struct AVOption *option;
|
||||
|
||||
/**
|
||||
* LIBAVUTIL_VERSION with which this structure was created.
|
||||
* This is used to allow fields to be added without requiring major
|
||||
* version bumps everywhere.
|
||||
*/
|
||||
|
||||
int version;
|
||||
|
||||
/**
|
||||
* Offset in the structure where log_level_offset is stored.
|
||||
* 0 means there is no such variable
|
||||
*/
|
||||
int log_level_offset_offset;
|
||||
|
||||
/**
|
||||
* Offset in the structure where a pointer to the parent context for loging is stored.
|
||||
* for example a decoder that uses eval.c could pass its AVCodecContext to eval as such
|
||||
* parent context. And a av_log() implementation could then display the parent context
|
||||
* can be NULL of course
|
||||
*/
|
||||
int parent_log_context_offset;
|
||||
|
||||
/**
|
||||
* Return next AVOptions-enabled child or NULL
|
||||
*/
|
||||
void* (*child_next)(void *obj, void *prev);
|
||||
|
||||
/**
|
||||
* Return an AVClass corresponding to next potential
|
||||
* AVOptions-enabled child.
|
||||
*
|
||||
* The difference between child_next and this is that
|
||||
* child_next iterates over _already existing_ objects, while
|
||||
* child_class_next iterates over _all possible_ children.
|
||||
*/
|
||||
const struct AVClass* (*child_class_next)(const struct AVClass *prev);
|
||||
} AVClass;
|
||||
|
||||
/* av_log API */
|
||||
|
||||
#define AV_LOG_QUIET -8
|
||||
|
||||
/**
|
||||
* Something went really wrong and we will crash now.
|
||||
*/
|
||||
#define AV_LOG_PANIC 0
|
||||
|
||||
/**
|
||||
* Something went wrong and recovery is not possible.
|
||||
* For example, no header was found for a format which depends
|
||||
* on headers or an illegal combination of parameters is used.
|
||||
*/
|
||||
#define AV_LOG_FATAL 8
|
||||
|
||||
/**
|
||||
* Something went wrong and cannot losslessly be recovered.
|
||||
* However, not all future data is affected.
|
||||
*/
|
||||
#define AV_LOG_ERROR 16
|
||||
|
||||
/**
|
||||
* Something somehow does not look correct. This may or may not
|
||||
* lead to problems. An example would be the use of '-vstrict -2'.
|
||||
*/
|
||||
#define AV_LOG_WARNING 24
|
||||
|
||||
#define AV_LOG_INFO 32
|
||||
#define AV_LOG_VERBOSE 40
|
||||
|
||||
/**
|
||||
* Stuff which is only useful for libav* developers.
|
||||
*/
|
||||
#define AV_LOG_DEBUG 48
|
||||
|
||||
/**
|
||||
* Send the specified message to the log if the level is less than or equal
|
||||
* to the current av_log_level. By default, all logging messages are sent to
|
||||
* stderr. This behavior can be altered by setting a different av_vlog callback
|
||||
* function.
|
||||
*
|
||||
* @param avcl A pointer to an arbitrary struct of which the first field is a
|
||||
* pointer to an AVClass struct.
|
||||
* @param level The importance level of the message, lower values signifying
|
||||
* higher importance.
|
||||
* @param fmt The format string (printf-compatible) that specifies how
|
||||
* subsequent arguments are converted to output.
|
||||
* @see av_vlog
|
||||
*/
|
||||
void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4);
|
||||
|
||||
void av_vlog(void *avcl, int level, const char *fmt, va_list);
|
||||
int av_log_get_level(void);
|
||||
void av_log_set_level(int);
|
||||
void av_log_set_callback(void (*)(void*, int, const char*, va_list));
|
||||
void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl);
|
||||
const char* av_default_item_name(void* ctx);
|
||||
|
||||
/**
|
||||
* av_dlog macros
|
||||
* Useful to print debug messages that shouldn't get compiled in normally.
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
# define av_dlog(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__)
|
||||
#else
|
||||
# define av_dlog(pctx, ...)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Skip repeated messages, this requires the user app to use av_log() instead of
|
||||
* (f)printf as the 2 would otherwise interfere and lead to
|
||||
* "Last message repeated x times" messages below (f)printf messages with some
|
||||
* bad luck.
|
||||
* Also to receive the last, "last repeated" line if any, the user app must
|
||||
* call av_log(NULL, AV_LOG_QUIET, ""); at the end
|
||||
*/
|
||||
#define AV_LOG_SKIP_REPEATED 1
|
||||
void av_log_set_flags(int arg);
|
||||
|
||||
#endif /* AVUTIL_LOG_H */
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* LZO 1x decompression
|
||||
* copyright (c) 2006 Reimar Doeffinger
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_LZO_H
|
||||
#define AVUTIL_LZO_H
|
||||
|
||||
/**
|
||||
* @defgroup lavu_lzo LZO
|
||||
* @ingroup lavu_crypto
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/** @name Error flags returned by av_lzo1x_decode
|
||||
* @{ */
|
||||
/// end of the input buffer reached before decoding finished
|
||||
#define AV_LZO_INPUT_DEPLETED 1
|
||||
/// decoded data did not fit into output buffer
|
||||
#define AV_LZO_OUTPUT_FULL 2
|
||||
/// a reference to previously decoded data was wrong
|
||||
#define AV_LZO_INVALID_BACKPTR 4
|
||||
/// a non-specific error in the compressed bitstream
|
||||
#define AV_LZO_ERROR 8
|
||||
/** @} */
|
||||
|
||||
#define AV_LZO_INPUT_PADDING 8
|
||||
#define AV_LZO_OUTPUT_PADDING 12
|
||||
|
||||
/**
|
||||
* @brief Decodes LZO 1x compressed data.
|
||||
* @param out output buffer
|
||||
* @param outlen size of output buffer, number of bytes left are returned here
|
||||
* @param in input buffer
|
||||
* @param inlen size of input buffer, number of bytes left are returned here
|
||||
* @return 0 on success, otherwise a combination of the error flags above
|
||||
*
|
||||
* Make sure all buffers are appropriately padded, in must provide
|
||||
* AV_LZO_INPUT_PADDING, out must provide AV_LZO_OUTPUT_PADDING additional bytes.
|
||||
*/
|
||||
int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen);
|
||||
|
||||
/**
|
||||
* @brief deliberately overlapping memcpy implementation
|
||||
* @param dst destination buffer; must be padded with 12 additional bytes
|
||||
* @param back how many bytes back we start (the initial size of the overlapping window)
|
||||
* @param cnt number of bytes to copy, must be >= 0
|
||||
*
|
||||
* cnt > back is valid, this will copy the bytes we just copied,
|
||||
* thus creating a repeating pattern with a period length of back.
|
||||
*/
|
||||
void av_memcpy_backptr(uint8_t *dst, int back, int cnt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_LZO_H */
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_MATHEMATICS_H
|
||||
#define AVUTIL_MATHEMATICS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include "attributes.h"
|
||||
#include "rational.h"
|
||||
|
||||
#ifndef M_E
|
||||
#define M_E 2.7182818284590452354 /* e */
|
||||
#endif
|
||||
#ifndef M_LN2
|
||||
#define M_LN2 0.69314718055994530942 /* log_e 2 */
|
||||
#endif
|
||||
#ifndef M_LN10
|
||||
#define M_LN10 2.30258509299404568402 /* log_e 10 */
|
||||
#endif
|
||||
#ifndef M_LOG2_10
|
||||
#define M_LOG2_10 3.32192809488736234787 /* log_2 10 */
|
||||
#endif
|
||||
#ifndef M_PHI
|
||||
#define M_PHI 1.61803398874989484820 /* phi / golden ratio */
|
||||
#endif
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 /* pi */
|
||||
#endif
|
||||
#ifndef M_SQRT1_2
|
||||
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
|
||||
#endif
|
||||
#ifndef M_SQRT2
|
||||
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
|
||||
#endif
|
||||
#ifndef NAN
|
||||
#define NAN (0.0/0.0)
|
||||
#endif
|
||||
#ifndef INFINITY
|
||||
#define INFINITY (1.0/0.0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_math
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
enum AVRounding {
|
||||
AV_ROUND_ZERO = 0, ///< Round toward zero.
|
||||
AV_ROUND_INF = 1, ///< Round away from zero.
|
||||
AV_ROUND_DOWN = 2, ///< Round toward -infinity.
|
||||
AV_ROUND_UP = 3, ///< Round toward +infinity.
|
||||
AV_ROUND_NEAR_INF = 5, ///< Round to nearest and halfway cases away from zero.
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the greatest common divisor of a and b.
|
||||
* If both a and b are 0 or either or both are <0 then behavior is
|
||||
* undefined.
|
||||
*/
|
||||
int64_t av_const av_gcd(int64_t a, int64_t b);
|
||||
|
||||
/**
|
||||
* Rescale a 64-bit integer with rounding to nearest.
|
||||
* A simple a*b/c isn't possible as it can overflow.
|
||||
*/
|
||||
int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const;
|
||||
|
||||
/**
|
||||
* Rescale a 64-bit integer with specified rounding.
|
||||
* A simple a*b/c isn't possible as it can overflow.
|
||||
*/
|
||||
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const;
|
||||
|
||||
/**
|
||||
* Rescale a 64-bit integer by 2 rational numbers.
|
||||
*/
|
||||
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const;
|
||||
|
||||
/**
|
||||
* Compare 2 timestamps each in its own timebases.
|
||||
* The result of the function is undefined if one of the timestamps
|
||||
* is outside the int64_t range when represented in the others timebase.
|
||||
* @return -1 if ts_a is before ts_b, 1 if ts_a is after ts_b or 0 if they represent the same position
|
||||
*/
|
||||
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b);
|
||||
|
||||
/**
|
||||
* Compare 2 integers modulo mod.
|
||||
* That is we compare integers a and b for which only the least
|
||||
* significant log2(mod) bits are known.
|
||||
*
|
||||
* @param mod must be a power of 2
|
||||
* @return a negative value if a is smaller than b
|
||||
* a positive value if a is greater than b
|
||||
* 0 if a equals b
|
||||
*/
|
||||
int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_MATHEMATICS_H */
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче