mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-21 00:59:22 +00:00
Remove gl
This commit is contained in:
commit
e56e21f5f7
123 changed files with 37895 additions and 0 deletions
87
index.html
Normal file
87
index.html
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<html>
|
||||
|
||||
<style>
|
||||
textarea {
|
||||
width: 60%;
|
||||
height: 50px;
|
||||
}
|
||||
</style>
|
||||
<div>
|
||||
<a href="https://github.com/poi5305/go-yuv2webRTC">https://github.com/poi5305/go-yuv2webRTC</a>
|
||||
<br />
|
||||
<a href="https://github.com/pions/webrtc/tree/v1.2.0/examples/gstreamer-send/jsfiddle">https://github.com/pions/webrtc/tree/v1.2.0/examples/gstreamer-send/jsfiddle</a>
|
||||
</div>
|
||||
|
||||
<div id="remoteVideos"></div> <br />
|
||||
Browser base64 Session Description <br /><textarea id="localSessionDescription" readonly="true"></textarea> <br />
|
||||
|
||||
Golang base64 Session Description: <br /><textarea id="remoteSessionDescription"> </textarea> <br/>
|
||||
|
||||
<button onclick="window.startSession()"> Start Session </button>
|
||||
<div id="div"></div>
|
||||
|
||||
<div>
|
||||
Refresh to retry
|
||||
</div>
|
||||
<script>
|
||||
function postSession(session) {
|
||||
if (session == "") {
|
||||
return;
|
||||
}
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
document.getElementById('remoteSessionDescription').value = this.responseText;
|
||||
}
|
||||
};
|
||||
xhttp.open("POST", "/session", true);
|
||||
xhttp.setRequestHeader("Content-type", "text/plain");
|
||||
xhttp.send(session);
|
||||
}
|
||||
|
||||
let pc = new RTCPeerConnection({
|
||||
iceServers: [
|
||||
{
|
||||
urls: 'stun:stun.l.google.com:19302'
|
||||
}
|
||||
]
|
||||
})
|
||||
let log = msg => {
|
||||
document.getElementById('div').innerHTML += msg + '<br>'
|
||||
}
|
||||
|
||||
pc.ontrack = function (event) {
|
||||
var el = document.createElement(event.track.kind)
|
||||
el.srcObject = event.streams[0]
|
||||
el.autoplay = true
|
||||
el.controls = true
|
||||
|
||||
document.getElementById('remoteVideos').appendChild(el)
|
||||
}
|
||||
|
||||
pc.oniceconnectionstatechange = e => log(pc.iceConnectionState)
|
||||
pc.onicecandidate = event => {
|
||||
if (event.candidate === null) {
|
||||
var session = btoa(JSON.stringify(pc.localDescription));
|
||||
document.getElementById('localSessionDescription').value = session;
|
||||
postSession(session)
|
||||
}
|
||||
}
|
||||
|
||||
pc.createOffer({offerToReceiveVideo: true, offerToReceiveAudio: true}).then(d => pc.setLocalDescription(d)).catch(log)
|
||||
|
||||
window.startSession = () => {
|
||||
let sd = document.getElementById('remoteSessionDescription').value
|
||||
if (sd === '') {
|
||||
return alert('Session Description must not be empty')
|
||||
}
|
||||
|
||||
try {
|
||||
pc.setRemoteDescription(new RTCSessionDescription(JSON.parse(atob(sd))))
|
||||
} catch (e) {
|
||||
alert(e)
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</html>
|
||||
85
main.go
Normal file
85
main.go
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/giongto35/game-online/ui"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/poi5305/go-yuv2webRTC/screenshot"
|
||||
"github.com/poi5305/go-yuv2webRTC/webrtc"
|
||||
)
|
||||
|
||||
var webRTC *webrtc.WebRTC
|
||||
var width = 800
|
||||
var height = 600
|
||||
|
||||
func init() {
|
||||
webRTC = webrtc.NewWebRTC()
|
||||
director := ui.NewDirector()
|
||||
director.Start("games/supermariobros.rom")
|
||||
// start screenshot loop, wait for connection
|
||||
go screenshotLoop(director.GetImageChannel())
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("http://localhost:8000")
|
||||
|
||||
router := mux.NewRouter()
|
||||
router.HandleFunc("/", getWeb).Methods("GET")
|
||||
router.HandleFunc("/session", postSession).Methods("POST")
|
||||
|
||||
http.ListenAndServe(":8000", router)
|
||||
|
||||
}
|
||||
|
||||
func getWeb(w http.ResponseWriter, r *http.Request) {
|
||||
bs, err := ioutil.ReadFile("./index.html")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
w.Write(bs)
|
||||
}
|
||||
|
||||
func postSession(w http.ResponseWriter, r *http.Request) {
|
||||
bs, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
r.Body.Close()
|
||||
|
||||
localSession, err := webRTC.StartClient(string(bs), width, height)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
w.Write([]byte(localSession))
|
||||
}
|
||||
|
||||
func randomImage(width, height int) *image.RGBA {
|
||||
img := image.NewRGBA(image.Rectangle{image.Point{0, 0}, image.Point{width, height}})
|
||||
for x := 0; x < width; x++ {
|
||||
for y := 0; y < height; y++ {
|
||||
img.Set(x, y, color.RGBA{uint8(rand.Int31n(0xff)), uint8(rand.Int31n(0xff)), uint8(rand.Int31n(0xff)), 0xff - 1})
|
||||
}
|
||||
}
|
||||
|
||||
return img
|
||||
}
|
||||
|
||||
func screenshotLoop(imageChannel chan *image.RGBA) {
|
||||
for image := range imageChannel {
|
||||
if webRTC.IsConnected() {
|
||||
//rgbaImg := randomImage(width, height)
|
||||
yuv := screenshot.RgbaToYuv(image)
|
||||
webRTC.ImageChannel <- yuv
|
||||
}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
9
mario_main.go
Normal file
9
mario_main.go
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/giongto35/game-online/ui"
|
||||
)
|
||||
|
||||
func startGame(path string) {
|
||||
ui.Run(path)
|
||||
}
|
||||
862
nes/apu.go
Normal file
862
nes/apu.go
Normal file
|
|
@ -0,0 +1,862 @@
|
|||
package nes
|
||||
|
||||
import "encoding/gob"
|
||||
|
||||
const frameCounterRate = CPUFrequency / 240.0
|
||||
|
||||
var lengthTable = []byte{
|
||||
10, 254, 20, 2, 40, 4, 80, 6, 160, 8, 60, 10, 14, 12, 26, 14,
|
||||
12, 16, 24, 18, 48, 20, 96, 22, 192, 24, 72, 26, 16, 28, 32, 30,
|
||||
}
|
||||
|
||||
var dutyTable = [][]byte{
|
||||
{0, 1, 0, 0, 0, 0, 0, 0},
|
||||
{0, 1, 1, 0, 0, 0, 0, 0},
|
||||
{0, 1, 1, 1, 1, 0, 0, 0},
|
||||
{1, 0, 0, 1, 1, 1, 1, 1},
|
||||
}
|
||||
|
||||
var triangleTable = []byte{
|
||||
15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
}
|
||||
|
||||
var noiseTable = []uint16{
|
||||
4, 8, 16, 32, 64, 96, 128, 160, 202, 254, 380, 508, 762, 1016, 2034, 4068,
|
||||
}
|
||||
|
||||
var dmcTable = []byte{
|
||||
214, 190, 170, 160, 143, 127, 113, 107, 95, 80, 71, 64, 53, 42, 36, 27,
|
||||
}
|
||||
|
||||
var pulseTable [31]float32
|
||||
var tndTable [203]float32
|
||||
|
||||
func init() {
|
||||
for i := 0; i < 31; i++ {
|
||||
pulseTable[i] = 95.52 / (8128.0/float32(i) + 100)
|
||||
}
|
||||
for i := 0; i < 203; i++ {
|
||||
tndTable[i] = 163.67 / (24329.0/float32(i) + 100)
|
||||
}
|
||||
}
|
||||
|
||||
// APU
|
||||
|
||||
type APU struct {
|
||||
console *Console
|
||||
channel chan float32
|
||||
sampleRate float64
|
||||
pulse1 Pulse
|
||||
pulse2 Pulse
|
||||
triangle Triangle
|
||||
noise Noise
|
||||
dmc DMC
|
||||
cycle uint64
|
||||
framePeriod byte
|
||||
frameValue byte
|
||||
frameIRQ bool
|
||||
filterChain FilterChain
|
||||
}
|
||||
|
||||
func NewAPU(console *Console) *APU {
|
||||
apu := APU{}
|
||||
apu.console = console
|
||||
apu.noise.shiftRegister = 1
|
||||
apu.pulse1.channel = 1
|
||||
apu.pulse2.channel = 2
|
||||
apu.dmc.cpu = console.CPU
|
||||
return &apu
|
||||
}
|
||||
|
||||
func (apu *APU) Save(encoder *gob.Encoder) error {
|
||||
encoder.Encode(apu.cycle)
|
||||
encoder.Encode(apu.framePeriod)
|
||||
encoder.Encode(apu.frameValue)
|
||||
encoder.Encode(apu.frameIRQ)
|
||||
apu.pulse1.Save(encoder)
|
||||
apu.pulse2.Save(encoder)
|
||||
apu.triangle.Save(encoder)
|
||||
apu.noise.Save(encoder)
|
||||
apu.dmc.Save(encoder)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (apu *APU) Load(decoder *gob.Decoder) error {
|
||||
decoder.Decode(&apu.cycle)
|
||||
decoder.Decode(&apu.framePeriod)
|
||||
decoder.Decode(&apu.frameValue)
|
||||
decoder.Decode(&apu.frameIRQ)
|
||||
apu.pulse1.Load(decoder)
|
||||
apu.pulse2.Load(decoder)
|
||||
apu.triangle.Load(decoder)
|
||||
apu.noise.Load(decoder)
|
||||
apu.dmc.Load(decoder)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (apu *APU) Step() {
|
||||
cycle1 := apu.cycle
|
||||
apu.cycle++
|
||||
cycle2 := apu.cycle
|
||||
apu.stepTimer()
|
||||
f1 := int(float64(cycle1) / frameCounterRate)
|
||||
f2 := int(float64(cycle2) / frameCounterRate)
|
||||
if f1 != f2 {
|
||||
apu.stepFrameCounter()
|
||||
}
|
||||
s1 := int(float64(cycle1) / apu.sampleRate)
|
||||
s2 := int(float64(cycle2) / apu.sampleRate)
|
||||
if s1 != s2 {
|
||||
apu.sendSample()
|
||||
}
|
||||
}
|
||||
|
||||
func (apu *APU) sendSample() {
|
||||
output := apu.filterChain.Step(apu.output())
|
||||
select {
|
||||
case apu.channel <- output:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
func (apu *APU) output() float32 {
|
||||
p1 := apu.pulse1.output()
|
||||
p2 := apu.pulse2.output()
|
||||
t := apu.triangle.output()
|
||||
n := apu.noise.output()
|
||||
d := apu.dmc.output()
|
||||
pulseOut := pulseTable[p1+p2]
|
||||
tndOut := tndTable[3*t+2*n+d]
|
||||
return pulseOut + tndOut
|
||||
}
|
||||
|
||||
// mode 0: mode 1: function
|
||||
// --------- ----------- -----------------------------
|
||||
// - - - f - - - - - IRQ (if bit 6 is clear)
|
||||
// - l - l l - l - - Length counter and sweep
|
||||
// e e e e e e e e - Envelope and linear counter
|
||||
func (apu *APU) stepFrameCounter() {
|
||||
switch apu.framePeriod {
|
||||
case 4:
|
||||
apu.frameValue = (apu.frameValue + 1) % 4
|
||||
switch apu.frameValue {
|
||||
case 0, 2:
|
||||
apu.stepEnvelope()
|
||||
case 1:
|
||||
apu.stepEnvelope()
|
||||
apu.stepSweep()
|
||||
apu.stepLength()
|
||||
case 3:
|
||||
apu.stepEnvelope()
|
||||
apu.stepSweep()
|
||||
apu.stepLength()
|
||||
apu.fireIRQ()
|
||||
}
|
||||
case 5:
|
||||
apu.frameValue = (apu.frameValue + 1) % 5
|
||||
switch apu.frameValue {
|
||||
case 0, 2:
|
||||
apu.stepEnvelope()
|
||||
case 1, 3:
|
||||
apu.stepEnvelope()
|
||||
apu.stepSweep()
|
||||
apu.stepLength()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (apu *APU) stepTimer() {
|
||||
if apu.cycle%2 == 0 {
|
||||
apu.pulse1.stepTimer()
|
||||
apu.pulse2.stepTimer()
|
||||
apu.noise.stepTimer()
|
||||
apu.dmc.stepTimer()
|
||||
}
|
||||
apu.triangle.stepTimer()
|
||||
}
|
||||
|
||||
func (apu *APU) stepEnvelope() {
|
||||
apu.pulse1.stepEnvelope()
|
||||
apu.pulse2.stepEnvelope()
|
||||
apu.triangle.stepCounter()
|
||||
apu.noise.stepEnvelope()
|
||||
}
|
||||
|
||||
func (apu *APU) stepSweep() {
|
||||
apu.pulse1.stepSweep()
|
||||
apu.pulse2.stepSweep()
|
||||
}
|
||||
|
||||
func (apu *APU) stepLength() {
|
||||
apu.pulse1.stepLength()
|
||||
apu.pulse2.stepLength()
|
||||
apu.triangle.stepLength()
|
||||
apu.noise.stepLength()
|
||||
}
|
||||
|
||||
func (apu *APU) fireIRQ() {
|
||||
if apu.frameIRQ {
|
||||
apu.console.CPU.triggerIRQ()
|
||||
}
|
||||
}
|
||||
|
||||
func (apu *APU) readRegister(address uint16) byte {
|
||||
switch address {
|
||||
case 0x4015:
|
||||
return apu.readStatus()
|
||||
// default:
|
||||
// log.Fatalf("unhandled apu register read at address: 0x%04X", address)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (apu *APU) writeRegister(address uint16, value byte) {
|
||||
switch address {
|
||||
case 0x4000:
|
||||
apu.pulse1.writeControl(value)
|
||||
case 0x4001:
|
||||
apu.pulse1.writeSweep(value)
|
||||
case 0x4002:
|
||||
apu.pulse1.writeTimerLow(value)
|
||||
case 0x4003:
|
||||
apu.pulse1.writeTimerHigh(value)
|
||||
case 0x4004:
|
||||
apu.pulse2.writeControl(value)
|
||||
case 0x4005:
|
||||
apu.pulse2.writeSweep(value)
|
||||
case 0x4006:
|
||||
apu.pulse2.writeTimerLow(value)
|
||||
case 0x4007:
|
||||
apu.pulse2.writeTimerHigh(value)
|
||||
case 0x4008:
|
||||
apu.triangle.writeControl(value)
|
||||
case 0x4009:
|
||||
case 0x4010:
|
||||
apu.dmc.writeControl(value)
|
||||
case 0x4011:
|
||||
apu.dmc.writeValue(value)
|
||||
case 0x4012:
|
||||
apu.dmc.writeAddress(value)
|
||||
case 0x4013:
|
||||
apu.dmc.writeLength(value)
|
||||
case 0x400A:
|
||||
apu.triangle.writeTimerLow(value)
|
||||
case 0x400B:
|
||||
apu.triangle.writeTimerHigh(value)
|
||||
case 0x400C:
|
||||
apu.noise.writeControl(value)
|
||||
case 0x400D:
|
||||
case 0x400E:
|
||||
apu.noise.writePeriod(value)
|
||||
case 0x400F:
|
||||
apu.noise.writeLength(value)
|
||||
case 0x4015:
|
||||
apu.writeControl(value)
|
||||
case 0x4017:
|
||||
apu.writeFrameCounter(value)
|
||||
// default:
|
||||
// log.Fatalf("unhandled apu register write at address: 0x%04X", address)
|
||||
}
|
||||
}
|
||||
|
||||
func (apu *APU) readStatus() byte {
|
||||
var result byte
|
||||
if apu.pulse1.lengthValue > 0 {
|
||||
result |= 1
|
||||
}
|
||||
if apu.pulse2.lengthValue > 0 {
|
||||
result |= 2
|
||||
}
|
||||
if apu.triangle.lengthValue > 0 {
|
||||
result |= 4
|
||||
}
|
||||
if apu.noise.lengthValue > 0 {
|
||||
result |= 8
|
||||
}
|
||||
if apu.dmc.currentLength > 0 {
|
||||
result |= 16
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (apu *APU) writeControl(value byte) {
|
||||
apu.pulse1.enabled = value&1 == 1
|
||||
apu.pulse2.enabled = value&2 == 2
|
||||
apu.triangle.enabled = value&4 == 4
|
||||
apu.noise.enabled = value&8 == 8
|
||||
apu.dmc.enabled = value&16 == 16
|
||||
if !apu.pulse1.enabled {
|
||||
apu.pulse1.lengthValue = 0
|
||||
}
|
||||
if !apu.pulse2.enabled {
|
||||
apu.pulse2.lengthValue = 0
|
||||
}
|
||||
if !apu.triangle.enabled {
|
||||
apu.triangle.lengthValue = 0
|
||||
}
|
||||
if !apu.noise.enabled {
|
||||
apu.noise.lengthValue = 0
|
||||
}
|
||||
if !apu.dmc.enabled {
|
||||
apu.dmc.currentLength = 0
|
||||
} else {
|
||||
if apu.dmc.currentLength == 0 {
|
||||
apu.dmc.restart()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (apu *APU) writeFrameCounter(value byte) {
|
||||
apu.framePeriod = 4 + (value>>7)&1
|
||||
apu.frameIRQ = (value>>6)&1 == 0
|
||||
// apu.frameValue = 0
|
||||
if apu.framePeriod == 5 {
|
||||
apu.stepEnvelope()
|
||||
apu.stepSweep()
|
||||
apu.stepLength()
|
||||
}
|
||||
}
|
||||
|
||||
// Pulse
|
||||
|
||||
type Pulse struct {
|
||||
enabled bool
|
||||
channel byte
|
||||
lengthEnabled bool
|
||||
lengthValue byte
|
||||
timerPeriod uint16
|
||||
timerValue uint16
|
||||
dutyMode byte
|
||||
dutyValue byte
|
||||
sweepReload bool
|
||||
sweepEnabled bool
|
||||
sweepNegate bool
|
||||
sweepShift byte
|
||||
sweepPeriod byte
|
||||
sweepValue byte
|
||||
envelopeEnabled bool
|
||||
envelopeLoop bool
|
||||
envelopeStart bool
|
||||
envelopePeriod byte
|
||||
envelopeValue byte
|
||||
envelopeVolume byte
|
||||
constantVolume byte
|
||||
}
|
||||
|
||||
func (p *Pulse) Save(encoder *gob.Encoder) error {
|
||||
encoder.Encode(p.enabled)
|
||||
encoder.Encode(p.channel)
|
||||
encoder.Encode(p.lengthEnabled)
|
||||
encoder.Encode(p.lengthValue)
|
||||
encoder.Encode(p.timerPeriod)
|
||||
encoder.Encode(p.timerValue)
|
||||
encoder.Encode(p.dutyMode)
|
||||
encoder.Encode(p.dutyValue)
|
||||
encoder.Encode(p.sweepReload)
|
||||
encoder.Encode(p.sweepEnabled)
|
||||
encoder.Encode(p.sweepNegate)
|
||||
encoder.Encode(p.sweepShift)
|
||||
encoder.Encode(p.sweepPeriod)
|
||||
encoder.Encode(p.sweepValue)
|
||||
encoder.Encode(p.envelopeEnabled)
|
||||
encoder.Encode(p.envelopeLoop)
|
||||
encoder.Encode(p.envelopeStart)
|
||||
encoder.Encode(p.envelopePeriod)
|
||||
encoder.Encode(p.envelopeValue)
|
||||
encoder.Encode(p.envelopeVolume)
|
||||
encoder.Encode(p.constantVolume)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Pulse) Load(decoder *gob.Decoder) error {
|
||||
decoder.Decode(&p.enabled)
|
||||
decoder.Decode(&p.channel)
|
||||
decoder.Decode(&p.lengthEnabled)
|
||||
decoder.Decode(&p.lengthValue)
|
||||
decoder.Decode(&p.timerPeriod)
|
||||
decoder.Decode(&p.timerValue)
|
||||
decoder.Decode(&p.dutyMode)
|
||||
decoder.Decode(&p.dutyValue)
|
||||
decoder.Decode(&p.sweepReload)
|
||||
decoder.Decode(&p.sweepEnabled)
|
||||
decoder.Decode(&p.sweepNegate)
|
||||
decoder.Decode(&p.sweepShift)
|
||||
decoder.Decode(&p.sweepPeriod)
|
||||
decoder.Decode(&p.sweepValue)
|
||||
decoder.Decode(&p.envelopeEnabled)
|
||||
decoder.Decode(&p.envelopeLoop)
|
||||
decoder.Decode(&p.envelopeStart)
|
||||
decoder.Decode(&p.envelopePeriod)
|
||||
decoder.Decode(&p.envelopeValue)
|
||||
decoder.Decode(&p.envelopeVolume)
|
||||
decoder.Decode(&p.constantVolume)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Pulse) writeControl(value byte) {
|
||||
p.dutyMode = (value >> 6) & 3
|
||||
p.lengthEnabled = (value>>5)&1 == 0
|
||||
p.envelopeLoop = (value>>5)&1 == 1
|
||||
p.envelopeEnabled = (value>>4)&1 == 0
|
||||
p.envelopePeriod = value & 15
|
||||
p.constantVolume = value & 15
|
||||
p.envelopeStart = true
|
||||
}
|
||||
|
||||
func (p *Pulse) writeSweep(value byte) {
|
||||
p.sweepEnabled = (value>>7)&1 == 1
|
||||
p.sweepPeriod = (value>>4)&7 + 1
|
||||
p.sweepNegate = (value>>3)&1 == 1
|
||||
p.sweepShift = value & 7
|
||||
p.sweepReload = true
|
||||
}
|
||||
|
||||
func (p *Pulse) writeTimerLow(value byte) {
|
||||
p.timerPeriod = (p.timerPeriod & 0xFF00) | uint16(value)
|
||||
}
|
||||
|
||||
func (p *Pulse) writeTimerHigh(value byte) {
|
||||
p.lengthValue = lengthTable[value>>3]
|
||||
p.timerPeriod = (p.timerPeriod & 0x00FF) | (uint16(value&7) << 8)
|
||||
p.envelopeStart = true
|
||||
p.dutyValue = 0
|
||||
}
|
||||
|
||||
func (p *Pulse) stepTimer() {
|
||||
if p.timerValue == 0 {
|
||||
p.timerValue = p.timerPeriod
|
||||
p.dutyValue = (p.dutyValue + 1) % 8
|
||||
} else {
|
||||
p.timerValue--
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Pulse) stepEnvelope() {
|
||||
if p.envelopeStart {
|
||||
p.envelopeVolume = 15
|
||||
p.envelopeValue = p.envelopePeriod
|
||||
p.envelopeStart = false
|
||||
} else if p.envelopeValue > 0 {
|
||||
p.envelopeValue--
|
||||
} else {
|
||||
if p.envelopeVolume > 0 {
|
||||
p.envelopeVolume--
|
||||
} else if p.envelopeLoop {
|
||||
p.envelopeVolume = 15
|
||||
}
|
||||
p.envelopeValue = p.envelopePeriod
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Pulse) stepSweep() {
|
||||
if p.sweepReload {
|
||||
if p.sweepEnabled && p.sweepValue == 0 {
|
||||
p.sweep()
|
||||
}
|
||||
p.sweepValue = p.sweepPeriod
|
||||
p.sweepReload = false
|
||||
} else if p.sweepValue > 0 {
|
||||
p.sweepValue--
|
||||
} else {
|
||||
if p.sweepEnabled {
|
||||
p.sweep()
|
||||
}
|
||||
p.sweepValue = p.sweepPeriod
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Pulse) stepLength() {
|
||||
if p.lengthEnabled && p.lengthValue > 0 {
|
||||
p.lengthValue--
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Pulse) sweep() {
|
||||
delta := p.timerPeriod >> p.sweepShift
|
||||
if p.sweepNegate {
|
||||
p.timerPeriod -= delta
|
||||
if p.channel == 1 {
|
||||
p.timerPeriod--
|
||||
}
|
||||
} else {
|
||||
p.timerPeriod += delta
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Pulse) output() byte {
|
||||
if !p.enabled {
|
||||
return 0
|
||||
}
|
||||
if p.lengthValue == 0 {
|
||||
return 0
|
||||
}
|
||||
if dutyTable[p.dutyMode][p.dutyValue] == 0 {
|
||||
return 0
|
||||
}
|
||||
if p.timerPeriod < 8 || p.timerPeriod > 0x7FF {
|
||||
return 0
|
||||
}
|
||||
// if !p.sweepNegate && p.timerPeriod+(p.timerPeriod>>p.sweepShift) > 0x7FF {
|
||||
// return 0
|
||||
// }
|
||||
if p.envelopeEnabled {
|
||||
return p.envelopeVolume
|
||||
} else {
|
||||
return p.constantVolume
|
||||
}
|
||||
}
|
||||
|
||||
// Triangle
|
||||
|
||||
type Triangle struct {
|
||||
enabled bool
|
||||
lengthEnabled bool
|
||||
lengthValue byte
|
||||
timerPeriod uint16
|
||||
timerValue uint16
|
||||
dutyValue byte
|
||||
counterPeriod byte
|
||||
counterValue byte
|
||||
counterReload bool
|
||||
}
|
||||
|
||||
func (t *Triangle) Save(encoder *gob.Encoder) error {
|
||||
encoder.Encode(t.enabled)
|
||||
encoder.Encode(t.lengthEnabled)
|
||||
encoder.Encode(t.lengthValue)
|
||||
encoder.Encode(t.timerPeriod)
|
||||
encoder.Encode(t.timerValue)
|
||||
encoder.Encode(t.dutyValue)
|
||||
encoder.Encode(t.counterPeriod)
|
||||
encoder.Encode(t.counterValue)
|
||||
encoder.Encode(t.counterReload)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *Triangle) Load(decoder *gob.Decoder) error {
|
||||
decoder.Decode(&t.enabled)
|
||||
decoder.Decode(&t.lengthEnabled)
|
||||
decoder.Decode(&t.lengthValue)
|
||||
decoder.Decode(&t.timerPeriod)
|
||||
decoder.Decode(&t.timerValue)
|
||||
decoder.Decode(&t.dutyValue)
|
||||
decoder.Decode(&t.counterPeriod)
|
||||
decoder.Decode(&t.counterValue)
|
||||
decoder.Decode(&t.counterReload)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *Triangle) writeControl(value byte) {
|
||||
t.lengthEnabled = (value>>7)&1 == 0
|
||||
t.counterPeriod = value & 0x7F
|
||||
}
|
||||
|
||||
func (t *Triangle) writeTimerLow(value byte) {
|
||||
t.timerPeriod = (t.timerPeriod & 0xFF00) | uint16(value)
|
||||
}
|
||||
|
||||
func (t *Triangle) writeTimerHigh(value byte) {
|
||||
t.lengthValue = lengthTable[value>>3]
|
||||
t.timerPeriod = (t.timerPeriod & 0x00FF) | (uint16(value&7) << 8)
|
||||
t.timerValue = t.timerPeriod
|
||||
t.counterReload = true
|
||||
}
|
||||
|
||||
func (t *Triangle) stepTimer() {
|
||||
if t.timerValue == 0 {
|
||||
t.timerValue = t.timerPeriod
|
||||
if t.lengthValue > 0 && t.counterValue > 0 {
|
||||
t.dutyValue = (t.dutyValue + 1) % 32
|
||||
}
|
||||
} else {
|
||||
t.timerValue--
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Triangle) stepLength() {
|
||||
if t.lengthEnabled && t.lengthValue > 0 {
|
||||
t.lengthValue--
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Triangle) stepCounter() {
|
||||
if t.counterReload {
|
||||
t.counterValue = t.counterPeriod
|
||||
} else if t.counterValue > 0 {
|
||||
t.counterValue--
|
||||
}
|
||||
if t.lengthEnabled {
|
||||
t.counterReload = false
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Triangle) output() byte {
|
||||
if !t.enabled {
|
||||
return 0
|
||||
}
|
||||
if t.lengthValue == 0 {
|
||||
return 0
|
||||
}
|
||||
if t.counterValue == 0 {
|
||||
return 0
|
||||
}
|
||||
return triangleTable[t.dutyValue]
|
||||
}
|
||||
|
||||
// Noise
|
||||
|
||||
type Noise struct {
|
||||
enabled bool
|
||||
mode bool
|
||||
shiftRegister uint16
|
||||
lengthEnabled bool
|
||||
lengthValue byte
|
||||
timerPeriod uint16
|
||||
timerValue uint16
|
||||
envelopeEnabled bool
|
||||
envelopeLoop bool
|
||||
envelopeStart bool
|
||||
envelopePeriod byte
|
||||
envelopeValue byte
|
||||
envelopeVolume byte
|
||||
constantVolume byte
|
||||
}
|
||||
|
||||
func (n *Noise) Save(encoder *gob.Encoder) error {
|
||||
encoder.Encode(n.enabled)
|
||||
encoder.Encode(n.mode)
|
||||
encoder.Encode(n.shiftRegister)
|
||||
encoder.Encode(n.lengthEnabled)
|
||||
encoder.Encode(n.lengthValue)
|
||||
encoder.Encode(n.timerPeriod)
|
||||
encoder.Encode(n.timerValue)
|
||||
encoder.Encode(n.envelopeEnabled)
|
||||
encoder.Encode(n.envelopeLoop)
|
||||
encoder.Encode(n.envelopeStart)
|
||||
encoder.Encode(n.envelopePeriod)
|
||||
encoder.Encode(n.envelopeValue)
|
||||
encoder.Encode(n.envelopeVolume)
|
||||
encoder.Encode(n.constantVolume)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *Noise) Load(decoder *gob.Decoder) error {
|
||||
decoder.Decode(&n.enabled)
|
||||
decoder.Decode(&n.mode)
|
||||
decoder.Decode(&n.shiftRegister)
|
||||
decoder.Decode(&n.lengthEnabled)
|
||||
decoder.Decode(&n.lengthValue)
|
||||
decoder.Decode(&n.timerPeriod)
|
||||
decoder.Decode(&n.timerValue)
|
||||
decoder.Decode(&n.envelopeEnabled)
|
||||
decoder.Decode(&n.envelopeLoop)
|
||||
decoder.Decode(&n.envelopeStart)
|
||||
decoder.Decode(&n.envelopePeriod)
|
||||
decoder.Decode(&n.envelopeValue)
|
||||
decoder.Decode(&n.envelopeVolume)
|
||||
decoder.Decode(&n.constantVolume)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *Noise) writeControl(value byte) {
|
||||
n.lengthEnabled = (value>>5)&1 == 0
|
||||
n.envelopeLoop = (value>>5)&1 == 1
|
||||
n.envelopeEnabled = (value>>4)&1 == 0
|
||||
n.envelopePeriod = value & 15
|
||||
n.constantVolume = value & 15
|
||||
n.envelopeStart = true
|
||||
}
|
||||
|
||||
func (n *Noise) writePeriod(value byte) {
|
||||
n.mode = value&0x80 == 0x80
|
||||
n.timerPeriod = noiseTable[value&0x0F]
|
||||
}
|
||||
|
||||
func (n *Noise) writeLength(value byte) {
|
||||
n.lengthValue = lengthTable[value>>3]
|
||||
n.envelopeStart = true
|
||||
}
|
||||
|
||||
func (n *Noise) stepTimer() {
|
||||
if n.timerValue == 0 {
|
||||
n.timerValue = n.timerPeriod
|
||||
var shift byte
|
||||
if n.mode {
|
||||
shift = 6
|
||||
} else {
|
||||
shift = 1
|
||||
}
|
||||
b1 := n.shiftRegister & 1
|
||||
b2 := (n.shiftRegister >> shift) & 1
|
||||
n.shiftRegister >>= 1
|
||||
n.shiftRegister |= (b1 ^ b2) << 14
|
||||
} else {
|
||||
n.timerValue--
|
||||
}
|
||||
}
|
||||
|
||||
func (n *Noise) stepEnvelope() {
|
||||
if n.envelopeStart {
|
||||
n.envelopeVolume = 15
|
||||
n.envelopeValue = n.envelopePeriod
|
||||
n.envelopeStart = false
|
||||
} else if n.envelopeValue > 0 {
|
||||
n.envelopeValue--
|
||||
} else {
|
||||
if n.envelopeVolume > 0 {
|
||||
n.envelopeVolume--
|
||||
} else if n.envelopeLoop {
|
||||
n.envelopeVolume = 15
|
||||
}
|
||||
n.envelopeValue = n.envelopePeriod
|
||||
}
|
||||
}
|
||||
|
||||
func (n *Noise) stepLength() {
|
||||
if n.lengthEnabled && n.lengthValue > 0 {
|
||||
n.lengthValue--
|
||||
}
|
||||
}
|
||||
|
||||
func (n *Noise) output() byte {
|
||||
if !n.enabled {
|
||||
return 0
|
||||
}
|
||||
if n.lengthValue == 0 {
|
||||
return 0
|
||||
}
|
||||
if n.shiftRegister&1 == 1 {
|
||||
return 0
|
||||
}
|
||||
if n.envelopeEnabled {
|
||||
return n.envelopeVolume
|
||||
} else {
|
||||
return n.constantVolume
|
||||
}
|
||||
}
|
||||
|
||||
// DMC
|
||||
|
||||
type DMC struct {
|
||||
cpu *CPU
|
||||
enabled bool
|
||||
value byte
|
||||
sampleAddress uint16
|
||||
sampleLength uint16
|
||||
currentAddress uint16
|
||||
currentLength uint16
|
||||
shiftRegister byte
|
||||
bitCount byte
|
||||
tickPeriod byte
|
||||
tickValue byte
|
||||
loop bool
|
||||
irq bool
|
||||
}
|
||||
|
||||
func (d *DMC) Save(encoder *gob.Encoder) error {
|
||||
encoder.Encode(d.enabled)
|
||||
encoder.Encode(d.value)
|
||||
encoder.Encode(d.sampleAddress)
|
||||
encoder.Encode(d.sampleLength)
|
||||
encoder.Encode(d.currentAddress)
|
||||
encoder.Encode(d.currentLength)
|
||||
encoder.Encode(d.shiftRegister)
|
||||
encoder.Encode(d.bitCount)
|
||||
encoder.Encode(d.tickPeriod)
|
||||
encoder.Encode(d.tickValue)
|
||||
encoder.Encode(d.loop)
|
||||
encoder.Encode(d.irq)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DMC) Load(decoder *gob.Decoder) error {
|
||||
decoder.Decode(&d.enabled)
|
||||
decoder.Decode(&d.value)
|
||||
decoder.Decode(&d.sampleAddress)
|
||||
decoder.Decode(&d.sampleLength)
|
||||
decoder.Decode(&d.currentAddress)
|
||||
decoder.Decode(&d.currentLength)
|
||||
decoder.Decode(&d.shiftRegister)
|
||||
decoder.Decode(&d.bitCount)
|
||||
decoder.Decode(&d.tickPeriod)
|
||||
decoder.Decode(&d.tickValue)
|
||||
decoder.Decode(&d.loop)
|
||||
decoder.Decode(&d.irq)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DMC) writeControl(value byte) {
|
||||
d.irq = value&0x80 == 0x80
|
||||
d.loop = value&0x40 == 0x40
|
||||
d.tickPeriod = dmcTable[value&0x0F]
|
||||
}
|
||||
|
||||
func (d *DMC) writeValue(value byte) {
|
||||
d.value = value & 0x7F
|
||||
}
|
||||
|
||||
func (d *DMC) writeAddress(value byte) {
|
||||
// Sample address = %11AAAAAA.AA000000
|
||||
d.sampleAddress = 0xC000 | (uint16(value) << 6)
|
||||
}
|
||||
|
||||
func (d *DMC) writeLength(value byte) {
|
||||
// Sample length = %0000LLLL.LLLL0001
|
||||
d.sampleLength = (uint16(value) << 4) | 1
|
||||
}
|
||||
|
||||
func (d *DMC) restart() {
|
||||
d.currentAddress = d.sampleAddress
|
||||
d.currentLength = d.sampleLength
|
||||
}
|
||||
|
||||
func (d *DMC) stepTimer() {
|
||||
if !d.enabled {
|
||||
return
|
||||
}
|
||||
d.stepReader()
|
||||
if d.tickValue == 0 {
|
||||
d.tickValue = d.tickPeriod
|
||||
d.stepShifter()
|
||||
} else {
|
||||
d.tickValue--
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DMC) stepReader() {
|
||||
if d.currentLength > 0 && d.bitCount == 0 {
|
||||
d.cpu.stall += 4
|
||||
d.shiftRegister = d.cpu.Read(d.currentAddress)
|
||||
d.bitCount = 8
|
||||
d.currentAddress++
|
||||
if d.currentAddress == 0 {
|
||||
d.currentAddress = 0x8000
|
||||
}
|
||||
d.currentLength--
|
||||
if d.currentLength == 0 && d.loop {
|
||||
d.restart()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (d *DMC) stepShifter() {
|
||||
if d.bitCount == 0 {
|
||||
return
|
||||
}
|
||||
if d.shiftRegister&1 == 1 {
|
||||
if d.value <= 125 {
|
||||
d.value += 2
|
||||
}
|
||||
} else {
|
||||
if d.value >= 2 {
|
||||
d.value -= 2
|
||||
}
|
||||
}
|
||||
d.shiftRegister >>= 1
|
||||
d.bitCount--
|
||||
}
|
||||
|
||||
func (d *DMC) output() byte {
|
||||
return d.value
|
||||
}
|
||||
33
nes/cartridge.go
Normal file
33
nes/cartridge.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package nes
|
||||
|
||||
import "encoding/gob"
|
||||
|
||||
type Cartridge struct {
|
||||
PRG []byte // PRG-ROM banks
|
||||
CHR []byte // CHR-ROM banks
|
||||
SRAM []byte // Save RAM
|
||||
Mapper byte // mapper type
|
||||
Mirror byte // mirroring mode
|
||||
Battery byte // battery present
|
||||
}
|
||||
|
||||
func NewCartridge(prg, chr []byte, mapper, mirror, battery byte) *Cartridge {
|
||||
sram := make([]byte, 0x2000)
|
||||
return &Cartridge{prg, chr, sram, mapper, mirror, battery}
|
||||
}
|
||||
|
||||
func (cartridge *Cartridge) Save(encoder *gob.Encoder) error {
|
||||
encoder.Encode(cartridge.PRG)
|
||||
encoder.Encode(cartridge.CHR)
|
||||
encoder.Encode(cartridge.SRAM)
|
||||
encoder.Encode(cartridge.Mirror)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cartridge *Cartridge) Load(decoder *gob.Decoder) error {
|
||||
decoder.Decode(&cartridge.PRG)
|
||||
decoder.Decode(&cartridge.CHR)
|
||||
decoder.Decode(&cartridge.SRAM)
|
||||
decoder.Decode(&cartridge.Mirror)
|
||||
return nil
|
||||
}
|
||||
156
nes/console.go
Normal file
156
nes/console.go
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
package nes
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"image"
|
||||
"image/color"
|
||||
"os"
|
||||
"path"
|
||||
)
|
||||
|
||||
type Console struct {
|
||||
CPU *CPU
|
||||
APU *APU
|
||||
PPU *PPU
|
||||
Cartridge *Cartridge
|
||||
Controller1 *Controller
|
||||
Controller2 *Controller
|
||||
Mapper Mapper
|
||||
RAM []byte
|
||||
}
|
||||
|
||||
func NewConsole(path string) (*Console, error) {
|
||||
cartridge, err := LoadNESFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ram := make([]byte, 2048)
|
||||
controller1 := NewController()
|
||||
controller2 := NewController()
|
||||
console := Console{
|
||||
nil, nil, nil, cartridge, controller1, controller2, nil, ram}
|
||||
mapper, err := NewMapper(&console)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
console.Mapper = mapper
|
||||
console.CPU = NewCPU(&console)
|
||||
console.APU = NewAPU(&console)
|
||||
console.PPU = NewPPU(&console)
|
||||
return &console, nil
|
||||
}
|
||||
|
||||
func (console *Console) Reset() {
|
||||
console.CPU.Reset()
|
||||
}
|
||||
|
||||
func (console *Console) Step() int {
|
||||
cpuCycles := console.CPU.Step()
|
||||
ppuCycles := cpuCycles * 3
|
||||
for i := 0; i < ppuCycles; i++ {
|
||||
console.PPU.Step()
|
||||
console.Mapper.Step()
|
||||
}
|
||||
for i := 0; i < cpuCycles; i++ {
|
||||
console.APU.Step()
|
||||
}
|
||||
return cpuCycles
|
||||
}
|
||||
|
||||
func (console *Console) StepFrame() int {
|
||||
cpuCycles := 0
|
||||
frame := console.PPU.Frame
|
||||
for frame == console.PPU.Frame {
|
||||
cpuCycles += console.Step()
|
||||
}
|
||||
return cpuCycles
|
||||
}
|
||||
|
||||
func (console *Console) StepSeconds(seconds float64) {
|
||||
cycles := int(CPUFrequency * seconds)
|
||||
for cycles > 0 {
|
||||
cycles -= console.Step()
|
||||
}
|
||||
}
|
||||
|
||||
func (console *Console) Buffer() *image.RGBA {
|
||||
return console.PPU.front
|
||||
}
|
||||
|
||||
func (console *Console) BackgroundColor() color.RGBA {
|
||||
return Palette[console.PPU.readPalette(0)%64]
|
||||
}
|
||||
|
||||
func (console *Console) SetButtons1(buttons [8]bool) {
|
||||
console.Controller1.SetButtons(buttons)
|
||||
}
|
||||
|
||||
func (console *Console) SetButtons2(buttons [8]bool) {
|
||||
console.Controller2.SetButtons(buttons)
|
||||
}
|
||||
|
||||
func (console *Console) SetAudioChannel(channel chan float32) {
|
||||
console.APU.channel = channel
|
||||
}
|
||||
|
||||
func (console *Console) SetAudioSampleRate(sampleRate float64) {
|
||||
if sampleRate != 0 {
|
||||
// Convert samples per second to cpu steps per sample
|
||||
console.APU.sampleRate = CPUFrequency / sampleRate
|
||||
// Initialize filters
|
||||
console.APU.filterChain = FilterChain{
|
||||
HighPassFilter(float32(sampleRate), 90),
|
||||
HighPassFilter(float32(sampleRate), 440),
|
||||
LowPassFilter(float32(sampleRate), 14000),
|
||||
}
|
||||
} else {
|
||||
console.APU.filterChain = nil
|
||||
}
|
||||
}
|
||||
func (console *Console) SaveState(filename string) error {
|
||||
dir, _ := path.Split(filename)
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
file, err := os.Create(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
encoder := gob.NewEncoder(file)
|
||||
return console.Save(encoder)
|
||||
}
|
||||
|
||||
func (console *Console) Save(encoder *gob.Encoder) error {
|
||||
encoder.Encode(console.RAM)
|
||||
console.CPU.Save(encoder)
|
||||
console.APU.Save(encoder)
|
||||
console.PPU.Save(encoder)
|
||||
console.Cartridge.Save(encoder)
|
||||
console.Mapper.Save(encoder)
|
||||
return encoder.Encode(true)
|
||||
}
|
||||
|
||||
func (console *Console) LoadState(filename string) error {
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
decoder := gob.NewDecoder(file)
|
||||
return console.Load(decoder)
|
||||
}
|
||||
|
||||
func (console *Console) Load(decoder *gob.Decoder) error {
|
||||
decoder.Decode(&console.RAM)
|
||||
console.CPU.Load(decoder)
|
||||
console.APU.Load(decoder)
|
||||
console.PPU.Load(decoder)
|
||||
console.Cartridge.Load(decoder)
|
||||
console.Mapper.Load(decoder)
|
||||
var dummy bool
|
||||
if err := decoder.Decode(&dummy); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
45
nes/controller.go
Normal file
45
nes/controller.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package nes
|
||||
|
||||
const (
|
||||
ButtonA = iota
|
||||
ButtonB
|
||||
ButtonSelect
|
||||
ButtonStart
|
||||
ButtonUp
|
||||
ButtonDown
|
||||
ButtonLeft
|
||||
ButtonRight
|
||||
)
|
||||
|
||||
type Controller struct {
|
||||
buttons [8]bool
|
||||
index byte
|
||||
strobe byte
|
||||
}
|
||||
|
||||
func NewController() *Controller {
|
||||
return &Controller{}
|
||||
}
|
||||
|
||||
func (c *Controller) SetButtons(buttons [8]bool) {
|
||||
c.buttons = buttons
|
||||
}
|
||||
|
||||
func (c *Controller) Read() byte {
|
||||
value := byte(0)
|
||||
if c.index < 8 && c.buttons[c.index] {
|
||||
value = 1
|
||||
}
|
||||
c.index++
|
||||
if c.strobe&1 == 1 {
|
||||
c.index = 0
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func (c *Controller) Write(value byte) {
|
||||
c.strobe = value
|
||||
if c.strobe&1 == 1 {
|
||||
c.index = 0
|
||||
}
|
||||
}
|
||||
975
nes/cpu.go
Normal file
975
nes/cpu.go
Normal file
|
|
@ -0,0 +1,975 @@
|
|||
package nes
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const CPUFrequency = 1789773
|
||||
|
||||
// interrupt types
|
||||
const (
|
||||
_ = iota
|
||||
interruptNone
|
||||
interruptNMI
|
||||
interruptIRQ
|
||||
)
|
||||
|
||||
// addressing modes
|
||||
const (
|
||||
_ = iota
|
||||
modeAbsolute
|
||||
modeAbsoluteX
|
||||
modeAbsoluteY
|
||||
modeAccumulator
|
||||
modeImmediate
|
||||
modeImplied
|
||||
modeIndexedIndirect
|
||||
modeIndirect
|
||||
modeIndirectIndexed
|
||||
modeRelative
|
||||
modeZeroPage
|
||||
modeZeroPageX
|
||||
modeZeroPageY
|
||||
)
|
||||
|
||||
// instructionModes indicates the addressing mode for each instruction
|
||||
var instructionModes = [256]byte{
|
||||
6, 7, 6, 7, 11, 11, 11, 11, 6, 5, 4, 5, 1, 1, 1, 1,
|
||||
10, 9, 6, 9, 12, 12, 12, 12, 6, 3, 6, 3, 2, 2, 2, 2,
|
||||
1, 7, 6, 7, 11, 11, 11, 11, 6, 5, 4, 5, 1, 1, 1, 1,
|
||||
10, 9, 6, 9, 12, 12, 12, 12, 6, 3, 6, 3, 2, 2, 2, 2,
|
||||
6, 7, 6, 7, 11, 11, 11, 11, 6, 5, 4, 5, 1, 1, 1, 1,
|
||||
10, 9, 6, 9, 12, 12, 12, 12, 6, 3, 6, 3, 2, 2, 2, 2,
|
||||
6, 7, 6, 7, 11, 11, 11, 11, 6, 5, 4, 5, 8, 1, 1, 1,
|
||||
10, 9, 6, 9, 12, 12, 12, 12, 6, 3, 6, 3, 2, 2, 2, 2,
|
||||
5, 7, 5, 7, 11, 11, 11, 11, 6, 5, 6, 5, 1, 1, 1, 1,
|
||||
10, 9, 6, 9, 12, 12, 13, 13, 6, 3, 6, 3, 2, 2, 3, 3,
|
||||
5, 7, 5, 7, 11, 11, 11, 11, 6, 5, 6, 5, 1, 1, 1, 1,
|
||||
10, 9, 6, 9, 12, 12, 13, 13, 6, 3, 6, 3, 2, 2, 3, 3,
|
||||
5, 7, 5, 7, 11, 11, 11, 11, 6, 5, 6, 5, 1, 1, 1, 1,
|
||||
10, 9, 6, 9, 12, 12, 12, 12, 6, 3, 6, 3, 2, 2, 2, 2,
|
||||
5, 7, 5, 7, 11, 11, 11, 11, 6, 5, 6, 5, 1, 1, 1, 1,
|
||||
10, 9, 6, 9, 12, 12, 12, 12, 6, 3, 6, 3, 2, 2, 2, 2,
|
||||
}
|
||||
|
||||
// instructionSizes indicates the size of each instruction in bytes
|
||||
var instructionSizes = [256]byte{
|
||||
2, 2, 0, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0,
|
||||
2, 2, 0, 0, 2, 2, 2, 0, 1, 3, 1, 0, 3, 3, 3, 0,
|
||||
3, 2, 0, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0,
|
||||
2, 2, 0, 0, 2, 2, 2, 0, 1, 3, 1, 0, 3, 3, 3, 0,
|
||||
1, 2, 0, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0,
|
||||
2, 2, 0, 0, 2, 2, 2, 0, 1, 3, 1, 0, 3, 3, 3, 0,
|
||||
1, 2, 0, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0,
|
||||
2, 2, 0, 0, 2, 2, 2, 0, 1, 3, 1, 0, 3, 3, 3, 0,
|
||||
2, 2, 0, 0, 2, 2, 2, 0, 1, 0, 1, 0, 3, 3, 3, 0,
|
||||
2, 2, 0, 0, 2, 2, 2, 0, 1, 3, 1, 0, 0, 3, 0, 0,
|
||||
2, 2, 2, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0,
|
||||
2, 2, 0, 0, 2, 2, 2, 0, 1, 3, 1, 0, 3, 3, 3, 0,
|
||||
2, 2, 0, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0,
|
||||
2, 2, 0, 0, 2, 2, 2, 0, 1, 3, 1, 0, 3, 3, 3, 0,
|
||||
2, 2, 0, 0, 2, 2, 2, 0, 1, 2, 1, 0, 3, 3, 3, 0,
|
||||
2, 2, 0, 0, 2, 2, 2, 0, 1, 3, 1, 0, 3, 3, 3, 0,
|
||||
}
|
||||
|
||||
// instructionCycles indicates the number of cycles used by each instruction,
|
||||
// not including conditional cycles
|
||||
var instructionCycles = [256]byte{
|
||||
7, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 4, 4, 6, 6,
|
||||
2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7,
|
||||
6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 4, 4, 6, 6,
|
||||
2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7,
|
||||
6, 6, 2, 8, 3, 3, 5, 5, 3, 2, 2, 2, 3, 4, 6, 6,
|
||||
2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7,
|
||||
6, 6, 2, 8, 3, 3, 5, 5, 4, 2, 2, 2, 5, 4, 6, 6,
|
||||
2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7,
|
||||
2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4,
|
||||
2, 6, 2, 6, 4, 4, 4, 4, 2, 5, 2, 5, 5, 5, 5, 5,
|
||||
2, 6, 2, 6, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4,
|
||||
2, 5, 2, 5, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 4, 4,
|
||||
2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6,
|
||||
2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7,
|
||||
2, 6, 2, 8, 3, 3, 5, 5, 2, 2, 2, 2, 4, 4, 6, 6,
|
||||
2, 5, 2, 8, 4, 4, 6, 6, 2, 4, 2, 7, 4, 4, 7, 7,
|
||||
}
|
||||
|
||||
// instructionPageCycles indicates the number of cycles used by each
|
||||
// instruction when a page is crossed
|
||||
var instructionPageCycles = [256]byte{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0,
|
||||
}
|
||||
|
||||
// instructionNames indicates the name of each instruction
|
||||
var instructionNames = [256]string{
|
||||
"BRK", "ORA", "KIL", "SLO", "NOP", "ORA", "ASL", "SLO",
|
||||
"PHP", "ORA", "ASL", "ANC", "NOP", "ORA", "ASL", "SLO",
|
||||
"BPL", "ORA", "KIL", "SLO", "NOP", "ORA", "ASL", "SLO",
|
||||
"CLC", "ORA", "NOP", "SLO", "NOP", "ORA", "ASL", "SLO",
|
||||
"JSR", "AND", "KIL", "RLA", "BIT", "AND", "ROL", "RLA",
|
||||
"PLP", "AND", "ROL", "ANC", "BIT", "AND", "ROL", "RLA",
|
||||
"BMI", "AND", "KIL", "RLA", "NOP", "AND", "ROL", "RLA",
|
||||
"SEC", "AND", "NOP", "RLA", "NOP", "AND", "ROL", "RLA",
|
||||
"RTI", "EOR", "KIL", "SRE", "NOP", "EOR", "LSR", "SRE",
|
||||
"PHA", "EOR", "LSR", "ALR", "JMP", "EOR", "LSR", "SRE",
|
||||
"BVC", "EOR", "KIL", "SRE", "NOP", "EOR", "LSR", "SRE",
|
||||
"CLI", "EOR", "NOP", "SRE", "NOP", "EOR", "LSR", "SRE",
|
||||
"RTS", "ADC", "KIL", "RRA", "NOP", "ADC", "ROR", "RRA",
|
||||
"PLA", "ADC", "ROR", "ARR", "JMP", "ADC", "ROR", "RRA",
|
||||
"BVS", "ADC", "KIL", "RRA", "NOP", "ADC", "ROR", "RRA",
|
||||
"SEI", "ADC", "NOP", "RRA", "NOP", "ADC", "ROR", "RRA",
|
||||
"NOP", "STA", "NOP", "SAX", "STY", "STA", "STX", "SAX",
|
||||
"DEY", "NOP", "TXA", "XAA", "STY", "STA", "STX", "SAX",
|
||||
"BCC", "STA", "KIL", "AHX", "STY", "STA", "STX", "SAX",
|
||||
"TYA", "STA", "TXS", "TAS", "SHY", "STA", "SHX", "AHX",
|
||||
"LDY", "LDA", "LDX", "LAX", "LDY", "LDA", "LDX", "LAX",
|
||||
"TAY", "LDA", "TAX", "LAX", "LDY", "LDA", "LDX", "LAX",
|
||||
"BCS", "LDA", "KIL", "LAX", "LDY", "LDA", "LDX", "LAX",
|
||||
"CLV", "LDA", "TSX", "LAS", "LDY", "LDA", "LDX", "LAX",
|
||||
"CPY", "CMP", "NOP", "DCP", "CPY", "CMP", "DEC", "DCP",
|
||||
"INY", "CMP", "DEX", "AXS", "CPY", "CMP", "DEC", "DCP",
|
||||
"BNE", "CMP", "KIL", "DCP", "NOP", "CMP", "DEC", "DCP",
|
||||
"CLD", "CMP", "NOP", "DCP", "NOP", "CMP", "DEC", "DCP",
|
||||
"CPX", "SBC", "NOP", "ISC", "CPX", "SBC", "INC", "ISC",
|
||||
"INX", "SBC", "NOP", "SBC", "CPX", "SBC", "INC", "ISC",
|
||||
"BEQ", "SBC", "KIL", "ISC", "NOP", "SBC", "INC", "ISC",
|
||||
"SED", "SBC", "NOP", "ISC", "NOP", "SBC", "INC", "ISC",
|
||||
}
|
||||
|
||||
type CPU struct {
|
||||
Memory // memory interface
|
||||
Cycles uint64 // number of cycles
|
||||
PC uint16 // program counter
|
||||
SP byte // stack pointer
|
||||
A byte // accumulator
|
||||
X byte // x register
|
||||
Y byte // y register
|
||||
C byte // carry flag
|
||||
Z byte // zero flag
|
||||
I byte // interrupt disable flag
|
||||
D byte // decimal mode flag
|
||||
B byte // break command flag
|
||||
U byte // unused flag
|
||||
V byte // overflow flag
|
||||
N byte // negative flag
|
||||
interrupt byte // interrupt type to perform
|
||||
stall int // number of cycles to stall
|
||||
table [256]func(*stepInfo)
|
||||
}
|
||||
|
||||
func NewCPU(console *Console) *CPU {
|
||||
cpu := CPU{Memory: NewCPUMemory(console)}
|
||||
cpu.createTable()
|
||||
cpu.Reset()
|
||||
return &cpu
|
||||
}
|
||||
|
||||
// createTable builds a function table for each instruction
|
||||
func (c *CPU) createTable() {
|
||||
c.table = [256]func(*stepInfo){
|
||||
c.brk, c.ora, c.kil, c.slo, c.nop, c.ora, c.asl, c.slo,
|
||||
c.php, c.ora, c.asl, c.anc, c.nop, c.ora, c.asl, c.slo,
|
||||
c.bpl, c.ora, c.kil, c.slo, c.nop, c.ora, c.asl, c.slo,
|
||||
c.clc, c.ora, c.nop, c.slo, c.nop, c.ora, c.asl, c.slo,
|
||||
c.jsr, c.and, c.kil, c.rla, c.bit, c.and, c.rol, c.rla,
|
||||
c.plp, c.and, c.rol, c.anc, c.bit, c.and, c.rol, c.rla,
|
||||
c.bmi, c.and, c.kil, c.rla, c.nop, c.and, c.rol, c.rla,
|
||||
c.sec, c.and, c.nop, c.rla, c.nop, c.and, c.rol, c.rla,
|
||||
c.rti, c.eor, c.kil, c.sre, c.nop, c.eor, c.lsr, c.sre,
|
||||
c.pha, c.eor, c.lsr, c.alr, c.jmp, c.eor, c.lsr, c.sre,
|
||||
c.bvc, c.eor, c.kil, c.sre, c.nop, c.eor, c.lsr, c.sre,
|
||||
c.cli, c.eor, c.nop, c.sre, c.nop, c.eor, c.lsr, c.sre,
|
||||
c.rts, c.adc, c.kil, c.rra, c.nop, c.adc, c.ror, c.rra,
|
||||
c.pla, c.adc, c.ror, c.arr, c.jmp, c.adc, c.ror, c.rra,
|
||||
c.bvs, c.adc, c.kil, c.rra, c.nop, c.adc, c.ror, c.rra,
|
||||
c.sei, c.adc, c.nop, c.rra, c.nop, c.adc, c.ror, c.rra,
|
||||
c.nop, c.sta, c.nop, c.sax, c.sty, c.sta, c.stx, c.sax,
|
||||
c.dey, c.nop, c.txa, c.xaa, c.sty, c.sta, c.stx, c.sax,
|
||||
c.bcc, c.sta, c.kil, c.ahx, c.sty, c.sta, c.stx, c.sax,
|
||||
c.tya, c.sta, c.txs, c.tas, c.shy, c.sta, c.shx, c.ahx,
|
||||
c.ldy, c.lda, c.ldx, c.lax, c.ldy, c.lda, c.ldx, c.lax,
|
||||
c.tay, c.lda, c.tax, c.lax, c.ldy, c.lda, c.ldx, c.lax,
|
||||
c.bcs, c.lda, c.kil, c.lax, c.ldy, c.lda, c.ldx, c.lax,
|
||||
c.clv, c.lda, c.tsx, c.las, c.ldy, c.lda, c.ldx, c.lax,
|
||||
c.cpy, c.cmp, c.nop, c.dcp, c.cpy, c.cmp, c.dec, c.dcp,
|
||||
c.iny, c.cmp, c.dex, c.axs, c.cpy, c.cmp, c.dec, c.dcp,
|
||||
c.bne, c.cmp, c.kil, c.dcp, c.nop, c.cmp, c.dec, c.dcp,
|
||||
c.cld, c.cmp, c.nop, c.dcp, c.nop, c.cmp, c.dec, c.dcp,
|
||||
c.cpx, c.sbc, c.nop, c.isc, c.cpx, c.sbc, c.inc, c.isc,
|
||||
c.inx, c.sbc, c.nop, c.sbc, c.cpx, c.sbc, c.inc, c.isc,
|
||||
c.beq, c.sbc, c.kil, c.isc, c.nop, c.sbc, c.inc, c.isc,
|
||||
c.sed, c.sbc, c.nop, c.isc, c.nop, c.sbc, c.inc, c.isc,
|
||||
}
|
||||
}
|
||||
|
||||
func (cpu *CPU) Save(encoder *gob.Encoder) error {
|
||||
encoder.Encode(cpu.Cycles)
|
||||
encoder.Encode(cpu.PC)
|
||||
encoder.Encode(cpu.SP)
|
||||
encoder.Encode(cpu.A)
|
||||
encoder.Encode(cpu.X)
|
||||
encoder.Encode(cpu.Y)
|
||||
encoder.Encode(cpu.C)
|
||||
encoder.Encode(cpu.Z)
|
||||
encoder.Encode(cpu.I)
|
||||
encoder.Encode(cpu.D)
|
||||
encoder.Encode(cpu.B)
|
||||
encoder.Encode(cpu.U)
|
||||
encoder.Encode(cpu.V)
|
||||
encoder.Encode(cpu.N)
|
||||
encoder.Encode(cpu.interrupt)
|
||||
encoder.Encode(cpu.stall)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cpu *CPU) Load(decoder *gob.Decoder) error {
|
||||
decoder.Decode(&cpu.Cycles)
|
||||
decoder.Decode(&cpu.PC)
|
||||
decoder.Decode(&cpu.SP)
|
||||
decoder.Decode(&cpu.A)
|
||||
decoder.Decode(&cpu.X)
|
||||
decoder.Decode(&cpu.Y)
|
||||
decoder.Decode(&cpu.C)
|
||||
decoder.Decode(&cpu.Z)
|
||||
decoder.Decode(&cpu.I)
|
||||
decoder.Decode(&cpu.D)
|
||||
decoder.Decode(&cpu.B)
|
||||
decoder.Decode(&cpu.U)
|
||||
decoder.Decode(&cpu.V)
|
||||
decoder.Decode(&cpu.N)
|
||||
decoder.Decode(&cpu.interrupt)
|
||||
decoder.Decode(&cpu.stall)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset resets the CPU to its initial powerup state
|
||||
func (cpu *CPU) Reset() {
|
||||
cpu.PC = cpu.Read16(0xFFFC)
|
||||
cpu.SP = 0xFD
|
||||
cpu.SetFlags(0x24)
|
||||
}
|
||||
|
||||
// PrintInstruction prints the current CPU state
|
||||
func (cpu *CPU) PrintInstruction() {
|
||||
opcode := cpu.Read(cpu.PC)
|
||||
bytes := instructionSizes[opcode]
|
||||
name := instructionNames[opcode]
|
||||
w0 := fmt.Sprintf("%02X", cpu.Read(cpu.PC+0))
|
||||
w1 := fmt.Sprintf("%02X", cpu.Read(cpu.PC+1))
|
||||
w2 := fmt.Sprintf("%02X", cpu.Read(cpu.PC+2))
|
||||
if bytes < 2 {
|
||||
w1 = " "
|
||||
}
|
||||
if bytes < 3 {
|
||||
w2 = " "
|
||||
}
|
||||
fmt.Printf(
|
||||
"%4X %s %s %s %s %28s"+
|
||||
"A:%02X X:%02X Y:%02X P:%02X SP:%02X CYC:%3d\n",
|
||||
cpu.PC, w0, w1, w2, name, "",
|
||||
cpu.A, cpu.X, cpu.Y, cpu.Flags(), cpu.SP, (cpu.Cycles*3)%341)
|
||||
}
|
||||
|
||||
// pagesDiffer returns true if the two addresses reference different pages
|
||||
func pagesDiffer(a, b uint16) bool {
|
||||
return a&0xFF00 != b&0xFF00
|
||||
}
|
||||
|
||||
// addBranchCycles adds a cycle for taking a branch and adds another cycle
|
||||
// if the branch jumps to a new page
|
||||
func (cpu *CPU) addBranchCycles(info *stepInfo) {
|
||||
cpu.Cycles++
|
||||
if pagesDiffer(info.pc, info.address) {
|
||||
cpu.Cycles++
|
||||
}
|
||||
}
|
||||
|
||||
func (cpu *CPU) compare(a, b byte) {
|
||||
cpu.setZN(a - b)
|
||||
if a >= b {
|
||||
cpu.C = 1
|
||||
} else {
|
||||
cpu.C = 0
|
||||
}
|
||||
}
|
||||
|
||||
// Read16 reads two bytes using Read to return a double-word value
|
||||
func (cpu *CPU) Read16(address uint16) uint16 {
|
||||
lo := uint16(cpu.Read(address))
|
||||
hi := uint16(cpu.Read(address + 1))
|
||||
return hi<<8 | lo
|
||||
}
|
||||
|
||||
// read16bug emulates a 6502 bug that caused the low byte to wrap without
|
||||
// incrementing the high byte
|
||||
func (cpu *CPU) read16bug(address uint16) uint16 {
|
||||
a := address
|
||||
b := (a & 0xFF00) | uint16(byte(a)+1)
|
||||
lo := cpu.Read(a)
|
||||
hi := cpu.Read(b)
|
||||
return uint16(hi)<<8 | uint16(lo)
|
||||
}
|
||||
|
||||
// push pushes a byte onto the stack
|
||||
func (cpu *CPU) push(value byte) {
|
||||
cpu.Write(0x100|uint16(cpu.SP), value)
|
||||
cpu.SP--
|
||||
}
|
||||
|
||||
// pull pops a byte from the stack
|
||||
func (cpu *CPU) pull() byte {
|
||||
cpu.SP++
|
||||
return cpu.Read(0x100 | uint16(cpu.SP))
|
||||
}
|
||||
|
||||
// push16 pushes two bytes onto the stack
|
||||
func (cpu *CPU) push16(value uint16) {
|
||||
hi := byte(value >> 8)
|
||||
lo := byte(value & 0xFF)
|
||||
cpu.push(hi)
|
||||
cpu.push(lo)
|
||||
}
|
||||
|
||||
// pull16 pops two bytes from the stack
|
||||
func (cpu *CPU) pull16() uint16 {
|
||||
lo := uint16(cpu.pull())
|
||||
hi := uint16(cpu.pull())
|
||||
return hi<<8 | lo
|
||||
}
|
||||
|
||||
// Flags returns the processor status flags
|
||||
func (cpu *CPU) Flags() byte {
|
||||
var flags byte
|
||||
flags |= cpu.C << 0
|
||||
flags |= cpu.Z << 1
|
||||
flags |= cpu.I << 2
|
||||
flags |= cpu.D << 3
|
||||
flags |= cpu.B << 4
|
||||
flags |= cpu.U << 5
|
||||
flags |= cpu.V << 6
|
||||
flags |= cpu.N << 7
|
||||
return flags
|
||||
}
|
||||
|
||||
// SetFlags sets the processor status flags
|
||||
func (cpu *CPU) SetFlags(flags byte) {
|
||||
cpu.C = (flags >> 0) & 1
|
||||
cpu.Z = (flags >> 1) & 1
|
||||
cpu.I = (flags >> 2) & 1
|
||||
cpu.D = (flags >> 3) & 1
|
||||
cpu.B = (flags >> 4) & 1
|
||||
cpu.U = (flags >> 5) & 1
|
||||
cpu.V = (flags >> 6) & 1
|
||||
cpu.N = (flags >> 7) & 1
|
||||
}
|
||||
|
||||
// setZ sets the zero flag if the argument is zero
|
||||
func (cpu *CPU) setZ(value byte) {
|
||||
if value == 0 {
|
||||
cpu.Z = 1
|
||||
} else {
|
||||
cpu.Z = 0
|
||||
}
|
||||
}
|
||||
|
||||
// setN sets the negative flag if the argument is negative (high bit is set)
|
||||
func (cpu *CPU) setN(value byte) {
|
||||
if value&0x80 != 0 {
|
||||
cpu.N = 1
|
||||
} else {
|
||||
cpu.N = 0
|
||||
}
|
||||
}
|
||||
|
||||
// setZN sets the zero flag and the negative flag
|
||||
func (cpu *CPU) setZN(value byte) {
|
||||
cpu.setZ(value)
|
||||
cpu.setN(value)
|
||||
}
|
||||
|
||||
// triggerNMI causes a non-maskable interrupt to occur on the next cycle
|
||||
func (cpu *CPU) triggerNMI() {
|
||||
cpu.interrupt = interruptNMI
|
||||
}
|
||||
|
||||
// triggerIRQ causes an IRQ interrupt to occur on the next cycle
|
||||
func (cpu *CPU) triggerIRQ() {
|
||||
if cpu.I == 0 {
|
||||
cpu.interrupt = interruptIRQ
|
||||
}
|
||||
}
|
||||
|
||||
// stepInfo contains information that the instruction functions use
|
||||
type stepInfo struct {
|
||||
address uint16
|
||||
pc uint16
|
||||
mode byte
|
||||
}
|
||||
|
||||
// Step executes a single CPU instruction
|
||||
func (cpu *CPU) Step() int {
|
||||
if cpu.stall > 0 {
|
||||
cpu.stall--
|
||||
return 1
|
||||
}
|
||||
|
||||
cycles := cpu.Cycles
|
||||
|
||||
switch cpu.interrupt {
|
||||
case interruptNMI:
|
||||
cpu.nmi()
|
||||
case interruptIRQ:
|
||||
cpu.irq()
|
||||
}
|
||||
cpu.interrupt = interruptNone
|
||||
|
||||
opcode := cpu.Read(cpu.PC)
|
||||
mode := instructionModes[opcode]
|
||||
|
||||
var address uint16
|
||||
var pageCrossed bool
|
||||
switch mode {
|
||||
case modeAbsolute:
|
||||
address = cpu.Read16(cpu.PC + 1)
|
||||
case modeAbsoluteX:
|
||||
address = cpu.Read16(cpu.PC+1) + uint16(cpu.X)
|
||||
pageCrossed = pagesDiffer(address-uint16(cpu.X), address)
|
||||
case modeAbsoluteY:
|
||||
address = cpu.Read16(cpu.PC+1) + uint16(cpu.Y)
|
||||
pageCrossed = pagesDiffer(address-uint16(cpu.Y), address)
|
||||
case modeAccumulator:
|
||||
address = 0
|
||||
case modeImmediate:
|
||||
address = cpu.PC + 1
|
||||
case modeImplied:
|
||||
address = 0
|
||||
case modeIndexedIndirect:
|
||||
address = cpu.read16bug(uint16(cpu.Read(cpu.PC+1) + cpu.X))
|
||||
case modeIndirect:
|
||||
address = cpu.read16bug(cpu.Read16(cpu.PC + 1))
|
||||
case modeIndirectIndexed:
|
||||
address = cpu.read16bug(uint16(cpu.Read(cpu.PC+1))) + uint16(cpu.Y)
|
||||
pageCrossed = pagesDiffer(address-uint16(cpu.Y), address)
|
||||
case modeRelative:
|
||||
offset := uint16(cpu.Read(cpu.PC + 1))
|
||||
if offset < 0x80 {
|
||||
address = cpu.PC + 2 + offset
|
||||
} else {
|
||||
address = cpu.PC + 2 + offset - 0x100
|
||||
}
|
||||
case modeZeroPage:
|
||||
address = uint16(cpu.Read(cpu.PC + 1))
|
||||
case modeZeroPageX:
|
||||
address = uint16(cpu.Read(cpu.PC+1)+cpu.X) & 0xff
|
||||
case modeZeroPageY:
|
||||
address = uint16(cpu.Read(cpu.PC+1)+cpu.Y) & 0xff
|
||||
}
|
||||
|
||||
cpu.PC += uint16(instructionSizes[opcode])
|
||||
cpu.Cycles += uint64(instructionCycles[opcode])
|
||||
if pageCrossed {
|
||||
cpu.Cycles += uint64(instructionPageCycles[opcode])
|
||||
}
|
||||
info := &stepInfo{address, cpu.PC, mode}
|
||||
cpu.table[opcode](info)
|
||||
|
||||
return int(cpu.Cycles - cycles)
|
||||
}
|
||||
|
||||
// NMI - Non-Maskable Interrupt
|
||||
func (cpu *CPU) nmi() {
|
||||
cpu.push16(cpu.PC)
|
||||
cpu.php(nil)
|
||||
cpu.PC = cpu.Read16(0xFFFA)
|
||||
cpu.I = 1
|
||||
cpu.Cycles += 7
|
||||
}
|
||||
|
||||
// IRQ - IRQ Interrupt
|
||||
func (cpu *CPU) irq() {
|
||||
cpu.push16(cpu.PC)
|
||||
cpu.php(nil)
|
||||
cpu.PC = cpu.Read16(0xFFFE)
|
||||
cpu.I = 1
|
||||
cpu.Cycles += 7
|
||||
}
|
||||
|
||||
// ADC - Add with Carry
|
||||
func (cpu *CPU) adc(info *stepInfo) {
|
||||
a := cpu.A
|
||||
b := cpu.Read(info.address)
|
||||
c := cpu.C
|
||||
cpu.A = a + b + c
|
||||
cpu.setZN(cpu.A)
|
||||
if int(a)+int(b)+int(c) > 0xFF {
|
||||
cpu.C = 1
|
||||
} else {
|
||||
cpu.C = 0
|
||||
}
|
||||
if (a^b)&0x80 == 0 && (a^cpu.A)&0x80 != 0 {
|
||||
cpu.V = 1
|
||||
} else {
|
||||
cpu.V = 0
|
||||
}
|
||||
}
|
||||
|
||||
// AND - Logical AND
|
||||
func (cpu *CPU) and(info *stepInfo) {
|
||||
cpu.A = cpu.A & cpu.Read(info.address)
|
||||
cpu.setZN(cpu.A)
|
||||
}
|
||||
|
||||
// ASL - Arithmetic Shift Left
|
||||
func (cpu *CPU) asl(info *stepInfo) {
|
||||
if info.mode == modeAccumulator {
|
||||
cpu.C = (cpu.A >> 7) & 1
|
||||
cpu.A <<= 1
|
||||
cpu.setZN(cpu.A)
|
||||
} else {
|
||||
value := cpu.Read(info.address)
|
||||
cpu.C = (value >> 7) & 1
|
||||
value <<= 1
|
||||
cpu.Write(info.address, value)
|
||||
cpu.setZN(value)
|
||||
}
|
||||
}
|
||||
|
||||
// BCC - Branch if Carry Clear
|
||||
func (cpu *CPU) bcc(info *stepInfo) {
|
||||
if cpu.C == 0 {
|
||||
cpu.PC = info.address
|
||||
cpu.addBranchCycles(info)
|
||||
}
|
||||
}
|
||||
|
||||
// BCS - Branch if Carry Set
|
||||
func (cpu *CPU) bcs(info *stepInfo) {
|
||||
if cpu.C != 0 {
|
||||
cpu.PC = info.address
|
||||
cpu.addBranchCycles(info)
|
||||
}
|
||||
}
|
||||
|
||||
// BEQ - Branch if Equal
|
||||
func (cpu *CPU) beq(info *stepInfo) {
|
||||
if cpu.Z != 0 {
|
||||
cpu.PC = info.address
|
||||
cpu.addBranchCycles(info)
|
||||
}
|
||||
}
|
||||
|
||||
// BIT - Bit Test
|
||||
func (cpu *CPU) bit(info *stepInfo) {
|
||||
value := cpu.Read(info.address)
|
||||
cpu.V = (value >> 6) & 1
|
||||
cpu.setZ(value & cpu.A)
|
||||
cpu.setN(value)
|
||||
}
|
||||
|
||||
// BMI - Branch if Minus
|
||||
func (cpu *CPU) bmi(info *stepInfo) {
|
||||
if cpu.N != 0 {
|
||||
cpu.PC = info.address
|
||||
cpu.addBranchCycles(info)
|
||||
}
|
||||
}
|
||||
|
||||
// BNE - Branch if Not Equal
|
||||
func (cpu *CPU) bne(info *stepInfo) {
|
||||
if cpu.Z == 0 {
|
||||
cpu.PC = info.address
|
||||
cpu.addBranchCycles(info)
|
||||
}
|
||||
}
|
||||
|
||||
// BPL - Branch if Positive
|
||||
func (cpu *CPU) bpl(info *stepInfo) {
|
||||
if cpu.N == 0 {
|
||||
cpu.PC = info.address
|
||||
cpu.addBranchCycles(info)
|
||||
}
|
||||
}
|
||||
|
||||
// BRK - Force Interrupt
|
||||
func (cpu *CPU) brk(info *stepInfo) {
|
||||
cpu.push16(cpu.PC)
|
||||
cpu.php(info)
|
||||
cpu.sei(info)
|
||||
cpu.PC = cpu.Read16(0xFFFE)
|
||||
}
|
||||
|
||||
// BVC - Branch if Overflow Clear
|
||||
func (cpu *CPU) bvc(info *stepInfo) {
|
||||
if cpu.V == 0 {
|
||||
cpu.PC = info.address
|
||||
cpu.addBranchCycles(info)
|
||||
}
|
||||
}
|
||||
|
||||
// BVS - Branch if Overflow Set
|
||||
func (cpu *CPU) bvs(info *stepInfo) {
|
||||
if cpu.V != 0 {
|
||||
cpu.PC = info.address
|
||||
cpu.addBranchCycles(info)
|
||||
}
|
||||
}
|
||||
|
||||
// CLC - Clear Carry Flag
|
||||
func (cpu *CPU) clc(info *stepInfo) {
|
||||
cpu.C = 0
|
||||
}
|
||||
|
||||
// CLD - Clear Decimal Mode
|
||||
func (cpu *CPU) cld(info *stepInfo) {
|
||||
cpu.D = 0
|
||||
}
|
||||
|
||||
// CLI - Clear Interrupt Disable
|
||||
func (cpu *CPU) cli(info *stepInfo) {
|
||||
cpu.I = 0
|
||||
}
|
||||
|
||||
// CLV - Clear Overflow Flag
|
||||
func (cpu *CPU) clv(info *stepInfo) {
|
||||
cpu.V = 0
|
||||
}
|
||||
|
||||
// CMP - Compare
|
||||
func (cpu *CPU) cmp(info *stepInfo) {
|
||||
value := cpu.Read(info.address)
|
||||
cpu.compare(cpu.A, value)
|
||||
}
|
||||
|
||||
// CPX - Compare X Register
|
||||
func (cpu *CPU) cpx(info *stepInfo) {
|
||||
value := cpu.Read(info.address)
|
||||
cpu.compare(cpu.X, value)
|
||||
}
|
||||
|
||||
// CPY - Compare Y Register
|
||||
func (cpu *CPU) cpy(info *stepInfo) {
|
||||
value := cpu.Read(info.address)
|
||||
cpu.compare(cpu.Y, value)
|
||||
}
|
||||
|
||||
// DEC - Decrement Memory
|
||||
func (cpu *CPU) dec(info *stepInfo) {
|
||||
value := cpu.Read(info.address) - 1
|
||||
cpu.Write(info.address, value)
|
||||
cpu.setZN(value)
|
||||
}
|
||||
|
||||
// DEX - Decrement X Register
|
||||
func (cpu *CPU) dex(info *stepInfo) {
|
||||
cpu.X--
|
||||
cpu.setZN(cpu.X)
|
||||
}
|
||||
|
||||
// DEY - Decrement Y Register
|
||||
func (cpu *CPU) dey(info *stepInfo) {
|
||||
cpu.Y--
|
||||
cpu.setZN(cpu.Y)
|
||||
}
|
||||
|
||||
// EOR - Exclusive OR
|
||||
func (cpu *CPU) eor(info *stepInfo) {
|
||||
cpu.A = cpu.A ^ cpu.Read(info.address)
|
||||
cpu.setZN(cpu.A)
|
||||
}
|
||||
|
||||
// INC - Increment Memory
|
||||
func (cpu *CPU) inc(info *stepInfo) {
|
||||
value := cpu.Read(info.address) + 1
|
||||
cpu.Write(info.address, value)
|
||||
cpu.setZN(value)
|
||||
}
|
||||
|
||||
// INX - Increment X Register
|
||||
func (cpu *CPU) inx(info *stepInfo) {
|
||||
cpu.X++
|
||||
cpu.setZN(cpu.X)
|
||||
}
|
||||
|
||||
// INY - Increment Y Register
|
||||
func (cpu *CPU) iny(info *stepInfo) {
|
||||
cpu.Y++
|
||||
cpu.setZN(cpu.Y)
|
||||
}
|
||||
|
||||
// JMP - Jump
|
||||
func (cpu *CPU) jmp(info *stepInfo) {
|
||||
cpu.PC = info.address
|
||||
}
|
||||
|
||||
// JSR - Jump to Subroutine
|
||||
func (cpu *CPU) jsr(info *stepInfo) {
|
||||
cpu.push16(cpu.PC - 1)
|
||||
cpu.PC = info.address
|
||||
}
|
||||
|
||||
// LDA - Load Accumulator
|
||||
func (cpu *CPU) lda(info *stepInfo) {
|
||||
cpu.A = cpu.Read(info.address)
|
||||
cpu.setZN(cpu.A)
|
||||
}
|
||||
|
||||
// LDX - Load X Register
|
||||
func (cpu *CPU) ldx(info *stepInfo) {
|
||||
cpu.X = cpu.Read(info.address)
|
||||
cpu.setZN(cpu.X)
|
||||
}
|
||||
|
||||
// LDY - Load Y Register
|
||||
func (cpu *CPU) ldy(info *stepInfo) {
|
||||
cpu.Y = cpu.Read(info.address)
|
||||
cpu.setZN(cpu.Y)
|
||||
}
|
||||
|
||||
// LSR - Logical Shift Right
|
||||
func (cpu *CPU) lsr(info *stepInfo) {
|
||||
if info.mode == modeAccumulator {
|
||||
cpu.C = cpu.A & 1
|
||||
cpu.A >>= 1
|
||||
cpu.setZN(cpu.A)
|
||||
} else {
|
||||
value := cpu.Read(info.address)
|
||||
cpu.C = value & 1
|
||||
value >>= 1
|
||||
cpu.Write(info.address, value)
|
||||
cpu.setZN(value)
|
||||
}
|
||||
}
|
||||
|
||||
// NOP - No Operation
|
||||
func (cpu *CPU) nop(info *stepInfo) {
|
||||
}
|
||||
|
||||
// ORA - Logical Inclusive OR
|
||||
func (cpu *CPU) ora(info *stepInfo) {
|
||||
cpu.A = cpu.A | cpu.Read(info.address)
|
||||
cpu.setZN(cpu.A)
|
||||
}
|
||||
|
||||
// PHA - Push Accumulator
|
||||
func (cpu *CPU) pha(info *stepInfo) {
|
||||
cpu.push(cpu.A)
|
||||
}
|
||||
|
||||
// PHP - Push Processor Status
|
||||
func (cpu *CPU) php(info *stepInfo) {
|
||||
cpu.push(cpu.Flags() | 0x10)
|
||||
}
|
||||
|
||||
// PLA - Pull Accumulator
|
||||
func (cpu *CPU) pla(info *stepInfo) {
|
||||
cpu.A = cpu.pull()
|
||||
cpu.setZN(cpu.A)
|
||||
}
|
||||
|
||||
// PLP - Pull Processor Status
|
||||
func (cpu *CPU) plp(info *stepInfo) {
|
||||
cpu.SetFlags(cpu.pull()&0xEF | 0x20)
|
||||
}
|
||||
|
||||
// ROL - Rotate Left
|
||||
func (cpu *CPU) rol(info *stepInfo) {
|
||||
if info.mode == modeAccumulator {
|
||||
c := cpu.C
|
||||
cpu.C = (cpu.A >> 7) & 1
|
||||
cpu.A = (cpu.A << 1) | c
|
||||
cpu.setZN(cpu.A)
|
||||
} else {
|
||||
c := cpu.C
|
||||
value := cpu.Read(info.address)
|
||||
cpu.C = (value >> 7) & 1
|
||||
value = (value << 1) | c
|
||||
cpu.Write(info.address, value)
|
||||
cpu.setZN(value)
|
||||
}
|
||||
}
|
||||
|
||||
// ROR - Rotate Right
|
||||
func (cpu *CPU) ror(info *stepInfo) {
|
||||
if info.mode == modeAccumulator {
|
||||
c := cpu.C
|
||||
cpu.C = cpu.A & 1
|
||||
cpu.A = (cpu.A >> 1) | (c << 7)
|
||||
cpu.setZN(cpu.A)
|
||||
} else {
|
||||
c := cpu.C
|
||||
value := cpu.Read(info.address)
|
||||
cpu.C = value & 1
|
||||
value = (value >> 1) | (c << 7)
|
||||
cpu.Write(info.address, value)
|
||||
cpu.setZN(value)
|
||||
}
|
||||
}
|
||||
|
||||
// RTI - Return from Interrupt
|
||||
func (cpu *CPU) rti(info *stepInfo) {
|
||||
cpu.SetFlags(cpu.pull()&0xEF | 0x20)
|
||||
cpu.PC = cpu.pull16()
|
||||
}
|
||||
|
||||
// RTS - Return from Subroutine
|
||||
func (cpu *CPU) rts(info *stepInfo) {
|
||||
cpu.PC = cpu.pull16() + 1
|
||||
}
|
||||
|
||||
// SBC - Subtract with Carry
|
||||
func (cpu *CPU) sbc(info *stepInfo) {
|
||||
a := cpu.A
|
||||
b := cpu.Read(info.address)
|
||||
c := cpu.C
|
||||
cpu.A = a - b - (1 - c)
|
||||
cpu.setZN(cpu.A)
|
||||
if int(a)-int(b)-int(1-c) >= 0 {
|
||||
cpu.C = 1
|
||||
} else {
|
||||
cpu.C = 0
|
||||
}
|
||||
if (a^b)&0x80 != 0 && (a^cpu.A)&0x80 != 0 {
|
||||
cpu.V = 1
|
||||
} else {
|
||||
cpu.V = 0
|
||||
}
|
||||
}
|
||||
|
||||
// SEC - Set Carry Flag
|
||||
func (cpu *CPU) sec(info *stepInfo) {
|
||||
cpu.C = 1
|
||||
}
|
||||
|
||||
// SED - Set Decimal Flag
|
||||
func (cpu *CPU) sed(info *stepInfo) {
|
||||
cpu.D = 1
|
||||
}
|
||||
|
||||
// SEI - Set Interrupt Disable
|
||||
func (cpu *CPU) sei(info *stepInfo) {
|
||||
cpu.I = 1
|
||||
}
|
||||
|
||||
// STA - Store Accumulator
|
||||
func (cpu *CPU) sta(info *stepInfo) {
|
||||
cpu.Write(info.address, cpu.A)
|
||||
}
|
||||
|
||||
// STX - Store X Register
|
||||
func (cpu *CPU) stx(info *stepInfo) {
|
||||
cpu.Write(info.address, cpu.X)
|
||||
}
|
||||
|
||||
// STY - Store Y Register
|
||||
func (cpu *CPU) sty(info *stepInfo) {
|
||||
cpu.Write(info.address, cpu.Y)
|
||||
}
|
||||
|
||||
// TAX - Transfer Accumulator to X
|
||||
func (cpu *CPU) tax(info *stepInfo) {
|
||||
cpu.X = cpu.A
|
||||
cpu.setZN(cpu.X)
|
||||
}
|
||||
|
||||
// TAY - Transfer Accumulator to Y
|
||||
func (cpu *CPU) tay(info *stepInfo) {
|
||||
cpu.Y = cpu.A
|
||||
cpu.setZN(cpu.Y)
|
||||
}
|
||||
|
||||
// TSX - Transfer Stack Pointer to X
|
||||
func (cpu *CPU) tsx(info *stepInfo) {
|
||||
cpu.X = cpu.SP
|
||||
cpu.setZN(cpu.X)
|
||||
}
|
||||
|
||||
// TXA - Transfer X to Accumulator
|
||||
func (cpu *CPU) txa(info *stepInfo) {
|
||||
cpu.A = cpu.X
|
||||
cpu.setZN(cpu.A)
|
||||
}
|
||||
|
||||
// TXS - Transfer X to Stack Pointer
|
||||
func (cpu *CPU) txs(info *stepInfo) {
|
||||
cpu.SP = cpu.X
|
||||
}
|
||||
|
||||
// TYA - Transfer Y to Accumulator
|
||||
func (cpu *CPU) tya(info *stepInfo) {
|
||||
cpu.A = cpu.Y
|
||||
cpu.setZN(cpu.A)
|
||||
}
|
||||
|
||||
// illegal opcodes below
|
||||
|
||||
func (cpu *CPU) ahx(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) alr(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) anc(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) arr(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) axs(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) dcp(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) isc(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) kil(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) las(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) lax(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) rla(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) rra(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) sax(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) shx(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) shy(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) slo(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) sre(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) tas(info *stepInfo) {
|
||||
}
|
||||
|
||||
func (cpu *CPU) xaa(info *stepInfo) {
|
||||
}
|
||||
57
nes/filter.go
Normal file
57
nes/filter.go
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
package nes
|
||||
|
||||
import "math"
|
||||
|
||||
type Filter interface {
|
||||
Step(x float32) float32
|
||||
}
|
||||
|
||||
// First order filters are defined by the following parameters.
|
||||
// y[n] = B0*x[n] + B1*x[n-1] - A1*y[n-1]
|
||||
type FirstOrderFilter struct {
|
||||
B0 float32
|
||||
B1 float32
|
||||
A1 float32
|
||||
prevX float32
|
||||
prevY float32
|
||||
}
|
||||
|
||||
func (f *FirstOrderFilter) Step(x float32) float32 {
|
||||
y := f.B0*x + f.B1*f.prevX - f.A1*f.prevY
|
||||
f.prevY = y
|
||||
f.prevX = x
|
||||
return y
|
||||
}
|
||||
|
||||
// sampleRate: samples per second
|
||||
// cutoffFreq: oscillations per second
|
||||
func LowPassFilter(sampleRate float32, cutoffFreq float32) Filter {
|
||||
c := sampleRate / math.Pi / cutoffFreq
|
||||
a0i := 1 / (1 + c)
|
||||
return &FirstOrderFilter{
|
||||
B0: a0i,
|
||||
B1: a0i,
|
||||
A1: (1 - c) * a0i,
|
||||
}
|
||||
}
|
||||
|
||||
func HighPassFilter(sampleRate float32, cutoffFreq float32) Filter {
|
||||
c := sampleRate / math.Pi / cutoffFreq
|
||||
a0i := 1 / (1 + c)
|
||||
return &FirstOrderFilter{
|
||||
B0: c * a0i,
|
||||
B1: -c * a0i,
|
||||
A1: (1 - c) * a0i,
|
||||
}
|
||||
}
|
||||
|
||||
type FilterChain []Filter
|
||||
|
||||
func (fc FilterChain) Step(x float32) float32 {
|
||||
if fc != nil {
|
||||
for i := range fc {
|
||||
x = fc[i].Step(x)
|
||||
}
|
||||
}
|
||||
return x
|
||||
}
|
||||
84
nes/ines.go
Normal file
84
nes/ines.go
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
package nes
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
const iNESFileMagic = 0x1a53454e
|
||||
|
||||
type iNESFileHeader struct {
|
||||
Magic uint32 // iNES magic number
|
||||
NumPRG byte // number of PRG-ROM banks (16KB each)
|
||||
NumCHR byte // number of CHR-ROM banks (8KB each)
|
||||
Control1 byte // control bits
|
||||
Control2 byte // control bits
|
||||
NumRAM byte // PRG-RAM size (x 8KB)
|
||||
_ [7]byte // unused padding
|
||||
}
|
||||
|
||||
// LoadNESFile reads an iNES file (.nes) and returns a Cartridge on success.
|
||||
// http://wiki.nesdev.com/w/index.php/INES
|
||||
// http://nesdev.com/NESDoc.pdf (page 28)
|
||||
func LoadNESFile(path string) (*Cartridge, error) {
|
||||
// open file
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
// read file header
|
||||
header := iNESFileHeader{}
|
||||
if err := binary.Read(file, binary.LittleEndian, &header); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// verify header magic number
|
||||
if header.Magic != iNESFileMagic {
|
||||
return nil, errors.New("invalid .nes file")
|
||||
}
|
||||
|
||||
// mapper type
|
||||
mapper1 := header.Control1 >> 4
|
||||
mapper2 := header.Control2 >> 4
|
||||
mapper := mapper1 | mapper2<<4
|
||||
|
||||
// mirroring type
|
||||
mirror1 := header.Control1 & 1
|
||||
mirror2 := (header.Control1 >> 3) & 1
|
||||
mirror := mirror1 | mirror2<<1
|
||||
|
||||
// battery-backed RAM
|
||||
battery := (header.Control1 >> 1) & 1
|
||||
|
||||
// read trainer if present (unused)
|
||||
if header.Control1&4 == 4 {
|
||||
trainer := make([]byte, 512)
|
||||
if _, err := io.ReadFull(file, trainer); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// read prg-rom bank(s)
|
||||
prg := make([]byte, int(header.NumPRG)*16384)
|
||||
if _, err := io.ReadFull(file, prg); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// read chr-rom bank(s)
|
||||
chr := make([]byte, int(header.NumCHR)*8192)
|
||||
if _, err := io.ReadFull(file, chr); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// provide chr-rom/ram if not in file
|
||||
if header.NumCHR == 0 {
|
||||
chr = make([]byte, 8192)
|
||||
}
|
||||
|
||||
// success
|
||||
return NewCartridge(prg, chr, mapper, mirror, battery), nil
|
||||
}
|
||||
36
nes/mapper.go
Normal file
36
nes/mapper.go
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package nes
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Mapper interface {
|
||||
Read(address uint16) byte
|
||||
Write(address uint16, value byte)
|
||||
Step()
|
||||
Save(encoder *gob.Encoder) error
|
||||
Load(decoder *gob.Decoder) error
|
||||
}
|
||||
|
||||
func NewMapper(console *Console) (Mapper, error) {
|
||||
cartridge := console.Cartridge
|
||||
switch cartridge.Mapper {
|
||||
case 0:
|
||||
return NewMapper2(cartridge), nil
|
||||
case 1:
|
||||
return NewMapper1(cartridge), nil
|
||||
case 2:
|
||||
return NewMapper2(cartridge), nil
|
||||
case 3:
|
||||
return NewMapper3(cartridge), nil
|
||||
case 4:
|
||||
return NewMapper4(console, cartridge), nil
|
||||
case 7:
|
||||
return NewMapper7(cartridge), nil
|
||||
case 225:
|
||||
return NewMapper225(cartridge), nil
|
||||
}
|
||||
err := fmt.Errorf("unsupported mapper: %d", cartridge.Mapper)
|
||||
return nil, err
|
||||
}
|
||||
205
nes/mapper1.go
Normal file
205
nes/mapper1.go
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
package nes
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"log"
|
||||
)
|
||||
|
||||
type Mapper1 struct {
|
||||
*Cartridge
|
||||
shiftRegister byte
|
||||
control byte
|
||||
prgMode byte
|
||||
chrMode byte
|
||||
prgBank byte
|
||||
chrBank0 byte
|
||||
chrBank1 byte
|
||||
prgOffsets [2]int
|
||||
chrOffsets [2]int
|
||||
}
|
||||
|
||||
func NewMapper1(cartridge *Cartridge) Mapper {
|
||||
m := Mapper1{}
|
||||
m.Cartridge = cartridge
|
||||
m.shiftRegister = 0x10
|
||||
m.prgOffsets[1] = m.prgBankOffset(-1)
|
||||
return &m
|
||||
}
|
||||
|
||||
func (m *Mapper1) Save(encoder *gob.Encoder) error {
|
||||
encoder.Encode(m.shiftRegister)
|
||||
encoder.Encode(m.control)
|
||||
encoder.Encode(m.prgMode)
|
||||
encoder.Encode(m.chrMode)
|
||||
encoder.Encode(m.prgBank)
|
||||
encoder.Encode(m.chrBank0)
|
||||
encoder.Encode(m.chrBank1)
|
||||
encoder.Encode(m.prgOffsets)
|
||||
encoder.Encode(m.chrOffsets)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mapper1) Load(decoder *gob.Decoder) error {
|
||||
decoder.Decode(&m.shiftRegister)
|
||||
decoder.Decode(&m.control)
|
||||
decoder.Decode(&m.prgMode)
|
||||
decoder.Decode(&m.chrMode)
|
||||
decoder.Decode(&m.prgBank)
|
||||
decoder.Decode(&m.chrBank0)
|
||||
decoder.Decode(&m.chrBank1)
|
||||
decoder.Decode(&m.prgOffsets)
|
||||
decoder.Decode(&m.chrOffsets)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mapper1) Step() {
|
||||
}
|
||||
|
||||
func (m *Mapper1) Read(address uint16) byte {
|
||||
switch {
|
||||
case address < 0x2000:
|
||||
bank := address / 0x1000
|
||||
offset := address % 0x1000
|
||||
return m.CHR[m.chrOffsets[bank]+int(offset)]
|
||||
case address >= 0x8000:
|
||||
address = address - 0x8000
|
||||
bank := address / 0x4000
|
||||
offset := address % 0x4000
|
||||
return m.PRG[m.prgOffsets[bank]+int(offset)]
|
||||
case address >= 0x6000:
|
||||
return m.SRAM[int(address)-0x6000]
|
||||
default:
|
||||
log.Fatalf("unhandled mapper1 read at address: 0x%04X", address)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Mapper1) Write(address uint16, value byte) {
|
||||
switch {
|
||||
case address < 0x2000:
|
||||
bank := address / 0x1000
|
||||
offset := address % 0x1000
|
||||
m.CHR[m.chrOffsets[bank]+int(offset)] = value
|
||||
case address >= 0x8000:
|
||||
m.loadRegister(address, value)
|
||||
case address >= 0x6000:
|
||||
m.SRAM[int(address)-0x6000] = value
|
||||
default:
|
||||
log.Fatalf("unhandled mapper1 write at address: 0x%04X", address)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Mapper1) loadRegister(address uint16, value byte) {
|
||||
if value&0x80 == 0x80 {
|
||||
m.shiftRegister = 0x10
|
||||
m.writeControl(m.control | 0x0C)
|
||||
} else {
|
||||
complete := m.shiftRegister&1 == 1
|
||||
m.shiftRegister >>= 1
|
||||
m.shiftRegister |= (value & 1) << 4
|
||||
if complete {
|
||||
m.writeRegister(address, m.shiftRegister)
|
||||
m.shiftRegister = 0x10
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Mapper1) writeRegister(address uint16, value byte) {
|
||||
switch {
|
||||
case address <= 0x9FFF:
|
||||
m.writeControl(value)
|
||||
case address <= 0xBFFF:
|
||||
m.writeCHRBank0(value)
|
||||
case address <= 0xDFFF:
|
||||
m.writeCHRBank1(value)
|
||||
case address <= 0xFFFF:
|
||||
m.writePRGBank(value)
|
||||
}
|
||||
}
|
||||
|
||||
// Control (internal, $8000-$9FFF)
|
||||
func (m *Mapper1) writeControl(value byte) {
|
||||
m.control = value
|
||||
m.chrMode = (value >> 4) & 1
|
||||
m.prgMode = (value >> 2) & 3
|
||||
mirror := value & 3
|
||||
switch mirror {
|
||||
case 0:
|
||||
m.Cartridge.Mirror = MirrorSingle0
|
||||
case 1:
|
||||
m.Cartridge.Mirror = MirrorSingle1
|
||||
case 2:
|
||||
m.Cartridge.Mirror = MirrorVertical
|
||||
case 3:
|
||||
m.Cartridge.Mirror = MirrorHorizontal
|
||||
}
|
||||
m.updateOffsets()
|
||||
}
|
||||
|
||||
// CHR bank 0 (internal, $A000-$BFFF)
|
||||
func (m *Mapper1) writeCHRBank0(value byte) {
|
||||
m.chrBank0 = value
|
||||
m.updateOffsets()
|
||||
}
|
||||
|
||||
// CHR bank 1 (internal, $C000-$DFFF)
|
||||
func (m *Mapper1) writeCHRBank1(value byte) {
|
||||
m.chrBank1 = value
|
||||
m.updateOffsets()
|
||||
}
|
||||
|
||||
// PRG bank (internal, $E000-$FFFF)
|
||||
func (m *Mapper1) writePRGBank(value byte) {
|
||||
m.prgBank = value & 0x0F
|
||||
m.updateOffsets()
|
||||
}
|
||||
|
||||
func (m *Mapper1) prgBankOffset(index int) int {
|
||||
if index >= 0x80 {
|
||||
index -= 0x100
|
||||
}
|
||||
index %= len(m.PRG) / 0x4000
|
||||
offset := index * 0x4000
|
||||
if offset < 0 {
|
||||
offset += len(m.PRG)
|
||||
}
|
||||
return offset
|
||||
}
|
||||
|
||||
func (m *Mapper1) chrBankOffset(index int) int {
|
||||
if index >= 0x80 {
|
||||
index -= 0x100
|
||||
}
|
||||
index %= len(m.CHR) / 0x1000
|
||||
offset := index * 0x1000
|
||||
if offset < 0 {
|
||||
offset += len(m.CHR)
|
||||
}
|
||||
return offset
|
||||
}
|
||||
|
||||
// PRG ROM bank mode (0, 1: switch 32 KB at $8000, ignoring low bit of bank number;
|
||||
// 2: fix first bank at $8000 and switch 16 KB bank at $C000;
|
||||
// 3: fix last bank at $C000 and switch 16 KB bank at $8000)
|
||||
// CHR ROM bank mode (0: switch 8 KB at a time; 1: switch two separate 4 KB banks)
|
||||
func (m *Mapper1) updateOffsets() {
|
||||
switch m.prgMode {
|
||||
case 0, 1:
|
||||
m.prgOffsets[0] = m.prgBankOffset(int(m.prgBank & 0xFE))
|
||||
m.prgOffsets[1] = m.prgBankOffset(int(m.prgBank | 0x01))
|
||||
case 2:
|
||||
m.prgOffsets[0] = 0
|
||||
m.prgOffsets[1] = m.prgBankOffset(int(m.prgBank))
|
||||
case 3:
|
||||
m.prgOffsets[0] = m.prgBankOffset(int(m.prgBank))
|
||||
m.prgOffsets[1] = m.prgBankOffset(-1)
|
||||
}
|
||||
switch m.chrMode {
|
||||
case 0:
|
||||
m.chrOffsets[0] = m.chrBankOffset(int(m.chrBank0 & 0xFE))
|
||||
m.chrOffsets[1] = m.chrBankOffset(int(m.chrBank0 | 0x01))
|
||||
case 1:
|
||||
m.chrOffsets[0] = m.chrBankOffset(int(m.chrBank0))
|
||||
m.chrOffsets[1] = m.chrBankOffset(int(m.chrBank1))
|
||||
}
|
||||
}
|
||||
70
nes/mapper2.go
Normal file
70
nes/mapper2.go
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
package nes
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"log"
|
||||
)
|
||||
|
||||
type Mapper2 struct {
|
||||
*Cartridge
|
||||
prgBanks int
|
||||
prgBank1 int
|
||||
prgBank2 int
|
||||
}
|
||||
|
||||
func NewMapper2(cartridge *Cartridge) Mapper {
|
||||
prgBanks := len(cartridge.PRG) / 0x4000
|
||||
prgBank1 := 0
|
||||
prgBank2 := prgBanks - 1
|
||||
return &Mapper2{cartridge, prgBanks, prgBank1, prgBank2}
|
||||
}
|
||||
|
||||
func (m *Mapper2) Save(encoder *gob.Encoder) error {
|
||||
encoder.Encode(m.prgBanks)
|
||||
encoder.Encode(m.prgBank1)
|
||||
encoder.Encode(m.prgBank2)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mapper2) Load(decoder *gob.Decoder) error {
|
||||
decoder.Decode(&m.prgBanks)
|
||||
decoder.Decode(&m.prgBank1)
|
||||
decoder.Decode(&m.prgBank2)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mapper2) Step() {
|
||||
}
|
||||
|
||||
func (m *Mapper2) Read(address uint16) byte {
|
||||
switch {
|
||||
case address < 0x2000:
|
||||
return m.CHR[address]
|
||||
case address >= 0xC000:
|
||||
index := m.prgBank2*0x4000 + int(address-0xC000)
|
||||
return m.PRG[index]
|
||||
case address >= 0x8000:
|
||||
index := m.prgBank1*0x4000 + int(address-0x8000)
|
||||
return m.PRG[index]
|
||||
case address >= 0x6000:
|
||||
index := int(address) - 0x6000
|
||||
return m.SRAM[index]
|
||||
default:
|
||||
log.Fatalf("unhandled mapper2 read at address: 0x%04X", address)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Mapper2) Write(address uint16, value byte) {
|
||||
switch {
|
||||
case address < 0x2000:
|
||||
m.CHR[address] = value
|
||||
case address >= 0x8000:
|
||||
m.prgBank1 = int(value) % m.prgBanks
|
||||
case address >= 0x6000:
|
||||
index := int(address) - 0x6000
|
||||
m.SRAM[index] = value
|
||||
default:
|
||||
log.Fatalf("unhandled mapper2 write at address: 0x%04X", address)
|
||||
}
|
||||
}
|
||||
85
nes/mapper225.go
Normal file
85
nes/mapper225.go
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
package nes
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"log"
|
||||
)
|
||||
|
||||
// https://github.com/asfdfdfd/fceux/blob/master/src/boards/225.cpp
|
||||
// https://wiki.nesdev.com/w/index.php/INES_Mapper_225
|
||||
|
||||
type Mapper225 struct {
|
||||
*Cartridge
|
||||
chrBank int
|
||||
prgBank1 int
|
||||
prgBank2 int
|
||||
}
|
||||
|
||||
func NewMapper225(cartridge *Cartridge) Mapper {
|
||||
prgBanks := len(cartridge.PRG) / 0x4000
|
||||
return &Mapper225{cartridge, 0, 0, prgBanks - 1}
|
||||
}
|
||||
|
||||
func (m *Mapper225) Save(encoder *gob.Encoder) error {
|
||||
encoder.Encode(m.chrBank)
|
||||
encoder.Encode(m.prgBank1)
|
||||
encoder.Encode(m.prgBank2)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mapper225) Load(decoder *gob.Decoder) error {
|
||||
decoder.Decode(&m.chrBank)
|
||||
decoder.Decode(&m.prgBank1)
|
||||
decoder.Decode(&m.prgBank2)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mapper225) Step() {
|
||||
}
|
||||
|
||||
func (m *Mapper225) Read(address uint16) byte {
|
||||
switch {
|
||||
case address < 0x2000:
|
||||
index := m.chrBank*0x2000 + int(address)
|
||||
return m.CHR[index]
|
||||
case address >= 0xC000:
|
||||
index := m.prgBank2*0x4000 + int(address-0xC000)
|
||||
return m.PRG[index]
|
||||
case address >= 0x8000:
|
||||
index := m.prgBank1*0x4000 + int(address-0x8000)
|
||||
return m.PRG[index]
|
||||
case address >= 0x6000:
|
||||
index := int(address) - 0x6000
|
||||
return m.SRAM[index]
|
||||
default:
|
||||
log.Fatalf("unhandled Mapper225 read at address: 0x%04X", address)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Mapper225) Write(address uint16, value byte) {
|
||||
if (address < 0x8000) {
|
||||
return
|
||||
}
|
||||
|
||||
A := int(address)
|
||||
bank := (A >> 14) & 1
|
||||
m.chrBank = (A & 0x3f) | (bank << 6)
|
||||
prg := ((A >> 6) & 0x3f) | (bank << 6)
|
||||
mode := (A >> 12) & 1;
|
||||
if (mode == 1) {
|
||||
m.prgBank1 = prg
|
||||
m.prgBank2 = prg
|
||||
} else {
|
||||
m.prgBank1 = prg
|
||||
m.prgBank2 = prg + 1
|
||||
}
|
||||
mirr := (A >> 13) & 1
|
||||
if (mirr == 1) {
|
||||
m.Cartridge.Mirror = MirrorHorizontal
|
||||
} else {
|
||||
m.Cartridge.Mirror = MirrorVertical
|
||||
}
|
||||
|
||||
// fmt.Println(address, mirr, mode, prg)
|
||||
}
|
||||
70
nes/mapper3.go
Normal file
70
nes/mapper3.go
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
package nes
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"log"
|
||||
)
|
||||
|
||||
type Mapper3 struct {
|
||||
*Cartridge
|
||||
chrBank int
|
||||
prgBank1 int
|
||||
prgBank2 int
|
||||
}
|
||||
|
||||
func NewMapper3(cartridge *Cartridge) Mapper {
|
||||
prgBanks := len(cartridge.PRG) / 0x4000
|
||||
return &Mapper3{cartridge, 0, 0, prgBanks - 1}
|
||||
}
|
||||
|
||||
func (m *Mapper3) Save(encoder *gob.Encoder) error {
|
||||
encoder.Encode(m.chrBank)
|
||||
encoder.Encode(m.prgBank1)
|
||||
encoder.Encode(m.prgBank2)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mapper3) Load(decoder *gob.Decoder) error {
|
||||
decoder.Decode(&m.chrBank)
|
||||
decoder.Decode(&m.prgBank1)
|
||||
decoder.Decode(&m.prgBank2)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mapper3) Step() {
|
||||
}
|
||||
|
||||
func (m *Mapper3) Read(address uint16) byte {
|
||||
switch {
|
||||
case address < 0x2000:
|
||||
index := m.chrBank*0x2000 + int(address)
|
||||
return m.CHR[index]
|
||||
case address >= 0xC000:
|
||||
index := m.prgBank2*0x4000 + int(address-0xC000)
|
||||
return m.PRG[index]
|
||||
case address >= 0x8000:
|
||||
index := m.prgBank1*0x4000 + int(address-0x8000)
|
||||
return m.PRG[index]
|
||||
case address >= 0x6000:
|
||||
index := int(address) - 0x6000
|
||||
return m.SRAM[index]
|
||||
default:
|
||||
log.Fatalf("unhandled mapper3 read at address: 0x%04X", address)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Mapper3) Write(address uint16, value byte) {
|
||||
switch {
|
||||
case address < 0x2000:
|
||||
index := m.chrBank*0x2000 + int(address)
|
||||
m.CHR[index] = value
|
||||
case address >= 0x8000:
|
||||
m.chrBank = int(value & 3)
|
||||
case address >= 0x6000:
|
||||
index := int(address) - 0x6000
|
||||
m.SRAM[index] = value
|
||||
default:
|
||||
log.Fatalf("unhandled mapper3 write at address: 0x%04X", address)
|
||||
}
|
||||
}
|
||||
234
nes/mapper4.go
Normal file
234
nes/mapper4.go
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
package nes
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"log"
|
||||
)
|
||||
|
||||
type Mapper4 struct {
|
||||
*Cartridge
|
||||
console *Console
|
||||
register byte
|
||||
registers [8]byte
|
||||
prgMode byte
|
||||
chrMode byte
|
||||
prgOffsets [4]int
|
||||
chrOffsets [8]int
|
||||
reload byte
|
||||
counter byte
|
||||
irqEnable bool
|
||||
}
|
||||
|
||||
func NewMapper4(console *Console, cartridge *Cartridge) Mapper {
|
||||
m := Mapper4{Cartridge: cartridge, console: console}
|
||||
m.prgOffsets[0] = m.prgBankOffset(0)
|
||||
m.prgOffsets[1] = m.prgBankOffset(1)
|
||||
m.prgOffsets[2] = m.prgBankOffset(-2)
|
||||
m.prgOffsets[3] = m.prgBankOffset(-1)
|
||||
return &m
|
||||
}
|
||||
|
||||
func (m *Mapper4) Save(encoder *gob.Encoder) error {
|
||||
encoder.Encode(m.register)
|
||||
encoder.Encode(m.registers)
|
||||
encoder.Encode(m.prgMode)
|
||||
encoder.Encode(m.chrMode)
|
||||
encoder.Encode(m.prgOffsets)
|
||||
encoder.Encode(m.chrOffsets)
|
||||
encoder.Encode(m.reload)
|
||||
encoder.Encode(m.counter)
|
||||
encoder.Encode(m.irqEnable)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mapper4) Load(decoder *gob.Decoder) error {
|
||||
decoder.Decode(&m.register)
|
||||
decoder.Decode(&m.registers)
|
||||
decoder.Decode(&m.prgMode)
|
||||
decoder.Decode(&m.chrMode)
|
||||
decoder.Decode(&m.prgOffsets)
|
||||
decoder.Decode(&m.chrOffsets)
|
||||
decoder.Decode(&m.reload)
|
||||
decoder.Decode(&m.counter)
|
||||
decoder.Decode(&m.irqEnable)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mapper4) Step() {
|
||||
ppu := m.console.PPU
|
||||
if ppu.Cycle != 280 { // TODO: this *should* be 260
|
||||
return
|
||||
}
|
||||
if ppu.ScanLine > 239 && ppu.ScanLine < 261 {
|
||||
return
|
||||
}
|
||||
if ppu.flagShowBackground == 0 && ppu.flagShowSprites == 0 {
|
||||
return
|
||||
}
|
||||
m.HandleScanLine()
|
||||
}
|
||||
|
||||
func (m *Mapper4) HandleScanLine() {
|
||||
if m.counter == 0 {
|
||||
m.counter = m.reload
|
||||
} else {
|
||||
m.counter--
|
||||
if m.counter == 0 && m.irqEnable {
|
||||
m.console.CPU.triggerIRQ()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Mapper4) Read(address uint16) byte {
|
||||
switch {
|
||||
case address < 0x2000:
|
||||
bank := address / 0x0400
|
||||
offset := address % 0x0400
|
||||
return m.CHR[m.chrOffsets[bank]+int(offset)]
|
||||
case address >= 0x8000:
|
||||
address = address - 0x8000
|
||||
bank := address / 0x2000
|
||||
offset := address % 0x2000
|
||||
return m.PRG[m.prgOffsets[bank]+int(offset)]
|
||||
case address >= 0x6000:
|
||||
return m.SRAM[int(address)-0x6000]
|
||||
default:
|
||||
log.Fatalf("unhandled mapper4 read at address: 0x%04X", address)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Mapper4) Write(address uint16, value byte) {
|
||||
switch {
|
||||
case address < 0x2000:
|
||||
bank := address / 0x0400
|
||||
offset := address % 0x0400
|
||||
m.CHR[m.chrOffsets[bank]+int(offset)] = value
|
||||
case address >= 0x8000:
|
||||
m.writeRegister(address, value)
|
||||
case address >= 0x6000:
|
||||
m.SRAM[int(address)-0x6000] = value
|
||||
default:
|
||||
log.Fatalf("unhandled mapper4 write at address: 0x%04X", address)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Mapper4) writeRegister(address uint16, value byte) {
|
||||
switch {
|
||||
case address <= 0x9FFF && address%2 == 0:
|
||||
m.writeBankSelect(value)
|
||||
case address <= 0x9FFF && address%2 == 1:
|
||||
m.writeBankData(value)
|
||||
case address <= 0xBFFF && address%2 == 0:
|
||||
m.writeMirror(value)
|
||||
case address <= 0xBFFF && address%2 == 1:
|
||||
m.writeProtect(value)
|
||||
case address <= 0xDFFF && address%2 == 0:
|
||||
m.writeIRQLatch(value)
|
||||
case address <= 0xDFFF && address%2 == 1:
|
||||
m.writeIRQReload(value)
|
||||
case address <= 0xFFFF && address%2 == 0:
|
||||
m.writeIRQDisable(value)
|
||||
case address <= 0xFFFF && address%2 == 1:
|
||||
m.writeIRQEnable(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Mapper4) writeBankSelect(value byte) {
|
||||
m.prgMode = (value >> 6) & 1
|
||||
m.chrMode = (value >> 7) & 1
|
||||
m.register = value & 7
|
||||
m.updateOffsets()
|
||||
}
|
||||
|
||||
func (m *Mapper4) writeBankData(value byte) {
|
||||
m.registers[m.register] = value
|
||||
m.updateOffsets()
|
||||
}
|
||||
|
||||
func (m *Mapper4) writeMirror(value byte) {
|
||||
switch value & 1 {
|
||||
case 0:
|
||||
m.Cartridge.Mirror = MirrorVertical
|
||||
case 1:
|
||||
m.Cartridge.Mirror = MirrorHorizontal
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Mapper4) writeProtect(value byte) {
|
||||
}
|
||||
|
||||
func (m *Mapper4) writeIRQLatch(value byte) {
|
||||
m.reload = value
|
||||
}
|
||||
|
||||
func (m *Mapper4) writeIRQReload(value byte) {
|
||||
m.counter = 0
|
||||
}
|
||||
|
||||
func (m *Mapper4) writeIRQDisable(value byte) {
|
||||
m.irqEnable = false
|
||||
}
|
||||
|
||||
func (m *Mapper4) writeIRQEnable(value byte) {
|
||||
m.irqEnable = true
|
||||
}
|
||||
|
||||
func (m *Mapper4) prgBankOffset(index int) int {
|
||||
if index >= 0x80 {
|
||||
index -= 0x100
|
||||
}
|
||||
index %= len(m.PRG) / 0x2000
|
||||
offset := index * 0x2000
|
||||
if offset < 0 {
|
||||
offset += len(m.PRG)
|
||||
}
|
||||
return offset
|
||||
}
|
||||
|
||||
func (m *Mapper4) chrBankOffset(index int) int {
|
||||
if index >= 0x80 {
|
||||
index -= 0x100
|
||||
}
|
||||
index %= len(m.CHR) / 0x0400
|
||||
offset := index * 0x0400
|
||||
if offset < 0 {
|
||||
offset += len(m.CHR)
|
||||
}
|
||||
return offset
|
||||
}
|
||||
|
||||
func (m *Mapper4) updateOffsets() {
|
||||
switch m.prgMode {
|
||||
case 0:
|
||||
m.prgOffsets[0] = m.prgBankOffset(int(m.registers[6]))
|
||||
m.prgOffsets[1] = m.prgBankOffset(int(m.registers[7]))
|
||||
m.prgOffsets[2] = m.prgBankOffset(-2)
|
||||
m.prgOffsets[3] = m.prgBankOffset(-1)
|
||||
case 1:
|
||||
m.prgOffsets[0] = m.prgBankOffset(-2)
|
||||
m.prgOffsets[1] = m.prgBankOffset(int(m.registers[7]))
|
||||
m.prgOffsets[2] = m.prgBankOffset(int(m.registers[6]))
|
||||
m.prgOffsets[3] = m.prgBankOffset(-1)
|
||||
}
|
||||
switch m.chrMode {
|
||||
case 0:
|
||||
m.chrOffsets[0] = m.chrBankOffset(int(m.registers[0] & 0xFE))
|
||||
m.chrOffsets[1] = m.chrBankOffset(int(m.registers[0] | 0x01))
|
||||
m.chrOffsets[2] = m.chrBankOffset(int(m.registers[1] & 0xFE))
|
||||
m.chrOffsets[3] = m.chrBankOffset(int(m.registers[1] | 0x01))
|
||||
m.chrOffsets[4] = m.chrBankOffset(int(m.registers[2]))
|
||||
m.chrOffsets[5] = m.chrBankOffset(int(m.registers[3]))
|
||||
m.chrOffsets[6] = m.chrBankOffset(int(m.registers[4]))
|
||||
m.chrOffsets[7] = m.chrBankOffset(int(m.registers[5]))
|
||||
case 1:
|
||||
m.chrOffsets[0] = m.chrBankOffset(int(m.registers[2]))
|
||||
m.chrOffsets[1] = m.chrBankOffset(int(m.registers[3]))
|
||||
m.chrOffsets[2] = m.chrBankOffset(int(m.registers[4]))
|
||||
m.chrOffsets[3] = m.chrBankOffset(int(m.registers[5]))
|
||||
m.chrOffsets[4] = m.chrBankOffset(int(m.registers[0] & 0xFE))
|
||||
m.chrOffsets[5] = m.chrBankOffset(int(m.registers[0] | 0x01))
|
||||
m.chrOffsets[6] = m.chrBankOffset(int(m.registers[1] & 0xFE))
|
||||
m.chrOffsets[7] = m.chrBankOffset(int(m.registers[1] | 0x01))
|
||||
}
|
||||
}
|
||||
64
nes/mapper7.go
Normal file
64
nes/mapper7.go
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
package nes
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"log"
|
||||
)
|
||||
|
||||
type Mapper7 struct {
|
||||
*Cartridge
|
||||
prgBank int
|
||||
}
|
||||
|
||||
func NewMapper7(cartridge *Cartridge) Mapper {
|
||||
return &Mapper7{cartridge, 0}
|
||||
}
|
||||
|
||||
func (m *Mapper7) Save(encoder *gob.Encoder) error {
|
||||
encoder.Encode(m.prgBank)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mapper7) Load(decoder *gob.Decoder) error {
|
||||
decoder.Decode(&m.prgBank)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Mapper7) Step() {
|
||||
}
|
||||
|
||||
func (m *Mapper7) Read(address uint16) byte {
|
||||
switch {
|
||||
case address < 0x2000:
|
||||
return m.CHR[address]
|
||||
case address >= 0x8000:
|
||||
index := m.prgBank*0x8000 + int(address-0x8000)
|
||||
return m.PRG[index]
|
||||
case address >= 0x6000:
|
||||
index := int(address) - 0x6000
|
||||
return m.SRAM[index]
|
||||
default:
|
||||
log.Fatalf("unhandled mapper7 read at address: 0x%04X", address)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Mapper7) Write(address uint16, value byte) {
|
||||
switch {
|
||||
case address < 0x2000:
|
||||
m.CHR[address] = value
|
||||
case address >= 0x8000:
|
||||
m.prgBank = int(value & 7)
|
||||
switch value & 0x10 {
|
||||
case 0x00:
|
||||
m.Cartridge.Mirror = MirrorSingle0
|
||||
case 0x10:
|
||||
m.Cartridge.Mirror = MirrorSingle1
|
||||
}
|
||||
case address >= 0x6000:
|
||||
index := int(address) - 0x6000
|
||||
m.SRAM[index] = value
|
||||
default:
|
||||
log.Fatalf("unhandled mapper7 write at address: 0x%04X", address)
|
||||
}
|
||||
}
|
||||
134
nes/memory.go
Normal file
134
nes/memory.go
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
package nes
|
||||
|
||||
import "log"
|
||||
|
||||
type Memory interface {
|
||||
Read(address uint16) byte
|
||||
Write(address uint16, value byte)
|
||||
}
|
||||
|
||||
// CPU Memory Map
|
||||
|
||||
type cpuMemory struct {
|
||||
console *Console
|
||||
}
|
||||
|
||||
func NewCPUMemory(console *Console) Memory {
|
||||
return &cpuMemory{console}
|
||||
}
|
||||
|
||||
func (mem *cpuMemory) Read(address uint16) byte {
|
||||
switch {
|
||||
case address < 0x2000:
|
||||
return mem.console.RAM[address%0x0800]
|
||||
case address < 0x4000:
|
||||
return mem.console.PPU.readRegister(0x2000 + address%8)
|
||||
case address == 0x4014:
|
||||
return mem.console.PPU.readRegister(address)
|
||||
case address == 0x4015:
|
||||
return mem.console.APU.readRegister(address)
|
||||
case address == 0x4016:
|
||||
return mem.console.Controller1.Read()
|
||||
case address == 0x4017:
|
||||
return mem.console.Controller2.Read()
|
||||
case address < 0x6000:
|
||||
// TODO: I/O registers
|
||||
case address >= 0x6000:
|
||||
return mem.console.Mapper.Read(address)
|
||||
default:
|
||||
log.Fatalf("unhandled cpu memory read at address: 0x%04X", address)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (mem *cpuMemory) Write(address uint16, value byte) {
|
||||
switch {
|
||||
case address < 0x2000:
|
||||
mem.console.RAM[address%0x0800] = value
|
||||
case address < 0x4000:
|
||||
mem.console.PPU.writeRegister(0x2000+address%8, value)
|
||||
case address < 0x4014:
|
||||
mem.console.APU.writeRegister(address, value)
|
||||
case address == 0x4014:
|
||||
mem.console.PPU.writeRegister(address, value)
|
||||
case address == 0x4015:
|
||||
mem.console.APU.writeRegister(address, value)
|
||||
case address == 0x4016:
|
||||
mem.console.Controller1.Write(value)
|
||||
mem.console.Controller2.Write(value)
|
||||
case address == 0x4017:
|
||||
mem.console.APU.writeRegister(address, value)
|
||||
case address < 0x6000:
|
||||
// TODO: I/O registers
|
||||
case address >= 0x6000:
|
||||
mem.console.Mapper.Write(address, value)
|
||||
default:
|
||||
log.Fatalf("unhandled cpu memory write at address: 0x%04X", address)
|
||||
}
|
||||
}
|
||||
|
||||
// PPU Memory Map
|
||||
|
||||
type ppuMemory struct {
|
||||
console *Console
|
||||
}
|
||||
|
||||
func NewPPUMemory(console *Console) Memory {
|
||||
return &ppuMemory{console}
|
||||
}
|
||||
|
||||
func (mem *ppuMemory) Read(address uint16) byte {
|
||||
address = address % 0x4000
|
||||
switch {
|
||||
case address < 0x2000:
|
||||
return mem.console.Mapper.Read(address)
|
||||
case address < 0x3F00:
|
||||
mode := mem.console.Cartridge.Mirror
|
||||
return mem.console.PPU.nameTableData[MirrorAddress(mode, address)%2048]
|
||||
case address < 0x4000:
|
||||
return mem.console.PPU.readPalette(address % 32)
|
||||
default:
|
||||
log.Fatalf("unhandled ppu memory read at address: 0x%04X", address)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (mem *ppuMemory) Write(address uint16, value byte) {
|
||||
address = address % 0x4000
|
||||
switch {
|
||||
case address < 0x2000:
|
||||
mem.console.Mapper.Write(address, value)
|
||||
case address < 0x3F00:
|
||||
mode := mem.console.Cartridge.Mirror
|
||||
mem.console.PPU.nameTableData[MirrorAddress(mode, address)%2048] = value
|
||||
case address < 0x4000:
|
||||
mem.console.PPU.writePalette(address%32, value)
|
||||
default:
|
||||
log.Fatalf("unhandled ppu memory write at address: 0x%04X", address)
|
||||
}
|
||||
}
|
||||
|
||||
// Mirroring Modes
|
||||
|
||||
const (
|
||||
MirrorHorizontal = 0
|
||||
MirrorVertical = 1
|
||||
MirrorSingle0 = 2
|
||||
MirrorSingle1 = 3
|
||||
MirrorFour = 4
|
||||
)
|
||||
|
||||
var MirrorLookup = [...][4]uint16{
|
||||
{0, 0, 1, 1},
|
||||
{0, 1, 0, 1},
|
||||
{0, 0, 0, 0},
|
||||
{1, 1, 1, 1},
|
||||
{0, 1, 2, 3},
|
||||
}
|
||||
|
||||
func MirrorAddress(mode byte, address uint16) uint16 {
|
||||
address = (address - 0x2000) % 0x1000
|
||||
table := address / 0x0400
|
||||
offset := address % 0x0400
|
||||
return 0x2000 + MirrorLookup[mode][table]*0x0400 + offset
|
||||
}
|
||||
24
nes/palette.go
Normal file
24
nes/palette.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package nes
|
||||
|
||||
import "image/color"
|
||||
|
||||
var Palette [64]color.RGBA
|
||||
|
||||
func init() {
|
||||
colors := []uint32{
|
||||
0x666666, 0x002A88, 0x1412A7, 0x3B00A4, 0x5C007E, 0x6E0040, 0x6C0600, 0x561D00,
|
||||
0x333500, 0x0B4800, 0x005200, 0x004F08, 0x00404D, 0x000000, 0x000000, 0x000000,
|
||||
0xADADAD, 0x155FD9, 0x4240FF, 0x7527FE, 0xA01ACC, 0xB71E7B, 0xB53120, 0x994E00,
|
||||
0x6B6D00, 0x388700, 0x0C9300, 0x008F32, 0x007C8D, 0x000000, 0x000000, 0x000000,
|
||||
0xFFFEFF, 0x64B0FF, 0x9290FF, 0xC676FF, 0xF36AFF, 0xFE6ECC, 0xFE8170, 0xEA9E22,
|
||||
0xBCBE00, 0x88D800, 0x5CE430, 0x45E082, 0x48CDDE, 0x4F4F4F, 0x000000, 0x000000,
|
||||
0xFFFEFF, 0xC0DFFF, 0xD3D2FF, 0xE8C8FF, 0xFBC2FF, 0xFEC4EA, 0xFECCC5, 0xF7D8A5,
|
||||
0xE4E594, 0xCFEF96, 0xBDF4AB, 0xB3F3CC, 0xB5EBF2, 0xB8B8B8, 0x000000, 0x000000,
|
||||
}
|
||||
for i, c := range colors {
|
||||
r := byte(c >> 16)
|
||||
g := byte(c >> 8)
|
||||
b := byte(c)
|
||||
Palette[i] = color.RGBA{r, g, b, 0xFF}
|
||||
}
|
||||
}
|
||||
740
nes/ppu.go
Normal file
740
nes/ppu.go
Normal file
|
|
@ -0,0 +1,740 @@
|
|||
package nes
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"image"
|
||||
)
|
||||
|
||||
type PPU struct {
|
||||
Memory // memory interface
|
||||
console *Console // reference to parent object
|
||||
|
||||
Cycle int // 0-340
|
||||
ScanLine int // 0-261, 0-239=visible, 240=post, 241-260=vblank, 261=pre
|
||||
Frame uint64 // frame counter
|
||||
|
||||
// storage variables
|
||||
paletteData [32]byte
|
||||
nameTableData [2048]byte
|
||||
oamData [256]byte
|
||||
front *image.RGBA
|
||||
back *image.RGBA
|
||||
|
||||
// PPU registers
|
||||
v uint16 // current vram address (15 bit)
|
||||
t uint16 // temporary vram address (15 bit)
|
||||
x byte // fine x scroll (3 bit)
|
||||
w byte // write toggle (1 bit)
|
||||
f byte // even/odd frame flag (1 bit)
|
||||
|
||||
register byte
|
||||
|
||||
// NMI flags
|
||||
nmiOccurred bool
|
||||
nmiOutput bool
|
||||
nmiPrevious bool
|
||||
nmiDelay byte
|
||||
|
||||
// background temporary variables
|
||||
nameTableByte byte
|
||||
attributeTableByte byte
|
||||
lowTileByte byte
|
||||
highTileByte byte
|
||||
tileData uint64
|
||||
|
||||
// sprite temporary variables
|
||||
spriteCount int
|
||||
spritePatterns [8]uint32
|
||||
spritePositions [8]byte
|
||||
spritePriorities [8]byte
|
||||
spriteIndexes [8]byte
|
||||
|
||||
// $2000 PPUCTRL
|
||||
flagNameTable byte // 0: $2000; 1: $2400; 2: $2800; 3: $2C00
|
||||
flagIncrement byte // 0: add 1; 1: add 32
|
||||
flagSpriteTable byte // 0: $0000; 1: $1000; ignored in 8x16 mode
|
||||
flagBackgroundTable byte // 0: $0000; 1: $1000
|
||||
flagSpriteSize byte // 0: 8x8; 1: 8x16
|
||||
flagMasterSlave byte // 0: read EXT; 1: write EXT
|
||||
|
||||
// $2001 PPUMASK
|
||||
flagGrayscale byte // 0: color; 1: grayscale
|
||||
flagShowLeftBackground byte // 0: hide; 1: show
|
||||
flagShowLeftSprites byte // 0: hide; 1: show
|
||||
flagShowBackground byte // 0: hide; 1: show
|
||||
flagShowSprites byte // 0: hide; 1: show
|
||||
flagRedTint byte // 0: normal; 1: emphasized
|
||||
flagGreenTint byte // 0: normal; 1: emphasized
|
||||
flagBlueTint byte // 0: normal; 1: emphasized
|
||||
|
||||
// $2002 PPUSTATUS
|
||||
flagSpriteZeroHit byte
|
||||
flagSpriteOverflow byte
|
||||
|
||||
// $2003 OAMADDR
|
||||
oamAddress byte
|
||||
|
||||
// $2007 PPUDATA
|
||||
bufferedData byte // for buffered reads
|
||||
}
|
||||
|
||||
func NewPPU(console *Console) *PPU {
|
||||
ppu := PPU{Memory: NewPPUMemory(console), console: console}
|
||||
ppu.front = image.NewRGBA(image.Rect(0, 0, 256, 240))
|
||||
ppu.back = image.NewRGBA(image.Rect(0, 0, 256, 240))
|
||||
ppu.Reset()
|
||||
return &ppu
|
||||
}
|
||||
|
||||
func (ppu *PPU) Save(encoder *gob.Encoder) error {
|
||||
encoder.Encode(ppu.Cycle)
|
||||
encoder.Encode(ppu.ScanLine)
|
||||
encoder.Encode(ppu.Frame)
|
||||
encoder.Encode(ppu.paletteData)
|
||||
encoder.Encode(ppu.nameTableData)
|
||||
encoder.Encode(ppu.oamData)
|
||||
encoder.Encode(ppu.v)
|
||||
encoder.Encode(ppu.t)
|
||||
encoder.Encode(ppu.x)
|
||||
encoder.Encode(ppu.w)
|
||||
encoder.Encode(ppu.f)
|
||||
encoder.Encode(ppu.register)
|
||||
encoder.Encode(ppu.nmiOccurred)
|
||||
encoder.Encode(ppu.nmiOutput)
|
||||
encoder.Encode(ppu.nmiPrevious)
|
||||
encoder.Encode(ppu.nmiDelay)
|
||||
encoder.Encode(ppu.nameTableByte)
|
||||
encoder.Encode(ppu.attributeTableByte)
|
||||
encoder.Encode(ppu.lowTileByte)
|
||||
encoder.Encode(ppu.highTileByte)
|
||||
encoder.Encode(ppu.tileData)
|
||||
encoder.Encode(ppu.spriteCount)
|
||||
encoder.Encode(ppu.spritePatterns)
|
||||
encoder.Encode(ppu.spritePositions)
|
||||
encoder.Encode(ppu.spritePriorities)
|
||||
encoder.Encode(ppu.spriteIndexes)
|
||||
encoder.Encode(ppu.flagNameTable)
|
||||
encoder.Encode(ppu.flagIncrement)
|
||||
encoder.Encode(ppu.flagSpriteTable)
|
||||
encoder.Encode(ppu.flagBackgroundTable)
|
||||
encoder.Encode(ppu.flagSpriteSize)
|
||||
encoder.Encode(ppu.flagMasterSlave)
|
||||
encoder.Encode(ppu.flagGrayscale)
|
||||
encoder.Encode(ppu.flagShowLeftBackground)
|
||||
encoder.Encode(ppu.flagShowLeftSprites)
|
||||
encoder.Encode(ppu.flagShowBackground)
|
||||
encoder.Encode(ppu.flagShowSprites)
|
||||
encoder.Encode(ppu.flagRedTint)
|
||||
encoder.Encode(ppu.flagGreenTint)
|
||||
encoder.Encode(ppu.flagBlueTint)
|
||||
encoder.Encode(ppu.flagSpriteZeroHit)
|
||||
encoder.Encode(ppu.flagSpriteOverflow)
|
||||
encoder.Encode(ppu.oamAddress)
|
||||
encoder.Encode(ppu.bufferedData)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ppu *PPU) Load(decoder *gob.Decoder) error {
|
||||
decoder.Decode(&ppu.Cycle)
|
||||
decoder.Decode(&ppu.ScanLine)
|
||||
decoder.Decode(&ppu.Frame)
|
||||
decoder.Decode(&ppu.paletteData)
|
||||
decoder.Decode(&ppu.nameTableData)
|
||||
decoder.Decode(&ppu.oamData)
|
||||
decoder.Decode(&ppu.v)
|
||||
decoder.Decode(&ppu.t)
|
||||
decoder.Decode(&ppu.x)
|
||||
decoder.Decode(&ppu.w)
|
||||
decoder.Decode(&ppu.f)
|
||||
decoder.Decode(&ppu.register)
|
||||
decoder.Decode(&ppu.nmiOccurred)
|
||||
decoder.Decode(&ppu.nmiOutput)
|
||||
decoder.Decode(&ppu.nmiPrevious)
|
||||
decoder.Decode(&ppu.nmiDelay)
|
||||
decoder.Decode(&ppu.nameTableByte)
|
||||
decoder.Decode(&ppu.attributeTableByte)
|
||||
decoder.Decode(&ppu.lowTileByte)
|
||||
decoder.Decode(&ppu.highTileByte)
|
||||
decoder.Decode(&ppu.tileData)
|
||||
decoder.Decode(&ppu.spriteCount)
|
||||
decoder.Decode(&ppu.spritePatterns)
|
||||
decoder.Decode(&ppu.spritePositions)
|
||||
decoder.Decode(&ppu.spritePriorities)
|
||||
decoder.Decode(&ppu.spriteIndexes)
|
||||
decoder.Decode(&ppu.flagNameTable)
|
||||
decoder.Decode(&ppu.flagIncrement)
|
||||
decoder.Decode(&ppu.flagSpriteTable)
|
||||
decoder.Decode(&ppu.flagBackgroundTable)
|
||||
decoder.Decode(&ppu.flagSpriteSize)
|
||||
decoder.Decode(&ppu.flagMasterSlave)
|
||||
decoder.Decode(&ppu.flagGrayscale)
|
||||
decoder.Decode(&ppu.flagShowLeftBackground)
|
||||
decoder.Decode(&ppu.flagShowLeftSprites)
|
||||
decoder.Decode(&ppu.flagShowBackground)
|
||||
decoder.Decode(&ppu.flagShowSprites)
|
||||
decoder.Decode(&ppu.flagRedTint)
|
||||
decoder.Decode(&ppu.flagGreenTint)
|
||||
decoder.Decode(&ppu.flagBlueTint)
|
||||
decoder.Decode(&ppu.flagSpriteZeroHit)
|
||||
decoder.Decode(&ppu.flagSpriteOverflow)
|
||||
decoder.Decode(&ppu.oamAddress)
|
||||
decoder.Decode(&ppu.bufferedData)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ppu *PPU) Reset() {
|
||||
ppu.Cycle = 340
|
||||
ppu.ScanLine = 240
|
||||
ppu.Frame = 0
|
||||
ppu.writeControl(0)
|
||||
ppu.writeMask(0)
|
||||
ppu.writeOAMAddress(0)
|
||||
}
|
||||
|
||||
func (ppu *PPU) readPalette(address uint16) byte {
|
||||
if address >= 16 && address%4 == 0 {
|
||||
address -= 16
|
||||
}
|
||||
return ppu.paletteData[address]
|
||||
}
|
||||
|
||||
func (ppu *PPU) writePalette(address uint16, value byte) {
|
||||
if address >= 16 && address%4 == 0 {
|
||||
address -= 16
|
||||
}
|
||||
ppu.paletteData[address] = value
|
||||
}
|
||||
|
||||
func (ppu *PPU) readRegister(address uint16) byte {
|
||||
switch address {
|
||||
case 0x2002:
|
||||
return ppu.readStatus()
|
||||
case 0x2004:
|
||||
return ppu.readOAMData()
|
||||
case 0x2007:
|
||||
return ppu.readData()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (ppu *PPU) writeRegister(address uint16, value byte) {
|
||||
ppu.register = value
|
||||
switch address {
|
||||
case 0x2000:
|
||||
ppu.writeControl(value)
|
||||
case 0x2001:
|
||||
ppu.writeMask(value)
|
||||
case 0x2003:
|
||||
ppu.writeOAMAddress(value)
|
||||
case 0x2004:
|
||||
ppu.writeOAMData(value)
|
||||
case 0x2005:
|
||||
ppu.writeScroll(value)
|
||||
case 0x2006:
|
||||
ppu.writeAddress(value)
|
||||
case 0x2007:
|
||||
ppu.writeData(value)
|
||||
case 0x4014:
|
||||
ppu.writeDMA(value)
|
||||
}
|
||||
}
|
||||
|
||||
// $2000: PPUCTRL
|
||||
func (ppu *PPU) writeControl(value byte) {
|
||||
ppu.flagNameTable = (value >> 0) & 3
|
||||
ppu.flagIncrement = (value >> 2) & 1
|
||||
ppu.flagSpriteTable = (value >> 3) & 1
|
||||
ppu.flagBackgroundTable = (value >> 4) & 1
|
||||
ppu.flagSpriteSize = (value >> 5) & 1
|
||||
ppu.flagMasterSlave = (value >> 6) & 1
|
||||
ppu.nmiOutput = (value>>7)&1 == 1
|
||||
ppu.nmiChange()
|
||||
// t: ....BA.. ........ = d: ......BA
|
||||
ppu.t = (ppu.t & 0xF3FF) | ((uint16(value) & 0x03) << 10)
|
||||
}
|
||||
|
||||
// $2001: PPUMASK
|
||||
func (ppu *PPU) writeMask(value byte) {
|
||||
ppu.flagGrayscale = (value >> 0) & 1
|
||||
ppu.flagShowLeftBackground = (value >> 1) & 1
|
||||
ppu.flagShowLeftSprites = (value >> 2) & 1
|
||||
ppu.flagShowBackground = (value >> 3) & 1
|
||||
ppu.flagShowSprites = (value >> 4) & 1
|
||||
ppu.flagRedTint = (value >> 5) & 1
|
||||
ppu.flagGreenTint = (value >> 6) & 1
|
||||
ppu.flagBlueTint = (value >> 7) & 1
|
||||
}
|
||||
|
||||
// $2002: PPUSTATUS
|
||||
func (ppu *PPU) readStatus() byte {
|
||||
result := ppu.register & 0x1F
|
||||
result |= ppu.flagSpriteOverflow << 5
|
||||
result |= ppu.flagSpriteZeroHit << 6
|
||||
if ppu.nmiOccurred {
|
||||
result |= 1 << 7
|
||||
}
|
||||
ppu.nmiOccurred = false
|
||||
ppu.nmiChange()
|
||||
// w: = 0
|
||||
ppu.w = 0
|
||||
return result
|
||||
}
|
||||
|
||||
// $2003: OAMADDR
|
||||
func (ppu *PPU) writeOAMAddress(value byte) {
|
||||
ppu.oamAddress = value
|
||||
}
|
||||
|
||||
// $2004: OAMDATA (read)
|
||||
func (ppu *PPU) readOAMData() byte {
|
||||
return ppu.oamData[ppu.oamAddress]
|
||||
}
|
||||
|
||||
// $2004: OAMDATA (write)
|
||||
func (ppu *PPU) writeOAMData(value byte) {
|
||||
ppu.oamData[ppu.oamAddress] = value
|
||||
ppu.oamAddress++
|
||||
}
|
||||
|
||||
// $2005: PPUSCROLL
|
||||
func (ppu *PPU) writeScroll(value byte) {
|
||||
if ppu.w == 0 {
|
||||
// t: ........ ...HGFED = d: HGFED...
|
||||
// x: CBA = d: .....CBA
|
||||
// w: = 1
|
||||
ppu.t = (ppu.t & 0xFFE0) | (uint16(value) >> 3)
|
||||
ppu.x = value & 0x07
|
||||
ppu.w = 1
|
||||
} else {
|
||||
// t: .CBA..HG FED..... = d: HGFEDCBA
|
||||
// w: = 0
|
||||
ppu.t = (ppu.t & 0x8FFF) | ((uint16(value) & 0x07) << 12)
|
||||
ppu.t = (ppu.t & 0xFC1F) | ((uint16(value) & 0xF8) << 2)
|
||||
ppu.w = 0
|
||||
}
|
||||
}
|
||||
|
||||
// $2006: PPUADDR
|
||||
func (ppu *PPU) writeAddress(value byte) {
|
||||
if ppu.w == 0 {
|
||||
// t: ..FEDCBA ........ = d: ..FEDCBA
|
||||
// t: .X...... ........ = 0
|
||||
// w: = 1
|
||||
ppu.t = (ppu.t & 0x80FF) | ((uint16(value) & 0x3F) << 8)
|
||||
ppu.w = 1
|
||||
} else {
|
||||
// t: ........ HGFEDCBA = d: HGFEDCBA
|
||||
// v = t
|
||||
// w: = 0
|
||||
ppu.t = (ppu.t & 0xFF00) | uint16(value)
|
||||
ppu.v = ppu.t
|
||||
ppu.w = 0
|
||||
}
|
||||
}
|
||||
|
||||
// $2007: PPUDATA (read)
|
||||
func (ppu *PPU) readData() byte {
|
||||
value := ppu.Read(ppu.v)
|
||||
// emulate buffered reads
|
||||
if ppu.v%0x4000 < 0x3F00 {
|
||||
buffered := ppu.bufferedData
|
||||
ppu.bufferedData = value
|
||||
value = buffered
|
||||
} else {
|
||||
ppu.bufferedData = ppu.Read(ppu.v - 0x1000)
|
||||
}
|
||||
// increment address
|
||||
if ppu.flagIncrement == 0 {
|
||||
ppu.v += 1
|
||||
} else {
|
||||
ppu.v += 32
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
// $2007: PPUDATA (write)
|
||||
func (ppu *PPU) writeData(value byte) {
|
||||
ppu.Write(ppu.v, value)
|
||||
if ppu.flagIncrement == 0 {
|
||||
ppu.v += 1
|
||||
} else {
|
||||
ppu.v += 32
|
||||
}
|
||||
}
|
||||
|
||||
// $4014: OAMDMA
|
||||
func (ppu *PPU) writeDMA(value byte) {
|
||||
cpu := ppu.console.CPU
|
||||
address := uint16(value) << 8
|
||||
for i := 0; i < 256; i++ {
|
||||
ppu.oamData[ppu.oamAddress] = cpu.Read(address)
|
||||
ppu.oamAddress++
|
||||
address++
|
||||
}
|
||||
cpu.stall += 513
|
||||
if cpu.Cycles%2 == 1 {
|
||||
cpu.stall++
|
||||
}
|
||||
}
|
||||
|
||||
// NTSC Timing Helper Functions
|
||||
|
||||
func (ppu *PPU) incrementX() {
|
||||
// increment hori(v)
|
||||
// if coarse X == 31
|
||||
if ppu.v&0x001F == 31 {
|
||||
// coarse X = 0
|
||||
ppu.v &= 0xFFE0
|
||||
// switch horizontal nametable
|
||||
ppu.v ^= 0x0400
|
||||
} else {
|
||||
// increment coarse X
|
||||
ppu.v++
|
||||
}
|
||||
}
|
||||
|
||||
func (ppu *PPU) incrementY() {
|
||||
// increment vert(v)
|
||||
// if fine Y < 7
|
||||
if ppu.v&0x7000 != 0x7000 {
|
||||
// increment fine Y
|
||||
ppu.v += 0x1000
|
||||
} else {
|
||||
// fine Y = 0
|
||||
ppu.v &= 0x8FFF
|
||||
// let y = coarse Y
|
||||
y := (ppu.v & 0x03E0) >> 5
|
||||
if y == 29 {
|
||||
// coarse Y = 0
|
||||
y = 0
|
||||
// switch vertical nametable
|
||||
ppu.v ^= 0x0800
|
||||
} else if y == 31 {
|
||||
// coarse Y = 0, nametable not switched
|
||||
y = 0
|
||||
} else {
|
||||
// increment coarse Y
|
||||
y++
|
||||
}
|
||||
// put coarse Y back into v
|
||||
ppu.v = (ppu.v & 0xFC1F) | (y << 5)
|
||||
}
|
||||
}
|
||||
|
||||
func (ppu *PPU) copyX() {
|
||||
// hori(v) = hori(t)
|
||||
// v: .....F.. ...EDCBA = t: .....F.. ...EDCBA
|
||||
ppu.v = (ppu.v & 0xFBE0) | (ppu.t & 0x041F)
|
||||
}
|
||||
|
||||
func (ppu *PPU) copyY() {
|
||||
// vert(v) = vert(t)
|
||||
// v: .IHGF.ED CBA..... = t: .IHGF.ED CBA.....
|
||||
ppu.v = (ppu.v & 0x841F) | (ppu.t & 0x7BE0)
|
||||
}
|
||||
|
||||
func (ppu *PPU) nmiChange() {
|
||||
nmi := ppu.nmiOutput && ppu.nmiOccurred
|
||||
if nmi && !ppu.nmiPrevious {
|
||||
// TODO: this fixes some games but the delay shouldn't have to be so
|
||||
// long, so the timings are off somewhere
|
||||
ppu.nmiDelay = 15
|
||||
}
|
||||
ppu.nmiPrevious = nmi
|
||||
}
|
||||
|
||||
func (ppu *PPU) setVerticalBlank() {
|
||||
ppu.front, ppu.back = ppu.back, ppu.front
|
||||
ppu.nmiOccurred = true
|
||||
ppu.nmiChange()
|
||||
}
|
||||
|
||||
func (ppu *PPU) clearVerticalBlank() {
|
||||
ppu.nmiOccurred = false
|
||||
ppu.nmiChange()
|
||||
}
|
||||
|
||||
func (ppu *PPU) fetchNameTableByte() {
|
||||
v := ppu.v
|
||||
address := 0x2000 | (v & 0x0FFF)
|
||||
ppu.nameTableByte = ppu.Read(address)
|
||||
}
|
||||
|
||||
func (ppu *PPU) fetchAttributeTableByte() {
|
||||
v := ppu.v
|
||||
address := 0x23C0 | (v & 0x0C00) | ((v >> 4) & 0x38) | ((v >> 2) & 0x07)
|
||||
shift := ((v >> 4) & 4) | (v & 2)
|
||||
ppu.attributeTableByte = ((ppu.Read(address) >> shift) & 3) << 2
|
||||
}
|
||||
|
||||
func (ppu *PPU) fetchLowTileByte() {
|
||||
fineY := (ppu.v >> 12) & 7
|
||||
table := ppu.flagBackgroundTable
|
||||
tile := ppu.nameTableByte
|
||||
address := 0x1000*uint16(table) + uint16(tile)*16 + fineY
|
||||
ppu.lowTileByte = ppu.Read(address)
|
||||
}
|
||||
|
||||
func (ppu *PPU) fetchHighTileByte() {
|
||||
fineY := (ppu.v >> 12) & 7
|
||||
table := ppu.flagBackgroundTable
|
||||
tile := ppu.nameTableByte
|
||||
address := 0x1000*uint16(table) + uint16(tile)*16 + fineY
|
||||
ppu.highTileByte = ppu.Read(address + 8)
|
||||
}
|
||||
|
||||
func (ppu *PPU) storeTileData() {
|
||||
var data uint32
|
||||
for i := 0; i < 8; i++ {
|
||||
a := ppu.attributeTableByte
|
||||
p1 := (ppu.lowTileByte & 0x80) >> 7
|
||||
p2 := (ppu.highTileByte & 0x80) >> 6
|
||||
ppu.lowTileByte <<= 1
|
||||
ppu.highTileByte <<= 1
|
||||
data <<= 4
|
||||
data |= uint32(a | p1 | p2)
|
||||
}
|
||||
ppu.tileData |= uint64(data)
|
||||
}
|
||||
|
||||
func (ppu *PPU) fetchTileData() uint32 {
|
||||
return uint32(ppu.tileData >> 32)
|
||||
}
|
||||
|
||||
func (ppu *PPU) backgroundPixel() byte {
|
||||
if ppu.flagShowBackground == 0 {
|
||||
return 0
|
||||
}
|
||||
data := ppu.fetchTileData() >> ((7 - ppu.x) * 4)
|
||||
return byte(data & 0x0F)
|
||||
}
|
||||
|
||||
func (ppu *PPU) spritePixel() (byte, byte) {
|
||||
if ppu.flagShowSprites == 0 {
|
||||
return 0, 0
|
||||
}
|
||||
for i := 0; i < ppu.spriteCount; i++ {
|
||||
offset := (ppu.Cycle - 1) - int(ppu.spritePositions[i])
|
||||
if offset < 0 || offset > 7 {
|
||||
continue
|
||||
}
|
||||
offset = 7 - offset
|
||||
color := byte((ppu.spritePatterns[i] >> byte(offset*4)) & 0x0F)
|
||||
if color%4 == 0 {
|
||||
continue
|
||||
}
|
||||
return byte(i), color
|
||||
}
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
func (ppu *PPU) renderPixel() {
|
||||
x := ppu.Cycle - 1
|
||||
y := ppu.ScanLine
|
||||
background := ppu.backgroundPixel()
|
||||
i, sprite := ppu.spritePixel()
|
||||
if x < 8 && ppu.flagShowLeftBackground == 0 {
|
||||
background = 0
|
||||
}
|
||||
if x < 8 && ppu.flagShowLeftSprites == 0 {
|
||||
sprite = 0
|
||||
}
|
||||
b := background%4 != 0
|
||||
s := sprite%4 != 0
|
||||
var color byte
|
||||
if !b && !s {
|
||||
color = 0
|
||||
} else if !b && s {
|
||||
color = sprite | 0x10
|
||||
} else if b && !s {
|
||||
color = background
|
||||
} else {
|
||||
if ppu.spriteIndexes[i] == 0 && x < 255 {
|
||||
ppu.flagSpriteZeroHit = 1
|
||||
}
|
||||
if ppu.spritePriorities[i] == 0 {
|
||||
color = sprite | 0x10
|
||||
} else {
|
||||
color = background
|
||||
}
|
||||
}
|
||||
c := Palette[ppu.readPalette(uint16(color))%64]
|
||||
ppu.back.SetRGBA(x, y, c)
|
||||
}
|
||||
|
||||
func (ppu *PPU) fetchSpritePattern(i, row int) uint32 {
|
||||
tile := ppu.oamData[i*4+1]
|
||||
attributes := ppu.oamData[i*4+2]
|
||||
var address uint16
|
||||
if ppu.flagSpriteSize == 0 {
|
||||
if attributes&0x80 == 0x80 {
|
||||
row = 7 - row
|
||||
}
|
||||
table := ppu.flagSpriteTable
|
||||
address = 0x1000*uint16(table) + uint16(tile)*16 + uint16(row)
|
||||
} else {
|
||||
if attributes&0x80 == 0x80 {
|
||||
row = 15 - row
|
||||
}
|
||||
table := tile & 1
|
||||
tile &= 0xFE
|
||||
if row > 7 {
|
||||
tile++
|
||||
row -= 8
|
||||
}
|
||||
address = 0x1000*uint16(table) + uint16(tile)*16 + uint16(row)
|
||||
}
|
||||
a := (attributes & 3) << 2
|
||||
lowTileByte := ppu.Read(address)
|
||||
highTileByte := ppu.Read(address + 8)
|
||||
var data uint32
|
||||
for i := 0; i < 8; i++ {
|
||||
var p1, p2 byte
|
||||
if attributes&0x40 == 0x40 {
|
||||
p1 = (lowTileByte & 1) << 0
|
||||
p2 = (highTileByte & 1) << 1
|
||||
lowTileByte >>= 1
|
||||
highTileByte >>= 1
|
||||
} else {
|
||||
p1 = (lowTileByte & 0x80) >> 7
|
||||
p2 = (highTileByte & 0x80) >> 6
|
||||
lowTileByte <<= 1
|
||||
highTileByte <<= 1
|
||||
}
|
||||
data <<= 4
|
||||
data |= uint32(a | p1 | p2)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (ppu *PPU) evaluateSprites() {
|
||||
var h int
|
||||
if ppu.flagSpriteSize == 0 {
|
||||
h = 8
|
||||
} else {
|
||||
h = 16
|
||||
}
|
||||
count := 0
|
||||
for i := 0; i < 64; i++ {
|
||||
y := ppu.oamData[i*4+0]
|
||||
a := ppu.oamData[i*4+2]
|
||||
x := ppu.oamData[i*4+3]
|
||||
row := ppu.ScanLine - int(y)
|
||||
if row < 0 || row >= h {
|
||||
continue
|
||||
}
|
||||
if count < 8 {
|
||||
ppu.spritePatterns[count] = ppu.fetchSpritePattern(i, row)
|
||||
ppu.spritePositions[count] = x
|
||||
ppu.spritePriorities[count] = (a >> 5) & 1
|
||||
ppu.spriteIndexes[count] = byte(i)
|
||||
}
|
||||
count++
|
||||
}
|
||||
if count > 8 {
|
||||
count = 8
|
||||
ppu.flagSpriteOverflow = 1
|
||||
}
|
||||
ppu.spriteCount = count
|
||||
}
|
||||
|
||||
// tick updates Cycle, ScanLine and Frame counters
|
||||
func (ppu *PPU) tick() {
|
||||
if ppu.nmiDelay > 0 {
|
||||
ppu.nmiDelay--
|
||||
if ppu.nmiDelay == 0 && ppu.nmiOutput && ppu.nmiOccurred {
|
||||
ppu.console.CPU.triggerNMI()
|
||||
}
|
||||
}
|
||||
|
||||
if ppu.flagShowBackground != 0 || ppu.flagShowSprites != 0 {
|
||||
if ppu.f == 1 && ppu.ScanLine == 261 && ppu.Cycle == 339 {
|
||||
ppu.Cycle = 0
|
||||
ppu.ScanLine = 0
|
||||
ppu.Frame++
|
||||
ppu.f ^= 1
|
||||
return
|
||||
}
|
||||
}
|
||||
ppu.Cycle++
|
||||
if ppu.Cycle > 340 {
|
||||
ppu.Cycle = 0
|
||||
ppu.ScanLine++
|
||||
if ppu.ScanLine > 261 {
|
||||
ppu.ScanLine = 0
|
||||
ppu.Frame++
|
||||
ppu.f ^= 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Step executes a single PPU cycle
|
||||
func (ppu *PPU) Step() {
|
||||
ppu.tick()
|
||||
|
||||
renderingEnabled := ppu.flagShowBackground != 0 || ppu.flagShowSprites != 0
|
||||
preLine := ppu.ScanLine == 261
|
||||
visibleLine := ppu.ScanLine < 240
|
||||
// postLine := ppu.ScanLine == 240
|
||||
renderLine := preLine || visibleLine
|
||||
preFetchCycle := ppu.Cycle >= 321 && ppu.Cycle <= 336
|
||||
visibleCycle := ppu.Cycle >= 1 && ppu.Cycle <= 256
|
||||
fetchCycle := preFetchCycle || visibleCycle
|
||||
|
||||
// background logic
|
||||
if renderingEnabled {
|
||||
if visibleLine && visibleCycle {
|
||||
ppu.renderPixel()
|
||||
}
|
||||
if renderLine && fetchCycle {
|
||||
ppu.tileData <<= 4
|
||||
switch ppu.Cycle % 8 {
|
||||
case 1:
|
||||
ppu.fetchNameTableByte()
|
||||
case 3:
|
||||
ppu.fetchAttributeTableByte()
|
||||
case 5:
|
||||
ppu.fetchLowTileByte()
|
||||
case 7:
|
||||
ppu.fetchHighTileByte()
|
||||
case 0:
|
||||
ppu.storeTileData()
|
||||
}
|
||||
}
|
||||
if preLine && ppu.Cycle >= 280 && ppu.Cycle <= 304 {
|
||||
ppu.copyY()
|
||||
}
|
||||
if renderLine {
|
||||
if fetchCycle && ppu.Cycle%8 == 0 {
|
||||
ppu.incrementX()
|
||||
}
|
||||
if ppu.Cycle == 256 {
|
||||
ppu.incrementY()
|
||||
}
|
||||
if ppu.Cycle == 257 {
|
||||
ppu.copyX()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sprite logic
|
||||
if renderingEnabled {
|
||||
if ppu.Cycle == 257 {
|
||||
if visibleLine {
|
||||
ppu.evaluateSprites()
|
||||
} else {
|
||||
ppu.spriteCount = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// vblank logic
|
||||
if ppu.ScanLine == 241 && ppu.Cycle == 1 {
|
||||
ppu.setVerticalBlank()
|
||||
}
|
||||
if preLine && ppu.Cycle == 1 {
|
||||
ppu.clearVerticalBlank()
|
||||
ppu.flagSpriteZeroHit = 0
|
||||
ppu.flagSpriteOverflow = 0
|
||||
}
|
||||
}
|
||||
72
ui/director.go
Normal file
72
ui/director.go
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"image"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/fogleman/nes/nes"
|
||||
)
|
||||
|
||||
type View interface {
|
||||
Enter()
|
||||
Exit()
|
||||
GetImageChannel() chan *image.RGBA
|
||||
Update(t, dt float64)
|
||||
}
|
||||
|
||||
type Director struct {
|
||||
view View
|
||||
timestamp float64
|
||||
}
|
||||
|
||||
func NewDirector() *Director {
|
||||
director := Director{}
|
||||
return &director
|
||||
}
|
||||
|
||||
func (d *Director) SetView(view View) {
|
||||
if d.view != nil {
|
||||
d.view.Exit()
|
||||
}
|
||||
d.view = view
|
||||
if d.view != nil {
|
||||
d.view.Enter()
|
||||
}
|
||||
d.timestamp = float64(time.Now().Unix())
|
||||
}
|
||||
|
||||
func (d *Director) Step() {
|
||||
//timestamp := glfw.GetTime()
|
||||
timestamp := float64(time.Now().Unix())
|
||||
dt := timestamp - d.timestamp
|
||||
d.timestamp = timestamp
|
||||
if d.view != nil {
|
||||
d.view.Update(timestamp, dt)
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Director) Start(path string) {
|
||||
d.PlayGame(path)
|
||||
d.Run()
|
||||
}
|
||||
|
||||
func (d *Director) Run() {
|
||||
d.SetView(nil)
|
||||
}
|
||||
|
||||
func (d *Director) PlayGame(path string) {
|
||||
hash, err := hashFile(path)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
console, err := nes.NewConsole(path)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
d.SetView(NewGameView(d, console, path, hash))
|
||||
}
|
||||
|
||||
func (d *Director) GetImageChannel() chan *image.RGBA {
|
||||
return d.view.GetImageChannel()
|
||||
}
|
||||
98
ui/gameview.go
Normal file
98
ui/gameview.go
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"image"
|
||||
|
||||
"github.com/fogleman/nes/nes"
|
||||
)
|
||||
|
||||
const padding = 0
|
||||
|
||||
type GameView struct {
|
||||
director *Director
|
||||
console *nes.Console
|
||||
title string
|
||||
hash string
|
||||
record bool
|
||||
frames []image.Image
|
||||
imageChannel chan *image.RGBA
|
||||
}
|
||||
|
||||
func NewGameView(director *Director, console *nes.Console, title, hash string) View {
|
||||
imageChannel := make(chan *image.RGBA, 2)
|
||||
return &GameView{director, console, title, hash, false, nil, imageChannel}
|
||||
}
|
||||
|
||||
func (view *GameView) GetImageChannel() chan *image.RGBA {
|
||||
return view.imageChannel
|
||||
}
|
||||
|
||||
func (view *GameView) Enter() {
|
||||
// load state
|
||||
if err := view.console.LoadState(savePath(view.hash)); err == nil {
|
||||
return
|
||||
} else {
|
||||
view.console.Reset()
|
||||
}
|
||||
// load sram
|
||||
cartridge := view.console.Cartridge
|
||||
if cartridge.Battery != 0 {
|
||||
if sram, err := readSRAM(sramPath(view.hash)); err == nil {
|
||||
cartridge.SRAM = sram
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (view *GameView) Exit() {
|
||||
view.console.SetAudioChannel(nil)
|
||||
view.console.SetAudioSampleRate(0)
|
||||
// save sram
|
||||
cartridge := view.console.Cartridge
|
||||
if cartridge.Battery != 0 {
|
||||
writeSRAM(sramPath(view.hash), cartridge.SRAM)
|
||||
}
|
||||
// save state
|
||||
view.console.SaveState(savePath(view.hash))
|
||||
}
|
||||
|
||||
func (view *GameView) Update(t, dt float64) {
|
||||
if dt > 1 {
|
||||
dt = 0
|
||||
}
|
||||
console := view.console
|
||||
//if readKey(window, glfw.KeyEscape) {
|
||||
//view.director.ShowMenu()
|
||||
//}
|
||||
//updateControllers(window, console)
|
||||
view.imageChannel <- console.Buffer()
|
||||
console.StepSeconds(dt)
|
||||
if view.record {
|
||||
view.frames = append(view.frames, copyImage(console.Buffer()))
|
||||
}
|
||||
}
|
||||
|
||||
//func (view *GameView) onKey(window *glfw.Window,
|
||||
//key glfw.Key, scancode int, action glfw.Action, mods glfw.ModifierKey) {
|
||||
//if action == glfw.Press {
|
||||
//switch key {
|
||||
//case glfw.KeyR:
|
||||
//view.console.Reset()
|
||||
//case glfw.KeyTab:
|
||||
//if view.record {
|
||||
//view.record = false
|
||||
//view.frames = nil
|
||||
//} else {
|
||||
//view.record = true
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
|
||||
//func updateControllers(window *glfw.Window, console *nes.Console) {
|
||||
//turbo := console.PPU.Frame%6 < 3
|
||||
//k1 := readKeys(window, turbo)
|
||||
//j1 := readJoystick(glfw.Joystick1, turbo)
|
||||
//j2 := readJoystick(glfw.Joystick2, turbo)
|
||||
//console.SetButtons1(combineButtons(k1, j1))
|
||||
//console.SetButtons2(j2)
|
||||
//}
|
||||
34
ui/run.go
Normal file
34
ui/run.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
)
|
||||
|
||||
const (
|
||||
width = 256
|
||||
height = 240
|
||||
scale = 3
|
||||
title = "NES"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// we need a parallel OS thread to avoid audio stuttering
|
||||
runtime.GOMAXPROCS(2)
|
||||
|
||||
// we need to keep OpenGL calls on a single thread
|
||||
runtime.LockOSThread()
|
||||
}
|
||||
|
||||
func Run(path string) {
|
||||
// initialize audio
|
||||
//portaudio.Initialize()
|
||||
//defer portaudio.Terminate()
|
||||
|
||||
//audio := NewAudio()
|
||||
//if err := audio.Start(); err != nil {
|
||||
//log.Fatalln(err)
|
||||
//}
|
||||
//defer audio.Stop()
|
||||
|
||||
// run director
|
||||
}
|
||||
216
ui/util.go
Normal file
216
ui/util.go
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
package ui
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
"image/gif"
|
||||
"image/png"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
|
||||
"github.com/fogleman/nes/nes"
|
||||
"github.com/go-gl/gl/v2.1/gl"
|
||||
"github.com/go-gl/glfw/v3.2/glfw"
|
||||
)
|
||||
|
||||
var homeDir string
|
||||
|
||||
func init() {
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
homeDir = u.HomeDir
|
||||
}
|
||||
|
||||
func thumbnailURL(hash string) string {
|
||||
return "http://www.michaelfogleman.com/static/nes/" + hash + ".png"
|
||||
}
|
||||
|
||||
func thumbnailPath(hash string) string {
|
||||
return homeDir + "/.nes/thumbnail/" + hash + ".png"
|
||||
}
|
||||
|
||||
func sramPath(hash string) string {
|
||||
return homeDir + "/.nes/sram/" + hash + ".dat"
|
||||
}
|
||||
|
||||
func savePath(hash string) string {
|
||||
return homeDir + "/.nes/save/" + hash + ".dat"
|
||||
}
|
||||
|
||||
func readKey(window *glfw.Window, key glfw.Key) bool {
|
||||
return window.GetKey(key) == glfw.Press
|
||||
}
|
||||
|
||||
func readKeys(window *glfw.Window, turbo bool) [8]bool {
|
||||
var result [8]bool
|
||||
result[nes.ButtonA] = readKey(window, glfw.KeyZ) || (turbo && readKey(window, glfw.KeyA))
|
||||
result[nes.ButtonB] = readKey(window, glfw.KeyX) || (turbo && readKey(window, glfw.KeyS))
|
||||
result[nes.ButtonSelect] = readKey(window, glfw.KeyRightShift)
|
||||
result[nes.ButtonStart] = readKey(window, glfw.KeyEnter)
|
||||
result[nes.ButtonUp] = readKey(window, glfw.KeyUp)
|
||||
result[nes.ButtonDown] = readKey(window, glfw.KeyDown)
|
||||
result[nes.ButtonLeft] = readKey(window, glfw.KeyLeft)
|
||||
result[nes.ButtonRight] = readKey(window, glfw.KeyRight)
|
||||
return result
|
||||
}
|
||||
|
||||
func readJoystick(joy glfw.Joystick, turbo bool) [8]bool {
|
||||
var result [8]bool
|
||||
if !glfw.JoystickPresent(joy) {
|
||||
return result
|
||||
}
|
||||
joyname := glfw.GetJoystickName(joy)
|
||||
axes := glfw.GetJoystickAxes(joy)
|
||||
buttons := glfw.GetJoystickButtons(joy)
|
||||
if joyname == "PLAYSTATION(R)3 Controller" {
|
||||
result[nes.ButtonA] = buttons[14] == 1 || (turbo && buttons[2] == 1)
|
||||
result[nes.ButtonB] = buttons[13] == 1 || (turbo && buttons[3] == 1)
|
||||
result[nes.ButtonSelect] = buttons[0] == 1
|
||||
result[nes.ButtonStart] = buttons[3] == 1
|
||||
result[nes.ButtonUp] = buttons[4] == 1 || axes[1] < -0.5
|
||||
result[nes.ButtonDown] = buttons[6] == 1 || axes[1] > 0.5
|
||||
result[nes.ButtonLeft] = buttons[7] == 1 || axes[0] < -0.5
|
||||
result[nes.ButtonRight] = buttons[5] == 1 || axes[0] > 0.5
|
||||
return result
|
||||
}
|
||||
if len(buttons) < 8 {
|
||||
return result
|
||||
}
|
||||
result[nes.ButtonA] = buttons[0] == 1 || (turbo && buttons[2] == 1)
|
||||
result[nes.ButtonB] = buttons[1] == 1 || (turbo && buttons[3] == 1)
|
||||
result[nes.ButtonSelect] = buttons[6] == 1
|
||||
result[nes.ButtonStart] = buttons[7] == 1
|
||||
result[nes.ButtonUp] = axes[1] < -0.5
|
||||
result[nes.ButtonDown] = axes[1] > 0.5
|
||||
result[nes.ButtonLeft] = axes[0] < -0.5
|
||||
result[nes.ButtonRight] = axes[0] > 0.5
|
||||
return result
|
||||
}
|
||||
|
||||
func joystickReset(joy glfw.Joystick) bool {
|
||||
if !glfw.JoystickPresent(joy) {
|
||||
return false
|
||||
}
|
||||
buttons := glfw.GetJoystickButtons(joy)
|
||||
if len(buttons) < 6 {
|
||||
return false
|
||||
}
|
||||
return buttons[4] == 1 && buttons[5] == 1
|
||||
}
|
||||
|
||||
func combineButtons(a, b [8]bool) [8]bool {
|
||||
var result [8]bool
|
||||
for i := 0; i < 8; i++ {
|
||||
result[i] = a[i] || b[i]
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func hashFile(path string) (string, error) {
|
||||
data, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return fmt.Sprintf("%x", md5.Sum(data)), nil
|
||||
}
|
||||
|
||||
func createTexture() uint32 {
|
||||
var texture uint32
|
||||
gl.GenTextures(1, &texture)
|
||||
gl.BindTexture(gl.TEXTURE_2D, texture)
|
||||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
|
||||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
|
||||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE)
|
||||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE)
|
||||
gl.BindTexture(gl.TEXTURE_2D, 0)
|
||||
return texture
|
||||
}
|
||||
|
||||
func setTexture(im *image.RGBA) {
|
||||
size := im.Rect.Size()
|
||||
gl.TexImage2D(
|
||||
gl.TEXTURE_2D, 0, gl.RGBA, int32(size.X), int32(size.Y),
|
||||
0, gl.RGBA, gl.UNSIGNED_BYTE, gl.Ptr(im.Pix))
|
||||
}
|
||||
|
||||
func copyImage(src image.Image) *image.RGBA {
|
||||
dst := image.NewRGBA(src.Bounds())
|
||||
draw.Draw(dst, dst.Rect, src, image.ZP, draw.Src)
|
||||
return dst
|
||||
}
|
||||
|
||||
func loadPNG(path string) (image.Image, error) {
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
return png.Decode(file)
|
||||
}
|
||||
|
||||
func savePNG(path string, im image.Image) error {
|
||||
file, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
return png.Encode(file, im)
|
||||
}
|
||||
|
||||
func saveGIF(path string, frames []image.Image) error {
|
||||
var palette []color.Color
|
||||
for _, c := range nes.Palette {
|
||||
palette = append(palette, c)
|
||||
}
|
||||
g := gif.GIF{}
|
||||
for i, src := range frames {
|
||||
if i%3 != 0 {
|
||||
continue
|
||||
}
|
||||
dst := image.NewPaletted(src.Bounds(), palette)
|
||||
draw.Draw(dst, dst.Rect, src, image.ZP, draw.Src)
|
||||
g.Image = append(g.Image, dst)
|
||||
g.Delay = append(g.Delay, 5)
|
||||
}
|
||||
file, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
return gif.EncodeAll(file, &g)
|
||||
}
|
||||
|
||||
func writeSRAM(filename string, sram []byte) error {
|
||||
dir, _ := path.Split(filename)
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
file, err := os.Create(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
return binary.Write(file, binary.LittleEndian, sram)
|
||||
}
|
||||
|
||||
func readSRAM(filename string) ([]byte, error) {
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
sram := make([]byte, 0x2000)
|
||||
if err := binary.Read(file, binary.LittleEndian, sram); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return sram, nil
|
||||
}
|
||||
52
util/roms.go
Normal file
52
util/roms.go
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/fogleman/nes/nes"
|
||||
)
|
||||
|
||||
func testRom(path string) (err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
err = r.(error)
|
||||
}
|
||||
}()
|
||||
console, err := nes.NewConsole(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
console.StepSeconds(3)
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
args := os.Args[1:]
|
||||
if len(args) != 1 {
|
||||
log.Fatalln("Usage: go run util/roms.go roms_directory")
|
||||
}
|
||||
dir := args[0]
|
||||
infos, err := ioutil.ReadDir(dir)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for _, info := range infos {
|
||||
name := info.Name()
|
||||
if !strings.HasSuffix(name, ".nes") {
|
||||
continue
|
||||
}
|
||||
name = path.Join(dir, name)
|
||||
err := testRom(name)
|
||||
if err == nil {
|
||||
fmt.Println("OK ", name)
|
||||
} else {
|
||||
fmt.Println("FAIL", name)
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
vpx-encoder/android_include/.DS_Store
vendored
Normal file
BIN
vpx-encoder/android_include/.DS_Store
vendored
Normal file
Binary file not shown.
136
vpx-encoder/android_include/vpx/vp8.h
Normal file
136
vpx-encoder/android_include/vpx/vp8.h
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\defgroup vp8 VP8
|
||||
* \ingroup codecs
|
||||
* VP8 is a video compression algorithm that uses motion
|
||||
* compensated prediction, Discrete Cosine Transform (DCT) coding of the
|
||||
* prediction error signal and context dependent entropy coding techniques
|
||||
* based on arithmetic principles. It features:
|
||||
* - YUV 4:2:0 image format
|
||||
* - Macro-block based coding (16x16 luma plus two 8x8 chroma)
|
||||
* - 1/4 (1/8) pixel accuracy motion compensated prediction
|
||||
* - 4x4 DCT transform
|
||||
* - 128 level linear quantizer
|
||||
* - In loop deblocking filter
|
||||
* - Context-based entropy coding
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*!\file
|
||||
* \brief Provides controls common to both the VP8 encoder and decoder.
|
||||
*/
|
||||
#ifndef VPX_VPX_VP8_H_
|
||||
#define VPX_VPX_VP8_H_
|
||||
|
||||
#include "./vpx_codec.h"
|
||||
#include "./vpx_image.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!\brief Control functions
|
||||
*
|
||||
* The set of macros define the control functions of VP8 interface
|
||||
*/
|
||||
enum vp8_com_control_id {
|
||||
/*!\brief pass in an external frame into decoder to be used as reference frame
|
||||
*/
|
||||
VP8_SET_REFERENCE = 1,
|
||||
VP8_COPY_REFERENCE = 2, /**< get a copy of reference frame from the decoder */
|
||||
VP8_SET_POSTPROC = 3, /**< set the decoder's post processing settings */
|
||||
|
||||
/* TODO(jkoleszar): The encoder incorrectly reuses some of these values (5+)
|
||||
* for its control ids. These should be migrated to something like the
|
||||
* VP8_DECODER_CTRL_ID_START range next time we're ready to break the ABI.
|
||||
*/
|
||||
VP9_GET_REFERENCE = 128, /**< get a pointer to a reference frame */
|
||||
VP8_COMMON_CTRL_ID_MAX,
|
||||
VP8_DECODER_CTRL_ID_START = 256
|
||||
};
|
||||
|
||||
/*!\brief post process flags
|
||||
*
|
||||
* The set of macros define VP8 decoder post processing flags
|
||||
*/
|
||||
enum vp8_postproc_level {
|
||||
VP8_NOFILTERING = 0,
|
||||
VP8_DEBLOCK = 1 << 0,
|
||||
VP8_DEMACROBLOCK = 1 << 1,
|
||||
VP8_ADDNOISE = 1 << 2,
|
||||
VP8_MFQE = 1 << 3
|
||||
};
|
||||
|
||||
/*!\brief post process flags
|
||||
*
|
||||
* This define a structure that describe the post processing settings. For
|
||||
* the best objective measure (using the PSNR metric) set post_proc_flag
|
||||
* to VP8_DEBLOCK and deblocking_level to 1.
|
||||
*/
|
||||
|
||||
typedef struct vp8_postproc_cfg {
|
||||
/*!\brief the types of post processing to be done, should be combination of
|
||||
* "vp8_postproc_level" */
|
||||
int post_proc_flag;
|
||||
int deblocking_level; /**< the strength of deblocking, valid range [0, 16] */
|
||||
int noise_level; /**< the strength of additive noise, valid range [0, 16] */
|
||||
} vp8_postproc_cfg_t;
|
||||
|
||||
/*!\brief reference frame type
|
||||
*
|
||||
* The set of macros define the type of VP8 reference frames
|
||||
*/
|
||||
typedef enum vpx_ref_frame_type {
|
||||
VP8_LAST_FRAME = 1,
|
||||
VP8_GOLD_FRAME = 2,
|
||||
VP8_ALTR_FRAME = 4
|
||||
} vpx_ref_frame_type_t;
|
||||
|
||||
/*!\brief reference frame data struct
|
||||
*
|
||||
* Define the data struct to access vp8 reference frames.
|
||||
*/
|
||||
typedef struct vpx_ref_frame {
|
||||
vpx_ref_frame_type_t frame_type; /**< which reference frame */
|
||||
vpx_image_t img; /**< reference frame data in image format */
|
||||
} vpx_ref_frame_t;
|
||||
|
||||
/*!\brief VP9 specific reference frame data struct
|
||||
*
|
||||
* Define the data struct to access vp9 reference frames.
|
||||
*/
|
||||
typedef struct vp9_ref_frame {
|
||||
int idx; /**< frame index to get (input) */
|
||||
vpx_image_t img; /**< img structure to populate (output) */
|
||||
} vp9_ref_frame_t;
|
||||
|
||||
/*!\cond */
|
||||
/*!\brief vp8 decoder control function parameter type
|
||||
*
|
||||
* defines the data type for each of VP8 decoder control function requires
|
||||
*/
|
||||
VPX_CTRL_USE_TYPE(VP8_SET_REFERENCE, vpx_ref_frame_t *)
|
||||
#define VPX_CTRL_VP8_SET_REFERENCE
|
||||
VPX_CTRL_USE_TYPE(VP8_COPY_REFERENCE, vpx_ref_frame_t *)
|
||||
#define VPX_CTRL_VP8_COPY_REFERENCE
|
||||
VPX_CTRL_USE_TYPE(VP8_SET_POSTPROC, vp8_postproc_cfg_t *)
|
||||
#define VPX_CTRL_VP8_SET_POSTPROC
|
||||
VPX_CTRL_USE_TYPE(VP9_GET_REFERENCE, vp9_ref_frame_t *)
|
||||
#define VPX_CTRL_VP9_GET_REFERENCE
|
||||
|
||||
/*!\endcond */
|
||||
/*! @} - end defgroup vp8 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VP8_H_
|
||||
1027
vpx-encoder/android_include/vpx/vp8cx.h
Normal file
1027
vpx-encoder/android_include/vpx/vp8cx.h
Normal file
File diff suppressed because it is too large
Load diff
210
vpx-encoder/android_include/vpx/vp8dx.h
Normal file
210
vpx-encoder/android_include/vpx/vp8dx.h
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\defgroup vp8_decoder WebM VP8/VP9 Decoder
|
||||
* \ingroup vp8
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*!\file
|
||||
* \brief Provides definitions for using VP8 or VP9 within the vpx Decoder
|
||||
* interface.
|
||||
*/
|
||||
#ifndef VPX_VPX_VP8DX_H_
|
||||
#define VPX_VPX_VP8DX_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Include controls common to both the encoder and decoder */
|
||||
#include "./vp8.h"
|
||||
|
||||
/*!\name Algorithm interface for VP8
|
||||
*
|
||||
* This interface provides the capability to decode VP8 streams.
|
||||
* @{
|
||||
*/
|
||||
extern vpx_codec_iface_t vpx_codec_vp8_dx_algo;
|
||||
extern vpx_codec_iface_t *vpx_codec_vp8_dx(void);
|
||||
/*!@} - end algorithm interface member group*/
|
||||
|
||||
/*!\name Algorithm interface for VP9
|
||||
*
|
||||
* This interface provides the capability to decode VP9 streams.
|
||||
* @{
|
||||
*/
|
||||
extern vpx_codec_iface_t vpx_codec_vp9_dx_algo;
|
||||
extern vpx_codec_iface_t *vpx_codec_vp9_dx(void);
|
||||
/*!@} - end algorithm interface member group*/
|
||||
|
||||
/*!\enum vp8_dec_control_id
|
||||
* \brief VP8 decoder control functions
|
||||
*
|
||||
* This set of macros define the control functions available for the VP8
|
||||
* decoder interface.
|
||||
*
|
||||
* \sa #vpx_codec_control
|
||||
*/
|
||||
enum vp8_dec_control_id {
|
||||
/** control function to get info on which reference frames were updated
|
||||
* by the last decode
|
||||
*/
|
||||
VP8D_GET_LAST_REF_UPDATES = VP8_DECODER_CTRL_ID_START,
|
||||
|
||||
/** check if the indicated frame is corrupted */
|
||||
VP8D_GET_FRAME_CORRUPTED,
|
||||
|
||||
/** control function to get info on which reference frames were used
|
||||
* by the last decode
|
||||
*/
|
||||
VP8D_GET_LAST_REF_USED,
|
||||
|
||||
/** decryption function to decrypt encoded buffer data immediately
|
||||
* before decoding. Takes a vpx_decrypt_init, which contains
|
||||
* a callback function and opaque context pointer.
|
||||
*/
|
||||
VPXD_SET_DECRYPTOR,
|
||||
VP8D_SET_DECRYPTOR = VPXD_SET_DECRYPTOR,
|
||||
|
||||
/** control function to get the dimensions that the current frame is decoded
|
||||
* at. This may be different to the intended display size for the frame as
|
||||
* specified in the wrapper or frame header (see VP9D_GET_DISPLAY_SIZE). */
|
||||
VP9D_GET_FRAME_SIZE,
|
||||
|
||||
/** control function to get the current frame's intended display dimensions
|
||||
* (as specified in the wrapper or frame header). This may be different to
|
||||
* the decoded dimensions of this frame (see VP9D_GET_FRAME_SIZE). */
|
||||
VP9D_GET_DISPLAY_SIZE,
|
||||
|
||||
/** control function to get the bit depth of the stream. */
|
||||
VP9D_GET_BIT_DEPTH,
|
||||
|
||||
/** control function to set the byte alignment of the planes in the reference
|
||||
* buffers. Valid values are power of 2, from 32 to 1024. A value of 0 sets
|
||||
* legacy alignment. I.e. Y plane is aligned to 32 bytes, U plane directly
|
||||
* follows Y plane, and V plane directly follows U plane. Default value is 0.
|
||||
*/
|
||||
VP9_SET_BYTE_ALIGNMENT,
|
||||
|
||||
/** control function to invert the decoding order to from right to left. The
|
||||
* function is used in a test to confirm the decoding independence of tile
|
||||
* columns. The function may be used in application where this order
|
||||
* of decoding is desired.
|
||||
*
|
||||
* TODO(yaowu): Rework the unit test that uses this control, and in a future
|
||||
* release, this test-only control shall be removed.
|
||||
*/
|
||||
VP9_INVERT_TILE_DECODE_ORDER,
|
||||
|
||||
/** control function to set the skip loop filter flag. Valid values are
|
||||
* integers. The decoder will skip the loop filter when its value is set to
|
||||
* nonzero. If the loop filter is skipped the decoder may accumulate decode
|
||||
* artifacts. The default value is 0.
|
||||
*/
|
||||
VP9_SET_SKIP_LOOP_FILTER,
|
||||
|
||||
/** control function to decode SVC stream up to the x spatial layers,
|
||||
* where x is passed in through the control, and is 0 for base layer.
|
||||
*/
|
||||
VP9_DECODE_SVC_SPATIAL_LAYER,
|
||||
|
||||
/*!\brief Codec control function to get last decoded frame quantizer.
|
||||
*
|
||||
* Return value uses internal quantizer scale defined by the codec.
|
||||
*
|
||||
* Supported in codecs: VP8, VP9
|
||||
*/
|
||||
VPXD_GET_LAST_QUANTIZER,
|
||||
|
||||
/*!\brief Codec control function to set row level multi-threading.
|
||||
*
|
||||
* 0 : off, 1 : on
|
||||
*
|
||||
* Supported in codecs: VP9
|
||||
*/
|
||||
VP9D_SET_ROW_MT,
|
||||
|
||||
/*!\brief Codec control function to set loopfilter optimization.
|
||||
*
|
||||
* 0 : off, Loop filter is done after all tiles have been decoded
|
||||
* 1 : on, Loop filter is done immediately after decode without
|
||||
* waiting for all threads to sync.
|
||||
*
|
||||
* Supported in codecs: VP9
|
||||
*/
|
||||
VP9D_SET_LOOP_FILTER_OPT,
|
||||
|
||||
VP8_DECODER_CTRL_ID_MAX
|
||||
};
|
||||
|
||||
/** Decrypt n bytes of data from input -> output, using the decrypt_state
|
||||
* passed in VPXD_SET_DECRYPTOR.
|
||||
*/
|
||||
typedef void (*vpx_decrypt_cb)(void *decrypt_state, const unsigned char *input,
|
||||
unsigned char *output, int count);
|
||||
|
||||
/*!\brief Structure to hold decryption state
|
||||
*
|
||||
* Defines a structure to hold the decryption state and access function.
|
||||
*/
|
||||
typedef struct vpx_decrypt_init {
|
||||
/*! Decrypt callback. */
|
||||
vpx_decrypt_cb decrypt_cb;
|
||||
|
||||
/*! Decryption state. */
|
||||
void *decrypt_state;
|
||||
} vpx_decrypt_init;
|
||||
|
||||
/*!\cond */
|
||||
/*!\brief VP8 decoder control function parameter type
|
||||
*
|
||||
* Defines the data types that VP8D control functions take. Note that
|
||||
* additional common controls are defined in vp8.h
|
||||
*
|
||||
*/
|
||||
|
||||
VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_UPDATES, int *)
|
||||
#define VPX_CTRL_VP8D_GET_LAST_REF_UPDATES
|
||||
VPX_CTRL_USE_TYPE(VP8D_GET_FRAME_CORRUPTED, int *)
|
||||
#define VPX_CTRL_VP8D_GET_FRAME_CORRUPTED
|
||||
VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_USED, int *)
|
||||
#define VPX_CTRL_VP8D_GET_LAST_REF_USED
|
||||
VPX_CTRL_USE_TYPE(VPXD_GET_LAST_QUANTIZER, int *)
|
||||
#define VPX_CTRL_VPXD_GET_LAST_QUANTIZER
|
||||
VPX_CTRL_USE_TYPE(VPXD_SET_DECRYPTOR, vpx_decrypt_init *)
|
||||
#define VPX_CTRL_VPXD_SET_DECRYPTOR
|
||||
VPX_CTRL_USE_TYPE(VP8D_SET_DECRYPTOR, vpx_decrypt_init *)
|
||||
#define VPX_CTRL_VP8D_SET_DECRYPTOR
|
||||
VPX_CTRL_USE_TYPE(VP9D_GET_DISPLAY_SIZE, int *)
|
||||
#define VPX_CTRL_VP9D_GET_DISPLAY_SIZE
|
||||
VPX_CTRL_USE_TYPE(VP9D_GET_BIT_DEPTH, unsigned int *)
|
||||
#define VPX_CTRL_VP9D_GET_BIT_DEPTH
|
||||
VPX_CTRL_USE_TYPE(VP9D_GET_FRAME_SIZE, int *)
|
||||
#define VPX_CTRL_VP9D_GET_FRAME_SIZE
|
||||
VPX_CTRL_USE_TYPE(VP9_INVERT_TILE_DECODE_ORDER, int)
|
||||
#define VPX_CTRL_VP9_INVERT_TILE_DECODE_ORDER
|
||||
#define VPX_CTRL_VP9_DECODE_SVC_SPATIAL_LAYER
|
||||
VPX_CTRL_USE_TYPE(VP9_DECODE_SVC_SPATIAL_LAYER, int)
|
||||
#define VPX_CTRL_VP9_SET_SKIP_LOOP_FILTER
|
||||
VPX_CTRL_USE_TYPE(VP9_SET_SKIP_LOOP_FILTER, int)
|
||||
#define VPX_CTRL_VP9_DECODE_SET_ROW_MT
|
||||
VPX_CTRL_USE_TYPE(VP9D_SET_ROW_MT, int)
|
||||
#define VPX_CTRL_VP9_SET_LOOP_FILTER_OPT
|
||||
VPX_CTRL_USE_TYPE(VP9D_SET_LOOP_FILTER_OPT, int)
|
||||
|
||||
/*!\endcond */
|
||||
/*! @} - end defgroup vp8_decoder */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VP8DX_H_
|
||||
468
vpx-encoder/android_include/vpx/vpx_codec.h
Normal file
468
vpx-encoder/android_include/vpx/vpx_codec.h
Normal file
|
|
@ -0,0 +1,468 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\defgroup codec Common Algorithm Interface
|
||||
* This abstraction allows applications to easily support multiple video
|
||||
* formats with minimal code duplication. This section describes the interface
|
||||
* common to all codecs (both encoders and decoders).
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the codec algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video codec algorithm.
|
||||
*
|
||||
* An application instantiates a specific codec instance by using
|
||||
* vpx_codec_init() and a pointer to the algorithm's interface structure:
|
||||
* <pre>
|
||||
* my_app.c:
|
||||
* extern vpx_codec_iface_t my_codec;
|
||||
* {
|
||||
* vpx_codec_ctx_t algo;
|
||||
* res = vpx_codec_init(&algo, &my_codec);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Once initialized, the instance is manged using other functions from
|
||||
* the vpx_codec_* family.
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_CODEC_H_
|
||||
#define VPX_VPX_VPX_CODEC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_image.h"
|
||||
#include "./vpx_integer.h"
|
||||
|
||||
/*!\brief Decorator indicating a function is deprecated */
|
||||
#ifndef VPX_DEPRECATED
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
#define VPX_DEPRECATED __attribute__((deprecated))
|
||||
#elif defined(_MSC_VER)
|
||||
#define VPX_DEPRECATED
|
||||
#else
|
||||
#define VPX_DEPRECATED
|
||||
#endif
|
||||
#endif /* VPX_DEPRECATED */
|
||||
|
||||
#ifndef VPX_DECLSPEC_DEPRECATED
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
#define VPX_DECLSPEC_DEPRECATED /**< \copydoc #VPX_DEPRECATED */
|
||||
#elif defined(_MSC_VER)
|
||||
/*!\brief \copydoc #VPX_DEPRECATED */
|
||||
#define VPX_DECLSPEC_DEPRECATED __declspec(deprecated)
|
||||
#else
|
||||
#define VPX_DECLSPEC_DEPRECATED /**< \copydoc #VPX_DEPRECATED */
|
||||
#endif
|
||||
#endif /* VPX_DECLSPEC_DEPRECATED */
|
||||
|
||||
/*!\brief Decorator indicating a function is potentially unused */
|
||||
#ifndef VPX_UNUSED
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define VPX_UNUSED __attribute__((unused))
|
||||
#else
|
||||
#define VPX_UNUSED
|
||||
#endif
|
||||
#endif /* VPX_UNUSED */
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_CODEC_ABI_VERSION (4 + VPX_IMAGE_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*!\brief Algorithm return codes */
|
||||
typedef enum {
|
||||
/*!\brief Operation completed without error */
|
||||
VPX_CODEC_OK,
|
||||
|
||||
/*!\brief Unspecified error */
|
||||
VPX_CODEC_ERROR,
|
||||
|
||||
/*!\brief Memory operation failed */
|
||||
VPX_CODEC_MEM_ERROR,
|
||||
|
||||
/*!\brief ABI version mismatch */
|
||||
VPX_CODEC_ABI_MISMATCH,
|
||||
|
||||
/*!\brief Algorithm does not have required capability */
|
||||
VPX_CODEC_INCAPABLE,
|
||||
|
||||
/*!\brief The given bitstream is not supported.
|
||||
*
|
||||
* The bitstream was unable to be parsed at the highest level. The decoder
|
||||
* is unable to proceed. This error \ref SHOULD be treated as fatal to the
|
||||
* stream. */
|
||||
VPX_CODEC_UNSUP_BITSTREAM,
|
||||
|
||||
/*!\brief Encoded bitstream uses an unsupported feature
|
||||
*
|
||||
* The decoder does not implement a feature required by the encoder. This
|
||||
* return code should only be used for features that prevent future
|
||||
* pictures from being properly decoded. This error \ref MAY be treated as
|
||||
* fatal to the stream or \ref MAY be treated as fatal to the current GOP.
|
||||
*/
|
||||
VPX_CODEC_UNSUP_FEATURE,
|
||||
|
||||
/*!\brief The coded data for this stream is corrupt or incomplete
|
||||
*
|
||||
* There was a problem decoding the current frame. This return code
|
||||
* should only be used for failures that prevent future pictures from
|
||||
* being properly decoded. This error \ref MAY be treated as fatal to the
|
||||
* stream or \ref MAY be treated as fatal to the current GOP. If decoding
|
||||
* is continued for the current GOP, artifacts may be present.
|
||||
*/
|
||||
VPX_CODEC_CORRUPT_FRAME,
|
||||
|
||||
/*!\brief An application-supplied parameter is not valid.
|
||||
*
|
||||
*/
|
||||
VPX_CODEC_INVALID_PARAM,
|
||||
|
||||
/*!\brief An iterator reached the end of list.
|
||||
*
|
||||
*/
|
||||
VPX_CODEC_LIST_END
|
||||
|
||||
} vpx_codec_err_t;
|
||||
|
||||
/*! \brief Codec capabilities bitfield
|
||||
*
|
||||
* Each codec advertises the capabilities it supports as part of its
|
||||
* ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
|
||||
* or functionality, and are not required to be supported.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_CAP_* defines.
|
||||
*/
|
||||
typedef long vpx_codec_caps_t;
|
||||
#define VPX_CODEC_CAP_DECODER 0x1 /**< Is a decoder */
|
||||
#define VPX_CODEC_CAP_ENCODER 0x2 /**< Is an encoder */
|
||||
|
||||
/*! Can support images at greater than 8 bitdepth.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_HIGHBITDEPTH 0x4
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow for
|
||||
* proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_USE_* defines.
|
||||
*/
|
||||
typedef long vpx_codec_flags_t;
|
||||
|
||||
/*!\brief Codec interface structure.
|
||||
*
|
||||
* Contains function pointers and other data private to the codec
|
||||
* implementation. This structure is opaque to the application.
|
||||
*/
|
||||
typedef const struct vpx_codec_iface vpx_codec_iface_t;
|
||||
|
||||
/*!\brief Codec private data structure.
|
||||
*
|
||||
* Contains data private to the codec implementation. This structure is opaque
|
||||
* to the application.
|
||||
*/
|
||||
typedef struct vpx_codec_priv vpx_codec_priv_t;
|
||||
|
||||
/*!\brief Iterator
|
||||
*
|
||||
* Opaque storage used for iterating over lists.
|
||||
*/
|
||||
typedef const void *vpx_codec_iter_t;
|
||||
|
||||
/*!\brief Codec context structure
|
||||
*
|
||||
* All codecs \ref MUST support this context structure fully. In general,
|
||||
* this data should be considered private to the codec algorithm, and
|
||||
* not be manipulated or examined by the calling application. Applications
|
||||
* may reference the 'name' member to get a printable description of the
|
||||
* algorithm.
|
||||
*/
|
||||
typedef struct vpx_codec_ctx {
|
||||
const char *name; /**< Printable interface name */
|
||||
vpx_codec_iface_t *iface; /**< Interface pointers */
|
||||
vpx_codec_err_t err; /**< Last returned error */
|
||||
const char *err_detail; /**< Detailed info, if available */
|
||||
vpx_codec_flags_t init_flags; /**< Flags passed at init time */
|
||||
union {
|
||||
/**< Decoder Configuration Pointer */
|
||||
const struct vpx_codec_dec_cfg *dec;
|
||||
/**< Encoder Configuration Pointer */
|
||||
const struct vpx_codec_enc_cfg *enc;
|
||||
const void *raw;
|
||||
} config; /**< Configuration pointer aliasing union */
|
||||
vpx_codec_priv_t *priv; /**< Algorithm private storage */
|
||||
} vpx_codec_ctx_t;
|
||||
|
||||
/*!\brief Bit depth for codec
|
||||
* *
|
||||
* This enumeration determines the bit depth of the codec.
|
||||
*/
|
||||
typedef enum vpx_bit_depth {
|
||||
VPX_BITS_8 = 8, /**< 8 bits */
|
||||
VPX_BITS_10 = 10, /**< 10 bits */
|
||||
VPX_BITS_12 = 12, /**< 12 bits */
|
||||
} vpx_bit_depth_t;
|
||||
|
||||
/*
|
||||
* Library Version Number Interface
|
||||
*
|
||||
* For example, see the following sample return values:
|
||||
* vpx_codec_version() (1<<16 | 2<<8 | 3)
|
||||
* vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
|
||||
* vpx_codec_version_extra_str() "rc1-16-gec6a1ba"
|
||||
*/
|
||||
|
||||
/*!\brief Return the version information (as an integer)
|
||||
*
|
||||
* Returns a packed encoding of the library version number. This will only
|
||||
* include
|
||||
* the major.minor.patch component of the version number. Note that this encoded
|
||||
* value should be accessed through the macros provided, as the encoding may
|
||||
* change
|
||||
* in the future.
|
||||
*
|
||||
*/
|
||||
int vpx_codec_version(void);
|
||||
#define VPX_VERSION_MAJOR(v) \
|
||||
((v >> 16) & 0xff) /**< extract major from packed version */
|
||||
#define VPX_VERSION_MINOR(v) \
|
||||
((v >> 8) & 0xff) /**< extract minor from packed version */
|
||||
#define VPX_VERSION_PATCH(v) \
|
||||
((v >> 0) & 0xff) /**< extract patch from packed version */
|
||||
|
||||
/*!\brief Return the version major number */
|
||||
#define vpx_codec_version_major() ((vpx_codec_version() >> 16) & 0xff)
|
||||
|
||||
/*!\brief Return the version minor number */
|
||||
#define vpx_codec_version_minor() ((vpx_codec_version() >> 8) & 0xff)
|
||||
|
||||
/*!\brief Return the version patch number */
|
||||
#define vpx_codec_version_patch() ((vpx_codec_version() >> 0) & 0xff)
|
||||
|
||||
/*!\brief Return the version information (as a string)
|
||||
*
|
||||
* Returns a printable string containing the full library version number. This
|
||||
* may
|
||||
* contain additional text following the three digit version number, as to
|
||||
* indicate
|
||||
* release candidates, prerelease versions, etc.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_version_str(void);
|
||||
|
||||
/*!\brief Return the version information (as a string)
|
||||
*
|
||||
* Returns a printable "extra string". This is the component of the string
|
||||
* returned
|
||||
* by vpx_codec_version_str() following the three digit version number.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_version_extra_str(void);
|
||||
|
||||
/*!\brief Return the build configuration
|
||||
*
|
||||
* Returns a printable string containing an encoded version of the build
|
||||
* configuration. This may be useful to vpx support.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_build_config(void);
|
||||
|
||||
/*!\brief Return the name for a given interface
|
||||
*
|
||||
* Returns a human readable string for name of the given codec interface.
|
||||
*
|
||||
* \param[in] iface Interface pointer
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_iface_name(vpx_codec_iface_t *iface);
|
||||
|
||||
/*!\brief Convert error number to printable string
|
||||
*
|
||||
* Returns a human readable string for the last error returned by the
|
||||
* algorithm. The returned error will be one line and will not contain
|
||||
* any newline characters.
|
||||
*
|
||||
*
|
||||
* \param[in] err Error number.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_err_to_string(vpx_codec_err_t err);
|
||||
|
||||
/*!\brief Retrieve error synopsis for codec context
|
||||
*
|
||||
* Returns a human readable string for the last error returned by the
|
||||
* algorithm. The returned error will be one line and will not contain
|
||||
* any newline characters.
|
||||
*
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_error(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!\brief Retrieve detailed error information for codec context
|
||||
*
|
||||
* Returns a human readable string providing detailed information about
|
||||
* the last error.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
*
|
||||
* \retval NULL
|
||||
* No detailed information is available.
|
||||
*/
|
||||
const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/* REQUIRED FUNCTIONS
|
||||
*
|
||||
* The following functions are required to be implemented for all codecs.
|
||||
* They represent the base case functionality expected of all codecs.
|
||||
*/
|
||||
|
||||
/*!\brief Destroy a codec instance
|
||||
*
|
||||
* Destroys a codec context, freeing any associated memory buffers.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The codec algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!\brief Get the capabilities of an algorithm.
|
||||
*
|
||||
* Retrieves the capabilities bitfield from the algorithm's interface.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface
|
||||
*
|
||||
*/
|
||||
vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface);
|
||||
|
||||
/*!\brief Control algorithm
|
||||
*
|
||||
* This function is used to exchange algorithm specific data with the codec
|
||||
* instance. This can be used to implement features specific to a particular
|
||||
* algorithm.
|
||||
*
|
||||
* This wrapper function dispatches the request to the helper function
|
||||
* associated with the given ctrl_id. It tries to call this function
|
||||
* transparently, but will return #VPX_CODEC_ERROR if the request could not
|
||||
* be dispatched.
|
||||
*
|
||||
* Note that this function should not be used directly. Call the
|
||||
* #vpx_codec_control wrapper macro instead.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] ctrl_id Algorithm specific control identifier
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The control request was processed.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* The control request was not processed.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* The data was not valid.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx, int ctrl_id, ...);
|
||||
#if defined(VPX_DISABLE_CTRL_TYPECHECKS) && VPX_DISABLE_CTRL_TYPECHECKS
|
||||
#define vpx_codec_control(ctx, id, data) vpx_codec_control_(ctx, id, data)
|
||||
#define VPX_CTRL_USE_TYPE(id, typ)
|
||||
#define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ)
|
||||
#define VPX_CTRL_VOID(id, typ)
|
||||
|
||||
#else
|
||||
/*!\brief vpx_codec_control wrapper macro
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to vpx_codec_control_().
|
||||
*
|
||||
* \internal
|
||||
* It works by dispatching the call to the control function through a wrapper
|
||||
* function named with the id parameter.
|
||||
*/
|
||||
#define vpx_codec_control(ctx, id, data) \
|
||||
vpx_codec_control_##id(ctx, id, data) /**<\hideinitializer*/
|
||||
|
||||
/*!\brief vpx_codec_control type definition macro
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to vpx_codec_control_(). It defines the type of the argument for a given
|
||||
* control identifier.
|
||||
*
|
||||
* \internal
|
||||
* It defines a static function with
|
||||
* the correctly typed arguments as a wrapper to the type-unsafe internal
|
||||
* function.
|
||||
*/
|
||||
#define VPX_CTRL_USE_TYPE(id, typ) \
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *, int, typ) \
|
||||
VPX_UNUSED; \
|
||||
\
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *ctx, \
|
||||
int ctrl_id, typ data) { \
|
||||
return vpx_codec_control_(ctx, ctrl_id, data); \
|
||||
} /**<\hideinitializer*/
|
||||
|
||||
/*!\brief vpx_codec_control deprecated type definition macro
|
||||
*
|
||||
* Like #VPX_CTRL_USE_TYPE, but indicates that the specified control is
|
||||
* deprecated and should not be used. Consult the documentation for your
|
||||
* codec for more information.
|
||||
*
|
||||
* \internal
|
||||
* It defines a static function with the correctly typed arguments as a
|
||||
* wrapper to the type-unsafe internal function.
|
||||
*/
|
||||
#define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \
|
||||
VPX_DECLSPEC_DEPRECATED static vpx_codec_err_t vpx_codec_control_##id( \
|
||||
vpx_codec_ctx_t *, int, typ) VPX_DEPRECATED VPX_UNUSED; \
|
||||
\
|
||||
VPX_DECLSPEC_DEPRECATED static vpx_codec_err_t vpx_codec_control_##id( \
|
||||
vpx_codec_ctx_t *ctx, int ctrl_id, typ data) { \
|
||||
return vpx_codec_control_(ctx, ctrl_id, data); \
|
||||
} /**<\hideinitializer*/
|
||||
|
||||
/*!\brief vpx_codec_control void type definition macro
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to vpx_codec_control_(). It indicates that a given control identifier takes
|
||||
* no argument.
|
||||
*
|
||||
* \internal
|
||||
* It defines a static function without a data argument as a wrapper to the
|
||||
* type-unsafe internal function.
|
||||
*/
|
||||
#define VPX_CTRL_VOID(id) \
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *, int) \
|
||||
VPX_UNUSED; \
|
||||
\
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *ctx, \
|
||||
int ctrl_id) { \
|
||||
return vpx_codec_control_(ctx, ctrl_id); \
|
||||
} /**<\hideinitializer*/
|
||||
|
||||
#endif
|
||||
|
||||
/*!@} - end defgroup codec*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // VPX_VPX_VPX_CODEC_H_
|
||||
365
vpx-encoder/android_include/vpx/vpx_decoder.h
Normal file
365
vpx-encoder/android_include/vpx/vpx_decoder.h
Normal file
|
|
@ -0,0 +1,365 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_DECODER_H_
|
||||
#define VPX_VPX_VPX_DECODER_H_
|
||||
|
||||
/*!\defgroup decoder Decoder Algorithm Interface
|
||||
* \ingroup codec
|
||||
* This abstraction allows applications using this decoder to easily support
|
||||
* multiple video formats with minimal code duplication. This section describes
|
||||
* the interface common to all decoders.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the decoder algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video decoder algorithm.
|
||||
*
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_codec.h"
|
||||
#include "./vpx_frame_buffer.h"
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_DECODER_ABI_VERSION \
|
||||
(3 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*! \brief Decoder capabilities bitfield
|
||||
*
|
||||
* Each decoder advertises the capabilities it supports as part of its
|
||||
* ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
|
||||
* or functionality, and are not required to be supported by a decoder.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_CAP_* defines.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_PUT_SLICE 0x10000 /**< Will issue put_slice callbacks */
|
||||
#define VPX_CODEC_CAP_PUT_FRAME 0x20000 /**< Will issue put_frame callbacks */
|
||||
#define VPX_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */
|
||||
/*!\brief Can conceal errors due to packet loss */
|
||||
#define VPX_CODEC_CAP_ERROR_CONCEALMENT 0x80000
|
||||
/*!\brief Can receive encoded frames one fragment at a time */
|
||||
#define VPX_CODEC_CAP_INPUT_FRAGMENTS 0x100000
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow for
|
||||
* proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_USE_* defines.
|
||||
*/
|
||||
/*!\brief Can support frame-based multi-threading */
|
||||
#define VPX_CODEC_CAP_FRAME_THREADING 0x200000
|
||||
/*!brief Can support external frame buffers */
|
||||
#define VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER 0x400000
|
||||
|
||||
#define VPX_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */
|
||||
/*!\brief Conceal errors in decoded frames */
|
||||
#define VPX_CODEC_USE_ERROR_CONCEALMENT 0x20000
|
||||
/*!\brief The input frame should be passed to the decoder one fragment at a
|
||||
* time */
|
||||
#define VPX_CODEC_USE_INPUT_FRAGMENTS 0x40000
|
||||
/*!\brief Enable frame-based multi-threading */
|
||||
#define VPX_CODEC_USE_FRAME_THREADING 0x80000
|
||||
|
||||
/*!\brief Stream properties
|
||||
*
|
||||
* This structure is used to query or set properties of the decoded
|
||||
* stream. Algorithms may extend this structure with data specific
|
||||
* to their bitstream by setting the sz member appropriately.
|
||||
*/
|
||||
typedef struct vpx_codec_stream_info {
|
||||
unsigned int sz; /**< Size of this structure */
|
||||
unsigned int w; /**< Width (or 0 for unknown/default) */
|
||||
unsigned int h; /**< Height (or 0 for unknown/default) */
|
||||
unsigned int is_kf; /**< Current frame is a keyframe */
|
||||
} vpx_codec_stream_info_t;
|
||||
|
||||
/* REQUIRED FUNCTIONS
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders.
|
||||
* They represent the base case functionality expected of all decoders.
|
||||
*/
|
||||
|
||||
/*!\brief Initialization Configurations
|
||||
*
|
||||
* This structure is used to pass init time configuration options to the
|
||||
* decoder.
|
||||
*/
|
||||
typedef struct vpx_codec_dec_cfg {
|
||||
unsigned int threads; /**< Maximum number of threads to use, default 1 */
|
||||
unsigned int w; /**< Width */
|
||||
unsigned int h; /**< Height */
|
||||
} vpx_codec_dec_cfg_t; /**< alias for struct vpx_codec_dec_cfg */
|
||||
|
||||
/*!\brief Initialize a decoder instance
|
||||
*
|
||||
* Initializes a decoder context using the given interface. Applications
|
||||
* should call the vpx_codec_dec_init convenience macro instead of this
|
||||
* function directly, to ensure that the ABI version number parameter
|
||||
* is properly initialized.
|
||||
*
|
||||
* If the library was configured with --disable-multithread, this call
|
||||
* is not thread safe and should be guarded with a lock if being used
|
||||
* in a multithreaded context.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[in] cfg Configuration to use, if known. May be NULL.
|
||||
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
|
||||
* \param[in] ver ABI version number. Must be set to
|
||||
* VPX_DECODER_ABI_VERSION
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The decoder algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_iface_t *iface,
|
||||
const vpx_codec_dec_cfg_t *cfg,
|
||||
vpx_codec_flags_t flags, int ver);
|
||||
|
||||
/*!\brief Convenience macro for vpx_codec_dec_init_ver()
|
||||
*
|
||||
* Ensures the ABI version parameter is properly set.
|
||||
*/
|
||||
#define vpx_codec_dec_init(ctx, iface, cfg, flags) \
|
||||
vpx_codec_dec_init_ver(ctx, iface, cfg, flags, VPX_DECODER_ABI_VERSION)
|
||||
|
||||
/*!\brief Parse stream info from a buffer
|
||||
*
|
||||
* Performs high level parsing of the bitstream. Construction of a decoder
|
||||
* context is not necessary. Can be used to determine if the bitstream is
|
||||
* of the proper format, and to extract information from the stream.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface
|
||||
* \param[in] data Pointer to a block of data to parse
|
||||
* \param[in] data_sz Size of the data buffer
|
||||
* \param[in,out] si Pointer to stream info to update. The size member
|
||||
* \ref MUST be properly initialized, but \ref MAY be
|
||||
* clobbered by the algorithm. This parameter \ref MAY
|
||||
* be NULL.
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Bitstream is parsable and stream information updated
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface,
|
||||
const uint8_t *data,
|
||||
unsigned int data_sz,
|
||||
vpx_codec_stream_info_t *si);
|
||||
|
||||
/*!\brief Return information about the current stream.
|
||||
*
|
||||
* Returns information about the stream that has been parsed during decoding.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] si Pointer to stream info to update. The size member
|
||||
* \ref MUST be properly initialized, but \ref MAY be
|
||||
* clobbered by the algorithm. This parameter \ref MAY
|
||||
* be NULL.
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Bitstream is parsable and stream information updated
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_stream_info_t *si);
|
||||
|
||||
/*!\brief Decode data
|
||||
*
|
||||
* Processes a buffer of coded data. If the processing results in a new
|
||||
* decoded frame becoming available, PUT_SLICE and PUT_FRAME events may be
|
||||
* generated, as appropriate. Encoded data \ref MUST be passed in DTS (decode
|
||||
* time stamp) order. Frames produced will always be in PTS (presentation
|
||||
* time stamp) order.
|
||||
* If the decoder is configured with VPX_CODEC_USE_INPUT_FRAGMENTS enabled,
|
||||
* data and data_sz can contain a fragment of the encoded frame. Fragment
|
||||
* \#n must contain at least partition \#n, but can also contain subsequent
|
||||
* partitions (\#n+1 - \#n+i), and if so, fragments \#n+1, .., \#n+i must
|
||||
* be empty. When no more data is available, this function should be called
|
||||
* with NULL as data and 0 as data_sz. The memory passed to this function
|
||||
* must be available until the frame has been decoded.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] data Pointer to this block of new coded data. If
|
||||
* NULL, a VPX_CODEC_CB_PUT_FRAME event is posted
|
||||
* for the previously decoded frame.
|
||||
* \param[in] data_sz Size of the coded data, in bytes.
|
||||
* \param[in] user_priv Application specific data to associate with
|
||||
* this frame.
|
||||
* \param[in] deadline Soft deadline the decoder should attempt to meet,
|
||||
* in us. Set to zero for unlimited.
|
||||
*
|
||||
* \return Returns #VPX_CODEC_OK if the coded data was processed completely
|
||||
* and future pictures can be decoded without error. Otherwise,
|
||||
* see the descriptions of the other error codes in ::vpx_codec_err_t
|
||||
* for recoverability capabilities.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, const uint8_t *data,
|
||||
unsigned int data_sz, void *user_priv,
|
||||
long deadline);
|
||||
|
||||
/*!\brief Decoded frames iterator
|
||||
*
|
||||
* Iterates over a list of the frames available for display. The iterator
|
||||
* storage should be initialized to NULL to start the iteration. Iteration is
|
||||
* complete when this function returns NULL.
|
||||
*
|
||||
* The list of available frames becomes valid upon completion of the
|
||||
* vpx_codec_decode call, and remains valid until the next call to
|
||||
* vpx_codec_decode.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] iter Iterator storage, initialized to NULL
|
||||
*
|
||||
* \return Returns a pointer to an image, if one is ready for display. Frames
|
||||
* produced will always be in PTS (presentation time stamp) order.
|
||||
*/
|
||||
vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx, vpx_codec_iter_t *iter);
|
||||
|
||||
/*!\defgroup cap_put_frame Frame-Based Decoding Functions
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders
|
||||
* that advertise the VPX_CODEC_CAP_PUT_FRAME capability. Calling these
|
||||
* functions
|
||||
* for codecs that don't advertise this capability will result in an error
|
||||
* code being returned, usually VPX_CODEC_ERROR
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief put frame callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to notify the application of
|
||||
* the availability of decoded image data.
|
||||
*/
|
||||
typedef void (*vpx_codec_put_frame_cb_fn_t)(void *user_priv,
|
||||
const vpx_image_t *img);
|
||||
|
||||
/*!\brief Register for notification of frame completion.
|
||||
*
|
||||
* Registers a given function to be called when a decoded frame is
|
||||
* available.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb Pointer to the callback function
|
||||
* \param[in] user_priv User's private data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Callback successfully registered.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* Decoder context not initialized, or algorithm not capable of
|
||||
* posting slice completion.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_put_frame_cb_fn_t cb,
|
||||
void *user_priv);
|
||||
|
||||
/*!@} - end defgroup cap_put_frame */
|
||||
|
||||
/*!\defgroup cap_put_slice Slice-Based Decoding Functions
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders
|
||||
* that advertise the VPX_CODEC_CAP_PUT_SLICE capability. Calling these
|
||||
* functions
|
||||
* for codecs that don't advertise this capability will result in an error
|
||||
* code being returned, usually VPX_CODEC_ERROR
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief put slice callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to notify the application of
|
||||
* the availability of partially decoded image data. The
|
||||
*/
|
||||
typedef void (*vpx_codec_put_slice_cb_fn_t)(void *user_priv,
|
||||
const vpx_image_t *img,
|
||||
const vpx_image_rect_t *valid,
|
||||
const vpx_image_rect_t *update);
|
||||
|
||||
/*!\brief Register for notification of slice completion.
|
||||
*
|
||||
* Registers a given function to be called when a decoded slice is
|
||||
* available.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb Pointer to the callback function
|
||||
* \param[in] user_priv User's private data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Callback successfully registered.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* Decoder context not initialized, or algorithm not capable of
|
||||
* posting slice completion.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_register_put_slice_cb(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_put_slice_cb_fn_t cb,
|
||||
void *user_priv);
|
||||
|
||||
/*!@} - end defgroup cap_put_slice*/
|
||||
|
||||
/*!\defgroup cap_external_frame_buffer External Frame Buffer Functions
|
||||
*
|
||||
* The following section is required to be implemented for all decoders
|
||||
* that advertise the VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER capability.
|
||||
* Calling this function for codecs that don't advertise this capability
|
||||
* will result in an error code being returned, usually VPX_CODEC_ERROR.
|
||||
*
|
||||
* \note
|
||||
* Currently this only works with VP9.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief Pass in external frame buffers for the decoder to use.
|
||||
*
|
||||
* Registers functions to be called when libvpx needs a frame buffer
|
||||
* to decode the current frame and a function to be called when libvpx does
|
||||
* not internally reference the frame buffer. This set function must
|
||||
* be called before the first call to decode or libvpx will assume the
|
||||
* default behavior of allocating frame buffers internally.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb_get Pointer to the get callback function
|
||||
* \param[in] cb_release Pointer to the release callback function
|
||||
* \param[in] cb_priv Callback's private data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* External frame buffers will be used by libvpx.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* One or more of the callbacks were NULL.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* Decoder context not initialized, or algorithm not capable of
|
||||
* using external frame buffers.
|
||||
*
|
||||
* \note
|
||||
* When decoding VP9, the application may be required to pass in at least
|
||||
* #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS external frame
|
||||
* buffers.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_set_frame_buffer_functions(
|
||||
vpx_codec_ctx_t *ctx, vpx_get_frame_buffer_cb_fn_t cb_get,
|
||||
vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv);
|
||||
|
||||
/*!@} - end defgroup cap_external_frame_buffer */
|
||||
|
||||
/*!@} - end defgroup decoder*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // VPX_VPX_VPX_DECODER_H_
|
||||
968
vpx-encoder/android_include/vpx/vpx_encoder.h
Normal file
968
vpx-encoder/android_include/vpx/vpx_encoder.h
Normal file
|
|
@ -0,0 +1,968 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_ENCODER_H_
|
||||
#define VPX_VPX_VPX_ENCODER_H_
|
||||
|
||||
/*!\defgroup encoder Encoder Algorithm Interface
|
||||
* \ingroup codec
|
||||
* This abstraction allows applications using this encoder to easily support
|
||||
* multiple video formats with minimal code duplication. This section describes
|
||||
* the interface common to all encoders.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the encoder algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video encoder algorithm.
|
||||
*
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_codec.h"
|
||||
|
||||
/*! Temporal Scalability: Maximum length of the sequence defining frame
|
||||
* layer membership
|
||||
*/
|
||||
#define VPX_TS_MAX_PERIODICITY 16
|
||||
|
||||
/*! Temporal Scalability: Maximum number of coding layers */
|
||||
#define VPX_TS_MAX_LAYERS 5
|
||||
|
||||
/*! Temporal+Spatial Scalability: Maximum number of coding layers */
|
||||
#define VPX_MAX_LAYERS 12 // 3 temporal + 4 spatial layers are allowed.
|
||||
|
||||
/*! Spatial Scalability: Maximum number of coding layers */
|
||||
#define VPX_SS_MAX_LAYERS 5
|
||||
|
||||
/*! Spatial Scalability: Default number of coding layers */
|
||||
#define VPX_SS_DEFAULT_LAYERS 1
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_ENCODER_ABI_VERSION \
|
||||
(14 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*! \brief Encoder capabilities bitfield
|
||||
*
|
||||
* Each encoder advertises the capabilities it supports as part of its
|
||||
* ::vpx_codec_iface_t interface structure. Capabilities are extra
|
||||
* interfaces or functionality, and are not required to be supported
|
||||
* by an encoder.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_CAP_* defines.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_PSNR 0x10000 /**< Can issue PSNR packets */
|
||||
|
||||
/*! Can output one partition at a time. Each partition is returned in its
|
||||
* own VPX_CODEC_CX_FRAME_PKT, with the FRAME_IS_FRAGMENT flag set for
|
||||
* every partition but the last. In this mode all frames are always
|
||||
* returned partition by partition.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_OUTPUT_PARTITION 0x20000
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow
|
||||
* for proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_USE_* defines.
|
||||
*/
|
||||
#define VPX_CODEC_USE_PSNR 0x10000 /**< Calculate PSNR on each frame */
|
||||
/*!\brief Make the encoder output one partition at a time. */
|
||||
#define VPX_CODEC_USE_OUTPUT_PARTITION 0x20000
|
||||
#define VPX_CODEC_USE_HIGHBITDEPTH 0x40000 /**< Use high bitdepth */
|
||||
|
||||
/*!\brief Generic fixed size buffer structure
|
||||
*
|
||||
* This structure is able to hold a reference to any fixed size buffer.
|
||||
*/
|
||||
typedef struct vpx_fixed_buf {
|
||||
void *buf; /**< Pointer to the data */
|
||||
size_t sz; /**< Length of the buffer, in chars */
|
||||
} vpx_fixed_buf_t; /**< alias for struct vpx_fixed_buf */
|
||||
|
||||
/*!\brief Time Stamp Type
|
||||
*
|
||||
* An integer, which when multiplied by the stream's time base, provides
|
||||
* the absolute time of a sample.
|
||||
*/
|
||||
typedef int64_t vpx_codec_pts_t;
|
||||
|
||||
/*!\brief Compressed Frame Flags
|
||||
*
|
||||
* This type represents a bitfield containing information about a compressed
|
||||
* frame that may be useful to an application. The most significant 16 bits
|
||||
* can be used by an algorithm to provide additional detail, for example to
|
||||
* support frame types that are codec specific (MPEG-1 D-frames for example)
|
||||
*/
|
||||
typedef uint32_t vpx_codec_frame_flags_t;
|
||||
#define VPX_FRAME_IS_KEY 0x1 /**< frame is the start of a GOP */
|
||||
/*!\brief frame can be dropped without affecting the stream (no future frame
|
||||
* depends on this one) */
|
||||
#define VPX_FRAME_IS_DROPPABLE 0x2
|
||||
/*!\brief frame should be decoded but will not be shown */
|
||||
#define VPX_FRAME_IS_INVISIBLE 0x4
|
||||
/*!\brief this is a fragment of the encoded frame */
|
||||
#define VPX_FRAME_IS_FRAGMENT 0x8
|
||||
|
||||
/*!\brief Error Resilient flags
|
||||
*
|
||||
* These flags define which error resilient features to enable in the
|
||||
* encoder. The flags are specified through the
|
||||
* vpx_codec_enc_cfg::g_error_resilient variable.
|
||||
*/
|
||||
typedef uint32_t vpx_codec_er_flags_t;
|
||||
/*!\brief Improve resiliency against losses of whole frames */
|
||||
#define VPX_ERROR_RESILIENT_DEFAULT 0x1
|
||||
/*!\brief The frame partitions are independently decodable by the bool decoder,
|
||||
* meaning that partitions can be decoded even though earlier partitions have
|
||||
* been lost. Note that intra prediction is still done over the partition
|
||||
* boundary. */
|
||||
#define VPX_ERROR_RESILIENT_PARTITIONS 0x2
|
||||
|
||||
/*!\brief Encoder output packet variants
|
||||
*
|
||||
* This enumeration lists the different kinds of data packets that can be
|
||||
* returned by calls to vpx_codec_get_cx_data(). Algorithms \ref MAY
|
||||
* extend this list to provide additional functionality.
|
||||
*/
|
||||
enum vpx_codec_cx_pkt_kind {
|
||||
VPX_CODEC_CX_FRAME_PKT, /**< Compressed video frame */
|
||||
VPX_CODEC_STATS_PKT, /**< Two-pass statistics for this frame */
|
||||
VPX_CODEC_FPMB_STATS_PKT, /**< first pass mb statistics for this frame */
|
||||
VPX_CODEC_PSNR_PKT, /**< PSNR statistics for this frame */
|
||||
VPX_CODEC_CUSTOM_PKT = 256 /**< Algorithm extensions */
|
||||
};
|
||||
|
||||
/*!\brief Encoder output packet
|
||||
*
|
||||
* This structure contains the different kinds of output data the encoder
|
||||
* may produce while compressing a frame.
|
||||
*/
|
||||
typedef struct vpx_codec_cx_pkt {
|
||||
enum vpx_codec_cx_pkt_kind kind; /**< packet variant */
|
||||
union {
|
||||
struct {
|
||||
void *buf; /**< compressed data buffer */
|
||||
size_t sz; /**< length of compressed data */
|
||||
/*!\brief time stamp to show frame (in timebase units) */
|
||||
vpx_codec_pts_t pts;
|
||||
/*!\brief duration to show frame (in timebase units) */
|
||||
unsigned long duration;
|
||||
vpx_codec_frame_flags_t flags; /**< flags for this frame */
|
||||
/*!\brief the partition id defines the decoding order of the partitions.
|
||||
* Only applicable when "output partition" mode is enabled. First
|
||||
* partition has id 0.*/
|
||||
int partition_id;
|
||||
/*!\brief Width and height of frames in this packet. VP8 will only use the
|
||||
* first one.*/
|
||||
unsigned int width[VPX_SS_MAX_LAYERS]; /**< frame width */
|
||||
unsigned int height[VPX_SS_MAX_LAYERS]; /**< frame height */
|
||||
/*!\brief Flag to indicate if spatial layer frame in this packet is
|
||||
* encoded or dropped. VP8 will always be set to 1.*/
|
||||
uint8_t spatial_layer_encoded[VPX_SS_MAX_LAYERS];
|
||||
} frame; /**< data for compressed frame packet */
|
||||
vpx_fixed_buf_t twopass_stats; /**< data for two-pass packet */
|
||||
vpx_fixed_buf_t firstpass_mb_stats; /**< first pass mb packet */
|
||||
struct vpx_psnr_pkt {
|
||||
unsigned int samples[4]; /**< Number of samples, total/y/u/v */
|
||||
uint64_t sse[4]; /**< sum squared error, total/y/u/v */
|
||||
double psnr[4]; /**< PSNR, total/y/u/v */
|
||||
} psnr; /**< data for PSNR packet */
|
||||
vpx_fixed_buf_t raw; /**< data for arbitrary packets */
|
||||
|
||||
/* This packet size is fixed to allow codecs to extend this
|
||||
* interface without having to manage storage for raw packets,
|
||||
* i.e., if it's smaller than 128 bytes, you can store in the
|
||||
* packet list directly.
|
||||
*/
|
||||
char pad[128 - sizeof(enum vpx_codec_cx_pkt_kind)]; /**< fixed sz */
|
||||
} data; /**< packet data */
|
||||
} vpx_codec_cx_pkt_t; /**< alias for struct vpx_codec_cx_pkt */
|
||||
|
||||
/*!\brief Encoder return output buffer callback
|
||||
*
|
||||
* This callback function, when registered, returns with packets when each
|
||||
* spatial layer is encoded.
|
||||
*/
|
||||
typedef void (*vpx_codec_enc_output_cx_pkt_cb_fn_t)(vpx_codec_cx_pkt_t *pkt,
|
||||
void *user_data);
|
||||
|
||||
/*!\brief Callback function pointer / user data pair storage */
|
||||
typedef struct vpx_codec_enc_output_cx_cb_pair {
|
||||
vpx_codec_enc_output_cx_pkt_cb_fn_t output_cx_pkt; /**< Callback function */
|
||||
void *user_priv; /**< Pointer to private data */
|
||||
} vpx_codec_priv_output_cx_pkt_cb_pair_t;
|
||||
|
||||
/*!\brief Rational Number
|
||||
*
|
||||
* This structure holds a fractional value.
|
||||
*/
|
||||
typedef struct vpx_rational {
|
||||
int num; /**< fraction numerator */
|
||||
int den; /**< fraction denominator */
|
||||
} vpx_rational_t; /**< alias for struct vpx_rational */
|
||||
|
||||
/*!\brief Multi-pass Encoding Pass */
|
||||
enum vpx_enc_pass {
|
||||
VPX_RC_ONE_PASS, /**< Single pass mode */
|
||||
VPX_RC_FIRST_PASS, /**< First pass of multi-pass mode */
|
||||
VPX_RC_LAST_PASS /**< Final pass of multi-pass mode */
|
||||
};
|
||||
|
||||
/*!\brief Rate control mode */
|
||||
enum vpx_rc_mode {
|
||||
VPX_VBR, /**< Variable Bit Rate (VBR) mode */
|
||||
VPX_CBR, /**< Constant Bit Rate (CBR) mode */
|
||||
VPX_CQ, /**< Constrained Quality (CQ) mode */
|
||||
VPX_Q, /**< Constant Quality (Q) mode */
|
||||
};
|
||||
|
||||
/*!\brief Keyframe placement mode.
|
||||
*
|
||||
* This enumeration determines whether keyframes are placed automatically by
|
||||
* the encoder or whether this behavior is disabled. Older releases of this
|
||||
* SDK were implemented such that VPX_KF_FIXED meant keyframes were disabled.
|
||||
* This name is confusing for this behavior, so the new symbols to be used
|
||||
* are VPX_KF_AUTO and VPX_KF_DISABLED.
|
||||
*/
|
||||
enum vpx_kf_mode {
|
||||
VPX_KF_FIXED, /**< deprecated, implies VPX_KF_DISABLED */
|
||||
VPX_KF_AUTO, /**< Encoder determines optimal placement automatically */
|
||||
VPX_KF_DISABLED = 0 /**< Encoder does not place keyframes. */
|
||||
};
|
||||
|
||||
/*!\brief Encoded Frame Flags
|
||||
*
|
||||
* This type indicates a bitfield to be passed to vpx_codec_encode(), defining
|
||||
* per-frame boolean values. By convention, bits common to all codecs will be
|
||||
* named VPX_EFLAG_*, and bits specific to an algorithm will be named
|
||||
* /algo/_eflag_*. The lower order 16 bits are reserved for common use.
|
||||
*/
|
||||
typedef long vpx_enc_frame_flags_t;
|
||||
#define VPX_EFLAG_FORCE_KF (1 << 0) /**< Force this frame to be a keyframe */
|
||||
|
||||
/*!\brief Encoder configuration structure
|
||||
*
|
||||
* This structure contains the encoder settings that have common representations
|
||||
* across all codecs. This doesn't imply that all codecs support all features,
|
||||
* however.
|
||||
*/
|
||||
typedef struct vpx_codec_enc_cfg {
|
||||
/*
|
||||
* generic settings (g)
|
||||
*/
|
||||
|
||||
/*!\brief Deprecated: Algorithm specific "usage" value
|
||||
*
|
||||
* This value must be zero.
|
||||
*/
|
||||
unsigned int g_usage;
|
||||
|
||||
/*!\brief Maximum number of threads to use
|
||||
*
|
||||
* For multi-threaded implementations, use no more than this number of
|
||||
* threads. The codec may use fewer threads than allowed. The value
|
||||
* 0 is equivalent to the value 1.
|
||||
*/
|
||||
unsigned int g_threads;
|
||||
|
||||
/*!\brief Bitstream profile to use
|
||||
*
|
||||
* Some codecs support a notion of multiple bitstream profiles. Typically
|
||||
* this maps to a set of features that are turned on or off. Often the
|
||||
* profile to use is determined by the features of the intended decoder.
|
||||
* Consult the documentation for the codec to determine the valid values
|
||||
* for this parameter, or set to zero for a sane default.
|
||||
*/
|
||||
unsigned int g_profile; /**< profile of bitstream to use */
|
||||
|
||||
/*!\brief Width of the frame
|
||||
*
|
||||
* This value identifies the presentation resolution of the frame,
|
||||
* in pixels. Note that the frames passed as input to the encoder must
|
||||
* have this resolution. Frames will be presented by the decoder in this
|
||||
* resolution, independent of any spatial resampling the encoder may do.
|
||||
*/
|
||||
unsigned int g_w;
|
||||
|
||||
/*!\brief Height of the frame
|
||||
*
|
||||
* This value identifies the presentation resolution of the frame,
|
||||
* in pixels. Note that the frames passed as input to the encoder must
|
||||
* have this resolution. Frames will be presented by the decoder in this
|
||||
* resolution, independent of any spatial resampling the encoder may do.
|
||||
*/
|
||||
unsigned int g_h;
|
||||
|
||||
/*!\brief Bit-depth of the codec
|
||||
*
|
||||
* This value identifies the bit_depth of the codec,
|
||||
* Only certain bit-depths are supported as identified in the
|
||||
* vpx_bit_depth_t enum.
|
||||
*/
|
||||
vpx_bit_depth_t g_bit_depth;
|
||||
|
||||
/*!\brief Bit-depth of the input frames
|
||||
*
|
||||
* This value identifies the bit_depth of the input frames in bits.
|
||||
* Note that the frames passed as input to the encoder must have
|
||||
* this bit-depth.
|
||||
*/
|
||||
unsigned int g_input_bit_depth;
|
||||
|
||||
/*!\brief Stream timebase units
|
||||
*
|
||||
* Indicates the smallest interval of time, in seconds, used by the stream.
|
||||
* For fixed frame rate material, or variable frame rate material where
|
||||
* frames are timed at a multiple of a given clock (ex: video capture),
|
||||
* the \ref RECOMMENDED method is to set the timebase to the reciprocal
|
||||
* of the frame rate (ex: 1001/30000 for 29.970 Hz NTSC). This allows the
|
||||
* pts to correspond to the frame number, which can be handy. For
|
||||
* re-encoding video from containers with absolute time timestamps, the
|
||||
* \ref RECOMMENDED method is to set the timebase to that of the parent
|
||||
* container or multimedia framework (ex: 1/1000 for ms, as in FLV).
|
||||
*/
|
||||
struct vpx_rational g_timebase;
|
||||
|
||||
/*!\brief Enable error resilient modes.
|
||||
*
|
||||
* The error resilient bitfield indicates to the encoder which features
|
||||
* it should enable to take measures for streaming over lossy or noisy
|
||||
* links.
|
||||
*/
|
||||
vpx_codec_er_flags_t g_error_resilient;
|
||||
|
||||
/*!\brief Multi-pass Encoding Mode
|
||||
*
|
||||
* This value should be set to the current phase for multi-pass encoding.
|
||||
* For single pass, set to #VPX_RC_ONE_PASS.
|
||||
*/
|
||||
enum vpx_enc_pass g_pass;
|
||||
|
||||
/*!\brief Allow lagged encoding
|
||||
*
|
||||
* If set, this value allows the encoder to consume a number of input
|
||||
* frames before producing output frames. This allows the encoder to
|
||||
* base decisions for the current frame on future frames. This does
|
||||
* increase the latency of the encoding pipeline, so it is not appropriate
|
||||
* in all situations (ex: realtime encoding).
|
||||
*
|
||||
* Note that this is a maximum value -- the encoder may produce frames
|
||||
* sooner than the given limit. Set this value to 0 to disable this
|
||||
* feature.
|
||||
*/
|
||||
unsigned int g_lag_in_frames;
|
||||
|
||||
/*
|
||||
* rate control settings (rc)
|
||||
*/
|
||||
|
||||
/*!\brief Temporal resampling configuration, if supported by the codec.
|
||||
*
|
||||
* Temporal resampling allows the codec to "drop" frames as a strategy to
|
||||
* meet its target data rate. This can cause temporal discontinuities in
|
||||
* the encoded video, which may appear as stuttering during playback. This
|
||||
* trade-off is often acceptable, but for many applications is not. It can
|
||||
* be disabled in these cases.
|
||||
*
|
||||
* This threshold is described as a percentage of the target data buffer.
|
||||
* When the data buffer falls below this percentage of fullness, a
|
||||
* dropped frame is indicated. Set the threshold to zero (0) to disable
|
||||
* this feature.
|
||||
*/
|
||||
unsigned int rc_dropframe_thresh;
|
||||
|
||||
/*!\brief Enable/disable spatial resampling, if supported by the codec.
|
||||
*
|
||||
* Spatial resampling allows the codec to compress a lower resolution
|
||||
* version of the frame, which is then upscaled by the encoder to the
|
||||
* correct presentation resolution. This increases visual quality at
|
||||
* low data rates, at the expense of CPU time on the encoder/decoder.
|
||||
*/
|
||||
unsigned int rc_resize_allowed;
|
||||
|
||||
/*!\brief Internal coded frame width.
|
||||
*
|
||||
* If spatial resampling is enabled this specifies the width of the
|
||||
* encoded frame.
|
||||
*/
|
||||
unsigned int rc_scaled_width;
|
||||
|
||||
/*!\brief Internal coded frame height.
|
||||
*
|
||||
* If spatial resampling is enabled this specifies the height of the
|
||||
* encoded frame.
|
||||
*/
|
||||
unsigned int rc_scaled_height;
|
||||
|
||||
/*!\brief Spatial resampling up watermark.
|
||||
*
|
||||
* This threshold is described as a percentage of the target data buffer.
|
||||
* When the data buffer rises above this percentage of fullness, the
|
||||
* encoder will step up to a higher resolution version of the frame.
|
||||
*/
|
||||
unsigned int rc_resize_up_thresh;
|
||||
|
||||
/*!\brief Spatial resampling down watermark.
|
||||
*
|
||||
* This threshold is described as a percentage of the target data buffer.
|
||||
* When the data buffer falls below this percentage of fullness, the
|
||||
* encoder will step down to a lower resolution version of the frame.
|
||||
*/
|
||||
unsigned int rc_resize_down_thresh;
|
||||
|
||||
/*!\brief Rate control algorithm to use.
|
||||
*
|
||||
* Indicates whether the end usage of this stream is to be streamed over
|
||||
* a bandwidth constrained link, indicating that Constant Bit Rate (CBR)
|
||||
* mode should be used, or whether it will be played back on a high
|
||||
* bandwidth link, as from a local disk, where higher variations in
|
||||
* bitrate are acceptable.
|
||||
*/
|
||||
enum vpx_rc_mode rc_end_usage;
|
||||
|
||||
/*!\brief Two-pass stats buffer.
|
||||
*
|
||||
* A buffer containing all of the stats packets produced in the first
|
||||
* pass, concatenated.
|
||||
*/
|
||||
vpx_fixed_buf_t rc_twopass_stats_in;
|
||||
|
||||
/*!\brief first pass mb stats buffer.
|
||||
*
|
||||
* A buffer containing all of the first pass mb stats packets produced
|
||||
* in the first pass, concatenated.
|
||||
*/
|
||||
vpx_fixed_buf_t rc_firstpass_mb_stats_in;
|
||||
|
||||
/*!\brief Target data rate
|
||||
*
|
||||
* Target bandwidth to use for this stream, in kilobits per second.
|
||||
*/
|
||||
unsigned int rc_target_bitrate;
|
||||
|
||||
/*
|
||||
* quantizer settings
|
||||
*/
|
||||
|
||||
/*!\brief Minimum (Best Quality) Quantizer
|
||||
*
|
||||
* The quantizer is the most direct control over the quality of the
|
||||
* encoded image. The range of valid values for the quantizer is codec
|
||||
* specific. Consult the documentation for the codec to determine the
|
||||
* values to use.
|
||||
*/
|
||||
unsigned int rc_min_quantizer;
|
||||
|
||||
/*!\brief Maximum (Worst Quality) Quantizer
|
||||
*
|
||||
* The quantizer is the most direct control over the quality of the
|
||||
* encoded image. The range of valid values for the quantizer is codec
|
||||
* specific. Consult the documentation for the codec to determine the
|
||||
* values to use.
|
||||
*/
|
||||
unsigned int rc_max_quantizer;
|
||||
|
||||
/*
|
||||
* bitrate tolerance
|
||||
*/
|
||||
|
||||
/*!\brief Rate control adaptation undershoot control
|
||||
*
|
||||
* VP8: Expressed as a percentage of the target bitrate,
|
||||
* controls the maximum allowed adaptation speed of the codec.
|
||||
* This factor controls the maximum amount of bits that can
|
||||
* be subtracted from the target bitrate in order to compensate
|
||||
* for prior overshoot.
|
||||
* VP9: Expressed as a percentage of the target bitrate, a threshold
|
||||
* undershoot level (current rate vs target) beyond which more aggressive
|
||||
* corrective measures are taken.
|
||||
* *
|
||||
* Valid values in the range VP8:0-1000 VP9: 0-100.
|
||||
*/
|
||||
unsigned int rc_undershoot_pct;
|
||||
|
||||
/*!\brief Rate control adaptation overshoot control
|
||||
*
|
||||
* VP8: Expressed as a percentage of the target bitrate,
|
||||
* controls the maximum allowed adaptation speed of the codec.
|
||||
* This factor controls the maximum amount of bits that can
|
||||
* be added to the target bitrate in order to compensate for
|
||||
* prior undershoot.
|
||||
* VP9: Expressed as a percentage of the target bitrate, a threshold
|
||||
* overshoot level (current rate vs target) beyond which more aggressive
|
||||
* corrective measures are taken.
|
||||
*
|
||||
* Valid values in the range VP8:0-1000 VP9: 0-100.
|
||||
*/
|
||||
unsigned int rc_overshoot_pct;
|
||||
|
||||
/*
|
||||
* decoder buffer model parameters
|
||||
*/
|
||||
|
||||
/*!\brief Decoder Buffer Size
|
||||
*
|
||||
* This value indicates the amount of data that may be buffered by the
|
||||
* decoding application. Note that this value is expressed in units of
|
||||
* time (milliseconds). For example, a value of 5000 indicates that the
|
||||
* client will buffer (at least) 5000ms worth of encoded data. Use the
|
||||
* target bitrate (#rc_target_bitrate) to convert to bits/bytes, if
|
||||
* necessary.
|
||||
*/
|
||||
unsigned int rc_buf_sz;
|
||||
|
||||
/*!\brief Decoder Buffer Initial Size
|
||||
*
|
||||
* This value indicates the amount of data that will be buffered by the
|
||||
* decoding application prior to beginning playback. This value is
|
||||
* expressed in units of time (milliseconds). Use the target bitrate
|
||||
* (#rc_target_bitrate) to convert to bits/bytes, if necessary.
|
||||
*/
|
||||
unsigned int rc_buf_initial_sz;
|
||||
|
||||
/*!\brief Decoder Buffer Optimal Size
|
||||
*
|
||||
* This value indicates the amount of data that the encoder should try
|
||||
* to maintain in the decoder's buffer. This value is expressed in units
|
||||
* of time (milliseconds). Use the target bitrate (#rc_target_bitrate)
|
||||
* to convert to bits/bytes, if necessary.
|
||||
*/
|
||||
unsigned int rc_buf_optimal_sz;
|
||||
|
||||
/*
|
||||
* 2 pass rate control parameters
|
||||
*/
|
||||
|
||||
/*!\brief Two-pass mode CBR/VBR bias
|
||||
*
|
||||
* Bias, expressed on a scale of 0 to 100, for determining target size
|
||||
* for the current frame. The value 0 indicates the optimal CBR mode
|
||||
* value should be used. The value 100 indicates the optimal VBR mode
|
||||
* value should be used. Values in between indicate which way the
|
||||
* encoder should "lean."
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_bias_pct;
|
||||
|
||||
/*!\brief Two-pass mode per-GOP minimum bitrate
|
||||
*
|
||||
* This value, expressed as a percentage of the target bitrate, indicates
|
||||
* the minimum bitrate to be used for a single GOP (aka "section")
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_minsection_pct;
|
||||
|
||||
/*!\brief Two-pass mode per-GOP maximum bitrate
|
||||
*
|
||||
* This value, expressed as a percentage of the target bitrate, indicates
|
||||
* the maximum bitrate to be used for a single GOP (aka "section")
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_maxsection_pct;
|
||||
|
||||
/*!\brief Two-pass corpus vbr mode complexity control
|
||||
* Used only in VP9: A value representing the corpus midpoint complexity
|
||||
* for corpus vbr mode. This value defaults to 0 which disables corpus vbr
|
||||
* mode in favour of normal vbr mode.
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_corpus_complexity;
|
||||
|
||||
/*
|
||||
* keyframing settings (kf)
|
||||
*/
|
||||
|
||||
/*!\brief Keyframe placement mode
|
||||
*
|
||||
* This value indicates whether the encoder should place keyframes at a
|
||||
* fixed interval, or determine the optimal placement automatically
|
||||
* (as governed by the #kf_min_dist and #kf_max_dist parameters)
|
||||
*/
|
||||
enum vpx_kf_mode kf_mode;
|
||||
|
||||
/*!\brief Keyframe minimum interval
|
||||
*
|
||||
* This value, expressed as a number of frames, prevents the encoder from
|
||||
* placing a keyframe nearer than kf_min_dist to the previous keyframe. At
|
||||
* least kf_min_dist frames non-keyframes will be coded before the next
|
||||
* keyframe. Set kf_min_dist equal to kf_max_dist for a fixed interval.
|
||||
*/
|
||||
unsigned int kf_min_dist;
|
||||
|
||||
/*!\brief Keyframe maximum interval
|
||||
*
|
||||
* This value, expressed as a number of frames, forces the encoder to code
|
||||
* a keyframe if one has not been coded in the last kf_max_dist frames.
|
||||
* A value of 0 implies all frames will be keyframes. Set kf_min_dist
|
||||
* equal to kf_max_dist for a fixed interval.
|
||||
*/
|
||||
unsigned int kf_max_dist;
|
||||
|
||||
/*
|
||||
* Spatial scalability settings (ss)
|
||||
*/
|
||||
|
||||
/*!\brief Number of spatial coding layers.
|
||||
*
|
||||
* This value specifies the number of spatial coding layers to be used.
|
||||
*/
|
||||
unsigned int ss_number_layers;
|
||||
|
||||
/*!\brief Enable auto alt reference flags for each spatial layer.
|
||||
*
|
||||
* These values specify if auto alt reference frame is enabled for each
|
||||
* spatial layer.
|
||||
*/
|
||||
int ss_enable_auto_alt_ref[VPX_SS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Target bitrate for each spatial layer.
|
||||
*
|
||||
* These values specify the target coding bitrate to be used for each
|
||||
* spatial layer.
|
||||
*/
|
||||
unsigned int ss_target_bitrate[VPX_SS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Number of temporal coding layers.
|
||||
*
|
||||
* This value specifies the number of temporal layers to be used.
|
||||
*/
|
||||
unsigned int ts_number_layers;
|
||||
|
||||
/*!\brief Target bitrate for each temporal layer.
|
||||
*
|
||||
* These values specify the target coding bitrate to be used for each
|
||||
* temporal layer.
|
||||
*/
|
||||
unsigned int ts_target_bitrate[VPX_TS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Frame rate decimation factor for each temporal layer.
|
||||
*
|
||||
* These values specify the frame rate decimation factors to apply
|
||||
* to each temporal layer.
|
||||
*/
|
||||
unsigned int ts_rate_decimator[VPX_TS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Length of the sequence defining frame temporal layer membership.
|
||||
*
|
||||
* This value specifies the length of the sequence that defines the
|
||||
* membership of frames to temporal layers. For example, if the
|
||||
* ts_periodicity = 8, then the frames are assigned to coding layers with a
|
||||
* repeated sequence of length 8.
|
||||
*/
|
||||
unsigned int ts_periodicity;
|
||||
|
||||
/*!\brief Template defining the membership of frames to temporal layers.
|
||||
*
|
||||
* This array defines the membership of frames to temporal coding layers.
|
||||
* For a 2-layer encoding that assigns even numbered frames to one temporal
|
||||
* layer (0) and odd numbered frames to a second temporal layer (1) with
|
||||
* ts_periodicity=8, then ts_layer_id = (0,1,0,1,0,1,0,1).
|
||||
*/
|
||||
unsigned int ts_layer_id[VPX_TS_MAX_PERIODICITY];
|
||||
|
||||
/*!\brief Target bitrate for each spatial/temporal layer.
|
||||
*
|
||||
* These values specify the target coding bitrate to be used for each
|
||||
* spatial/temporal layer.
|
||||
*
|
||||
*/
|
||||
unsigned int layer_target_bitrate[VPX_MAX_LAYERS];
|
||||
|
||||
/*!\brief Temporal layering mode indicating which temporal layering scheme to
|
||||
* use.
|
||||
*
|
||||
* The value (refer to VP9E_TEMPORAL_LAYERING_MODE) specifies the
|
||||
* temporal layering mode to use.
|
||||
*
|
||||
*/
|
||||
int temporal_layering_mode;
|
||||
} vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */
|
||||
|
||||
/*!\brief vp9 svc extra configure parameters
|
||||
*
|
||||
* This defines max/min quantizers and scale factors for each layer
|
||||
*
|
||||
*/
|
||||
typedef struct vpx_svc_parameters {
|
||||
int max_quantizers[VPX_MAX_LAYERS]; /**< Max Q for each layer */
|
||||
int min_quantizers[VPX_MAX_LAYERS]; /**< Min Q for each layer */
|
||||
int scaling_factor_num[VPX_MAX_LAYERS]; /**< Scaling factor-numerator */
|
||||
int scaling_factor_den[VPX_MAX_LAYERS]; /**< Scaling factor-denominator */
|
||||
int speed_per_layer[VPX_MAX_LAYERS]; /**< Speed setting for each sl */
|
||||
int temporal_layering_mode; /**< Temporal layering mode */
|
||||
} vpx_svc_extra_cfg_t;
|
||||
|
||||
/*!\brief Initialize an encoder instance
|
||||
*
|
||||
* Initializes a encoder context using the given interface. Applications
|
||||
* should call the vpx_codec_enc_init convenience macro instead of this
|
||||
* function directly, to ensure that the ABI version number parameter
|
||||
* is properly initialized.
|
||||
*
|
||||
* If the library was configured with --disable-multithread, this call
|
||||
* is not thread safe and should be guarded with a lock if being used
|
||||
* in a multithreaded context.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[in] cfg Configuration to use, if known. May be NULL.
|
||||
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
|
||||
* \param[in] ver ABI version number. Must be set to
|
||||
* VPX_ENCODER_ABI_VERSION
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The decoder algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_iface_t *iface,
|
||||
const vpx_codec_enc_cfg_t *cfg,
|
||||
vpx_codec_flags_t flags, int ver);
|
||||
|
||||
/*!\brief Convenience macro for vpx_codec_enc_init_ver()
|
||||
*
|
||||
* Ensures the ABI version parameter is properly set.
|
||||
*/
|
||||
#define vpx_codec_enc_init(ctx, iface, cfg, flags) \
|
||||
vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION)
|
||||
|
||||
/*!\brief Initialize multi-encoder instance
|
||||
*
|
||||
* Initializes multi-encoder context using the given interface.
|
||||
* Applications should call the vpx_codec_enc_init_multi convenience macro
|
||||
* instead of this function directly, to ensure that the ABI version number
|
||||
* parameter is properly initialized.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[in] cfg Configuration to use, if known. May be NULL.
|
||||
* \param[in] num_enc Total number of encoders.
|
||||
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
|
||||
* \param[in] dsf Pointer to down-sampling factors.
|
||||
* \param[in] ver ABI version number. Must be set to
|
||||
* VPX_ENCODER_ABI_VERSION
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The decoder algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_init_multi_ver(
|
||||
vpx_codec_ctx_t *ctx, vpx_codec_iface_t *iface, vpx_codec_enc_cfg_t *cfg,
|
||||
int num_enc, vpx_codec_flags_t flags, vpx_rational_t *dsf, int ver);
|
||||
|
||||
/*!\brief Convenience macro for vpx_codec_enc_init_multi_ver()
|
||||
*
|
||||
* Ensures the ABI version parameter is properly set.
|
||||
*/
|
||||
#define vpx_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \
|
||||
vpx_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \
|
||||
VPX_ENCODER_ABI_VERSION)
|
||||
|
||||
/*!\brief Get a default configuration
|
||||
*
|
||||
* Initializes a encoder configuration structure with default values. Supports
|
||||
* the notion of "usages" so that an algorithm may offer different default
|
||||
* settings depending on the user's intended goal. This function \ref SHOULD
|
||||
* be called by all applications to initialize the configuration structure
|
||||
* before specializing the configuration with application specific values.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[out] cfg Configuration buffer to populate.
|
||||
* \param[in] usage Must be set to 0.
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The configuration was populated.
|
||||
* \retval #VPX_CODEC_INCAPABLE
|
||||
* Interface is not an encoder interface.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, or the usage value was not recognized.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface,
|
||||
vpx_codec_enc_cfg_t *cfg,
|
||||
unsigned int usage);
|
||||
|
||||
/*!\brief Set or change configuration
|
||||
*
|
||||
* Reconfigures an encoder instance according to the given configuration.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cfg Configuration buffer to use
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The configuration was populated.
|
||||
* \retval #VPX_CODEC_INCAPABLE
|
||||
* Interface is not an encoder interface.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, or the usage value was not recognized.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx,
|
||||
const vpx_codec_enc_cfg_t *cfg);
|
||||
|
||||
/*!\brief Get global stream headers
|
||||
*
|
||||
* Retrieves a stream level global header packet, if supported by the codec.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
*
|
||||
* \retval NULL
|
||||
* Encoder does not support global header
|
||||
* \retval Non-NULL
|
||||
* Pointer to buffer containing global header packet
|
||||
*/
|
||||
vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!\brief deadline parameter analogous to VPx REALTIME mode. */
|
||||
#define VPX_DL_REALTIME (1)
|
||||
/*!\brief deadline parameter analogous to VPx GOOD QUALITY mode. */
|
||||
#define VPX_DL_GOOD_QUALITY (1000000)
|
||||
/*!\brief deadline parameter analogous to VPx BEST QUALITY mode. */
|
||||
#define VPX_DL_BEST_QUALITY (0)
|
||||
/*!\brief Encode a frame
|
||||
*
|
||||
* Encodes a video frame at the given "presentation time." The presentation
|
||||
* time stamp (PTS) \ref MUST be strictly increasing.
|
||||
*
|
||||
* The encoder supports the notion of a soft real-time deadline. Given a
|
||||
* non-zero value to the deadline parameter, the encoder will make a "best
|
||||
* effort" guarantee to return before the given time slice expires. It is
|
||||
* implicit that limiting the available time to encode will degrade the
|
||||
* output quality. The encoder can be given an unlimited time to produce the
|
||||
* best possible frame by specifying a deadline of '0'. This deadline
|
||||
* supersedes the VPx notion of "best quality, good quality, realtime".
|
||||
* Applications that wish to map these former settings to the new deadline
|
||||
* based system can use the symbols #VPX_DL_REALTIME, #VPX_DL_GOOD_QUALITY,
|
||||
* and #VPX_DL_BEST_QUALITY.
|
||||
*
|
||||
* When the last frame has been passed to the encoder, this function should
|
||||
* continue to be called, with the img parameter set to NULL. This will
|
||||
* signal the end-of-stream condition to the encoder and allow it to encode
|
||||
* any held buffers. Encoding is complete when vpx_codec_encode() is called
|
||||
* and vpx_codec_get_cx_data() returns no data.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] img Image data to encode, NULL to flush.
|
||||
* \param[in] pts Presentation time stamp, in timebase units.
|
||||
* \param[in] duration Duration to show frame, in timebase units.
|
||||
* \param[in] flags Flags to use for encoding this frame.
|
||||
* \param[in] deadline Time to spend encoding, in microseconds. (0=infinite)
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The configuration was populated.
|
||||
* \retval #VPX_CODEC_INCAPABLE
|
||||
* Interface is not an encoder interface.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, the image format is unsupported, etc.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx, const vpx_image_t *img,
|
||||
vpx_codec_pts_t pts, unsigned long duration,
|
||||
vpx_enc_frame_flags_t flags,
|
||||
unsigned long deadline);
|
||||
|
||||
/*!\brief Set compressed data output buffer
|
||||
*
|
||||
* Sets the buffer that the codec should output the compressed data
|
||||
* into. This call effectively sets the buffer pointer returned in the
|
||||
* next VPX_CODEC_CX_FRAME_PKT packet. Subsequent packets will be
|
||||
* appended into this buffer. The buffer is preserved across frames,
|
||||
* so applications must periodically call this function after flushing
|
||||
* the accumulated compressed data to disk or to the network to reset
|
||||
* the pointer to the buffer's head.
|
||||
*
|
||||
* `pad_before` bytes will be skipped before writing the compressed
|
||||
* data, and `pad_after` bytes will be appended to the packet. The size
|
||||
* of the packet will be the sum of the size of the actual compressed
|
||||
* data, pad_before, and pad_after. The padding bytes will be preserved
|
||||
* (not overwritten).
|
||||
*
|
||||
* Note that calling this function does not guarantee that the returned
|
||||
* compressed data will be placed into the specified buffer. In the
|
||||
* event that the encoded data will not fit into the buffer provided,
|
||||
* the returned packet \ref MAY point to an internal buffer, as it would
|
||||
* if this call were never used. In this event, the output packet will
|
||||
* NOT have any padding, and the application must free space and copy it
|
||||
* to the proper place. This is of particular note in configurations
|
||||
* that may output multiple packets for a single encoded frame (e.g., lagged
|
||||
* encoding) or if the application does not reset the buffer periodically.
|
||||
*
|
||||
* Applications may restore the default behavior of the codec providing
|
||||
* the compressed data buffer by calling this function with a NULL
|
||||
* buffer.
|
||||
*
|
||||
* Applications \ref MUSTNOT call this function during iteration of
|
||||
* vpx_codec_get_cx_data().
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] buf Buffer to store compressed data into
|
||||
* \param[in] pad_before Bytes to skip before writing compressed data
|
||||
* \param[in] pad_after Bytes to skip after writing compressed data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The buffer was set successfully.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, the image format is unsupported, etc.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx,
|
||||
const vpx_fixed_buf_t *buf,
|
||||
unsigned int pad_before,
|
||||
unsigned int pad_after);
|
||||
|
||||
/*!\brief Encoded data iterator
|
||||
*
|
||||
* Iterates over a list of data packets to be passed from the encoder to the
|
||||
* application. The different kinds of packets available are enumerated in
|
||||
* #vpx_codec_cx_pkt_kind.
|
||||
*
|
||||
* #VPX_CODEC_CX_FRAME_PKT packets should be passed to the application's
|
||||
* muxer. Multiple compressed frames may be in the list.
|
||||
* #VPX_CODEC_STATS_PKT packets should be appended to a global buffer.
|
||||
*
|
||||
* The application \ref MUST silently ignore any packet kinds that it does
|
||||
* not recognize or support.
|
||||
*
|
||||
* The data buffers returned from this function are only guaranteed to be
|
||||
* valid until the application makes another call to any vpx_codec_* function.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] iter Iterator storage, initialized to NULL
|
||||
*
|
||||
* \return Returns a pointer to an output data packet (compressed frame data,
|
||||
* two-pass statistics, etc.) or NULL to signal end-of-list.
|
||||
*
|
||||
*/
|
||||
const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_iter_t *iter);
|
||||
|
||||
/*!\brief Get Preview Frame
|
||||
*
|
||||
* Returns an image that can be used as a preview. Shows the image as it would
|
||||
* exist at the decompressor. The application \ref MUST NOT write into this
|
||||
* image buffer.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
*
|
||||
* \return Returns a pointer to a preview image, or NULL if no image is
|
||||
* available.
|
||||
*
|
||||
*/
|
||||
const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!@} - end defgroup encoder*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // VPX_VPX_VPX_ENCODER_H_
|
||||
83
vpx-encoder/android_include/vpx/vpx_frame_buffer.h
Normal file
83
vpx-encoder/android_include/vpx/vpx_frame_buffer.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef VPX_VPX_VPX_FRAME_BUFFER_H_
|
||||
#define VPX_VPX_VPX_FRAME_BUFFER_H_
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the decoder external frame buffer interface.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_integer.h"
|
||||
|
||||
/*!\brief The maximum number of work buffers used by libvpx.
|
||||
* Support maximum 4 threads to decode video in parallel.
|
||||
* Each thread will use one work buffer.
|
||||
* TODO(hkuang): Add support to set number of worker threads dynamically.
|
||||
*/
|
||||
#define VPX_MAXIMUM_WORK_BUFFERS 8
|
||||
|
||||
/*!\brief The maximum number of reference buffers that a VP9 encoder may use.
|
||||
*/
|
||||
#define VP9_MAXIMUM_REF_BUFFERS 8
|
||||
|
||||
/*!\brief External frame buffer
|
||||
*
|
||||
* This structure holds allocated frame buffers used by the decoder.
|
||||
*/
|
||||
typedef struct vpx_codec_frame_buffer {
|
||||
uint8_t *data; /**< Pointer to the data buffer */
|
||||
size_t size; /**< Size of data in bytes */
|
||||
void *priv; /**< Frame's private data */
|
||||
} vpx_codec_frame_buffer_t;
|
||||
|
||||
/*!\brief get frame buffer callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to retrieve data for the frame
|
||||
* buffer in order for the decode call to complete. The callback must
|
||||
* allocate at least min_size in bytes and assign it to fb->data. The callback
|
||||
* must zero out all the data allocated. Then the callback must set fb->size
|
||||
* to the allocated size. The application does not need to align the allocated
|
||||
* data. The callback is triggered when the decoder needs a frame buffer to
|
||||
* decode a compressed image into. This function may be called more than once
|
||||
* for every call to vpx_codec_decode. The application may set fb->priv to
|
||||
* some data which will be passed back in the ximage and the release function
|
||||
* call. |fb| is guaranteed to not be NULL. On success the callback must
|
||||
* return 0. Any failure the callback must return a value less than 0.
|
||||
*
|
||||
* \param[in] priv Callback's private data
|
||||
* \param[in] min_size Size in bytes needed by the buffer
|
||||
* \param[in,out] fb Pointer to vpx_codec_frame_buffer_t
|
||||
*/
|
||||
typedef int (*vpx_get_frame_buffer_cb_fn_t)(void *priv, size_t min_size,
|
||||
vpx_codec_frame_buffer_t *fb);
|
||||
|
||||
/*!\brief release frame buffer callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder when the frame buffer is not
|
||||
* referenced by any other buffers. |fb| is guaranteed to not be NULL. On
|
||||
* success the callback must return 0. Any failure the callback must return
|
||||
* a value less than 0.
|
||||
*
|
||||
* \param[in] priv Callback's private data
|
||||
* \param[in] fb Pointer to vpx_codec_frame_buffer_t
|
||||
*/
|
||||
typedef int (*vpx_release_frame_buffer_cb_fn_t)(void *priv,
|
||||
vpx_codec_frame_buffer_t *fb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VPX_FRAME_BUFFER_H_
|
||||
207
vpx-encoder/android_include/vpx/vpx_image.h
Normal file
207
vpx-encoder/android_include/vpx/vpx_image.h
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the vpx image descriptor and associated operations
|
||||
*
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_IMAGE_H_
|
||||
#define VPX_VPX_VPX_IMAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_IMAGE_ABI_VERSION (5) /**<\hideinitializer*/
|
||||
|
||||
#define VPX_IMG_FMT_PLANAR 0x100 /**< Image is a planar format. */
|
||||
#define VPX_IMG_FMT_UV_FLIP 0x200 /**< V plane precedes U in memory. */
|
||||
#define VPX_IMG_FMT_HAS_ALPHA 0x400 /**< Image has an alpha channel. */
|
||||
#define VPX_IMG_FMT_HIGHBITDEPTH 0x800 /**< Image uses 16bit framebuffer. */
|
||||
|
||||
/*!\brief List of supported image formats */
|
||||
typedef enum vpx_img_fmt {
|
||||
VPX_IMG_FMT_NONE,
|
||||
VPX_IMG_FMT_YV12 =
|
||||
VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
|
||||
VPX_IMG_FMT_I420 = VPX_IMG_FMT_PLANAR | 2,
|
||||
VPX_IMG_FMT_I422 = VPX_IMG_FMT_PLANAR | 5,
|
||||
VPX_IMG_FMT_I444 = VPX_IMG_FMT_PLANAR | 6,
|
||||
VPX_IMG_FMT_I440 = VPX_IMG_FMT_PLANAR | 7,
|
||||
VPX_IMG_FMT_I42016 = VPX_IMG_FMT_I420 | VPX_IMG_FMT_HIGHBITDEPTH,
|
||||
VPX_IMG_FMT_I42216 = VPX_IMG_FMT_I422 | VPX_IMG_FMT_HIGHBITDEPTH,
|
||||
VPX_IMG_FMT_I44416 = VPX_IMG_FMT_I444 | VPX_IMG_FMT_HIGHBITDEPTH,
|
||||
VPX_IMG_FMT_I44016 = VPX_IMG_FMT_I440 | VPX_IMG_FMT_HIGHBITDEPTH
|
||||
} vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
|
||||
|
||||
/*!\brief List of supported color spaces */
|
||||
typedef enum vpx_color_space {
|
||||
VPX_CS_UNKNOWN = 0, /**< Unknown */
|
||||
VPX_CS_BT_601 = 1, /**< BT.601 */
|
||||
VPX_CS_BT_709 = 2, /**< BT.709 */
|
||||
VPX_CS_SMPTE_170 = 3, /**< SMPTE.170 */
|
||||
VPX_CS_SMPTE_240 = 4, /**< SMPTE.240 */
|
||||
VPX_CS_BT_2020 = 5, /**< BT.2020 */
|
||||
VPX_CS_RESERVED = 6, /**< Reserved */
|
||||
VPX_CS_SRGB = 7 /**< sRGB */
|
||||
} vpx_color_space_t; /**< alias for enum vpx_color_space */
|
||||
|
||||
/*!\brief List of supported color range */
|
||||
typedef enum vpx_color_range {
|
||||
VPX_CR_STUDIO_RANGE = 0, /**< Y [16..235], UV [16..240] */
|
||||
VPX_CR_FULL_RANGE = 1 /**< YUV/RGB [0..255] */
|
||||
} vpx_color_range_t; /**< alias for enum vpx_color_range */
|
||||
|
||||
/**\brief Image Descriptor */
|
||||
typedef struct vpx_image {
|
||||
vpx_img_fmt_t fmt; /**< Image Format */
|
||||
vpx_color_space_t cs; /**< Color Space */
|
||||
vpx_color_range_t range; /**< Color Range */
|
||||
|
||||
/* Image storage dimensions */
|
||||
unsigned int w; /**< Stored image width */
|
||||
unsigned int h; /**< Stored image height */
|
||||
unsigned int bit_depth; /**< Stored image bit-depth */
|
||||
|
||||
/* Image display dimensions */
|
||||
unsigned int d_w; /**< Displayed image width */
|
||||
unsigned int d_h; /**< Displayed image height */
|
||||
|
||||
/* Image intended rendering dimensions */
|
||||
unsigned int r_w; /**< Intended rendering image width */
|
||||
unsigned int r_h; /**< Intended rendering image height */
|
||||
|
||||
/* Chroma subsampling info */
|
||||
unsigned int x_chroma_shift; /**< subsampling order, X */
|
||||
unsigned int y_chroma_shift; /**< subsampling order, Y */
|
||||
|
||||
/* Image data pointers. */
|
||||
#define VPX_PLANE_PACKED 0 /**< To be used for all packed formats */
|
||||
#define VPX_PLANE_Y 0 /**< Y (Luminance) plane */
|
||||
#define VPX_PLANE_U 1 /**< U (Chroma) plane */
|
||||
#define VPX_PLANE_V 2 /**< V (Chroma) plane */
|
||||
#define VPX_PLANE_ALPHA 3 /**< A (Transparency) plane */
|
||||
unsigned char *planes[4]; /**< pointer to the top left pixel for each plane */
|
||||
int stride[4]; /**< stride between rows for each plane */
|
||||
|
||||
int bps; /**< bits per sample (for packed formats) */
|
||||
|
||||
/*!\brief The following member may be set by the application to associate
|
||||
* data with this image.
|
||||
*/
|
||||
void *user_priv;
|
||||
|
||||
/* The following members should be treated as private. */
|
||||
unsigned char *img_data; /**< private */
|
||||
int img_data_owner; /**< private */
|
||||
int self_allocd; /**< private */
|
||||
|
||||
void *fb_priv; /**< Frame buffer data associated with the image. */
|
||||
} vpx_image_t; /**< alias for struct vpx_image */
|
||||
|
||||
/**\brief Representation of a rectangle on a surface */
|
||||
typedef struct vpx_image_rect {
|
||||
unsigned int x; /**< leftmost column */
|
||||
unsigned int y; /**< topmost row */
|
||||
unsigned int w; /**< width */
|
||||
unsigned int h; /**< height */
|
||||
} vpx_image_rect_t; /**< alias for struct vpx_image_rect */
|
||||
|
||||
/*!\brief Open a descriptor, allocating storage for the underlying image
|
||||
*
|
||||
* Returns a descriptor for storing an image of the given format. The
|
||||
* storage for the descriptor is allocated on the heap.
|
||||
*
|
||||
* \param[in] img Pointer to storage for descriptor. If this parameter
|
||||
* is NULL, the storage for the descriptor will be
|
||||
* allocated on the heap.
|
||||
* \param[in] fmt Format for the image
|
||||
* \param[in] d_w Width of the image
|
||||
* \param[in] d_h Height of the image
|
||||
* \param[in] align Alignment, in bytes, of the image buffer and
|
||||
* each row in the image(stride).
|
||||
*
|
||||
* \return Returns a pointer to the initialized image descriptor. If the img
|
||||
* parameter is non-null, the value of the img parameter will be
|
||||
* returned.
|
||||
*/
|
||||
vpx_image_t *vpx_img_alloc(vpx_image_t *img, vpx_img_fmt_t fmt,
|
||||
unsigned int d_w, unsigned int d_h,
|
||||
unsigned int align);
|
||||
|
||||
/*!\brief Open a descriptor, using existing storage for the underlying image
|
||||
*
|
||||
* Returns a descriptor for storing an image of the given format. The
|
||||
* storage for descriptor has been allocated elsewhere, and a descriptor is
|
||||
* desired to "wrap" that storage.
|
||||
*
|
||||
* \param[in] img Pointer to storage for descriptor. If this
|
||||
* parameter is NULL, the storage for the descriptor
|
||||
* will be allocated on the heap.
|
||||
* \param[in] fmt Format for the image
|
||||
* \param[in] d_w Width of the image
|
||||
* \param[in] d_h Height of the image
|
||||
* \param[in] stride_align Alignment, in bytes, of each row in the image.
|
||||
* \param[in] img_data Storage to use for the image
|
||||
*
|
||||
* \return Returns a pointer to the initialized image descriptor. If the img
|
||||
* parameter is non-null, the value of the img parameter will be
|
||||
* returned.
|
||||
*/
|
||||
vpx_image_t *vpx_img_wrap(vpx_image_t *img, vpx_img_fmt_t fmt, unsigned int d_w,
|
||||
unsigned int d_h, unsigned int stride_align,
|
||||
unsigned char *img_data);
|
||||
|
||||
/*!\brief Set the rectangle identifying the displayed portion of the image
|
||||
*
|
||||
* Updates the displayed rectangle (aka viewport) on the image surface to
|
||||
* match the specified coordinates and size.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
* \param[in] x leftmost column
|
||||
* \param[in] y topmost row
|
||||
* \param[in] w width
|
||||
* \param[in] h height
|
||||
*
|
||||
* \return 0 if the requested rectangle is valid, nonzero otherwise.
|
||||
*/
|
||||
int vpx_img_set_rect(vpx_image_t *img, unsigned int x, unsigned int y,
|
||||
unsigned int w, unsigned int h);
|
||||
|
||||
/*!\brief Flip the image vertically (top for bottom)
|
||||
*
|
||||
* Adjusts the image descriptor's pointers and strides to make the image
|
||||
* be referenced upside-down.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
*/
|
||||
void vpx_img_flip(vpx_image_t *img);
|
||||
|
||||
/*!\brief Close an image descriptor
|
||||
*
|
||||
* Frees all allocated storage associated with an image descriptor.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
*/
|
||||
void vpx_img_free(vpx_image_t *img);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VPX_IMAGE_H_
|
||||
40
vpx-encoder/android_include/vpx/vpx_integer.h
Normal file
40
vpx-encoder/android_include/vpx/vpx_integer.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef VPX_VPX_VPX_INTEGER_H_
|
||||
#define VPX_VPX_VPX_INTEGER_H_
|
||||
|
||||
/* get ptrdiff_t, size_t, wchar_t, NULL */
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define VPX_FORCE_INLINE __forceinline
|
||||
#define VPX_INLINE __inline
|
||||
#else
|
||||
#define VPX_FORCE_INLINE __inline__ __attribute__((always_inline))
|
||||
// TODO(jbb): Allow a way to force inline off for older compilers.
|
||||
#define VPX_INLINE inline
|
||||
#endif
|
||||
|
||||
/* Assume platforms have the C99 standard integer types. */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#if !defined(__STDC_FORMAT_MACROS)
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#endif
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
#define __STDC_LIMIT_MACROS
|
||||
#endif
|
||||
#endif // __cplusplus
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#endif // VPX_VPX_VPX_INTEGER_H_
|
||||
BIN
vpx-encoder/android_libs/.DS_Store
vendored
Normal file
BIN
vpx-encoder/android_libs/.DS_Store
vendored
Normal file
Binary file not shown.
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright (c) 2016 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
#ifndef LIBWEBM_COMMON_FILE_UTIL_H_
|
||||
#define LIBWEBM_COMMON_FILE_UTIL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "mkvmuxer/mkvmuxertypes.h" // LIBWEBM_DISALLOW_COPY_AND_ASSIGN()
|
||||
|
||||
namespace libwebm {
|
||||
|
||||
// Returns a temporary file name.
|
||||
std::string GetTempFileName();
|
||||
|
||||
// Returns size of file specified by |file_name|, or 0 upon failure.
|
||||
uint64_t GetFileSize(const std::string& file_name);
|
||||
|
||||
// Gets the contents file_name as a string. Returns false on error.
|
||||
bool GetFileContents(const std::string& file_name, std::string* contents);
|
||||
|
||||
// Manages life of temporary file specified at time of construction. Deletes
|
||||
// file upon destruction.
|
||||
class TempFileDeleter {
|
||||
public:
|
||||
TempFileDeleter();
|
||||
explicit TempFileDeleter(std::string file_name) : file_name_(file_name) {}
|
||||
~TempFileDeleter();
|
||||
const std::string& name() const { return file_name_; }
|
||||
|
||||
private:
|
||||
std::string file_name_;
|
||||
LIBWEBM_DISALLOW_COPY_AND_ASSIGN(TempFileDeleter);
|
||||
};
|
||||
|
||||
} // namespace libwebm
|
||||
|
||||
#endif // LIBWEBM_COMMON_FILE_UTIL_H_
|
||||
71
vpx-encoder/android_libs/arm64-v8a/include/common/hdr_util.h
Normal file
71
vpx-encoder/android_libs/arm64-v8a/include/common/hdr_util.h
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
// Copyright (c) 2016 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
#ifndef LIBWEBM_COMMON_HDR_UTIL_H_
|
||||
#define LIBWEBM_COMMON_HDR_UTIL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "mkvmuxer/mkvmuxer.h"
|
||||
|
||||
namespace mkvparser {
|
||||
struct Colour;
|
||||
struct MasteringMetadata;
|
||||
struct PrimaryChromaticity;
|
||||
} // namespace mkvparser
|
||||
|
||||
namespace libwebm {
|
||||
// Utility types and functions for working with the Colour element and its
|
||||
// children. Copiers return true upon success. Presence functions return true
|
||||
// when the specified element is present.
|
||||
|
||||
// TODO(tomfinegan): These should be moved to libwebm_utils once c++11 is
|
||||
// required by libwebm.
|
||||
|
||||
// Features of the VP9 codec that may be set in the CodecPrivate of a VP9 video
|
||||
// stream. A value of kValueNotPresent represents that the value was not set in
|
||||
// the CodecPrivate.
|
||||
struct Vp9CodecFeatures {
|
||||
static const int kValueNotPresent;
|
||||
|
||||
Vp9CodecFeatures()
|
||||
: profile(kValueNotPresent),
|
||||
level(kValueNotPresent),
|
||||
bit_depth(kValueNotPresent),
|
||||
chroma_subsampling(kValueNotPresent) {}
|
||||
~Vp9CodecFeatures() {}
|
||||
|
||||
int profile;
|
||||
int level;
|
||||
int bit_depth;
|
||||
int chroma_subsampling;
|
||||
};
|
||||
|
||||
typedef std::unique_ptr<mkvmuxer::PrimaryChromaticity> PrimaryChromaticityPtr;
|
||||
|
||||
bool CopyPrimaryChromaticity(const mkvparser::PrimaryChromaticity& parser_pc,
|
||||
PrimaryChromaticityPtr* muxer_pc);
|
||||
|
||||
bool MasteringMetadataValuePresent(double value);
|
||||
|
||||
bool CopyMasteringMetadata(const mkvparser::MasteringMetadata& parser_mm,
|
||||
mkvmuxer::MasteringMetadata* muxer_mm);
|
||||
|
||||
bool ColourValuePresent(long long value);
|
||||
|
||||
bool CopyColour(const mkvparser::Colour& parser_colour,
|
||||
mkvmuxer::Colour* muxer_colour);
|
||||
|
||||
// Returns true if |features| is set to one or more valid values.
|
||||
bool ParseVpxCodecPrivate(const uint8_t* private_data, int32_t length,
|
||||
Vp9CodecFeatures* features);
|
||||
|
||||
} // namespace libwebm
|
||||
|
||||
#endif // LIBWEBM_COMMON_HDR_UTIL_H_
|
||||
193
vpx-encoder/android_libs/arm64-v8a/include/common/webmids.h
Normal file
193
vpx-encoder/android_libs/arm64-v8a/include/common/webmids.h
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
#ifndef COMMON_WEBMIDS_H_
|
||||
#define COMMON_WEBMIDS_H_
|
||||
|
||||
namespace libwebm {
|
||||
|
||||
enum MkvId {
|
||||
kMkvEBML = 0x1A45DFA3,
|
||||
kMkvEBMLVersion = 0x4286,
|
||||
kMkvEBMLReadVersion = 0x42F7,
|
||||
kMkvEBMLMaxIDLength = 0x42F2,
|
||||
kMkvEBMLMaxSizeLength = 0x42F3,
|
||||
kMkvDocType = 0x4282,
|
||||
kMkvDocTypeVersion = 0x4287,
|
||||
kMkvDocTypeReadVersion = 0x4285,
|
||||
kMkvVoid = 0xEC,
|
||||
kMkvSignatureSlot = 0x1B538667,
|
||||
kMkvSignatureAlgo = 0x7E8A,
|
||||
kMkvSignatureHash = 0x7E9A,
|
||||
kMkvSignaturePublicKey = 0x7EA5,
|
||||
kMkvSignature = 0x7EB5,
|
||||
kMkvSignatureElements = 0x7E5B,
|
||||
kMkvSignatureElementList = 0x7E7B,
|
||||
kMkvSignedElement = 0x6532,
|
||||
// segment
|
||||
kMkvSegment = 0x18538067,
|
||||
// Meta Seek Information
|
||||
kMkvSeekHead = 0x114D9B74,
|
||||
kMkvSeek = 0x4DBB,
|
||||
kMkvSeekID = 0x53AB,
|
||||
kMkvSeekPosition = 0x53AC,
|
||||
// Segment Information
|
||||
kMkvInfo = 0x1549A966,
|
||||
kMkvTimecodeScale = 0x2AD7B1,
|
||||
kMkvDuration = 0x4489,
|
||||
kMkvDateUTC = 0x4461,
|
||||
kMkvTitle = 0x7BA9,
|
||||
kMkvMuxingApp = 0x4D80,
|
||||
kMkvWritingApp = 0x5741,
|
||||
// Cluster
|
||||
kMkvCluster = 0x1F43B675,
|
||||
kMkvTimecode = 0xE7,
|
||||
kMkvPrevSize = 0xAB,
|
||||
kMkvBlockGroup = 0xA0,
|
||||
kMkvBlock = 0xA1,
|
||||
kMkvBlockDuration = 0x9B,
|
||||
kMkvReferenceBlock = 0xFB,
|
||||
kMkvLaceNumber = 0xCC,
|
||||
kMkvSimpleBlock = 0xA3,
|
||||
kMkvBlockAdditions = 0x75A1,
|
||||
kMkvBlockMore = 0xA6,
|
||||
kMkvBlockAddID = 0xEE,
|
||||
kMkvBlockAdditional = 0xA5,
|
||||
kMkvDiscardPadding = 0x75A2,
|
||||
// Track
|
||||
kMkvTracks = 0x1654AE6B,
|
||||
kMkvTrackEntry = 0xAE,
|
||||
kMkvTrackNumber = 0xD7,
|
||||
kMkvTrackUID = 0x73C5,
|
||||
kMkvTrackType = 0x83,
|
||||
kMkvFlagEnabled = 0xB9,
|
||||
kMkvFlagDefault = 0x88,
|
||||
kMkvFlagForced = 0x55AA,
|
||||
kMkvFlagLacing = 0x9C,
|
||||
kMkvDefaultDuration = 0x23E383,
|
||||
kMkvMaxBlockAdditionID = 0x55EE,
|
||||
kMkvName = 0x536E,
|
||||
kMkvLanguage = 0x22B59C,
|
||||
kMkvCodecID = 0x86,
|
||||
kMkvCodecPrivate = 0x63A2,
|
||||
kMkvCodecName = 0x258688,
|
||||
kMkvCodecDelay = 0x56AA,
|
||||
kMkvSeekPreRoll = 0x56BB,
|
||||
// video
|
||||
kMkvVideo = 0xE0,
|
||||
kMkvFlagInterlaced = 0x9A,
|
||||
kMkvStereoMode = 0x53B8,
|
||||
kMkvAlphaMode = 0x53C0,
|
||||
kMkvPixelWidth = 0xB0,
|
||||
kMkvPixelHeight = 0xBA,
|
||||
kMkvPixelCropBottom = 0x54AA,
|
||||
kMkvPixelCropTop = 0x54BB,
|
||||
kMkvPixelCropLeft = 0x54CC,
|
||||
kMkvPixelCropRight = 0x54DD,
|
||||
kMkvDisplayWidth = 0x54B0,
|
||||
kMkvDisplayHeight = 0x54BA,
|
||||
kMkvDisplayUnit = 0x54B2,
|
||||
kMkvAspectRatioType = 0x54B3,
|
||||
kMkvColourSpace = 0x2EB524,
|
||||
kMkvFrameRate = 0x2383E3,
|
||||
// end video
|
||||
// colour
|
||||
kMkvColour = 0x55B0,
|
||||
kMkvMatrixCoefficients = 0x55B1,
|
||||
kMkvBitsPerChannel = 0x55B2,
|
||||
kMkvChromaSubsamplingHorz = 0x55B3,
|
||||
kMkvChromaSubsamplingVert = 0x55B4,
|
||||
kMkvCbSubsamplingHorz = 0x55B5,
|
||||
kMkvCbSubsamplingVert = 0x55B6,
|
||||
kMkvChromaSitingHorz = 0x55B7,
|
||||
kMkvChromaSitingVert = 0x55B8,
|
||||
kMkvRange = 0x55B9,
|
||||
kMkvTransferCharacteristics = 0x55BA,
|
||||
kMkvPrimaries = 0x55BB,
|
||||
kMkvMaxCLL = 0x55BC,
|
||||
kMkvMaxFALL = 0x55BD,
|
||||
// mastering metadata
|
||||
kMkvMasteringMetadata = 0x55D0,
|
||||
kMkvPrimaryRChromaticityX = 0x55D1,
|
||||
kMkvPrimaryRChromaticityY = 0x55D2,
|
||||
kMkvPrimaryGChromaticityX = 0x55D3,
|
||||
kMkvPrimaryGChromaticityY = 0x55D4,
|
||||
kMkvPrimaryBChromaticityX = 0x55D5,
|
||||
kMkvPrimaryBChromaticityY = 0x55D6,
|
||||
kMkvWhitePointChromaticityX = 0x55D7,
|
||||
kMkvWhitePointChromaticityY = 0x55D8,
|
||||
kMkvLuminanceMax = 0x55D9,
|
||||
kMkvLuminanceMin = 0x55DA,
|
||||
// end mastering metadata
|
||||
// end colour
|
||||
// projection
|
||||
kMkvProjection = 0x7670,
|
||||
kMkvProjectionType = 0x7671,
|
||||
kMkvProjectionPrivate = 0x7672,
|
||||
kMkvProjectionPoseYaw = 0x7673,
|
||||
kMkvProjectionPosePitch = 0x7674,
|
||||
kMkvProjectionPoseRoll = 0x7675,
|
||||
// end projection
|
||||
// audio
|
||||
kMkvAudio = 0xE1,
|
||||
kMkvSamplingFrequency = 0xB5,
|
||||
kMkvOutputSamplingFrequency = 0x78B5,
|
||||
kMkvChannels = 0x9F,
|
||||
kMkvBitDepth = 0x6264,
|
||||
// end audio
|
||||
// ContentEncodings
|
||||
kMkvContentEncodings = 0x6D80,
|
||||
kMkvContentEncoding = 0x6240,
|
||||
kMkvContentEncodingOrder = 0x5031,
|
||||
kMkvContentEncodingScope = 0x5032,
|
||||
kMkvContentEncodingType = 0x5033,
|
||||
kMkvContentCompression = 0x5034,
|
||||
kMkvContentCompAlgo = 0x4254,
|
||||
kMkvContentCompSettings = 0x4255,
|
||||
kMkvContentEncryption = 0x5035,
|
||||
kMkvContentEncAlgo = 0x47E1,
|
||||
kMkvContentEncKeyID = 0x47E2,
|
||||
kMkvContentSignature = 0x47E3,
|
||||
kMkvContentSigKeyID = 0x47E4,
|
||||
kMkvContentSigAlgo = 0x47E5,
|
||||
kMkvContentSigHashAlgo = 0x47E6,
|
||||
kMkvContentEncAESSettings = 0x47E7,
|
||||
kMkvAESSettingsCipherMode = 0x47E8,
|
||||
kMkvAESSettingsCipherInitData = 0x47E9,
|
||||
// end ContentEncodings
|
||||
// Cueing Data
|
||||
kMkvCues = 0x1C53BB6B,
|
||||
kMkvCuePoint = 0xBB,
|
||||
kMkvCueTime = 0xB3,
|
||||
kMkvCueTrackPositions = 0xB7,
|
||||
kMkvCueTrack = 0xF7,
|
||||
kMkvCueClusterPosition = 0xF1,
|
||||
kMkvCueBlockNumber = 0x5378,
|
||||
// Chapters
|
||||
kMkvChapters = 0x1043A770,
|
||||
kMkvEditionEntry = 0x45B9,
|
||||
kMkvChapterAtom = 0xB6,
|
||||
kMkvChapterUID = 0x73C4,
|
||||
kMkvChapterStringUID = 0x5654,
|
||||
kMkvChapterTimeStart = 0x91,
|
||||
kMkvChapterTimeEnd = 0x92,
|
||||
kMkvChapterDisplay = 0x80,
|
||||
kMkvChapString = 0x85,
|
||||
kMkvChapLanguage = 0x437C,
|
||||
kMkvChapCountry = 0x437E,
|
||||
// Tags
|
||||
kMkvTags = 0x1254C367,
|
||||
kMkvTag = 0x7373,
|
||||
kMkvSimpleTag = 0x67C8,
|
||||
kMkvTagName = 0x45A3,
|
||||
kMkvTagString = 0x4487
|
||||
};
|
||||
|
||||
} // namespace libwebm
|
||||
|
||||
#endif // COMMON_WEBMIDS_H_
|
||||
1924
vpx-encoder/android_libs/arm64-v8a/include/mkvmuxer/mkvmuxer.h
Normal file
1924
vpx-encoder/android_libs/arm64-v8a/include/mkvmuxer/mkvmuxer.h
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
#ifndef MKVMUXER_MKVMUXERTYPES_H_
|
||||
#define MKVMUXER_MKVMUXERTYPES_H_
|
||||
|
||||
namespace mkvmuxer {
|
||||
typedef unsigned char uint8;
|
||||
typedef short int16;
|
||||
typedef int int32;
|
||||
typedef unsigned int uint32;
|
||||
typedef long long int64;
|
||||
typedef unsigned long long uint64;
|
||||
} // namespace mkvmuxer
|
||||
|
||||
// Copied from Chromium basictypes.h
|
||||
// A macro to disallow the copy constructor and operator= functions
|
||||
// This should be used in the private: declarations for a class
|
||||
#define LIBWEBM_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
TypeName(const TypeName&); \
|
||||
void operator=(const TypeName&)
|
||||
|
||||
#endif // MKVMUXER_MKVMUXERTYPES_HPP_
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
#ifndef MKVMUXER_MKVMUXERUTIL_H_
|
||||
#define MKVMUXER_MKVMUXERUTIL_H_
|
||||
|
||||
#include "mkvmuxertypes.h"
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
namespace mkvmuxer {
|
||||
class Cluster;
|
||||
class Frame;
|
||||
class IMkvWriter;
|
||||
|
||||
// TODO(tomfinegan): mkvmuxer:: integer types continue to be used here because
|
||||
// changing them causes pain for downstream projects. It would be nice if a
|
||||
// solution that allows removal of the mkvmuxer:: integer types while avoiding
|
||||
// pain for downstream users of libwebm. Considering that mkvmuxerutil.{cc,h}
|
||||
// are really, for the great majority of cases, EBML size calculation and writer
|
||||
// functions, perhaps a more EBML focused utility would be the way to go as a
|
||||
// first step.
|
||||
|
||||
const uint64 kEbmlUnknownValue = 0x01FFFFFFFFFFFFFFULL;
|
||||
const int64 kMaxBlockTimecode = 0x07FFFLL;
|
||||
|
||||
// Writes out |value| in Big Endian order. Returns 0 on success.
|
||||
int32 SerializeInt(IMkvWriter* writer, int64 value, int32 size);
|
||||
|
||||
// Returns the size in bytes of the element.
|
||||
int32 GetUIntSize(uint64 value);
|
||||
int32 GetIntSize(int64 value);
|
||||
int32 GetCodedUIntSize(uint64 value);
|
||||
uint64 EbmlMasterElementSize(uint64 type, uint64 value);
|
||||
uint64 EbmlElementSize(uint64 type, int64 value);
|
||||
uint64 EbmlElementSize(uint64 type, uint64 value);
|
||||
uint64 EbmlElementSize(uint64 type, float value);
|
||||
uint64 EbmlElementSize(uint64 type, const char* value);
|
||||
uint64 EbmlElementSize(uint64 type, const uint8* value, uint64 size);
|
||||
uint64 EbmlDateElementSize(uint64 type);
|
||||
|
||||
// Returns the size in bytes of the element assuming that the element was
|
||||
// written using |fixed_size| bytes. If |fixed_size| is set to zero, then it
|
||||
// computes the necessary number of bytes based on |value|.
|
||||
uint64 EbmlElementSize(uint64 type, uint64 value, uint64 fixed_size);
|
||||
|
||||
// Creates an EBML coded number from |value| and writes it out. The size of
|
||||
// the coded number is determined by the value of |value|. |value| must not
|
||||
// be in a coded form. Returns 0 on success.
|
||||
int32 WriteUInt(IMkvWriter* writer, uint64 value);
|
||||
|
||||
// Creates an EBML coded number from |value| and writes it out. The size of
|
||||
// the coded number is determined by the value of |size|. |value| must not
|
||||
// be in a coded form. Returns 0 on success.
|
||||
int32 WriteUIntSize(IMkvWriter* writer, uint64 value, int32 size);
|
||||
|
||||
// Output an Mkv master element. Returns true if the element was written.
|
||||
bool WriteEbmlMasterElement(IMkvWriter* writer, uint64 value, uint64 size);
|
||||
|
||||
// Outputs an Mkv ID, calls |IMkvWriter::ElementStartNotify|, and passes the
|
||||
// ID to |SerializeInt|. Returns 0 on success.
|
||||
int32 WriteID(IMkvWriter* writer, uint64 type);
|
||||
|
||||
// Output an Mkv non-master element. Returns true if the element was written.
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, uint64 value);
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, int64 value);
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, float value);
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const char* value);
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const uint8* value,
|
||||
uint64 size);
|
||||
bool WriteEbmlDateElement(IMkvWriter* writer, uint64 type, int64 value);
|
||||
|
||||
// Output an Mkv non-master element using fixed size. The element will be
|
||||
// written out using exactly |fixed_size| bytes. If |fixed_size| is set to zero
|
||||
// then it computes the necessary number of bytes based on |value|. Returns true
|
||||
// if the element was written.
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, uint64 value,
|
||||
uint64 fixed_size);
|
||||
|
||||
// Output a Mkv Frame. It decides the correct element to write (Block vs
|
||||
// SimpleBlock) based on the parameters of the Frame.
|
||||
uint64 WriteFrame(IMkvWriter* writer, const Frame* const frame,
|
||||
Cluster* cluster);
|
||||
|
||||
// Output a void element. |size| must be the entire size in bytes that will be
|
||||
// void. The function will calculate the size of the void header and subtract
|
||||
// it from |size|.
|
||||
uint64 WriteVoidElement(IMkvWriter* writer, uint64 size);
|
||||
|
||||
// Returns the version number of the muxer in |major|, |minor|, |build|,
|
||||
// and |revision|.
|
||||
void GetVersion(int32* major, int32* minor, int32* build, int32* revision);
|
||||
|
||||
// Returns a random number to be used for UID, using |seed| to seed
|
||||
// the random-number generator (see POSIX rand_r() for semantics).
|
||||
uint64 MakeUID(unsigned int* seed);
|
||||
|
||||
// Colour field validation helpers. All return true when |value| is valid.
|
||||
bool IsMatrixCoefficientsValueValid(uint64_t value);
|
||||
bool IsChromaSitingHorzValueValid(uint64_t value);
|
||||
bool IsChromaSitingVertValueValid(uint64_t value);
|
||||
bool IsColourRangeValueValid(uint64_t value);
|
||||
bool IsTransferCharacteristicsValueValid(uint64_t value);
|
||||
bool IsPrimariesValueValid(uint64_t value);
|
||||
|
||||
} // namespace mkvmuxer
|
||||
|
||||
#endif // MKVMUXER_MKVMUXERUTIL_H_
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
#ifndef MKVMUXER_MKVWRITER_H_
|
||||
#define MKVMUXER_MKVWRITER_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mkvmuxer/mkvmuxer.h"
|
||||
#include "mkvmuxer/mkvmuxertypes.h"
|
||||
|
||||
namespace mkvmuxer {
|
||||
|
||||
// Default implementation of the IMkvWriter interface on Windows.
|
||||
class MkvWriter : public IMkvWriter {
|
||||
public:
|
||||
MkvWriter();
|
||||
explicit MkvWriter(FILE* fp);
|
||||
virtual ~MkvWriter();
|
||||
|
||||
// IMkvWriter interface
|
||||
virtual int64 Position() const;
|
||||
virtual int32 Position(int64 position);
|
||||
virtual bool Seekable() const;
|
||||
virtual int32 Write(const void* buffer, uint32 length);
|
||||
virtual void ElementStartNotify(uint64 element_id, int64 position);
|
||||
|
||||
// Creates and opens a file for writing. |filename| is the name of the file
|
||||
// to open. This function will overwrite the contents of |filename|. Returns
|
||||
// true on success.
|
||||
bool Open(const char* filename);
|
||||
|
||||
// Closes an opened file.
|
||||
void Close();
|
||||
|
||||
private:
|
||||
// File handle to output file.
|
||||
FILE* file_;
|
||||
bool writer_owns_file_;
|
||||
|
||||
LIBWEBM_DISALLOW_COPY_AND_ASSIGN(MkvWriter);
|
||||
};
|
||||
|
||||
} // namespace mkvmuxer
|
||||
|
||||
#endif // MKVMUXER_MKVWRITER_H_
|
||||
1147
vpx-encoder/android_libs/arm64-v8a/include/mkvparser/mkvparser.h
Normal file
1147
vpx-encoder/android_libs/arm64-v8a/include/mkvparser/mkvparser.h
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
#ifndef MKVPARSER_MKVREADER_H_
|
||||
#define MKVPARSER_MKVREADER_H_
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "mkvparser/mkvparser.h"
|
||||
|
||||
namespace mkvparser {
|
||||
|
||||
class MkvReader : public IMkvReader {
|
||||
public:
|
||||
MkvReader();
|
||||
explicit MkvReader(FILE* fp);
|
||||
virtual ~MkvReader();
|
||||
|
||||
int Open(const char*);
|
||||
void Close();
|
||||
|
||||
virtual int Read(long long position, long length, unsigned char* buffer);
|
||||
virtual int Length(long long* total, long long* available);
|
||||
|
||||
private:
|
||||
MkvReader(const MkvReader&);
|
||||
MkvReader& operator=(const MkvReader&);
|
||||
|
||||
// Determines the size of the file. This is called either by the constructor
|
||||
// or by the Open function depending on file ownership. Returns true on
|
||||
// success.
|
||||
bool GetFileSize();
|
||||
|
||||
long long m_length;
|
||||
FILE* m_file;
|
||||
bool reader_owns_file_;
|
||||
};
|
||||
|
||||
} // namespace mkvparser
|
||||
|
||||
#endif // MKVPARSER_MKVREADER_H_
|
||||
136
vpx-encoder/android_libs/arm64-v8a/include/vpx/vp8.h
Normal file
136
vpx-encoder/android_libs/arm64-v8a/include/vpx/vp8.h
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\defgroup vp8 VP8
|
||||
* \ingroup codecs
|
||||
* VP8 is a video compression algorithm that uses motion
|
||||
* compensated prediction, Discrete Cosine Transform (DCT) coding of the
|
||||
* prediction error signal and context dependent entropy coding techniques
|
||||
* based on arithmetic principles. It features:
|
||||
* - YUV 4:2:0 image format
|
||||
* - Macro-block based coding (16x16 luma plus two 8x8 chroma)
|
||||
* - 1/4 (1/8) pixel accuracy motion compensated prediction
|
||||
* - 4x4 DCT transform
|
||||
* - 128 level linear quantizer
|
||||
* - In loop deblocking filter
|
||||
* - Context-based entropy coding
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*!\file
|
||||
* \brief Provides controls common to both the VP8 encoder and decoder.
|
||||
*/
|
||||
#ifndef VPX_VPX_VP8_H_
|
||||
#define VPX_VPX_VP8_H_
|
||||
|
||||
#include "./vpx_codec.h"
|
||||
#include "./vpx_image.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!\brief Control functions
|
||||
*
|
||||
* The set of macros define the control functions of VP8 interface
|
||||
*/
|
||||
enum vp8_com_control_id {
|
||||
/*!\brief pass in an external frame into decoder to be used as reference frame
|
||||
*/
|
||||
VP8_SET_REFERENCE = 1,
|
||||
VP8_COPY_REFERENCE = 2, /**< get a copy of reference frame from the decoder */
|
||||
VP8_SET_POSTPROC = 3, /**< set the decoder's post processing settings */
|
||||
|
||||
/* TODO(jkoleszar): The encoder incorrectly reuses some of these values (5+)
|
||||
* for its control ids. These should be migrated to something like the
|
||||
* VP8_DECODER_CTRL_ID_START range next time we're ready to break the ABI.
|
||||
*/
|
||||
VP9_GET_REFERENCE = 128, /**< get a pointer to a reference frame */
|
||||
VP8_COMMON_CTRL_ID_MAX,
|
||||
VP8_DECODER_CTRL_ID_START = 256
|
||||
};
|
||||
|
||||
/*!\brief post process flags
|
||||
*
|
||||
* The set of macros define VP8 decoder post processing flags
|
||||
*/
|
||||
enum vp8_postproc_level {
|
||||
VP8_NOFILTERING = 0,
|
||||
VP8_DEBLOCK = 1 << 0,
|
||||
VP8_DEMACROBLOCK = 1 << 1,
|
||||
VP8_ADDNOISE = 1 << 2,
|
||||
VP8_MFQE = 1 << 3
|
||||
};
|
||||
|
||||
/*!\brief post process flags
|
||||
*
|
||||
* This define a structure that describe the post processing settings. For
|
||||
* the best objective measure (using the PSNR metric) set post_proc_flag
|
||||
* to VP8_DEBLOCK and deblocking_level to 1.
|
||||
*/
|
||||
|
||||
typedef struct vp8_postproc_cfg {
|
||||
/*!\brief the types of post processing to be done, should be combination of
|
||||
* "vp8_postproc_level" */
|
||||
int post_proc_flag;
|
||||
int deblocking_level; /**< the strength of deblocking, valid range [0, 16] */
|
||||
int noise_level; /**< the strength of additive noise, valid range [0, 16] */
|
||||
} vp8_postproc_cfg_t;
|
||||
|
||||
/*!\brief reference frame type
|
||||
*
|
||||
* The set of macros define the type of VP8 reference frames
|
||||
*/
|
||||
typedef enum vpx_ref_frame_type {
|
||||
VP8_LAST_FRAME = 1,
|
||||
VP8_GOLD_FRAME = 2,
|
||||
VP8_ALTR_FRAME = 4
|
||||
} vpx_ref_frame_type_t;
|
||||
|
||||
/*!\brief reference frame data struct
|
||||
*
|
||||
* Define the data struct to access vp8 reference frames.
|
||||
*/
|
||||
typedef struct vpx_ref_frame {
|
||||
vpx_ref_frame_type_t frame_type; /**< which reference frame */
|
||||
vpx_image_t img; /**< reference frame data in image format */
|
||||
} vpx_ref_frame_t;
|
||||
|
||||
/*!\brief VP9 specific reference frame data struct
|
||||
*
|
||||
* Define the data struct to access vp9 reference frames.
|
||||
*/
|
||||
typedef struct vp9_ref_frame {
|
||||
int idx; /**< frame index to get (input) */
|
||||
vpx_image_t img; /**< img structure to populate (output) */
|
||||
} vp9_ref_frame_t;
|
||||
|
||||
/*!\cond */
|
||||
/*!\brief vp8 decoder control function parameter type
|
||||
*
|
||||
* defines the data type for each of VP8 decoder control function requires
|
||||
*/
|
||||
VPX_CTRL_USE_TYPE(VP8_SET_REFERENCE, vpx_ref_frame_t *)
|
||||
#define VPX_CTRL_VP8_SET_REFERENCE
|
||||
VPX_CTRL_USE_TYPE(VP8_COPY_REFERENCE, vpx_ref_frame_t *)
|
||||
#define VPX_CTRL_VP8_COPY_REFERENCE
|
||||
VPX_CTRL_USE_TYPE(VP8_SET_POSTPROC, vp8_postproc_cfg_t *)
|
||||
#define VPX_CTRL_VP8_SET_POSTPROC
|
||||
VPX_CTRL_USE_TYPE(VP9_GET_REFERENCE, vp9_ref_frame_t *)
|
||||
#define VPX_CTRL_VP9_GET_REFERENCE
|
||||
|
||||
/*!\endcond */
|
||||
/*! @} - end defgroup vp8 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VP8_H_
|
||||
1027
vpx-encoder/android_libs/arm64-v8a/include/vpx/vp8cx.h
Normal file
1027
vpx-encoder/android_libs/arm64-v8a/include/vpx/vp8cx.h
Normal file
File diff suppressed because it is too large
Load diff
210
vpx-encoder/android_libs/arm64-v8a/include/vpx/vp8dx.h
Normal file
210
vpx-encoder/android_libs/arm64-v8a/include/vpx/vp8dx.h
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\defgroup vp8_decoder WebM VP8/VP9 Decoder
|
||||
* \ingroup vp8
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*!\file
|
||||
* \brief Provides definitions for using VP8 or VP9 within the vpx Decoder
|
||||
* interface.
|
||||
*/
|
||||
#ifndef VPX_VPX_VP8DX_H_
|
||||
#define VPX_VPX_VP8DX_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Include controls common to both the encoder and decoder */
|
||||
#include "./vp8.h"
|
||||
|
||||
/*!\name Algorithm interface for VP8
|
||||
*
|
||||
* This interface provides the capability to decode VP8 streams.
|
||||
* @{
|
||||
*/
|
||||
extern vpx_codec_iface_t vpx_codec_vp8_dx_algo;
|
||||
extern vpx_codec_iface_t *vpx_codec_vp8_dx(void);
|
||||
/*!@} - end algorithm interface member group*/
|
||||
|
||||
/*!\name Algorithm interface for VP9
|
||||
*
|
||||
* This interface provides the capability to decode VP9 streams.
|
||||
* @{
|
||||
*/
|
||||
extern vpx_codec_iface_t vpx_codec_vp9_dx_algo;
|
||||
extern vpx_codec_iface_t *vpx_codec_vp9_dx(void);
|
||||
/*!@} - end algorithm interface member group*/
|
||||
|
||||
/*!\enum vp8_dec_control_id
|
||||
* \brief VP8 decoder control functions
|
||||
*
|
||||
* This set of macros define the control functions available for the VP8
|
||||
* decoder interface.
|
||||
*
|
||||
* \sa #vpx_codec_control
|
||||
*/
|
||||
enum vp8_dec_control_id {
|
||||
/** control function to get info on which reference frames were updated
|
||||
* by the last decode
|
||||
*/
|
||||
VP8D_GET_LAST_REF_UPDATES = VP8_DECODER_CTRL_ID_START,
|
||||
|
||||
/** check if the indicated frame is corrupted */
|
||||
VP8D_GET_FRAME_CORRUPTED,
|
||||
|
||||
/** control function to get info on which reference frames were used
|
||||
* by the last decode
|
||||
*/
|
||||
VP8D_GET_LAST_REF_USED,
|
||||
|
||||
/** decryption function to decrypt encoded buffer data immediately
|
||||
* before decoding. Takes a vpx_decrypt_init, which contains
|
||||
* a callback function and opaque context pointer.
|
||||
*/
|
||||
VPXD_SET_DECRYPTOR,
|
||||
VP8D_SET_DECRYPTOR = VPXD_SET_DECRYPTOR,
|
||||
|
||||
/** control function to get the dimensions that the current frame is decoded
|
||||
* at. This may be different to the intended display size for the frame as
|
||||
* specified in the wrapper or frame header (see VP9D_GET_DISPLAY_SIZE). */
|
||||
VP9D_GET_FRAME_SIZE,
|
||||
|
||||
/** control function to get the current frame's intended display dimensions
|
||||
* (as specified in the wrapper or frame header). This may be different to
|
||||
* the decoded dimensions of this frame (see VP9D_GET_FRAME_SIZE). */
|
||||
VP9D_GET_DISPLAY_SIZE,
|
||||
|
||||
/** control function to get the bit depth of the stream. */
|
||||
VP9D_GET_BIT_DEPTH,
|
||||
|
||||
/** control function to set the byte alignment of the planes in the reference
|
||||
* buffers. Valid values are power of 2, from 32 to 1024. A value of 0 sets
|
||||
* legacy alignment. I.e. Y plane is aligned to 32 bytes, U plane directly
|
||||
* follows Y plane, and V plane directly follows U plane. Default value is 0.
|
||||
*/
|
||||
VP9_SET_BYTE_ALIGNMENT,
|
||||
|
||||
/** control function to invert the decoding order to from right to left. The
|
||||
* function is used in a test to confirm the decoding independence of tile
|
||||
* columns. The function may be used in application where this order
|
||||
* of decoding is desired.
|
||||
*
|
||||
* TODO(yaowu): Rework the unit test that uses this control, and in a future
|
||||
* release, this test-only control shall be removed.
|
||||
*/
|
||||
VP9_INVERT_TILE_DECODE_ORDER,
|
||||
|
||||
/** control function to set the skip loop filter flag. Valid values are
|
||||
* integers. The decoder will skip the loop filter when its value is set to
|
||||
* nonzero. If the loop filter is skipped the decoder may accumulate decode
|
||||
* artifacts. The default value is 0.
|
||||
*/
|
||||
VP9_SET_SKIP_LOOP_FILTER,
|
||||
|
||||
/** control function to decode SVC stream up to the x spatial layers,
|
||||
* where x is passed in through the control, and is 0 for base layer.
|
||||
*/
|
||||
VP9_DECODE_SVC_SPATIAL_LAYER,
|
||||
|
||||
/*!\brief Codec control function to get last decoded frame quantizer.
|
||||
*
|
||||
* Return value uses internal quantizer scale defined by the codec.
|
||||
*
|
||||
* Supported in codecs: VP8, VP9
|
||||
*/
|
||||
VPXD_GET_LAST_QUANTIZER,
|
||||
|
||||
/*!\brief Codec control function to set row level multi-threading.
|
||||
*
|
||||
* 0 : off, 1 : on
|
||||
*
|
||||
* Supported in codecs: VP9
|
||||
*/
|
||||
VP9D_SET_ROW_MT,
|
||||
|
||||
/*!\brief Codec control function to set loopfilter optimization.
|
||||
*
|
||||
* 0 : off, Loop filter is done after all tiles have been decoded
|
||||
* 1 : on, Loop filter is done immediately after decode without
|
||||
* waiting for all threads to sync.
|
||||
*
|
||||
* Supported in codecs: VP9
|
||||
*/
|
||||
VP9D_SET_LOOP_FILTER_OPT,
|
||||
|
||||
VP8_DECODER_CTRL_ID_MAX
|
||||
};
|
||||
|
||||
/** Decrypt n bytes of data from input -> output, using the decrypt_state
|
||||
* passed in VPXD_SET_DECRYPTOR.
|
||||
*/
|
||||
typedef void (*vpx_decrypt_cb)(void *decrypt_state, const unsigned char *input,
|
||||
unsigned char *output, int count);
|
||||
|
||||
/*!\brief Structure to hold decryption state
|
||||
*
|
||||
* Defines a structure to hold the decryption state and access function.
|
||||
*/
|
||||
typedef struct vpx_decrypt_init {
|
||||
/*! Decrypt callback. */
|
||||
vpx_decrypt_cb decrypt_cb;
|
||||
|
||||
/*! Decryption state. */
|
||||
void *decrypt_state;
|
||||
} vpx_decrypt_init;
|
||||
|
||||
/*!\cond */
|
||||
/*!\brief VP8 decoder control function parameter type
|
||||
*
|
||||
* Defines the data types that VP8D control functions take. Note that
|
||||
* additional common controls are defined in vp8.h
|
||||
*
|
||||
*/
|
||||
|
||||
VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_UPDATES, int *)
|
||||
#define VPX_CTRL_VP8D_GET_LAST_REF_UPDATES
|
||||
VPX_CTRL_USE_TYPE(VP8D_GET_FRAME_CORRUPTED, int *)
|
||||
#define VPX_CTRL_VP8D_GET_FRAME_CORRUPTED
|
||||
VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_USED, int *)
|
||||
#define VPX_CTRL_VP8D_GET_LAST_REF_USED
|
||||
VPX_CTRL_USE_TYPE(VPXD_GET_LAST_QUANTIZER, int *)
|
||||
#define VPX_CTRL_VPXD_GET_LAST_QUANTIZER
|
||||
VPX_CTRL_USE_TYPE(VPXD_SET_DECRYPTOR, vpx_decrypt_init *)
|
||||
#define VPX_CTRL_VPXD_SET_DECRYPTOR
|
||||
VPX_CTRL_USE_TYPE(VP8D_SET_DECRYPTOR, vpx_decrypt_init *)
|
||||
#define VPX_CTRL_VP8D_SET_DECRYPTOR
|
||||
VPX_CTRL_USE_TYPE(VP9D_GET_DISPLAY_SIZE, int *)
|
||||
#define VPX_CTRL_VP9D_GET_DISPLAY_SIZE
|
||||
VPX_CTRL_USE_TYPE(VP9D_GET_BIT_DEPTH, unsigned int *)
|
||||
#define VPX_CTRL_VP9D_GET_BIT_DEPTH
|
||||
VPX_CTRL_USE_TYPE(VP9D_GET_FRAME_SIZE, int *)
|
||||
#define VPX_CTRL_VP9D_GET_FRAME_SIZE
|
||||
VPX_CTRL_USE_TYPE(VP9_INVERT_TILE_DECODE_ORDER, int)
|
||||
#define VPX_CTRL_VP9_INVERT_TILE_DECODE_ORDER
|
||||
#define VPX_CTRL_VP9_DECODE_SVC_SPATIAL_LAYER
|
||||
VPX_CTRL_USE_TYPE(VP9_DECODE_SVC_SPATIAL_LAYER, int)
|
||||
#define VPX_CTRL_VP9_SET_SKIP_LOOP_FILTER
|
||||
VPX_CTRL_USE_TYPE(VP9_SET_SKIP_LOOP_FILTER, int)
|
||||
#define VPX_CTRL_VP9_DECODE_SET_ROW_MT
|
||||
VPX_CTRL_USE_TYPE(VP9D_SET_ROW_MT, int)
|
||||
#define VPX_CTRL_VP9_SET_LOOP_FILTER_OPT
|
||||
VPX_CTRL_USE_TYPE(VP9D_SET_LOOP_FILTER_OPT, int)
|
||||
|
||||
/*!\endcond */
|
||||
/*! @} - end defgroup vp8_decoder */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VP8DX_H_
|
||||
468
vpx-encoder/android_libs/arm64-v8a/include/vpx/vpx_codec.h
Normal file
468
vpx-encoder/android_libs/arm64-v8a/include/vpx/vpx_codec.h
Normal file
|
|
@ -0,0 +1,468 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\defgroup codec Common Algorithm Interface
|
||||
* This abstraction allows applications to easily support multiple video
|
||||
* formats with minimal code duplication. This section describes the interface
|
||||
* common to all codecs (both encoders and decoders).
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the codec algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video codec algorithm.
|
||||
*
|
||||
* An application instantiates a specific codec instance by using
|
||||
* vpx_codec_init() and a pointer to the algorithm's interface structure:
|
||||
* <pre>
|
||||
* my_app.c:
|
||||
* extern vpx_codec_iface_t my_codec;
|
||||
* {
|
||||
* vpx_codec_ctx_t algo;
|
||||
* res = vpx_codec_init(&algo, &my_codec);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Once initialized, the instance is manged using other functions from
|
||||
* the vpx_codec_* family.
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_CODEC_H_
|
||||
#define VPX_VPX_VPX_CODEC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_image.h"
|
||||
#include "./vpx_integer.h"
|
||||
|
||||
/*!\brief Decorator indicating a function is deprecated */
|
||||
#ifndef VPX_DEPRECATED
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
#define VPX_DEPRECATED __attribute__((deprecated))
|
||||
#elif defined(_MSC_VER)
|
||||
#define VPX_DEPRECATED
|
||||
#else
|
||||
#define VPX_DEPRECATED
|
||||
#endif
|
||||
#endif /* VPX_DEPRECATED */
|
||||
|
||||
#ifndef VPX_DECLSPEC_DEPRECATED
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
#define VPX_DECLSPEC_DEPRECATED /**< \copydoc #VPX_DEPRECATED */
|
||||
#elif defined(_MSC_VER)
|
||||
/*!\brief \copydoc #VPX_DEPRECATED */
|
||||
#define VPX_DECLSPEC_DEPRECATED __declspec(deprecated)
|
||||
#else
|
||||
#define VPX_DECLSPEC_DEPRECATED /**< \copydoc #VPX_DEPRECATED */
|
||||
#endif
|
||||
#endif /* VPX_DECLSPEC_DEPRECATED */
|
||||
|
||||
/*!\brief Decorator indicating a function is potentially unused */
|
||||
#ifndef VPX_UNUSED
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define VPX_UNUSED __attribute__((unused))
|
||||
#else
|
||||
#define VPX_UNUSED
|
||||
#endif
|
||||
#endif /* VPX_UNUSED */
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_CODEC_ABI_VERSION (4 + VPX_IMAGE_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*!\brief Algorithm return codes */
|
||||
typedef enum {
|
||||
/*!\brief Operation completed without error */
|
||||
VPX_CODEC_OK,
|
||||
|
||||
/*!\brief Unspecified error */
|
||||
VPX_CODEC_ERROR,
|
||||
|
||||
/*!\brief Memory operation failed */
|
||||
VPX_CODEC_MEM_ERROR,
|
||||
|
||||
/*!\brief ABI version mismatch */
|
||||
VPX_CODEC_ABI_MISMATCH,
|
||||
|
||||
/*!\brief Algorithm does not have required capability */
|
||||
VPX_CODEC_INCAPABLE,
|
||||
|
||||
/*!\brief The given bitstream is not supported.
|
||||
*
|
||||
* The bitstream was unable to be parsed at the highest level. The decoder
|
||||
* is unable to proceed. This error \ref SHOULD be treated as fatal to the
|
||||
* stream. */
|
||||
VPX_CODEC_UNSUP_BITSTREAM,
|
||||
|
||||
/*!\brief Encoded bitstream uses an unsupported feature
|
||||
*
|
||||
* The decoder does not implement a feature required by the encoder. This
|
||||
* return code should only be used for features that prevent future
|
||||
* pictures from being properly decoded. This error \ref MAY be treated as
|
||||
* fatal to the stream or \ref MAY be treated as fatal to the current GOP.
|
||||
*/
|
||||
VPX_CODEC_UNSUP_FEATURE,
|
||||
|
||||
/*!\brief The coded data for this stream is corrupt or incomplete
|
||||
*
|
||||
* There was a problem decoding the current frame. This return code
|
||||
* should only be used for failures that prevent future pictures from
|
||||
* being properly decoded. This error \ref MAY be treated as fatal to the
|
||||
* stream or \ref MAY be treated as fatal to the current GOP. If decoding
|
||||
* is continued for the current GOP, artifacts may be present.
|
||||
*/
|
||||
VPX_CODEC_CORRUPT_FRAME,
|
||||
|
||||
/*!\brief An application-supplied parameter is not valid.
|
||||
*
|
||||
*/
|
||||
VPX_CODEC_INVALID_PARAM,
|
||||
|
||||
/*!\brief An iterator reached the end of list.
|
||||
*
|
||||
*/
|
||||
VPX_CODEC_LIST_END
|
||||
|
||||
} vpx_codec_err_t;
|
||||
|
||||
/*! \brief Codec capabilities bitfield
|
||||
*
|
||||
* Each codec advertises the capabilities it supports as part of its
|
||||
* ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
|
||||
* or functionality, and are not required to be supported.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_CAP_* defines.
|
||||
*/
|
||||
typedef long vpx_codec_caps_t;
|
||||
#define VPX_CODEC_CAP_DECODER 0x1 /**< Is a decoder */
|
||||
#define VPX_CODEC_CAP_ENCODER 0x2 /**< Is an encoder */
|
||||
|
||||
/*! Can support images at greater than 8 bitdepth.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_HIGHBITDEPTH 0x4
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow for
|
||||
* proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_USE_* defines.
|
||||
*/
|
||||
typedef long vpx_codec_flags_t;
|
||||
|
||||
/*!\brief Codec interface structure.
|
||||
*
|
||||
* Contains function pointers and other data private to the codec
|
||||
* implementation. This structure is opaque to the application.
|
||||
*/
|
||||
typedef const struct vpx_codec_iface vpx_codec_iface_t;
|
||||
|
||||
/*!\brief Codec private data structure.
|
||||
*
|
||||
* Contains data private to the codec implementation. This structure is opaque
|
||||
* to the application.
|
||||
*/
|
||||
typedef struct vpx_codec_priv vpx_codec_priv_t;
|
||||
|
||||
/*!\brief Iterator
|
||||
*
|
||||
* Opaque storage used for iterating over lists.
|
||||
*/
|
||||
typedef const void *vpx_codec_iter_t;
|
||||
|
||||
/*!\brief Codec context structure
|
||||
*
|
||||
* All codecs \ref MUST support this context structure fully. In general,
|
||||
* this data should be considered private to the codec algorithm, and
|
||||
* not be manipulated or examined by the calling application. Applications
|
||||
* may reference the 'name' member to get a printable description of the
|
||||
* algorithm.
|
||||
*/
|
||||
typedef struct vpx_codec_ctx {
|
||||
const char *name; /**< Printable interface name */
|
||||
vpx_codec_iface_t *iface; /**< Interface pointers */
|
||||
vpx_codec_err_t err; /**< Last returned error */
|
||||
const char *err_detail; /**< Detailed info, if available */
|
||||
vpx_codec_flags_t init_flags; /**< Flags passed at init time */
|
||||
union {
|
||||
/**< Decoder Configuration Pointer */
|
||||
const struct vpx_codec_dec_cfg *dec;
|
||||
/**< Encoder Configuration Pointer */
|
||||
const struct vpx_codec_enc_cfg *enc;
|
||||
const void *raw;
|
||||
} config; /**< Configuration pointer aliasing union */
|
||||
vpx_codec_priv_t *priv; /**< Algorithm private storage */
|
||||
} vpx_codec_ctx_t;
|
||||
|
||||
/*!\brief Bit depth for codec
|
||||
* *
|
||||
* This enumeration determines the bit depth of the codec.
|
||||
*/
|
||||
typedef enum vpx_bit_depth {
|
||||
VPX_BITS_8 = 8, /**< 8 bits */
|
||||
VPX_BITS_10 = 10, /**< 10 bits */
|
||||
VPX_BITS_12 = 12, /**< 12 bits */
|
||||
} vpx_bit_depth_t;
|
||||
|
||||
/*
|
||||
* Library Version Number Interface
|
||||
*
|
||||
* For example, see the following sample return values:
|
||||
* vpx_codec_version() (1<<16 | 2<<8 | 3)
|
||||
* vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
|
||||
* vpx_codec_version_extra_str() "rc1-16-gec6a1ba"
|
||||
*/
|
||||
|
||||
/*!\brief Return the version information (as an integer)
|
||||
*
|
||||
* Returns a packed encoding of the library version number. This will only
|
||||
* include
|
||||
* the major.minor.patch component of the version number. Note that this encoded
|
||||
* value should be accessed through the macros provided, as the encoding may
|
||||
* change
|
||||
* in the future.
|
||||
*
|
||||
*/
|
||||
int vpx_codec_version(void);
|
||||
#define VPX_VERSION_MAJOR(v) \
|
||||
((v >> 16) & 0xff) /**< extract major from packed version */
|
||||
#define VPX_VERSION_MINOR(v) \
|
||||
((v >> 8) & 0xff) /**< extract minor from packed version */
|
||||
#define VPX_VERSION_PATCH(v) \
|
||||
((v >> 0) & 0xff) /**< extract patch from packed version */
|
||||
|
||||
/*!\brief Return the version major number */
|
||||
#define vpx_codec_version_major() ((vpx_codec_version() >> 16) & 0xff)
|
||||
|
||||
/*!\brief Return the version minor number */
|
||||
#define vpx_codec_version_minor() ((vpx_codec_version() >> 8) & 0xff)
|
||||
|
||||
/*!\brief Return the version patch number */
|
||||
#define vpx_codec_version_patch() ((vpx_codec_version() >> 0) & 0xff)
|
||||
|
||||
/*!\brief Return the version information (as a string)
|
||||
*
|
||||
* Returns a printable string containing the full library version number. This
|
||||
* may
|
||||
* contain additional text following the three digit version number, as to
|
||||
* indicate
|
||||
* release candidates, prerelease versions, etc.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_version_str(void);
|
||||
|
||||
/*!\brief Return the version information (as a string)
|
||||
*
|
||||
* Returns a printable "extra string". This is the component of the string
|
||||
* returned
|
||||
* by vpx_codec_version_str() following the three digit version number.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_version_extra_str(void);
|
||||
|
||||
/*!\brief Return the build configuration
|
||||
*
|
||||
* Returns a printable string containing an encoded version of the build
|
||||
* configuration. This may be useful to vpx support.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_build_config(void);
|
||||
|
||||
/*!\brief Return the name for a given interface
|
||||
*
|
||||
* Returns a human readable string for name of the given codec interface.
|
||||
*
|
||||
* \param[in] iface Interface pointer
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_iface_name(vpx_codec_iface_t *iface);
|
||||
|
||||
/*!\brief Convert error number to printable string
|
||||
*
|
||||
* Returns a human readable string for the last error returned by the
|
||||
* algorithm. The returned error will be one line and will not contain
|
||||
* any newline characters.
|
||||
*
|
||||
*
|
||||
* \param[in] err Error number.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_err_to_string(vpx_codec_err_t err);
|
||||
|
||||
/*!\brief Retrieve error synopsis for codec context
|
||||
*
|
||||
* Returns a human readable string for the last error returned by the
|
||||
* algorithm. The returned error will be one line and will not contain
|
||||
* any newline characters.
|
||||
*
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_error(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!\brief Retrieve detailed error information for codec context
|
||||
*
|
||||
* Returns a human readable string providing detailed information about
|
||||
* the last error.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
*
|
||||
* \retval NULL
|
||||
* No detailed information is available.
|
||||
*/
|
||||
const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/* REQUIRED FUNCTIONS
|
||||
*
|
||||
* The following functions are required to be implemented for all codecs.
|
||||
* They represent the base case functionality expected of all codecs.
|
||||
*/
|
||||
|
||||
/*!\brief Destroy a codec instance
|
||||
*
|
||||
* Destroys a codec context, freeing any associated memory buffers.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The codec algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!\brief Get the capabilities of an algorithm.
|
||||
*
|
||||
* Retrieves the capabilities bitfield from the algorithm's interface.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface
|
||||
*
|
||||
*/
|
||||
vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface);
|
||||
|
||||
/*!\brief Control algorithm
|
||||
*
|
||||
* This function is used to exchange algorithm specific data with the codec
|
||||
* instance. This can be used to implement features specific to a particular
|
||||
* algorithm.
|
||||
*
|
||||
* This wrapper function dispatches the request to the helper function
|
||||
* associated with the given ctrl_id. It tries to call this function
|
||||
* transparently, but will return #VPX_CODEC_ERROR if the request could not
|
||||
* be dispatched.
|
||||
*
|
||||
* Note that this function should not be used directly. Call the
|
||||
* #vpx_codec_control wrapper macro instead.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] ctrl_id Algorithm specific control identifier
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The control request was processed.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* The control request was not processed.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* The data was not valid.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx, int ctrl_id, ...);
|
||||
#if defined(VPX_DISABLE_CTRL_TYPECHECKS) && VPX_DISABLE_CTRL_TYPECHECKS
|
||||
#define vpx_codec_control(ctx, id, data) vpx_codec_control_(ctx, id, data)
|
||||
#define VPX_CTRL_USE_TYPE(id, typ)
|
||||
#define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ)
|
||||
#define VPX_CTRL_VOID(id, typ)
|
||||
|
||||
#else
|
||||
/*!\brief vpx_codec_control wrapper macro
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to vpx_codec_control_().
|
||||
*
|
||||
* \internal
|
||||
* It works by dispatching the call to the control function through a wrapper
|
||||
* function named with the id parameter.
|
||||
*/
|
||||
#define vpx_codec_control(ctx, id, data) \
|
||||
vpx_codec_control_##id(ctx, id, data) /**<\hideinitializer*/
|
||||
|
||||
/*!\brief vpx_codec_control type definition macro
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to vpx_codec_control_(). It defines the type of the argument for a given
|
||||
* control identifier.
|
||||
*
|
||||
* \internal
|
||||
* It defines a static function with
|
||||
* the correctly typed arguments as a wrapper to the type-unsafe internal
|
||||
* function.
|
||||
*/
|
||||
#define VPX_CTRL_USE_TYPE(id, typ) \
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *, int, typ) \
|
||||
VPX_UNUSED; \
|
||||
\
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *ctx, \
|
||||
int ctrl_id, typ data) { \
|
||||
return vpx_codec_control_(ctx, ctrl_id, data); \
|
||||
} /**<\hideinitializer*/
|
||||
|
||||
/*!\brief vpx_codec_control deprecated type definition macro
|
||||
*
|
||||
* Like #VPX_CTRL_USE_TYPE, but indicates that the specified control is
|
||||
* deprecated and should not be used. Consult the documentation for your
|
||||
* codec for more information.
|
||||
*
|
||||
* \internal
|
||||
* It defines a static function with the correctly typed arguments as a
|
||||
* wrapper to the type-unsafe internal function.
|
||||
*/
|
||||
#define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \
|
||||
VPX_DECLSPEC_DEPRECATED static vpx_codec_err_t vpx_codec_control_##id( \
|
||||
vpx_codec_ctx_t *, int, typ) VPX_DEPRECATED VPX_UNUSED; \
|
||||
\
|
||||
VPX_DECLSPEC_DEPRECATED static vpx_codec_err_t vpx_codec_control_##id( \
|
||||
vpx_codec_ctx_t *ctx, int ctrl_id, typ data) { \
|
||||
return vpx_codec_control_(ctx, ctrl_id, data); \
|
||||
} /**<\hideinitializer*/
|
||||
|
||||
/*!\brief vpx_codec_control void type definition macro
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to vpx_codec_control_(). It indicates that a given control identifier takes
|
||||
* no argument.
|
||||
*
|
||||
* \internal
|
||||
* It defines a static function without a data argument as a wrapper to the
|
||||
* type-unsafe internal function.
|
||||
*/
|
||||
#define VPX_CTRL_VOID(id) \
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *, int) \
|
||||
VPX_UNUSED; \
|
||||
\
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *ctx, \
|
||||
int ctrl_id) { \
|
||||
return vpx_codec_control_(ctx, ctrl_id); \
|
||||
} /**<\hideinitializer*/
|
||||
|
||||
#endif
|
||||
|
||||
/*!@} - end defgroup codec*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // VPX_VPX_VPX_CODEC_H_
|
||||
365
vpx-encoder/android_libs/arm64-v8a/include/vpx/vpx_decoder.h
Normal file
365
vpx-encoder/android_libs/arm64-v8a/include/vpx/vpx_decoder.h
Normal file
|
|
@ -0,0 +1,365 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_DECODER_H_
|
||||
#define VPX_VPX_VPX_DECODER_H_
|
||||
|
||||
/*!\defgroup decoder Decoder Algorithm Interface
|
||||
* \ingroup codec
|
||||
* This abstraction allows applications using this decoder to easily support
|
||||
* multiple video formats with minimal code duplication. This section describes
|
||||
* the interface common to all decoders.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the decoder algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video decoder algorithm.
|
||||
*
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_codec.h"
|
||||
#include "./vpx_frame_buffer.h"
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_DECODER_ABI_VERSION \
|
||||
(3 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*! \brief Decoder capabilities bitfield
|
||||
*
|
||||
* Each decoder advertises the capabilities it supports as part of its
|
||||
* ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
|
||||
* or functionality, and are not required to be supported by a decoder.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_CAP_* defines.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_PUT_SLICE 0x10000 /**< Will issue put_slice callbacks */
|
||||
#define VPX_CODEC_CAP_PUT_FRAME 0x20000 /**< Will issue put_frame callbacks */
|
||||
#define VPX_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */
|
||||
/*!\brief Can conceal errors due to packet loss */
|
||||
#define VPX_CODEC_CAP_ERROR_CONCEALMENT 0x80000
|
||||
/*!\brief Can receive encoded frames one fragment at a time */
|
||||
#define VPX_CODEC_CAP_INPUT_FRAGMENTS 0x100000
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow for
|
||||
* proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_USE_* defines.
|
||||
*/
|
||||
/*!\brief Can support frame-based multi-threading */
|
||||
#define VPX_CODEC_CAP_FRAME_THREADING 0x200000
|
||||
/*!brief Can support external frame buffers */
|
||||
#define VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER 0x400000
|
||||
|
||||
#define VPX_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */
|
||||
/*!\brief Conceal errors in decoded frames */
|
||||
#define VPX_CODEC_USE_ERROR_CONCEALMENT 0x20000
|
||||
/*!\brief The input frame should be passed to the decoder one fragment at a
|
||||
* time */
|
||||
#define VPX_CODEC_USE_INPUT_FRAGMENTS 0x40000
|
||||
/*!\brief Enable frame-based multi-threading */
|
||||
#define VPX_CODEC_USE_FRAME_THREADING 0x80000
|
||||
|
||||
/*!\brief Stream properties
|
||||
*
|
||||
* This structure is used to query or set properties of the decoded
|
||||
* stream. Algorithms may extend this structure with data specific
|
||||
* to their bitstream by setting the sz member appropriately.
|
||||
*/
|
||||
typedef struct vpx_codec_stream_info {
|
||||
unsigned int sz; /**< Size of this structure */
|
||||
unsigned int w; /**< Width (or 0 for unknown/default) */
|
||||
unsigned int h; /**< Height (or 0 for unknown/default) */
|
||||
unsigned int is_kf; /**< Current frame is a keyframe */
|
||||
} vpx_codec_stream_info_t;
|
||||
|
||||
/* REQUIRED FUNCTIONS
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders.
|
||||
* They represent the base case functionality expected of all decoders.
|
||||
*/
|
||||
|
||||
/*!\brief Initialization Configurations
|
||||
*
|
||||
* This structure is used to pass init time configuration options to the
|
||||
* decoder.
|
||||
*/
|
||||
typedef struct vpx_codec_dec_cfg {
|
||||
unsigned int threads; /**< Maximum number of threads to use, default 1 */
|
||||
unsigned int w; /**< Width */
|
||||
unsigned int h; /**< Height */
|
||||
} vpx_codec_dec_cfg_t; /**< alias for struct vpx_codec_dec_cfg */
|
||||
|
||||
/*!\brief Initialize a decoder instance
|
||||
*
|
||||
* Initializes a decoder context using the given interface. Applications
|
||||
* should call the vpx_codec_dec_init convenience macro instead of this
|
||||
* function directly, to ensure that the ABI version number parameter
|
||||
* is properly initialized.
|
||||
*
|
||||
* If the library was configured with --disable-multithread, this call
|
||||
* is not thread safe and should be guarded with a lock if being used
|
||||
* in a multithreaded context.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[in] cfg Configuration to use, if known. May be NULL.
|
||||
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
|
||||
* \param[in] ver ABI version number. Must be set to
|
||||
* VPX_DECODER_ABI_VERSION
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The decoder algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_iface_t *iface,
|
||||
const vpx_codec_dec_cfg_t *cfg,
|
||||
vpx_codec_flags_t flags, int ver);
|
||||
|
||||
/*!\brief Convenience macro for vpx_codec_dec_init_ver()
|
||||
*
|
||||
* Ensures the ABI version parameter is properly set.
|
||||
*/
|
||||
#define vpx_codec_dec_init(ctx, iface, cfg, flags) \
|
||||
vpx_codec_dec_init_ver(ctx, iface, cfg, flags, VPX_DECODER_ABI_VERSION)
|
||||
|
||||
/*!\brief Parse stream info from a buffer
|
||||
*
|
||||
* Performs high level parsing of the bitstream. Construction of a decoder
|
||||
* context is not necessary. Can be used to determine if the bitstream is
|
||||
* of the proper format, and to extract information from the stream.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface
|
||||
* \param[in] data Pointer to a block of data to parse
|
||||
* \param[in] data_sz Size of the data buffer
|
||||
* \param[in,out] si Pointer to stream info to update. The size member
|
||||
* \ref MUST be properly initialized, but \ref MAY be
|
||||
* clobbered by the algorithm. This parameter \ref MAY
|
||||
* be NULL.
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Bitstream is parsable and stream information updated
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface,
|
||||
const uint8_t *data,
|
||||
unsigned int data_sz,
|
||||
vpx_codec_stream_info_t *si);
|
||||
|
||||
/*!\brief Return information about the current stream.
|
||||
*
|
||||
* Returns information about the stream that has been parsed during decoding.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] si Pointer to stream info to update. The size member
|
||||
* \ref MUST be properly initialized, but \ref MAY be
|
||||
* clobbered by the algorithm. This parameter \ref MAY
|
||||
* be NULL.
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Bitstream is parsable and stream information updated
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_stream_info_t *si);
|
||||
|
||||
/*!\brief Decode data
|
||||
*
|
||||
* Processes a buffer of coded data. If the processing results in a new
|
||||
* decoded frame becoming available, PUT_SLICE and PUT_FRAME events may be
|
||||
* generated, as appropriate. Encoded data \ref MUST be passed in DTS (decode
|
||||
* time stamp) order. Frames produced will always be in PTS (presentation
|
||||
* time stamp) order.
|
||||
* If the decoder is configured with VPX_CODEC_USE_INPUT_FRAGMENTS enabled,
|
||||
* data and data_sz can contain a fragment of the encoded frame. Fragment
|
||||
* \#n must contain at least partition \#n, but can also contain subsequent
|
||||
* partitions (\#n+1 - \#n+i), and if so, fragments \#n+1, .., \#n+i must
|
||||
* be empty. When no more data is available, this function should be called
|
||||
* with NULL as data and 0 as data_sz. The memory passed to this function
|
||||
* must be available until the frame has been decoded.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] data Pointer to this block of new coded data. If
|
||||
* NULL, a VPX_CODEC_CB_PUT_FRAME event is posted
|
||||
* for the previously decoded frame.
|
||||
* \param[in] data_sz Size of the coded data, in bytes.
|
||||
* \param[in] user_priv Application specific data to associate with
|
||||
* this frame.
|
||||
* \param[in] deadline Soft deadline the decoder should attempt to meet,
|
||||
* in us. Set to zero for unlimited.
|
||||
*
|
||||
* \return Returns #VPX_CODEC_OK if the coded data was processed completely
|
||||
* and future pictures can be decoded without error. Otherwise,
|
||||
* see the descriptions of the other error codes in ::vpx_codec_err_t
|
||||
* for recoverability capabilities.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, const uint8_t *data,
|
||||
unsigned int data_sz, void *user_priv,
|
||||
long deadline);
|
||||
|
||||
/*!\brief Decoded frames iterator
|
||||
*
|
||||
* Iterates over a list of the frames available for display. The iterator
|
||||
* storage should be initialized to NULL to start the iteration. Iteration is
|
||||
* complete when this function returns NULL.
|
||||
*
|
||||
* The list of available frames becomes valid upon completion of the
|
||||
* vpx_codec_decode call, and remains valid until the next call to
|
||||
* vpx_codec_decode.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] iter Iterator storage, initialized to NULL
|
||||
*
|
||||
* \return Returns a pointer to an image, if one is ready for display. Frames
|
||||
* produced will always be in PTS (presentation time stamp) order.
|
||||
*/
|
||||
vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx, vpx_codec_iter_t *iter);
|
||||
|
||||
/*!\defgroup cap_put_frame Frame-Based Decoding Functions
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders
|
||||
* that advertise the VPX_CODEC_CAP_PUT_FRAME capability. Calling these
|
||||
* functions
|
||||
* for codecs that don't advertise this capability will result in an error
|
||||
* code being returned, usually VPX_CODEC_ERROR
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief put frame callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to notify the application of
|
||||
* the availability of decoded image data.
|
||||
*/
|
||||
typedef void (*vpx_codec_put_frame_cb_fn_t)(void *user_priv,
|
||||
const vpx_image_t *img);
|
||||
|
||||
/*!\brief Register for notification of frame completion.
|
||||
*
|
||||
* Registers a given function to be called when a decoded frame is
|
||||
* available.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb Pointer to the callback function
|
||||
* \param[in] user_priv User's private data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Callback successfully registered.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* Decoder context not initialized, or algorithm not capable of
|
||||
* posting slice completion.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_put_frame_cb_fn_t cb,
|
||||
void *user_priv);
|
||||
|
||||
/*!@} - end defgroup cap_put_frame */
|
||||
|
||||
/*!\defgroup cap_put_slice Slice-Based Decoding Functions
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders
|
||||
* that advertise the VPX_CODEC_CAP_PUT_SLICE capability. Calling these
|
||||
* functions
|
||||
* for codecs that don't advertise this capability will result in an error
|
||||
* code being returned, usually VPX_CODEC_ERROR
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief put slice callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to notify the application of
|
||||
* the availability of partially decoded image data. The
|
||||
*/
|
||||
typedef void (*vpx_codec_put_slice_cb_fn_t)(void *user_priv,
|
||||
const vpx_image_t *img,
|
||||
const vpx_image_rect_t *valid,
|
||||
const vpx_image_rect_t *update);
|
||||
|
||||
/*!\brief Register for notification of slice completion.
|
||||
*
|
||||
* Registers a given function to be called when a decoded slice is
|
||||
* available.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb Pointer to the callback function
|
||||
* \param[in] user_priv User's private data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Callback successfully registered.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* Decoder context not initialized, or algorithm not capable of
|
||||
* posting slice completion.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_register_put_slice_cb(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_put_slice_cb_fn_t cb,
|
||||
void *user_priv);
|
||||
|
||||
/*!@} - end defgroup cap_put_slice*/
|
||||
|
||||
/*!\defgroup cap_external_frame_buffer External Frame Buffer Functions
|
||||
*
|
||||
* The following section is required to be implemented for all decoders
|
||||
* that advertise the VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER capability.
|
||||
* Calling this function for codecs that don't advertise this capability
|
||||
* will result in an error code being returned, usually VPX_CODEC_ERROR.
|
||||
*
|
||||
* \note
|
||||
* Currently this only works with VP9.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief Pass in external frame buffers for the decoder to use.
|
||||
*
|
||||
* Registers functions to be called when libvpx needs a frame buffer
|
||||
* to decode the current frame and a function to be called when libvpx does
|
||||
* not internally reference the frame buffer. This set function must
|
||||
* be called before the first call to decode or libvpx will assume the
|
||||
* default behavior of allocating frame buffers internally.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb_get Pointer to the get callback function
|
||||
* \param[in] cb_release Pointer to the release callback function
|
||||
* \param[in] cb_priv Callback's private data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* External frame buffers will be used by libvpx.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* One or more of the callbacks were NULL.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* Decoder context not initialized, or algorithm not capable of
|
||||
* using external frame buffers.
|
||||
*
|
||||
* \note
|
||||
* When decoding VP9, the application may be required to pass in at least
|
||||
* #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS external frame
|
||||
* buffers.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_set_frame_buffer_functions(
|
||||
vpx_codec_ctx_t *ctx, vpx_get_frame_buffer_cb_fn_t cb_get,
|
||||
vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv);
|
||||
|
||||
/*!@} - end defgroup cap_external_frame_buffer */
|
||||
|
||||
/*!@} - end defgroup decoder*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // VPX_VPX_VPX_DECODER_H_
|
||||
968
vpx-encoder/android_libs/arm64-v8a/include/vpx/vpx_encoder.h
Normal file
968
vpx-encoder/android_libs/arm64-v8a/include/vpx/vpx_encoder.h
Normal file
|
|
@ -0,0 +1,968 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_ENCODER_H_
|
||||
#define VPX_VPX_VPX_ENCODER_H_
|
||||
|
||||
/*!\defgroup encoder Encoder Algorithm Interface
|
||||
* \ingroup codec
|
||||
* This abstraction allows applications using this encoder to easily support
|
||||
* multiple video formats with minimal code duplication. This section describes
|
||||
* the interface common to all encoders.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the encoder algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video encoder algorithm.
|
||||
*
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_codec.h"
|
||||
|
||||
/*! Temporal Scalability: Maximum length of the sequence defining frame
|
||||
* layer membership
|
||||
*/
|
||||
#define VPX_TS_MAX_PERIODICITY 16
|
||||
|
||||
/*! Temporal Scalability: Maximum number of coding layers */
|
||||
#define VPX_TS_MAX_LAYERS 5
|
||||
|
||||
/*! Temporal+Spatial Scalability: Maximum number of coding layers */
|
||||
#define VPX_MAX_LAYERS 12 // 3 temporal + 4 spatial layers are allowed.
|
||||
|
||||
/*! Spatial Scalability: Maximum number of coding layers */
|
||||
#define VPX_SS_MAX_LAYERS 5
|
||||
|
||||
/*! Spatial Scalability: Default number of coding layers */
|
||||
#define VPX_SS_DEFAULT_LAYERS 1
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_ENCODER_ABI_VERSION \
|
||||
(14 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*! \brief Encoder capabilities bitfield
|
||||
*
|
||||
* Each encoder advertises the capabilities it supports as part of its
|
||||
* ::vpx_codec_iface_t interface structure. Capabilities are extra
|
||||
* interfaces or functionality, and are not required to be supported
|
||||
* by an encoder.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_CAP_* defines.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_PSNR 0x10000 /**< Can issue PSNR packets */
|
||||
|
||||
/*! Can output one partition at a time. Each partition is returned in its
|
||||
* own VPX_CODEC_CX_FRAME_PKT, with the FRAME_IS_FRAGMENT flag set for
|
||||
* every partition but the last. In this mode all frames are always
|
||||
* returned partition by partition.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_OUTPUT_PARTITION 0x20000
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow
|
||||
* for proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_USE_* defines.
|
||||
*/
|
||||
#define VPX_CODEC_USE_PSNR 0x10000 /**< Calculate PSNR on each frame */
|
||||
/*!\brief Make the encoder output one partition at a time. */
|
||||
#define VPX_CODEC_USE_OUTPUT_PARTITION 0x20000
|
||||
#define VPX_CODEC_USE_HIGHBITDEPTH 0x40000 /**< Use high bitdepth */
|
||||
|
||||
/*!\brief Generic fixed size buffer structure
|
||||
*
|
||||
* This structure is able to hold a reference to any fixed size buffer.
|
||||
*/
|
||||
typedef struct vpx_fixed_buf {
|
||||
void *buf; /**< Pointer to the data */
|
||||
size_t sz; /**< Length of the buffer, in chars */
|
||||
} vpx_fixed_buf_t; /**< alias for struct vpx_fixed_buf */
|
||||
|
||||
/*!\brief Time Stamp Type
|
||||
*
|
||||
* An integer, which when multiplied by the stream's time base, provides
|
||||
* the absolute time of a sample.
|
||||
*/
|
||||
typedef int64_t vpx_codec_pts_t;
|
||||
|
||||
/*!\brief Compressed Frame Flags
|
||||
*
|
||||
* This type represents a bitfield containing information about a compressed
|
||||
* frame that may be useful to an application. The most significant 16 bits
|
||||
* can be used by an algorithm to provide additional detail, for example to
|
||||
* support frame types that are codec specific (MPEG-1 D-frames for example)
|
||||
*/
|
||||
typedef uint32_t vpx_codec_frame_flags_t;
|
||||
#define VPX_FRAME_IS_KEY 0x1 /**< frame is the start of a GOP */
|
||||
/*!\brief frame can be dropped without affecting the stream (no future frame
|
||||
* depends on this one) */
|
||||
#define VPX_FRAME_IS_DROPPABLE 0x2
|
||||
/*!\brief frame should be decoded but will not be shown */
|
||||
#define VPX_FRAME_IS_INVISIBLE 0x4
|
||||
/*!\brief this is a fragment of the encoded frame */
|
||||
#define VPX_FRAME_IS_FRAGMENT 0x8
|
||||
|
||||
/*!\brief Error Resilient flags
|
||||
*
|
||||
* These flags define which error resilient features to enable in the
|
||||
* encoder. The flags are specified through the
|
||||
* vpx_codec_enc_cfg::g_error_resilient variable.
|
||||
*/
|
||||
typedef uint32_t vpx_codec_er_flags_t;
|
||||
/*!\brief Improve resiliency against losses of whole frames */
|
||||
#define VPX_ERROR_RESILIENT_DEFAULT 0x1
|
||||
/*!\brief The frame partitions are independently decodable by the bool decoder,
|
||||
* meaning that partitions can be decoded even though earlier partitions have
|
||||
* been lost. Note that intra prediction is still done over the partition
|
||||
* boundary. */
|
||||
#define VPX_ERROR_RESILIENT_PARTITIONS 0x2
|
||||
|
||||
/*!\brief Encoder output packet variants
|
||||
*
|
||||
* This enumeration lists the different kinds of data packets that can be
|
||||
* returned by calls to vpx_codec_get_cx_data(). Algorithms \ref MAY
|
||||
* extend this list to provide additional functionality.
|
||||
*/
|
||||
enum vpx_codec_cx_pkt_kind {
|
||||
VPX_CODEC_CX_FRAME_PKT, /**< Compressed video frame */
|
||||
VPX_CODEC_STATS_PKT, /**< Two-pass statistics for this frame */
|
||||
VPX_CODEC_FPMB_STATS_PKT, /**< first pass mb statistics for this frame */
|
||||
VPX_CODEC_PSNR_PKT, /**< PSNR statistics for this frame */
|
||||
VPX_CODEC_CUSTOM_PKT = 256 /**< Algorithm extensions */
|
||||
};
|
||||
|
||||
/*!\brief Encoder output packet
|
||||
*
|
||||
* This structure contains the different kinds of output data the encoder
|
||||
* may produce while compressing a frame.
|
||||
*/
|
||||
typedef struct vpx_codec_cx_pkt {
|
||||
enum vpx_codec_cx_pkt_kind kind; /**< packet variant */
|
||||
union {
|
||||
struct {
|
||||
void *buf; /**< compressed data buffer */
|
||||
size_t sz; /**< length of compressed data */
|
||||
/*!\brief time stamp to show frame (in timebase units) */
|
||||
vpx_codec_pts_t pts;
|
||||
/*!\brief duration to show frame (in timebase units) */
|
||||
unsigned long duration;
|
||||
vpx_codec_frame_flags_t flags; /**< flags for this frame */
|
||||
/*!\brief the partition id defines the decoding order of the partitions.
|
||||
* Only applicable when "output partition" mode is enabled. First
|
||||
* partition has id 0.*/
|
||||
int partition_id;
|
||||
/*!\brief Width and height of frames in this packet. VP8 will only use the
|
||||
* first one.*/
|
||||
unsigned int width[VPX_SS_MAX_LAYERS]; /**< frame width */
|
||||
unsigned int height[VPX_SS_MAX_LAYERS]; /**< frame height */
|
||||
/*!\brief Flag to indicate if spatial layer frame in this packet is
|
||||
* encoded or dropped. VP8 will always be set to 1.*/
|
||||
uint8_t spatial_layer_encoded[VPX_SS_MAX_LAYERS];
|
||||
} frame; /**< data for compressed frame packet */
|
||||
vpx_fixed_buf_t twopass_stats; /**< data for two-pass packet */
|
||||
vpx_fixed_buf_t firstpass_mb_stats; /**< first pass mb packet */
|
||||
struct vpx_psnr_pkt {
|
||||
unsigned int samples[4]; /**< Number of samples, total/y/u/v */
|
||||
uint64_t sse[4]; /**< sum squared error, total/y/u/v */
|
||||
double psnr[4]; /**< PSNR, total/y/u/v */
|
||||
} psnr; /**< data for PSNR packet */
|
||||
vpx_fixed_buf_t raw; /**< data for arbitrary packets */
|
||||
|
||||
/* This packet size is fixed to allow codecs to extend this
|
||||
* interface without having to manage storage for raw packets,
|
||||
* i.e., if it's smaller than 128 bytes, you can store in the
|
||||
* packet list directly.
|
||||
*/
|
||||
char pad[128 - sizeof(enum vpx_codec_cx_pkt_kind)]; /**< fixed sz */
|
||||
} data; /**< packet data */
|
||||
} vpx_codec_cx_pkt_t; /**< alias for struct vpx_codec_cx_pkt */
|
||||
|
||||
/*!\brief Encoder return output buffer callback
|
||||
*
|
||||
* This callback function, when registered, returns with packets when each
|
||||
* spatial layer is encoded.
|
||||
*/
|
||||
typedef void (*vpx_codec_enc_output_cx_pkt_cb_fn_t)(vpx_codec_cx_pkt_t *pkt,
|
||||
void *user_data);
|
||||
|
||||
/*!\brief Callback function pointer / user data pair storage */
|
||||
typedef struct vpx_codec_enc_output_cx_cb_pair {
|
||||
vpx_codec_enc_output_cx_pkt_cb_fn_t output_cx_pkt; /**< Callback function */
|
||||
void *user_priv; /**< Pointer to private data */
|
||||
} vpx_codec_priv_output_cx_pkt_cb_pair_t;
|
||||
|
||||
/*!\brief Rational Number
|
||||
*
|
||||
* This structure holds a fractional value.
|
||||
*/
|
||||
typedef struct vpx_rational {
|
||||
int num; /**< fraction numerator */
|
||||
int den; /**< fraction denominator */
|
||||
} vpx_rational_t; /**< alias for struct vpx_rational */
|
||||
|
||||
/*!\brief Multi-pass Encoding Pass */
|
||||
enum vpx_enc_pass {
|
||||
VPX_RC_ONE_PASS, /**< Single pass mode */
|
||||
VPX_RC_FIRST_PASS, /**< First pass of multi-pass mode */
|
||||
VPX_RC_LAST_PASS /**< Final pass of multi-pass mode */
|
||||
};
|
||||
|
||||
/*!\brief Rate control mode */
|
||||
enum vpx_rc_mode {
|
||||
VPX_VBR, /**< Variable Bit Rate (VBR) mode */
|
||||
VPX_CBR, /**< Constant Bit Rate (CBR) mode */
|
||||
VPX_CQ, /**< Constrained Quality (CQ) mode */
|
||||
VPX_Q, /**< Constant Quality (Q) mode */
|
||||
};
|
||||
|
||||
/*!\brief Keyframe placement mode.
|
||||
*
|
||||
* This enumeration determines whether keyframes are placed automatically by
|
||||
* the encoder or whether this behavior is disabled. Older releases of this
|
||||
* SDK were implemented such that VPX_KF_FIXED meant keyframes were disabled.
|
||||
* This name is confusing for this behavior, so the new symbols to be used
|
||||
* are VPX_KF_AUTO and VPX_KF_DISABLED.
|
||||
*/
|
||||
enum vpx_kf_mode {
|
||||
VPX_KF_FIXED, /**< deprecated, implies VPX_KF_DISABLED */
|
||||
VPX_KF_AUTO, /**< Encoder determines optimal placement automatically */
|
||||
VPX_KF_DISABLED = 0 /**< Encoder does not place keyframes. */
|
||||
};
|
||||
|
||||
/*!\brief Encoded Frame Flags
|
||||
*
|
||||
* This type indicates a bitfield to be passed to vpx_codec_encode(), defining
|
||||
* per-frame boolean values. By convention, bits common to all codecs will be
|
||||
* named VPX_EFLAG_*, and bits specific to an algorithm will be named
|
||||
* /algo/_eflag_*. The lower order 16 bits are reserved for common use.
|
||||
*/
|
||||
typedef long vpx_enc_frame_flags_t;
|
||||
#define VPX_EFLAG_FORCE_KF (1 << 0) /**< Force this frame to be a keyframe */
|
||||
|
||||
/*!\brief Encoder configuration structure
|
||||
*
|
||||
* This structure contains the encoder settings that have common representations
|
||||
* across all codecs. This doesn't imply that all codecs support all features,
|
||||
* however.
|
||||
*/
|
||||
typedef struct vpx_codec_enc_cfg {
|
||||
/*
|
||||
* generic settings (g)
|
||||
*/
|
||||
|
||||
/*!\brief Deprecated: Algorithm specific "usage" value
|
||||
*
|
||||
* This value must be zero.
|
||||
*/
|
||||
unsigned int g_usage;
|
||||
|
||||
/*!\brief Maximum number of threads to use
|
||||
*
|
||||
* For multi-threaded implementations, use no more than this number of
|
||||
* threads. The codec may use fewer threads than allowed. The value
|
||||
* 0 is equivalent to the value 1.
|
||||
*/
|
||||
unsigned int g_threads;
|
||||
|
||||
/*!\brief Bitstream profile to use
|
||||
*
|
||||
* Some codecs support a notion of multiple bitstream profiles. Typically
|
||||
* this maps to a set of features that are turned on or off. Often the
|
||||
* profile to use is determined by the features of the intended decoder.
|
||||
* Consult the documentation for the codec to determine the valid values
|
||||
* for this parameter, or set to zero for a sane default.
|
||||
*/
|
||||
unsigned int g_profile; /**< profile of bitstream to use */
|
||||
|
||||
/*!\brief Width of the frame
|
||||
*
|
||||
* This value identifies the presentation resolution of the frame,
|
||||
* in pixels. Note that the frames passed as input to the encoder must
|
||||
* have this resolution. Frames will be presented by the decoder in this
|
||||
* resolution, independent of any spatial resampling the encoder may do.
|
||||
*/
|
||||
unsigned int g_w;
|
||||
|
||||
/*!\brief Height of the frame
|
||||
*
|
||||
* This value identifies the presentation resolution of the frame,
|
||||
* in pixels. Note that the frames passed as input to the encoder must
|
||||
* have this resolution. Frames will be presented by the decoder in this
|
||||
* resolution, independent of any spatial resampling the encoder may do.
|
||||
*/
|
||||
unsigned int g_h;
|
||||
|
||||
/*!\brief Bit-depth of the codec
|
||||
*
|
||||
* This value identifies the bit_depth of the codec,
|
||||
* Only certain bit-depths are supported as identified in the
|
||||
* vpx_bit_depth_t enum.
|
||||
*/
|
||||
vpx_bit_depth_t g_bit_depth;
|
||||
|
||||
/*!\brief Bit-depth of the input frames
|
||||
*
|
||||
* This value identifies the bit_depth of the input frames in bits.
|
||||
* Note that the frames passed as input to the encoder must have
|
||||
* this bit-depth.
|
||||
*/
|
||||
unsigned int g_input_bit_depth;
|
||||
|
||||
/*!\brief Stream timebase units
|
||||
*
|
||||
* Indicates the smallest interval of time, in seconds, used by the stream.
|
||||
* For fixed frame rate material, or variable frame rate material where
|
||||
* frames are timed at a multiple of a given clock (ex: video capture),
|
||||
* the \ref RECOMMENDED method is to set the timebase to the reciprocal
|
||||
* of the frame rate (ex: 1001/30000 for 29.970 Hz NTSC). This allows the
|
||||
* pts to correspond to the frame number, which can be handy. For
|
||||
* re-encoding video from containers with absolute time timestamps, the
|
||||
* \ref RECOMMENDED method is to set the timebase to that of the parent
|
||||
* container or multimedia framework (ex: 1/1000 for ms, as in FLV).
|
||||
*/
|
||||
struct vpx_rational g_timebase;
|
||||
|
||||
/*!\brief Enable error resilient modes.
|
||||
*
|
||||
* The error resilient bitfield indicates to the encoder which features
|
||||
* it should enable to take measures for streaming over lossy or noisy
|
||||
* links.
|
||||
*/
|
||||
vpx_codec_er_flags_t g_error_resilient;
|
||||
|
||||
/*!\brief Multi-pass Encoding Mode
|
||||
*
|
||||
* This value should be set to the current phase for multi-pass encoding.
|
||||
* For single pass, set to #VPX_RC_ONE_PASS.
|
||||
*/
|
||||
enum vpx_enc_pass g_pass;
|
||||
|
||||
/*!\brief Allow lagged encoding
|
||||
*
|
||||
* If set, this value allows the encoder to consume a number of input
|
||||
* frames before producing output frames. This allows the encoder to
|
||||
* base decisions for the current frame on future frames. This does
|
||||
* increase the latency of the encoding pipeline, so it is not appropriate
|
||||
* in all situations (ex: realtime encoding).
|
||||
*
|
||||
* Note that this is a maximum value -- the encoder may produce frames
|
||||
* sooner than the given limit. Set this value to 0 to disable this
|
||||
* feature.
|
||||
*/
|
||||
unsigned int g_lag_in_frames;
|
||||
|
||||
/*
|
||||
* rate control settings (rc)
|
||||
*/
|
||||
|
||||
/*!\brief Temporal resampling configuration, if supported by the codec.
|
||||
*
|
||||
* Temporal resampling allows the codec to "drop" frames as a strategy to
|
||||
* meet its target data rate. This can cause temporal discontinuities in
|
||||
* the encoded video, which may appear as stuttering during playback. This
|
||||
* trade-off is often acceptable, but for many applications is not. It can
|
||||
* be disabled in these cases.
|
||||
*
|
||||
* This threshold is described as a percentage of the target data buffer.
|
||||
* When the data buffer falls below this percentage of fullness, a
|
||||
* dropped frame is indicated. Set the threshold to zero (0) to disable
|
||||
* this feature.
|
||||
*/
|
||||
unsigned int rc_dropframe_thresh;
|
||||
|
||||
/*!\brief Enable/disable spatial resampling, if supported by the codec.
|
||||
*
|
||||
* Spatial resampling allows the codec to compress a lower resolution
|
||||
* version of the frame, which is then upscaled by the encoder to the
|
||||
* correct presentation resolution. This increases visual quality at
|
||||
* low data rates, at the expense of CPU time on the encoder/decoder.
|
||||
*/
|
||||
unsigned int rc_resize_allowed;
|
||||
|
||||
/*!\brief Internal coded frame width.
|
||||
*
|
||||
* If spatial resampling is enabled this specifies the width of the
|
||||
* encoded frame.
|
||||
*/
|
||||
unsigned int rc_scaled_width;
|
||||
|
||||
/*!\brief Internal coded frame height.
|
||||
*
|
||||
* If spatial resampling is enabled this specifies the height of the
|
||||
* encoded frame.
|
||||
*/
|
||||
unsigned int rc_scaled_height;
|
||||
|
||||
/*!\brief Spatial resampling up watermark.
|
||||
*
|
||||
* This threshold is described as a percentage of the target data buffer.
|
||||
* When the data buffer rises above this percentage of fullness, the
|
||||
* encoder will step up to a higher resolution version of the frame.
|
||||
*/
|
||||
unsigned int rc_resize_up_thresh;
|
||||
|
||||
/*!\brief Spatial resampling down watermark.
|
||||
*
|
||||
* This threshold is described as a percentage of the target data buffer.
|
||||
* When the data buffer falls below this percentage of fullness, the
|
||||
* encoder will step down to a lower resolution version of the frame.
|
||||
*/
|
||||
unsigned int rc_resize_down_thresh;
|
||||
|
||||
/*!\brief Rate control algorithm to use.
|
||||
*
|
||||
* Indicates whether the end usage of this stream is to be streamed over
|
||||
* a bandwidth constrained link, indicating that Constant Bit Rate (CBR)
|
||||
* mode should be used, or whether it will be played back on a high
|
||||
* bandwidth link, as from a local disk, where higher variations in
|
||||
* bitrate are acceptable.
|
||||
*/
|
||||
enum vpx_rc_mode rc_end_usage;
|
||||
|
||||
/*!\brief Two-pass stats buffer.
|
||||
*
|
||||
* A buffer containing all of the stats packets produced in the first
|
||||
* pass, concatenated.
|
||||
*/
|
||||
vpx_fixed_buf_t rc_twopass_stats_in;
|
||||
|
||||
/*!\brief first pass mb stats buffer.
|
||||
*
|
||||
* A buffer containing all of the first pass mb stats packets produced
|
||||
* in the first pass, concatenated.
|
||||
*/
|
||||
vpx_fixed_buf_t rc_firstpass_mb_stats_in;
|
||||
|
||||
/*!\brief Target data rate
|
||||
*
|
||||
* Target bandwidth to use for this stream, in kilobits per second.
|
||||
*/
|
||||
unsigned int rc_target_bitrate;
|
||||
|
||||
/*
|
||||
* quantizer settings
|
||||
*/
|
||||
|
||||
/*!\brief Minimum (Best Quality) Quantizer
|
||||
*
|
||||
* The quantizer is the most direct control over the quality of the
|
||||
* encoded image. The range of valid values for the quantizer is codec
|
||||
* specific. Consult the documentation for the codec to determine the
|
||||
* values to use.
|
||||
*/
|
||||
unsigned int rc_min_quantizer;
|
||||
|
||||
/*!\brief Maximum (Worst Quality) Quantizer
|
||||
*
|
||||
* The quantizer is the most direct control over the quality of the
|
||||
* encoded image. The range of valid values for the quantizer is codec
|
||||
* specific. Consult the documentation for the codec to determine the
|
||||
* values to use.
|
||||
*/
|
||||
unsigned int rc_max_quantizer;
|
||||
|
||||
/*
|
||||
* bitrate tolerance
|
||||
*/
|
||||
|
||||
/*!\brief Rate control adaptation undershoot control
|
||||
*
|
||||
* VP8: Expressed as a percentage of the target bitrate,
|
||||
* controls the maximum allowed adaptation speed of the codec.
|
||||
* This factor controls the maximum amount of bits that can
|
||||
* be subtracted from the target bitrate in order to compensate
|
||||
* for prior overshoot.
|
||||
* VP9: Expressed as a percentage of the target bitrate, a threshold
|
||||
* undershoot level (current rate vs target) beyond which more aggressive
|
||||
* corrective measures are taken.
|
||||
* *
|
||||
* Valid values in the range VP8:0-1000 VP9: 0-100.
|
||||
*/
|
||||
unsigned int rc_undershoot_pct;
|
||||
|
||||
/*!\brief Rate control adaptation overshoot control
|
||||
*
|
||||
* VP8: Expressed as a percentage of the target bitrate,
|
||||
* controls the maximum allowed adaptation speed of the codec.
|
||||
* This factor controls the maximum amount of bits that can
|
||||
* be added to the target bitrate in order to compensate for
|
||||
* prior undershoot.
|
||||
* VP9: Expressed as a percentage of the target bitrate, a threshold
|
||||
* overshoot level (current rate vs target) beyond which more aggressive
|
||||
* corrective measures are taken.
|
||||
*
|
||||
* Valid values in the range VP8:0-1000 VP9: 0-100.
|
||||
*/
|
||||
unsigned int rc_overshoot_pct;
|
||||
|
||||
/*
|
||||
* decoder buffer model parameters
|
||||
*/
|
||||
|
||||
/*!\brief Decoder Buffer Size
|
||||
*
|
||||
* This value indicates the amount of data that may be buffered by the
|
||||
* decoding application. Note that this value is expressed in units of
|
||||
* time (milliseconds). For example, a value of 5000 indicates that the
|
||||
* client will buffer (at least) 5000ms worth of encoded data. Use the
|
||||
* target bitrate (#rc_target_bitrate) to convert to bits/bytes, if
|
||||
* necessary.
|
||||
*/
|
||||
unsigned int rc_buf_sz;
|
||||
|
||||
/*!\brief Decoder Buffer Initial Size
|
||||
*
|
||||
* This value indicates the amount of data that will be buffered by the
|
||||
* decoding application prior to beginning playback. This value is
|
||||
* expressed in units of time (milliseconds). Use the target bitrate
|
||||
* (#rc_target_bitrate) to convert to bits/bytes, if necessary.
|
||||
*/
|
||||
unsigned int rc_buf_initial_sz;
|
||||
|
||||
/*!\brief Decoder Buffer Optimal Size
|
||||
*
|
||||
* This value indicates the amount of data that the encoder should try
|
||||
* to maintain in the decoder's buffer. This value is expressed in units
|
||||
* of time (milliseconds). Use the target bitrate (#rc_target_bitrate)
|
||||
* to convert to bits/bytes, if necessary.
|
||||
*/
|
||||
unsigned int rc_buf_optimal_sz;
|
||||
|
||||
/*
|
||||
* 2 pass rate control parameters
|
||||
*/
|
||||
|
||||
/*!\brief Two-pass mode CBR/VBR bias
|
||||
*
|
||||
* Bias, expressed on a scale of 0 to 100, for determining target size
|
||||
* for the current frame. The value 0 indicates the optimal CBR mode
|
||||
* value should be used. The value 100 indicates the optimal VBR mode
|
||||
* value should be used. Values in between indicate which way the
|
||||
* encoder should "lean."
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_bias_pct;
|
||||
|
||||
/*!\brief Two-pass mode per-GOP minimum bitrate
|
||||
*
|
||||
* This value, expressed as a percentage of the target bitrate, indicates
|
||||
* the minimum bitrate to be used for a single GOP (aka "section")
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_minsection_pct;
|
||||
|
||||
/*!\brief Two-pass mode per-GOP maximum bitrate
|
||||
*
|
||||
* This value, expressed as a percentage of the target bitrate, indicates
|
||||
* the maximum bitrate to be used for a single GOP (aka "section")
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_maxsection_pct;
|
||||
|
||||
/*!\brief Two-pass corpus vbr mode complexity control
|
||||
* Used only in VP9: A value representing the corpus midpoint complexity
|
||||
* for corpus vbr mode. This value defaults to 0 which disables corpus vbr
|
||||
* mode in favour of normal vbr mode.
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_corpus_complexity;
|
||||
|
||||
/*
|
||||
* keyframing settings (kf)
|
||||
*/
|
||||
|
||||
/*!\brief Keyframe placement mode
|
||||
*
|
||||
* This value indicates whether the encoder should place keyframes at a
|
||||
* fixed interval, or determine the optimal placement automatically
|
||||
* (as governed by the #kf_min_dist and #kf_max_dist parameters)
|
||||
*/
|
||||
enum vpx_kf_mode kf_mode;
|
||||
|
||||
/*!\brief Keyframe minimum interval
|
||||
*
|
||||
* This value, expressed as a number of frames, prevents the encoder from
|
||||
* placing a keyframe nearer than kf_min_dist to the previous keyframe. At
|
||||
* least kf_min_dist frames non-keyframes will be coded before the next
|
||||
* keyframe. Set kf_min_dist equal to kf_max_dist for a fixed interval.
|
||||
*/
|
||||
unsigned int kf_min_dist;
|
||||
|
||||
/*!\brief Keyframe maximum interval
|
||||
*
|
||||
* This value, expressed as a number of frames, forces the encoder to code
|
||||
* a keyframe if one has not been coded in the last kf_max_dist frames.
|
||||
* A value of 0 implies all frames will be keyframes. Set kf_min_dist
|
||||
* equal to kf_max_dist for a fixed interval.
|
||||
*/
|
||||
unsigned int kf_max_dist;
|
||||
|
||||
/*
|
||||
* Spatial scalability settings (ss)
|
||||
*/
|
||||
|
||||
/*!\brief Number of spatial coding layers.
|
||||
*
|
||||
* This value specifies the number of spatial coding layers to be used.
|
||||
*/
|
||||
unsigned int ss_number_layers;
|
||||
|
||||
/*!\brief Enable auto alt reference flags for each spatial layer.
|
||||
*
|
||||
* These values specify if auto alt reference frame is enabled for each
|
||||
* spatial layer.
|
||||
*/
|
||||
int ss_enable_auto_alt_ref[VPX_SS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Target bitrate for each spatial layer.
|
||||
*
|
||||
* These values specify the target coding bitrate to be used for each
|
||||
* spatial layer.
|
||||
*/
|
||||
unsigned int ss_target_bitrate[VPX_SS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Number of temporal coding layers.
|
||||
*
|
||||
* This value specifies the number of temporal layers to be used.
|
||||
*/
|
||||
unsigned int ts_number_layers;
|
||||
|
||||
/*!\brief Target bitrate for each temporal layer.
|
||||
*
|
||||
* These values specify the target coding bitrate to be used for each
|
||||
* temporal layer.
|
||||
*/
|
||||
unsigned int ts_target_bitrate[VPX_TS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Frame rate decimation factor for each temporal layer.
|
||||
*
|
||||
* These values specify the frame rate decimation factors to apply
|
||||
* to each temporal layer.
|
||||
*/
|
||||
unsigned int ts_rate_decimator[VPX_TS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Length of the sequence defining frame temporal layer membership.
|
||||
*
|
||||
* This value specifies the length of the sequence that defines the
|
||||
* membership of frames to temporal layers. For example, if the
|
||||
* ts_periodicity = 8, then the frames are assigned to coding layers with a
|
||||
* repeated sequence of length 8.
|
||||
*/
|
||||
unsigned int ts_periodicity;
|
||||
|
||||
/*!\brief Template defining the membership of frames to temporal layers.
|
||||
*
|
||||
* This array defines the membership of frames to temporal coding layers.
|
||||
* For a 2-layer encoding that assigns even numbered frames to one temporal
|
||||
* layer (0) and odd numbered frames to a second temporal layer (1) with
|
||||
* ts_periodicity=8, then ts_layer_id = (0,1,0,1,0,1,0,1).
|
||||
*/
|
||||
unsigned int ts_layer_id[VPX_TS_MAX_PERIODICITY];
|
||||
|
||||
/*!\brief Target bitrate for each spatial/temporal layer.
|
||||
*
|
||||
* These values specify the target coding bitrate to be used for each
|
||||
* spatial/temporal layer.
|
||||
*
|
||||
*/
|
||||
unsigned int layer_target_bitrate[VPX_MAX_LAYERS];
|
||||
|
||||
/*!\brief Temporal layering mode indicating which temporal layering scheme to
|
||||
* use.
|
||||
*
|
||||
* The value (refer to VP9E_TEMPORAL_LAYERING_MODE) specifies the
|
||||
* temporal layering mode to use.
|
||||
*
|
||||
*/
|
||||
int temporal_layering_mode;
|
||||
} vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */
|
||||
|
||||
/*!\brief vp9 svc extra configure parameters
|
||||
*
|
||||
* This defines max/min quantizers and scale factors for each layer
|
||||
*
|
||||
*/
|
||||
typedef struct vpx_svc_parameters {
|
||||
int max_quantizers[VPX_MAX_LAYERS]; /**< Max Q for each layer */
|
||||
int min_quantizers[VPX_MAX_LAYERS]; /**< Min Q for each layer */
|
||||
int scaling_factor_num[VPX_MAX_LAYERS]; /**< Scaling factor-numerator */
|
||||
int scaling_factor_den[VPX_MAX_LAYERS]; /**< Scaling factor-denominator */
|
||||
int speed_per_layer[VPX_MAX_LAYERS]; /**< Speed setting for each sl */
|
||||
int temporal_layering_mode; /**< Temporal layering mode */
|
||||
} vpx_svc_extra_cfg_t;
|
||||
|
||||
/*!\brief Initialize an encoder instance
|
||||
*
|
||||
* Initializes a encoder context using the given interface. Applications
|
||||
* should call the vpx_codec_enc_init convenience macro instead of this
|
||||
* function directly, to ensure that the ABI version number parameter
|
||||
* is properly initialized.
|
||||
*
|
||||
* If the library was configured with --disable-multithread, this call
|
||||
* is not thread safe and should be guarded with a lock if being used
|
||||
* in a multithreaded context.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[in] cfg Configuration to use, if known. May be NULL.
|
||||
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
|
||||
* \param[in] ver ABI version number. Must be set to
|
||||
* VPX_ENCODER_ABI_VERSION
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The decoder algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_iface_t *iface,
|
||||
const vpx_codec_enc_cfg_t *cfg,
|
||||
vpx_codec_flags_t flags, int ver);
|
||||
|
||||
/*!\brief Convenience macro for vpx_codec_enc_init_ver()
|
||||
*
|
||||
* Ensures the ABI version parameter is properly set.
|
||||
*/
|
||||
#define vpx_codec_enc_init(ctx, iface, cfg, flags) \
|
||||
vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION)
|
||||
|
||||
/*!\brief Initialize multi-encoder instance
|
||||
*
|
||||
* Initializes multi-encoder context using the given interface.
|
||||
* Applications should call the vpx_codec_enc_init_multi convenience macro
|
||||
* instead of this function directly, to ensure that the ABI version number
|
||||
* parameter is properly initialized.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[in] cfg Configuration to use, if known. May be NULL.
|
||||
* \param[in] num_enc Total number of encoders.
|
||||
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
|
||||
* \param[in] dsf Pointer to down-sampling factors.
|
||||
* \param[in] ver ABI version number. Must be set to
|
||||
* VPX_ENCODER_ABI_VERSION
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The decoder algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_init_multi_ver(
|
||||
vpx_codec_ctx_t *ctx, vpx_codec_iface_t *iface, vpx_codec_enc_cfg_t *cfg,
|
||||
int num_enc, vpx_codec_flags_t flags, vpx_rational_t *dsf, int ver);
|
||||
|
||||
/*!\brief Convenience macro for vpx_codec_enc_init_multi_ver()
|
||||
*
|
||||
* Ensures the ABI version parameter is properly set.
|
||||
*/
|
||||
#define vpx_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \
|
||||
vpx_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \
|
||||
VPX_ENCODER_ABI_VERSION)
|
||||
|
||||
/*!\brief Get a default configuration
|
||||
*
|
||||
* Initializes a encoder configuration structure with default values. Supports
|
||||
* the notion of "usages" so that an algorithm may offer different default
|
||||
* settings depending on the user's intended goal. This function \ref SHOULD
|
||||
* be called by all applications to initialize the configuration structure
|
||||
* before specializing the configuration with application specific values.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[out] cfg Configuration buffer to populate.
|
||||
* \param[in] usage Must be set to 0.
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The configuration was populated.
|
||||
* \retval #VPX_CODEC_INCAPABLE
|
||||
* Interface is not an encoder interface.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, or the usage value was not recognized.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface,
|
||||
vpx_codec_enc_cfg_t *cfg,
|
||||
unsigned int usage);
|
||||
|
||||
/*!\brief Set or change configuration
|
||||
*
|
||||
* Reconfigures an encoder instance according to the given configuration.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cfg Configuration buffer to use
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The configuration was populated.
|
||||
* \retval #VPX_CODEC_INCAPABLE
|
||||
* Interface is not an encoder interface.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, or the usage value was not recognized.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx,
|
||||
const vpx_codec_enc_cfg_t *cfg);
|
||||
|
||||
/*!\brief Get global stream headers
|
||||
*
|
||||
* Retrieves a stream level global header packet, if supported by the codec.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
*
|
||||
* \retval NULL
|
||||
* Encoder does not support global header
|
||||
* \retval Non-NULL
|
||||
* Pointer to buffer containing global header packet
|
||||
*/
|
||||
vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!\brief deadline parameter analogous to VPx REALTIME mode. */
|
||||
#define VPX_DL_REALTIME (1)
|
||||
/*!\brief deadline parameter analogous to VPx GOOD QUALITY mode. */
|
||||
#define VPX_DL_GOOD_QUALITY (1000000)
|
||||
/*!\brief deadline parameter analogous to VPx BEST QUALITY mode. */
|
||||
#define VPX_DL_BEST_QUALITY (0)
|
||||
/*!\brief Encode a frame
|
||||
*
|
||||
* Encodes a video frame at the given "presentation time." The presentation
|
||||
* time stamp (PTS) \ref MUST be strictly increasing.
|
||||
*
|
||||
* The encoder supports the notion of a soft real-time deadline. Given a
|
||||
* non-zero value to the deadline parameter, the encoder will make a "best
|
||||
* effort" guarantee to return before the given time slice expires. It is
|
||||
* implicit that limiting the available time to encode will degrade the
|
||||
* output quality. The encoder can be given an unlimited time to produce the
|
||||
* best possible frame by specifying a deadline of '0'. This deadline
|
||||
* supersedes the VPx notion of "best quality, good quality, realtime".
|
||||
* Applications that wish to map these former settings to the new deadline
|
||||
* based system can use the symbols #VPX_DL_REALTIME, #VPX_DL_GOOD_QUALITY,
|
||||
* and #VPX_DL_BEST_QUALITY.
|
||||
*
|
||||
* When the last frame has been passed to the encoder, this function should
|
||||
* continue to be called, with the img parameter set to NULL. This will
|
||||
* signal the end-of-stream condition to the encoder and allow it to encode
|
||||
* any held buffers. Encoding is complete when vpx_codec_encode() is called
|
||||
* and vpx_codec_get_cx_data() returns no data.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] img Image data to encode, NULL to flush.
|
||||
* \param[in] pts Presentation time stamp, in timebase units.
|
||||
* \param[in] duration Duration to show frame, in timebase units.
|
||||
* \param[in] flags Flags to use for encoding this frame.
|
||||
* \param[in] deadline Time to spend encoding, in microseconds. (0=infinite)
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The configuration was populated.
|
||||
* \retval #VPX_CODEC_INCAPABLE
|
||||
* Interface is not an encoder interface.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, the image format is unsupported, etc.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx, const vpx_image_t *img,
|
||||
vpx_codec_pts_t pts, unsigned long duration,
|
||||
vpx_enc_frame_flags_t flags,
|
||||
unsigned long deadline);
|
||||
|
||||
/*!\brief Set compressed data output buffer
|
||||
*
|
||||
* Sets the buffer that the codec should output the compressed data
|
||||
* into. This call effectively sets the buffer pointer returned in the
|
||||
* next VPX_CODEC_CX_FRAME_PKT packet. Subsequent packets will be
|
||||
* appended into this buffer. The buffer is preserved across frames,
|
||||
* so applications must periodically call this function after flushing
|
||||
* the accumulated compressed data to disk or to the network to reset
|
||||
* the pointer to the buffer's head.
|
||||
*
|
||||
* `pad_before` bytes will be skipped before writing the compressed
|
||||
* data, and `pad_after` bytes will be appended to the packet. The size
|
||||
* of the packet will be the sum of the size of the actual compressed
|
||||
* data, pad_before, and pad_after. The padding bytes will be preserved
|
||||
* (not overwritten).
|
||||
*
|
||||
* Note that calling this function does not guarantee that the returned
|
||||
* compressed data will be placed into the specified buffer. In the
|
||||
* event that the encoded data will not fit into the buffer provided,
|
||||
* the returned packet \ref MAY point to an internal buffer, as it would
|
||||
* if this call were never used. In this event, the output packet will
|
||||
* NOT have any padding, and the application must free space and copy it
|
||||
* to the proper place. This is of particular note in configurations
|
||||
* that may output multiple packets for a single encoded frame (e.g., lagged
|
||||
* encoding) or if the application does not reset the buffer periodically.
|
||||
*
|
||||
* Applications may restore the default behavior of the codec providing
|
||||
* the compressed data buffer by calling this function with a NULL
|
||||
* buffer.
|
||||
*
|
||||
* Applications \ref MUSTNOT call this function during iteration of
|
||||
* vpx_codec_get_cx_data().
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] buf Buffer to store compressed data into
|
||||
* \param[in] pad_before Bytes to skip before writing compressed data
|
||||
* \param[in] pad_after Bytes to skip after writing compressed data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The buffer was set successfully.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, the image format is unsupported, etc.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx,
|
||||
const vpx_fixed_buf_t *buf,
|
||||
unsigned int pad_before,
|
||||
unsigned int pad_after);
|
||||
|
||||
/*!\brief Encoded data iterator
|
||||
*
|
||||
* Iterates over a list of data packets to be passed from the encoder to the
|
||||
* application. The different kinds of packets available are enumerated in
|
||||
* #vpx_codec_cx_pkt_kind.
|
||||
*
|
||||
* #VPX_CODEC_CX_FRAME_PKT packets should be passed to the application's
|
||||
* muxer. Multiple compressed frames may be in the list.
|
||||
* #VPX_CODEC_STATS_PKT packets should be appended to a global buffer.
|
||||
*
|
||||
* The application \ref MUST silently ignore any packet kinds that it does
|
||||
* not recognize or support.
|
||||
*
|
||||
* The data buffers returned from this function are only guaranteed to be
|
||||
* valid until the application makes another call to any vpx_codec_* function.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] iter Iterator storage, initialized to NULL
|
||||
*
|
||||
* \return Returns a pointer to an output data packet (compressed frame data,
|
||||
* two-pass statistics, etc.) or NULL to signal end-of-list.
|
||||
*
|
||||
*/
|
||||
const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_iter_t *iter);
|
||||
|
||||
/*!\brief Get Preview Frame
|
||||
*
|
||||
* Returns an image that can be used as a preview. Shows the image as it would
|
||||
* exist at the decompressor. The application \ref MUST NOT write into this
|
||||
* image buffer.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
*
|
||||
* \return Returns a pointer to a preview image, or NULL if no image is
|
||||
* available.
|
||||
*
|
||||
*/
|
||||
const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!@} - end defgroup encoder*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // VPX_VPX_VPX_ENCODER_H_
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef VPX_VPX_VPX_FRAME_BUFFER_H_
|
||||
#define VPX_VPX_VPX_FRAME_BUFFER_H_
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the decoder external frame buffer interface.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_integer.h"
|
||||
|
||||
/*!\brief The maximum number of work buffers used by libvpx.
|
||||
* Support maximum 4 threads to decode video in parallel.
|
||||
* Each thread will use one work buffer.
|
||||
* TODO(hkuang): Add support to set number of worker threads dynamically.
|
||||
*/
|
||||
#define VPX_MAXIMUM_WORK_BUFFERS 8
|
||||
|
||||
/*!\brief The maximum number of reference buffers that a VP9 encoder may use.
|
||||
*/
|
||||
#define VP9_MAXIMUM_REF_BUFFERS 8
|
||||
|
||||
/*!\brief External frame buffer
|
||||
*
|
||||
* This structure holds allocated frame buffers used by the decoder.
|
||||
*/
|
||||
typedef struct vpx_codec_frame_buffer {
|
||||
uint8_t *data; /**< Pointer to the data buffer */
|
||||
size_t size; /**< Size of data in bytes */
|
||||
void *priv; /**< Frame's private data */
|
||||
} vpx_codec_frame_buffer_t;
|
||||
|
||||
/*!\brief get frame buffer callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to retrieve data for the frame
|
||||
* buffer in order for the decode call to complete. The callback must
|
||||
* allocate at least min_size in bytes and assign it to fb->data. The callback
|
||||
* must zero out all the data allocated. Then the callback must set fb->size
|
||||
* to the allocated size. The application does not need to align the allocated
|
||||
* data. The callback is triggered when the decoder needs a frame buffer to
|
||||
* decode a compressed image into. This function may be called more than once
|
||||
* for every call to vpx_codec_decode. The application may set fb->priv to
|
||||
* some data which will be passed back in the ximage and the release function
|
||||
* call. |fb| is guaranteed to not be NULL. On success the callback must
|
||||
* return 0. Any failure the callback must return a value less than 0.
|
||||
*
|
||||
* \param[in] priv Callback's private data
|
||||
* \param[in] min_size Size in bytes needed by the buffer
|
||||
* \param[in,out] fb Pointer to vpx_codec_frame_buffer_t
|
||||
*/
|
||||
typedef int (*vpx_get_frame_buffer_cb_fn_t)(void *priv, size_t min_size,
|
||||
vpx_codec_frame_buffer_t *fb);
|
||||
|
||||
/*!\brief release frame buffer callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder when the frame buffer is not
|
||||
* referenced by any other buffers. |fb| is guaranteed to not be NULL. On
|
||||
* success the callback must return 0. Any failure the callback must return
|
||||
* a value less than 0.
|
||||
*
|
||||
* \param[in] priv Callback's private data
|
||||
* \param[in] fb Pointer to vpx_codec_frame_buffer_t
|
||||
*/
|
||||
typedef int (*vpx_release_frame_buffer_cb_fn_t)(void *priv,
|
||||
vpx_codec_frame_buffer_t *fb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VPX_FRAME_BUFFER_H_
|
||||
207
vpx-encoder/android_libs/arm64-v8a/include/vpx/vpx_image.h
Normal file
207
vpx-encoder/android_libs/arm64-v8a/include/vpx/vpx_image.h
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the vpx image descriptor and associated operations
|
||||
*
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_IMAGE_H_
|
||||
#define VPX_VPX_VPX_IMAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_IMAGE_ABI_VERSION (5) /**<\hideinitializer*/
|
||||
|
||||
#define VPX_IMG_FMT_PLANAR 0x100 /**< Image is a planar format. */
|
||||
#define VPX_IMG_FMT_UV_FLIP 0x200 /**< V plane precedes U in memory. */
|
||||
#define VPX_IMG_FMT_HAS_ALPHA 0x400 /**< Image has an alpha channel. */
|
||||
#define VPX_IMG_FMT_HIGHBITDEPTH 0x800 /**< Image uses 16bit framebuffer. */
|
||||
|
||||
/*!\brief List of supported image formats */
|
||||
typedef enum vpx_img_fmt {
|
||||
VPX_IMG_FMT_NONE,
|
||||
VPX_IMG_FMT_YV12 =
|
||||
VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
|
||||
VPX_IMG_FMT_I420 = VPX_IMG_FMT_PLANAR | 2,
|
||||
VPX_IMG_FMT_I422 = VPX_IMG_FMT_PLANAR | 5,
|
||||
VPX_IMG_FMT_I444 = VPX_IMG_FMT_PLANAR | 6,
|
||||
VPX_IMG_FMT_I440 = VPX_IMG_FMT_PLANAR | 7,
|
||||
VPX_IMG_FMT_I42016 = VPX_IMG_FMT_I420 | VPX_IMG_FMT_HIGHBITDEPTH,
|
||||
VPX_IMG_FMT_I42216 = VPX_IMG_FMT_I422 | VPX_IMG_FMT_HIGHBITDEPTH,
|
||||
VPX_IMG_FMT_I44416 = VPX_IMG_FMT_I444 | VPX_IMG_FMT_HIGHBITDEPTH,
|
||||
VPX_IMG_FMT_I44016 = VPX_IMG_FMT_I440 | VPX_IMG_FMT_HIGHBITDEPTH
|
||||
} vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
|
||||
|
||||
/*!\brief List of supported color spaces */
|
||||
typedef enum vpx_color_space {
|
||||
VPX_CS_UNKNOWN = 0, /**< Unknown */
|
||||
VPX_CS_BT_601 = 1, /**< BT.601 */
|
||||
VPX_CS_BT_709 = 2, /**< BT.709 */
|
||||
VPX_CS_SMPTE_170 = 3, /**< SMPTE.170 */
|
||||
VPX_CS_SMPTE_240 = 4, /**< SMPTE.240 */
|
||||
VPX_CS_BT_2020 = 5, /**< BT.2020 */
|
||||
VPX_CS_RESERVED = 6, /**< Reserved */
|
||||
VPX_CS_SRGB = 7 /**< sRGB */
|
||||
} vpx_color_space_t; /**< alias for enum vpx_color_space */
|
||||
|
||||
/*!\brief List of supported color range */
|
||||
typedef enum vpx_color_range {
|
||||
VPX_CR_STUDIO_RANGE = 0, /**< Y [16..235], UV [16..240] */
|
||||
VPX_CR_FULL_RANGE = 1 /**< YUV/RGB [0..255] */
|
||||
} vpx_color_range_t; /**< alias for enum vpx_color_range */
|
||||
|
||||
/**\brief Image Descriptor */
|
||||
typedef struct vpx_image {
|
||||
vpx_img_fmt_t fmt; /**< Image Format */
|
||||
vpx_color_space_t cs; /**< Color Space */
|
||||
vpx_color_range_t range; /**< Color Range */
|
||||
|
||||
/* Image storage dimensions */
|
||||
unsigned int w; /**< Stored image width */
|
||||
unsigned int h; /**< Stored image height */
|
||||
unsigned int bit_depth; /**< Stored image bit-depth */
|
||||
|
||||
/* Image display dimensions */
|
||||
unsigned int d_w; /**< Displayed image width */
|
||||
unsigned int d_h; /**< Displayed image height */
|
||||
|
||||
/* Image intended rendering dimensions */
|
||||
unsigned int r_w; /**< Intended rendering image width */
|
||||
unsigned int r_h; /**< Intended rendering image height */
|
||||
|
||||
/* Chroma subsampling info */
|
||||
unsigned int x_chroma_shift; /**< subsampling order, X */
|
||||
unsigned int y_chroma_shift; /**< subsampling order, Y */
|
||||
|
||||
/* Image data pointers. */
|
||||
#define VPX_PLANE_PACKED 0 /**< To be used for all packed formats */
|
||||
#define VPX_PLANE_Y 0 /**< Y (Luminance) plane */
|
||||
#define VPX_PLANE_U 1 /**< U (Chroma) plane */
|
||||
#define VPX_PLANE_V 2 /**< V (Chroma) plane */
|
||||
#define VPX_PLANE_ALPHA 3 /**< A (Transparency) plane */
|
||||
unsigned char *planes[4]; /**< pointer to the top left pixel for each plane */
|
||||
int stride[4]; /**< stride between rows for each plane */
|
||||
|
||||
int bps; /**< bits per sample (for packed formats) */
|
||||
|
||||
/*!\brief The following member may be set by the application to associate
|
||||
* data with this image.
|
||||
*/
|
||||
void *user_priv;
|
||||
|
||||
/* The following members should be treated as private. */
|
||||
unsigned char *img_data; /**< private */
|
||||
int img_data_owner; /**< private */
|
||||
int self_allocd; /**< private */
|
||||
|
||||
void *fb_priv; /**< Frame buffer data associated with the image. */
|
||||
} vpx_image_t; /**< alias for struct vpx_image */
|
||||
|
||||
/**\brief Representation of a rectangle on a surface */
|
||||
typedef struct vpx_image_rect {
|
||||
unsigned int x; /**< leftmost column */
|
||||
unsigned int y; /**< topmost row */
|
||||
unsigned int w; /**< width */
|
||||
unsigned int h; /**< height */
|
||||
} vpx_image_rect_t; /**< alias for struct vpx_image_rect */
|
||||
|
||||
/*!\brief Open a descriptor, allocating storage for the underlying image
|
||||
*
|
||||
* Returns a descriptor for storing an image of the given format. The
|
||||
* storage for the descriptor is allocated on the heap.
|
||||
*
|
||||
* \param[in] img Pointer to storage for descriptor. If this parameter
|
||||
* is NULL, the storage for the descriptor will be
|
||||
* allocated on the heap.
|
||||
* \param[in] fmt Format for the image
|
||||
* \param[in] d_w Width of the image
|
||||
* \param[in] d_h Height of the image
|
||||
* \param[in] align Alignment, in bytes, of the image buffer and
|
||||
* each row in the image(stride).
|
||||
*
|
||||
* \return Returns a pointer to the initialized image descriptor. If the img
|
||||
* parameter is non-null, the value of the img parameter will be
|
||||
* returned.
|
||||
*/
|
||||
vpx_image_t *vpx_img_alloc(vpx_image_t *img, vpx_img_fmt_t fmt,
|
||||
unsigned int d_w, unsigned int d_h,
|
||||
unsigned int align);
|
||||
|
||||
/*!\brief Open a descriptor, using existing storage for the underlying image
|
||||
*
|
||||
* Returns a descriptor for storing an image of the given format. The
|
||||
* storage for descriptor has been allocated elsewhere, and a descriptor is
|
||||
* desired to "wrap" that storage.
|
||||
*
|
||||
* \param[in] img Pointer to storage for descriptor. If this
|
||||
* parameter is NULL, the storage for the descriptor
|
||||
* will be allocated on the heap.
|
||||
* \param[in] fmt Format for the image
|
||||
* \param[in] d_w Width of the image
|
||||
* \param[in] d_h Height of the image
|
||||
* \param[in] stride_align Alignment, in bytes, of each row in the image.
|
||||
* \param[in] img_data Storage to use for the image
|
||||
*
|
||||
* \return Returns a pointer to the initialized image descriptor. If the img
|
||||
* parameter is non-null, the value of the img parameter will be
|
||||
* returned.
|
||||
*/
|
||||
vpx_image_t *vpx_img_wrap(vpx_image_t *img, vpx_img_fmt_t fmt, unsigned int d_w,
|
||||
unsigned int d_h, unsigned int stride_align,
|
||||
unsigned char *img_data);
|
||||
|
||||
/*!\brief Set the rectangle identifying the displayed portion of the image
|
||||
*
|
||||
* Updates the displayed rectangle (aka viewport) on the image surface to
|
||||
* match the specified coordinates and size.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
* \param[in] x leftmost column
|
||||
* \param[in] y topmost row
|
||||
* \param[in] w width
|
||||
* \param[in] h height
|
||||
*
|
||||
* \return 0 if the requested rectangle is valid, nonzero otherwise.
|
||||
*/
|
||||
int vpx_img_set_rect(vpx_image_t *img, unsigned int x, unsigned int y,
|
||||
unsigned int w, unsigned int h);
|
||||
|
||||
/*!\brief Flip the image vertically (top for bottom)
|
||||
*
|
||||
* Adjusts the image descriptor's pointers and strides to make the image
|
||||
* be referenced upside-down.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
*/
|
||||
void vpx_img_flip(vpx_image_t *img);
|
||||
|
||||
/*!\brief Close an image descriptor
|
||||
*
|
||||
* Frees all allocated storage associated with an image descriptor.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
*/
|
||||
void vpx_img_free(vpx_image_t *img);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VPX_IMAGE_H_
|
||||
40
vpx-encoder/android_libs/arm64-v8a/include/vpx/vpx_integer.h
Normal file
40
vpx-encoder/android_libs/arm64-v8a/include/vpx/vpx_integer.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef VPX_VPX_VPX_INTEGER_H_
|
||||
#define VPX_VPX_VPX_INTEGER_H_
|
||||
|
||||
/* get ptrdiff_t, size_t, wchar_t, NULL */
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define VPX_FORCE_INLINE __forceinline
|
||||
#define VPX_INLINE __inline
|
||||
#else
|
||||
#define VPX_FORCE_INLINE __inline__ __attribute__((always_inline))
|
||||
// TODO(jbb): Allow a way to force inline off for older compilers.
|
||||
#define VPX_INLINE inline
|
||||
#endif
|
||||
|
||||
/* Assume platforms have the C99 standard integer types. */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#if !defined(__STDC_FORMAT_MACROS)
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#endif
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
#define __STDC_LIMIT_MACROS
|
||||
#endif
|
||||
#endif // __cplusplus
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#endif // VPX_VPX_VPX_INTEGER_H_
|
||||
BIN
vpx-encoder/android_libs/arm64-v8a/lib/libvpx.a
Normal file
BIN
vpx-encoder/android_libs/arm64-v8a/lib/libvpx.a
Normal file
Binary file not shown.
14
vpx-encoder/android_libs/arm64-v8a/lib/pkgconfig/vpx.pc
Normal file
14
vpx-encoder/android_libs/arm64-v8a/lib/pkgconfig/vpx.pc
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# pkg-config file from libvpx v1.8.0
|
||||
prefix=/Users/andy/go/src/github.com/webmproject/jni/vpx-android/output/android/arm64-v8a
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: vpx
|
||||
Description: WebM Project VPx codec implementation
|
||||
Version: 1.8.0
|
||||
Requires:
|
||||
Conflicts:
|
||||
Libs: -L${libdir} -lvpx -lm
|
||||
Libs.private: -lm
|
||||
Cflags: -I${includedir}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright (c) 2016 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
#ifndef LIBWEBM_COMMON_FILE_UTIL_H_
|
||||
#define LIBWEBM_COMMON_FILE_UTIL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "mkvmuxer/mkvmuxertypes.h" // LIBWEBM_DISALLOW_COPY_AND_ASSIGN()
|
||||
|
||||
namespace libwebm {
|
||||
|
||||
// Returns a temporary file name.
|
||||
std::string GetTempFileName();
|
||||
|
||||
// Returns size of file specified by |file_name|, or 0 upon failure.
|
||||
uint64_t GetFileSize(const std::string& file_name);
|
||||
|
||||
// Gets the contents file_name as a string. Returns false on error.
|
||||
bool GetFileContents(const std::string& file_name, std::string* contents);
|
||||
|
||||
// Manages life of temporary file specified at time of construction. Deletes
|
||||
// file upon destruction.
|
||||
class TempFileDeleter {
|
||||
public:
|
||||
TempFileDeleter();
|
||||
explicit TempFileDeleter(std::string file_name) : file_name_(file_name) {}
|
||||
~TempFileDeleter();
|
||||
const std::string& name() const { return file_name_; }
|
||||
|
||||
private:
|
||||
std::string file_name_;
|
||||
LIBWEBM_DISALLOW_COPY_AND_ASSIGN(TempFileDeleter);
|
||||
};
|
||||
|
||||
} // namespace libwebm
|
||||
|
||||
#endif // LIBWEBM_COMMON_FILE_UTIL_H_
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
// Copyright (c) 2016 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
#ifndef LIBWEBM_COMMON_HDR_UTIL_H_
|
||||
#define LIBWEBM_COMMON_HDR_UTIL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "mkvmuxer/mkvmuxer.h"
|
||||
|
||||
namespace mkvparser {
|
||||
struct Colour;
|
||||
struct MasteringMetadata;
|
||||
struct PrimaryChromaticity;
|
||||
} // namespace mkvparser
|
||||
|
||||
namespace libwebm {
|
||||
// Utility types and functions for working with the Colour element and its
|
||||
// children. Copiers return true upon success. Presence functions return true
|
||||
// when the specified element is present.
|
||||
|
||||
// TODO(tomfinegan): These should be moved to libwebm_utils once c++11 is
|
||||
// required by libwebm.
|
||||
|
||||
// Features of the VP9 codec that may be set in the CodecPrivate of a VP9 video
|
||||
// stream. A value of kValueNotPresent represents that the value was not set in
|
||||
// the CodecPrivate.
|
||||
struct Vp9CodecFeatures {
|
||||
static const int kValueNotPresent;
|
||||
|
||||
Vp9CodecFeatures()
|
||||
: profile(kValueNotPresent),
|
||||
level(kValueNotPresent),
|
||||
bit_depth(kValueNotPresent),
|
||||
chroma_subsampling(kValueNotPresent) {}
|
||||
~Vp9CodecFeatures() {}
|
||||
|
||||
int profile;
|
||||
int level;
|
||||
int bit_depth;
|
||||
int chroma_subsampling;
|
||||
};
|
||||
|
||||
typedef std::unique_ptr<mkvmuxer::PrimaryChromaticity> PrimaryChromaticityPtr;
|
||||
|
||||
bool CopyPrimaryChromaticity(const mkvparser::PrimaryChromaticity& parser_pc,
|
||||
PrimaryChromaticityPtr* muxer_pc);
|
||||
|
||||
bool MasteringMetadataValuePresent(double value);
|
||||
|
||||
bool CopyMasteringMetadata(const mkvparser::MasteringMetadata& parser_mm,
|
||||
mkvmuxer::MasteringMetadata* muxer_mm);
|
||||
|
||||
bool ColourValuePresent(long long value);
|
||||
|
||||
bool CopyColour(const mkvparser::Colour& parser_colour,
|
||||
mkvmuxer::Colour* muxer_colour);
|
||||
|
||||
// Returns true if |features| is set to one or more valid values.
|
||||
bool ParseVpxCodecPrivate(const uint8_t* private_data, int32_t length,
|
||||
Vp9CodecFeatures* features);
|
||||
|
||||
} // namespace libwebm
|
||||
|
||||
#endif // LIBWEBM_COMMON_HDR_UTIL_H_
|
||||
193
vpx-encoder/android_libs/armeabi-v7a/include/common/webmids.h
Normal file
193
vpx-encoder/android_libs/armeabi-v7a/include/common/webmids.h
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
#ifndef COMMON_WEBMIDS_H_
|
||||
#define COMMON_WEBMIDS_H_
|
||||
|
||||
namespace libwebm {
|
||||
|
||||
enum MkvId {
|
||||
kMkvEBML = 0x1A45DFA3,
|
||||
kMkvEBMLVersion = 0x4286,
|
||||
kMkvEBMLReadVersion = 0x42F7,
|
||||
kMkvEBMLMaxIDLength = 0x42F2,
|
||||
kMkvEBMLMaxSizeLength = 0x42F3,
|
||||
kMkvDocType = 0x4282,
|
||||
kMkvDocTypeVersion = 0x4287,
|
||||
kMkvDocTypeReadVersion = 0x4285,
|
||||
kMkvVoid = 0xEC,
|
||||
kMkvSignatureSlot = 0x1B538667,
|
||||
kMkvSignatureAlgo = 0x7E8A,
|
||||
kMkvSignatureHash = 0x7E9A,
|
||||
kMkvSignaturePublicKey = 0x7EA5,
|
||||
kMkvSignature = 0x7EB5,
|
||||
kMkvSignatureElements = 0x7E5B,
|
||||
kMkvSignatureElementList = 0x7E7B,
|
||||
kMkvSignedElement = 0x6532,
|
||||
// segment
|
||||
kMkvSegment = 0x18538067,
|
||||
// Meta Seek Information
|
||||
kMkvSeekHead = 0x114D9B74,
|
||||
kMkvSeek = 0x4DBB,
|
||||
kMkvSeekID = 0x53AB,
|
||||
kMkvSeekPosition = 0x53AC,
|
||||
// Segment Information
|
||||
kMkvInfo = 0x1549A966,
|
||||
kMkvTimecodeScale = 0x2AD7B1,
|
||||
kMkvDuration = 0x4489,
|
||||
kMkvDateUTC = 0x4461,
|
||||
kMkvTitle = 0x7BA9,
|
||||
kMkvMuxingApp = 0x4D80,
|
||||
kMkvWritingApp = 0x5741,
|
||||
// Cluster
|
||||
kMkvCluster = 0x1F43B675,
|
||||
kMkvTimecode = 0xE7,
|
||||
kMkvPrevSize = 0xAB,
|
||||
kMkvBlockGroup = 0xA0,
|
||||
kMkvBlock = 0xA1,
|
||||
kMkvBlockDuration = 0x9B,
|
||||
kMkvReferenceBlock = 0xFB,
|
||||
kMkvLaceNumber = 0xCC,
|
||||
kMkvSimpleBlock = 0xA3,
|
||||
kMkvBlockAdditions = 0x75A1,
|
||||
kMkvBlockMore = 0xA6,
|
||||
kMkvBlockAddID = 0xEE,
|
||||
kMkvBlockAdditional = 0xA5,
|
||||
kMkvDiscardPadding = 0x75A2,
|
||||
// Track
|
||||
kMkvTracks = 0x1654AE6B,
|
||||
kMkvTrackEntry = 0xAE,
|
||||
kMkvTrackNumber = 0xD7,
|
||||
kMkvTrackUID = 0x73C5,
|
||||
kMkvTrackType = 0x83,
|
||||
kMkvFlagEnabled = 0xB9,
|
||||
kMkvFlagDefault = 0x88,
|
||||
kMkvFlagForced = 0x55AA,
|
||||
kMkvFlagLacing = 0x9C,
|
||||
kMkvDefaultDuration = 0x23E383,
|
||||
kMkvMaxBlockAdditionID = 0x55EE,
|
||||
kMkvName = 0x536E,
|
||||
kMkvLanguage = 0x22B59C,
|
||||
kMkvCodecID = 0x86,
|
||||
kMkvCodecPrivate = 0x63A2,
|
||||
kMkvCodecName = 0x258688,
|
||||
kMkvCodecDelay = 0x56AA,
|
||||
kMkvSeekPreRoll = 0x56BB,
|
||||
// video
|
||||
kMkvVideo = 0xE0,
|
||||
kMkvFlagInterlaced = 0x9A,
|
||||
kMkvStereoMode = 0x53B8,
|
||||
kMkvAlphaMode = 0x53C0,
|
||||
kMkvPixelWidth = 0xB0,
|
||||
kMkvPixelHeight = 0xBA,
|
||||
kMkvPixelCropBottom = 0x54AA,
|
||||
kMkvPixelCropTop = 0x54BB,
|
||||
kMkvPixelCropLeft = 0x54CC,
|
||||
kMkvPixelCropRight = 0x54DD,
|
||||
kMkvDisplayWidth = 0x54B0,
|
||||
kMkvDisplayHeight = 0x54BA,
|
||||
kMkvDisplayUnit = 0x54B2,
|
||||
kMkvAspectRatioType = 0x54B3,
|
||||
kMkvColourSpace = 0x2EB524,
|
||||
kMkvFrameRate = 0x2383E3,
|
||||
// end video
|
||||
// colour
|
||||
kMkvColour = 0x55B0,
|
||||
kMkvMatrixCoefficients = 0x55B1,
|
||||
kMkvBitsPerChannel = 0x55B2,
|
||||
kMkvChromaSubsamplingHorz = 0x55B3,
|
||||
kMkvChromaSubsamplingVert = 0x55B4,
|
||||
kMkvCbSubsamplingHorz = 0x55B5,
|
||||
kMkvCbSubsamplingVert = 0x55B6,
|
||||
kMkvChromaSitingHorz = 0x55B7,
|
||||
kMkvChromaSitingVert = 0x55B8,
|
||||
kMkvRange = 0x55B9,
|
||||
kMkvTransferCharacteristics = 0x55BA,
|
||||
kMkvPrimaries = 0x55BB,
|
||||
kMkvMaxCLL = 0x55BC,
|
||||
kMkvMaxFALL = 0x55BD,
|
||||
// mastering metadata
|
||||
kMkvMasteringMetadata = 0x55D0,
|
||||
kMkvPrimaryRChromaticityX = 0x55D1,
|
||||
kMkvPrimaryRChromaticityY = 0x55D2,
|
||||
kMkvPrimaryGChromaticityX = 0x55D3,
|
||||
kMkvPrimaryGChromaticityY = 0x55D4,
|
||||
kMkvPrimaryBChromaticityX = 0x55D5,
|
||||
kMkvPrimaryBChromaticityY = 0x55D6,
|
||||
kMkvWhitePointChromaticityX = 0x55D7,
|
||||
kMkvWhitePointChromaticityY = 0x55D8,
|
||||
kMkvLuminanceMax = 0x55D9,
|
||||
kMkvLuminanceMin = 0x55DA,
|
||||
// end mastering metadata
|
||||
// end colour
|
||||
// projection
|
||||
kMkvProjection = 0x7670,
|
||||
kMkvProjectionType = 0x7671,
|
||||
kMkvProjectionPrivate = 0x7672,
|
||||
kMkvProjectionPoseYaw = 0x7673,
|
||||
kMkvProjectionPosePitch = 0x7674,
|
||||
kMkvProjectionPoseRoll = 0x7675,
|
||||
// end projection
|
||||
// audio
|
||||
kMkvAudio = 0xE1,
|
||||
kMkvSamplingFrequency = 0xB5,
|
||||
kMkvOutputSamplingFrequency = 0x78B5,
|
||||
kMkvChannels = 0x9F,
|
||||
kMkvBitDepth = 0x6264,
|
||||
// end audio
|
||||
// ContentEncodings
|
||||
kMkvContentEncodings = 0x6D80,
|
||||
kMkvContentEncoding = 0x6240,
|
||||
kMkvContentEncodingOrder = 0x5031,
|
||||
kMkvContentEncodingScope = 0x5032,
|
||||
kMkvContentEncodingType = 0x5033,
|
||||
kMkvContentCompression = 0x5034,
|
||||
kMkvContentCompAlgo = 0x4254,
|
||||
kMkvContentCompSettings = 0x4255,
|
||||
kMkvContentEncryption = 0x5035,
|
||||
kMkvContentEncAlgo = 0x47E1,
|
||||
kMkvContentEncKeyID = 0x47E2,
|
||||
kMkvContentSignature = 0x47E3,
|
||||
kMkvContentSigKeyID = 0x47E4,
|
||||
kMkvContentSigAlgo = 0x47E5,
|
||||
kMkvContentSigHashAlgo = 0x47E6,
|
||||
kMkvContentEncAESSettings = 0x47E7,
|
||||
kMkvAESSettingsCipherMode = 0x47E8,
|
||||
kMkvAESSettingsCipherInitData = 0x47E9,
|
||||
// end ContentEncodings
|
||||
// Cueing Data
|
||||
kMkvCues = 0x1C53BB6B,
|
||||
kMkvCuePoint = 0xBB,
|
||||
kMkvCueTime = 0xB3,
|
||||
kMkvCueTrackPositions = 0xB7,
|
||||
kMkvCueTrack = 0xF7,
|
||||
kMkvCueClusterPosition = 0xF1,
|
||||
kMkvCueBlockNumber = 0x5378,
|
||||
// Chapters
|
||||
kMkvChapters = 0x1043A770,
|
||||
kMkvEditionEntry = 0x45B9,
|
||||
kMkvChapterAtom = 0xB6,
|
||||
kMkvChapterUID = 0x73C4,
|
||||
kMkvChapterStringUID = 0x5654,
|
||||
kMkvChapterTimeStart = 0x91,
|
||||
kMkvChapterTimeEnd = 0x92,
|
||||
kMkvChapterDisplay = 0x80,
|
||||
kMkvChapString = 0x85,
|
||||
kMkvChapLanguage = 0x437C,
|
||||
kMkvChapCountry = 0x437E,
|
||||
// Tags
|
||||
kMkvTags = 0x1254C367,
|
||||
kMkvTag = 0x7373,
|
||||
kMkvSimpleTag = 0x67C8,
|
||||
kMkvTagName = 0x45A3,
|
||||
kMkvTagString = 0x4487
|
||||
};
|
||||
|
||||
} // namespace libwebm
|
||||
|
||||
#endif // COMMON_WEBMIDS_H_
|
||||
1924
vpx-encoder/android_libs/armeabi-v7a/include/mkvmuxer/mkvmuxer.h
Normal file
1924
vpx-encoder/android_libs/armeabi-v7a/include/mkvmuxer/mkvmuxer.h
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
#ifndef MKVMUXER_MKVMUXERTYPES_H_
|
||||
#define MKVMUXER_MKVMUXERTYPES_H_
|
||||
|
||||
namespace mkvmuxer {
|
||||
typedef unsigned char uint8;
|
||||
typedef short int16;
|
||||
typedef int int32;
|
||||
typedef unsigned int uint32;
|
||||
typedef long long int64;
|
||||
typedef unsigned long long uint64;
|
||||
} // namespace mkvmuxer
|
||||
|
||||
// Copied from Chromium basictypes.h
|
||||
// A macro to disallow the copy constructor and operator= functions
|
||||
// This should be used in the private: declarations for a class
|
||||
#define LIBWEBM_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
TypeName(const TypeName&); \
|
||||
void operator=(const TypeName&)
|
||||
|
||||
#endif // MKVMUXER_MKVMUXERTYPES_HPP_
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
#ifndef MKVMUXER_MKVMUXERUTIL_H_
|
||||
#define MKVMUXER_MKVMUXERUTIL_H_
|
||||
|
||||
#include "mkvmuxertypes.h"
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
namespace mkvmuxer {
|
||||
class Cluster;
|
||||
class Frame;
|
||||
class IMkvWriter;
|
||||
|
||||
// TODO(tomfinegan): mkvmuxer:: integer types continue to be used here because
|
||||
// changing them causes pain for downstream projects. It would be nice if a
|
||||
// solution that allows removal of the mkvmuxer:: integer types while avoiding
|
||||
// pain for downstream users of libwebm. Considering that mkvmuxerutil.{cc,h}
|
||||
// are really, for the great majority of cases, EBML size calculation and writer
|
||||
// functions, perhaps a more EBML focused utility would be the way to go as a
|
||||
// first step.
|
||||
|
||||
const uint64 kEbmlUnknownValue = 0x01FFFFFFFFFFFFFFULL;
|
||||
const int64 kMaxBlockTimecode = 0x07FFFLL;
|
||||
|
||||
// Writes out |value| in Big Endian order. Returns 0 on success.
|
||||
int32 SerializeInt(IMkvWriter* writer, int64 value, int32 size);
|
||||
|
||||
// Returns the size in bytes of the element.
|
||||
int32 GetUIntSize(uint64 value);
|
||||
int32 GetIntSize(int64 value);
|
||||
int32 GetCodedUIntSize(uint64 value);
|
||||
uint64 EbmlMasterElementSize(uint64 type, uint64 value);
|
||||
uint64 EbmlElementSize(uint64 type, int64 value);
|
||||
uint64 EbmlElementSize(uint64 type, uint64 value);
|
||||
uint64 EbmlElementSize(uint64 type, float value);
|
||||
uint64 EbmlElementSize(uint64 type, const char* value);
|
||||
uint64 EbmlElementSize(uint64 type, const uint8* value, uint64 size);
|
||||
uint64 EbmlDateElementSize(uint64 type);
|
||||
|
||||
// Returns the size in bytes of the element assuming that the element was
|
||||
// written using |fixed_size| bytes. If |fixed_size| is set to zero, then it
|
||||
// computes the necessary number of bytes based on |value|.
|
||||
uint64 EbmlElementSize(uint64 type, uint64 value, uint64 fixed_size);
|
||||
|
||||
// Creates an EBML coded number from |value| and writes it out. The size of
|
||||
// the coded number is determined by the value of |value|. |value| must not
|
||||
// be in a coded form. Returns 0 on success.
|
||||
int32 WriteUInt(IMkvWriter* writer, uint64 value);
|
||||
|
||||
// Creates an EBML coded number from |value| and writes it out. The size of
|
||||
// the coded number is determined by the value of |size|. |value| must not
|
||||
// be in a coded form. Returns 0 on success.
|
||||
int32 WriteUIntSize(IMkvWriter* writer, uint64 value, int32 size);
|
||||
|
||||
// Output an Mkv master element. Returns true if the element was written.
|
||||
bool WriteEbmlMasterElement(IMkvWriter* writer, uint64 value, uint64 size);
|
||||
|
||||
// Outputs an Mkv ID, calls |IMkvWriter::ElementStartNotify|, and passes the
|
||||
// ID to |SerializeInt|. Returns 0 on success.
|
||||
int32 WriteID(IMkvWriter* writer, uint64 type);
|
||||
|
||||
// Output an Mkv non-master element. Returns true if the element was written.
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, uint64 value);
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, int64 value);
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, float value);
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const char* value);
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const uint8* value,
|
||||
uint64 size);
|
||||
bool WriteEbmlDateElement(IMkvWriter* writer, uint64 type, int64 value);
|
||||
|
||||
// Output an Mkv non-master element using fixed size. The element will be
|
||||
// written out using exactly |fixed_size| bytes. If |fixed_size| is set to zero
|
||||
// then it computes the necessary number of bytes based on |value|. Returns true
|
||||
// if the element was written.
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, uint64 value,
|
||||
uint64 fixed_size);
|
||||
|
||||
// Output a Mkv Frame. It decides the correct element to write (Block vs
|
||||
// SimpleBlock) based on the parameters of the Frame.
|
||||
uint64 WriteFrame(IMkvWriter* writer, const Frame* const frame,
|
||||
Cluster* cluster);
|
||||
|
||||
// Output a void element. |size| must be the entire size in bytes that will be
|
||||
// void. The function will calculate the size of the void header and subtract
|
||||
// it from |size|.
|
||||
uint64 WriteVoidElement(IMkvWriter* writer, uint64 size);
|
||||
|
||||
// Returns the version number of the muxer in |major|, |minor|, |build|,
|
||||
// and |revision|.
|
||||
void GetVersion(int32* major, int32* minor, int32* build, int32* revision);
|
||||
|
||||
// Returns a random number to be used for UID, using |seed| to seed
|
||||
// the random-number generator (see POSIX rand_r() for semantics).
|
||||
uint64 MakeUID(unsigned int* seed);
|
||||
|
||||
// Colour field validation helpers. All return true when |value| is valid.
|
||||
bool IsMatrixCoefficientsValueValid(uint64_t value);
|
||||
bool IsChromaSitingHorzValueValid(uint64_t value);
|
||||
bool IsChromaSitingVertValueValid(uint64_t value);
|
||||
bool IsColourRangeValueValid(uint64_t value);
|
||||
bool IsTransferCharacteristicsValueValid(uint64_t value);
|
||||
bool IsPrimariesValueValid(uint64_t value);
|
||||
|
||||
} // namespace mkvmuxer
|
||||
|
||||
#endif // MKVMUXER_MKVMUXERUTIL_H_
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
#ifndef MKVMUXER_MKVWRITER_H_
|
||||
#define MKVMUXER_MKVWRITER_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mkvmuxer/mkvmuxer.h"
|
||||
#include "mkvmuxer/mkvmuxertypes.h"
|
||||
|
||||
namespace mkvmuxer {
|
||||
|
||||
// Default implementation of the IMkvWriter interface on Windows.
|
||||
class MkvWriter : public IMkvWriter {
|
||||
public:
|
||||
MkvWriter();
|
||||
explicit MkvWriter(FILE* fp);
|
||||
virtual ~MkvWriter();
|
||||
|
||||
// IMkvWriter interface
|
||||
virtual int64 Position() const;
|
||||
virtual int32 Position(int64 position);
|
||||
virtual bool Seekable() const;
|
||||
virtual int32 Write(const void* buffer, uint32 length);
|
||||
virtual void ElementStartNotify(uint64 element_id, int64 position);
|
||||
|
||||
// Creates and opens a file for writing. |filename| is the name of the file
|
||||
// to open. This function will overwrite the contents of |filename|. Returns
|
||||
// true on success.
|
||||
bool Open(const char* filename);
|
||||
|
||||
// Closes an opened file.
|
||||
void Close();
|
||||
|
||||
private:
|
||||
// File handle to output file.
|
||||
FILE* file_;
|
||||
bool writer_owns_file_;
|
||||
|
||||
LIBWEBM_DISALLOW_COPY_AND_ASSIGN(MkvWriter);
|
||||
};
|
||||
|
||||
} // namespace mkvmuxer
|
||||
|
||||
#endif // MKVMUXER_MKVWRITER_H_
|
||||
1147
vpx-encoder/android_libs/armeabi-v7a/include/mkvparser/mkvparser.h
Normal file
1147
vpx-encoder/android_libs/armeabi-v7a/include/mkvparser/mkvparser.h
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
#ifndef MKVPARSER_MKVREADER_H_
|
||||
#define MKVPARSER_MKVREADER_H_
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "mkvparser/mkvparser.h"
|
||||
|
||||
namespace mkvparser {
|
||||
|
||||
class MkvReader : public IMkvReader {
|
||||
public:
|
||||
MkvReader();
|
||||
explicit MkvReader(FILE* fp);
|
||||
virtual ~MkvReader();
|
||||
|
||||
int Open(const char*);
|
||||
void Close();
|
||||
|
||||
virtual int Read(long long position, long length, unsigned char* buffer);
|
||||
virtual int Length(long long* total, long long* available);
|
||||
|
||||
private:
|
||||
MkvReader(const MkvReader&);
|
||||
MkvReader& operator=(const MkvReader&);
|
||||
|
||||
// Determines the size of the file. This is called either by the constructor
|
||||
// or by the Open function depending on file ownership. Returns true on
|
||||
// success.
|
||||
bool GetFileSize();
|
||||
|
||||
long long m_length;
|
||||
FILE* m_file;
|
||||
bool reader_owns_file_;
|
||||
};
|
||||
|
||||
} // namespace mkvparser
|
||||
|
||||
#endif // MKVPARSER_MKVREADER_H_
|
||||
136
vpx-encoder/android_libs/armeabi-v7a/include/vpx/vp8.h
Normal file
136
vpx-encoder/android_libs/armeabi-v7a/include/vpx/vp8.h
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\defgroup vp8 VP8
|
||||
* \ingroup codecs
|
||||
* VP8 is a video compression algorithm that uses motion
|
||||
* compensated prediction, Discrete Cosine Transform (DCT) coding of the
|
||||
* prediction error signal and context dependent entropy coding techniques
|
||||
* based on arithmetic principles. It features:
|
||||
* - YUV 4:2:0 image format
|
||||
* - Macro-block based coding (16x16 luma plus two 8x8 chroma)
|
||||
* - 1/4 (1/8) pixel accuracy motion compensated prediction
|
||||
* - 4x4 DCT transform
|
||||
* - 128 level linear quantizer
|
||||
* - In loop deblocking filter
|
||||
* - Context-based entropy coding
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*!\file
|
||||
* \brief Provides controls common to both the VP8 encoder and decoder.
|
||||
*/
|
||||
#ifndef VPX_VPX_VP8_H_
|
||||
#define VPX_VPX_VP8_H_
|
||||
|
||||
#include "./vpx_codec.h"
|
||||
#include "./vpx_image.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!\brief Control functions
|
||||
*
|
||||
* The set of macros define the control functions of VP8 interface
|
||||
*/
|
||||
enum vp8_com_control_id {
|
||||
/*!\brief pass in an external frame into decoder to be used as reference frame
|
||||
*/
|
||||
VP8_SET_REFERENCE = 1,
|
||||
VP8_COPY_REFERENCE = 2, /**< get a copy of reference frame from the decoder */
|
||||
VP8_SET_POSTPROC = 3, /**< set the decoder's post processing settings */
|
||||
|
||||
/* TODO(jkoleszar): The encoder incorrectly reuses some of these values (5+)
|
||||
* for its control ids. These should be migrated to something like the
|
||||
* VP8_DECODER_CTRL_ID_START range next time we're ready to break the ABI.
|
||||
*/
|
||||
VP9_GET_REFERENCE = 128, /**< get a pointer to a reference frame */
|
||||
VP8_COMMON_CTRL_ID_MAX,
|
||||
VP8_DECODER_CTRL_ID_START = 256
|
||||
};
|
||||
|
||||
/*!\brief post process flags
|
||||
*
|
||||
* The set of macros define VP8 decoder post processing flags
|
||||
*/
|
||||
enum vp8_postproc_level {
|
||||
VP8_NOFILTERING = 0,
|
||||
VP8_DEBLOCK = 1 << 0,
|
||||
VP8_DEMACROBLOCK = 1 << 1,
|
||||
VP8_ADDNOISE = 1 << 2,
|
||||
VP8_MFQE = 1 << 3
|
||||
};
|
||||
|
||||
/*!\brief post process flags
|
||||
*
|
||||
* This define a structure that describe the post processing settings. For
|
||||
* the best objective measure (using the PSNR metric) set post_proc_flag
|
||||
* to VP8_DEBLOCK and deblocking_level to 1.
|
||||
*/
|
||||
|
||||
typedef struct vp8_postproc_cfg {
|
||||
/*!\brief the types of post processing to be done, should be combination of
|
||||
* "vp8_postproc_level" */
|
||||
int post_proc_flag;
|
||||
int deblocking_level; /**< the strength of deblocking, valid range [0, 16] */
|
||||
int noise_level; /**< the strength of additive noise, valid range [0, 16] */
|
||||
} vp8_postproc_cfg_t;
|
||||
|
||||
/*!\brief reference frame type
|
||||
*
|
||||
* The set of macros define the type of VP8 reference frames
|
||||
*/
|
||||
typedef enum vpx_ref_frame_type {
|
||||
VP8_LAST_FRAME = 1,
|
||||
VP8_GOLD_FRAME = 2,
|
||||
VP8_ALTR_FRAME = 4
|
||||
} vpx_ref_frame_type_t;
|
||||
|
||||
/*!\brief reference frame data struct
|
||||
*
|
||||
* Define the data struct to access vp8 reference frames.
|
||||
*/
|
||||
typedef struct vpx_ref_frame {
|
||||
vpx_ref_frame_type_t frame_type; /**< which reference frame */
|
||||
vpx_image_t img; /**< reference frame data in image format */
|
||||
} vpx_ref_frame_t;
|
||||
|
||||
/*!\brief VP9 specific reference frame data struct
|
||||
*
|
||||
* Define the data struct to access vp9 reference frames.
|
||||
*/
|
||||
typedef struct vp9_ref_frame {
|
||||
int idx; /**< frame index to get (input) */
|
||||
vpx_image_t img; /**< img structure to populate (output) */
|
||||
} vp9_ref_frame_t;
|
||||
|
||||
/*!\cond */
|
||||
/*!\brief vp8 decoder control function parameter type
|
||||
*
|
||||
* defines the data type for each of VP8 decoder control function requires
|
||||
*/
|
||||
VPX_CTRL_USE_TYPE(VP8_SET_REFERENCE, vpx_ref_frame_t *)
|
||||
#define VPX_CTRL_VP8_SET_REFERENCE
|
||||
VPX_CTRL_USE_TYPE(VP8_COPY_REFERENCE, vpx_ref_frame_t *)
|
||||
#define VPX_CTRL_VP8_COPY_REFERENCE
|
||||
VPX_CTRL_USE_TYPE(VP8_SET_POSTPROC, vp8_postproc_cfg_t *)
|
||||
#define VPX_CTRL_VP8_SET_POSTPROC
|
||||
VPX_CTRL_USE_TYPE(VP9_GET_REFERENCE, vp9_ref_frame_t *)
|
||||
#define VPX_CTRL_VP9_GET_REFERENCE
|
||||
|
||||
/*!\endcond */
|
||||
/*! @} - end defgroup vp8 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VP8_H_
|
||||
1027
vpx-encoder/android_libs/armeabi-v7a/include/vpx/vp8cx.h
Normal file
1027
vpx-encoder/android_libs/armeabi-v7a/include/vpx/vp8cx.h
Normal file
File diff suppressed because it is too large
Load diff
210
vpx-encoder/android_libs/armeabi-v7a/include/vpx/vp8dx.h
Normal file
210
vpx-encoder/android_libs/armeabi-v7a/include/vpx/vp8dx.h
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\defgroup vp8_decoder WebM VP8/VP9 Decoder
|
||||
* \ingroup vp8
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*!\file
|
||||
* \brief Provides definitions for using VP8 or VP9 within the vpx Decoder
|
||||
* interface.
|
||||
*/
|
||||
#ifndef VPX_VPX_VP8DX_H_
|
||||
#define VPX_VPX_VP8DX_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Include controls common to both the encoder and decoder */
|
||||
#include "./vp8.h"
|
||||
|
||||
/*!\name Algorithm interface for VP8
|
||||
*
|
||||
* This interface provides the capability to decode VP8 streams.
|
||||
* @{
|
||||
*/
|
||||
extern vpx_codec_iface_t vpx_codec_vp8_dx_algo;
|
||||
extern vpx_codec_iface_t *vpx_codec_vp8_dx(void);
|
||||
/*!@} - end algorithm interface member group*/
|
||||
|
||||
/*!\name Algorithm interface for VP9
|
||||
*
|
||||
* This interface provides the capability to decode VP9 streams.
|
||||
* @{
|
||||
*/
|
||||
extern vpx_codec_iface_t vpx_codec_vp9_dx_algo;
|
||||
extern vpx_codec_iface_t *vpx_codec_vp9_dx(void);
|
||||
/*!@} - end algorithm interface member group*/
|
||||
|
||||
/*!\enum vp8_dec_control_id
|
||||
* \brief VP8 decoder control functions
|
||||
*
|
||||
* This set of macros define the control functions available for the VP8
|
||||
* decoder interface.
|
||||
*
|
||||
* \sa #vpx_codec_control
|
||||
*/
|
||||
enum vp8_dec_control_id {
|
||||
/** control function to get info on which reference frames were updated
|
||||
* by the last decode
|
||||
*/
|
||||
VP8D_GET_LAST_REF_UPDATES = VP8_DECODER_CTRL_ID_START,
|
||||
|
||||
/** check if the indicated frame is corrupted */
|
||||
VP8D_GET_FRAME_CORRUPTED,
|
||||
|
||||
/** control function to get info on which reference frames were used
|
||||
* by the last decode
|
||||
*/
|
||||
VP8D_GET_LAST_REF_USED,
|
||||
|
||||
/** decryption function to decrypt encoded buffer data immediately
|
||||
* before decoding. Takes a vpx_decrypt_init, which contains
|
||||
* a callback function and opaque context pointer.
|
||||
*/
|
||||
VPXD_SET_DECRYPTOR,
|
||||
VP8D_SET_DECRYPTOR = VPXD_SET_DECRYPTOR,
|
||||
|
||||
/** control function to get the dimensions that the current frame is decoded
|
||||
* at. This may be different to the intended display size for the frame as
|
||||
* specified in the wrapper or frame header (see VP9D_GET_DISPLAY_SIZE). */
|
||||
VP9D_GET_FRAME_SIZE,
|
||||
|
||||
/** control function to get the current frame's intended display dimensions
|
||||
* (as specified in the wrapper or frame header). This may be different to
|
||||
* the decoded dimensions of this frame (see VP9D_GET_FRAME_SIZE). */
|
||||
VP9D_GET_DISPLAY_SIZE,
|
||||
|
||||
/** control function to get the bit depth of the stream. */
|
||||
VP9D_GET_BIT_DEPTH,
|
||||
|
||||
/** control function to set the byte alignment of the planes in the reference
|
||||
* buffers. Valid values are power of 2, from 32 to 1024. A value of 0 sets
|
||||
* legacy alignment. I.e. Y plane is aligned to 32 bytes, U plane directly
|
||||
* follows Y plane, and V plane directly follows U plane. Default value is 0.
|
||||
*/
|
||||
VP9_SET_BYTE_ALIGNMENT,
|
||||
|
||||
/** control function to invert the decoding order to from right to left. The
|
||||
* function is used in a test to confirm the decoding independence of tile
|
||||
* columns. The function may be used in application where this order
|
||||
* of decoding is desired.
|
||||
*
|
||||
* TODO(yaowu): Rework the unit test that uses this control, and in a future
|
||||
* release, this test-only control shall be removed.
|
||||
*/
|
||||
VP9_INVERT_TILE_DECODE_ORDER,
|
||||
|
||||
/** control function to set the skip loop filter flag. Valid values are
|
||||
* integers. The decoder will skip the loop filter when its value is set to
|
||||
* nonzero. If the loop filter is skipped the decoder may accumulate decode
|
||||
* artifacts. The default value is 0.
|
||||
*/
|
||||
VP9_SET_SKIP_LOOP_FILTER,
|
||||
|
||||
/** control function to decode SVC stream up to the x spatial layers,
|
||||
* where x is passed in through the control, and is 0 for base layer.
|
||||
*/
|
||||
VP9_DECODE_SVC_SPATIAL_LAYER,
|
||||
|
||||
/*!\brief Codec control function to get last decoded frame quantizer.
|
||||
*
|
||||
* Return value uses internal quantizer scale defined by the codec.
|
||||
*
|
||||
* Supported in codecs: VP8, VP9
|
||||
*/
|
||||
VPXD_GET_LAST_QUANTIZER,
|
||||
|
||||
/*!\brief Codec control function to set row level multi-threading.
|
||||
*
|
||||
* 0 : off, 1 : on
|
||||
*
|
||||
* Supported in codecs: VP9
|
||||
*/
|
||||
VP9D_SET_ROW_MT,
|
||||
|
||||
/*!\brief Codec control function to set loopfilter optimization.
|
||||
*
|
||||
* 0 : off, Loop filter is done after all tiles have been decoded
|
||||
* 1 : on, Loop filter is done immediately after decode without
|
||||
* waiting for all threads to sync.
|
||||
*
|
||||
* Supported in codecs: VP9
|
||||
*/
|
||||
VP9D_SET_LOOP_FILTER_OPT,
|
||||
|
||||
VP8_DECODER_CTRL_ID_MAX
|
||||
};
|
||||
|
||||
/** Decrypt n bytes of data from input -> output, using the decrypt_state
|
||||
* passed in VPXD_SET_DECRYPTOR.
|
||||
*/
|
||||
typedef void (*vpx_decrypt_cb)(void *decrypt_state, const unsigned char *input,
|
||||
unsigned char *output, int count);
|
||||
|
||||
/*!\brief Structure to hold decryption state
|
||||
*
|
||||
* Defines a structure to hold the decryption state and access function.
|
||||
*/
|
||||
typedef struct vpx_decrypt_init {
|
||||
/*! Decrypt callback. */
|
||||
vpx_decrypt_cb decrypt_cb;
|
||||
|
||||
/*! Decryption state. */
|
||||
void *decrypt_state;
|
||||
} vpx_decrypt_init;
|
||||
|
||||
/*!\cond */
|
||||
/*!\brief VP8 decoder control function parameter type
|
||||
*
|
||||
* Defines the data types that VP8D control functions take. Note that
|
||||
* additional common controls are defined in vp8.h
|
||||
*
|
||||
*/
|
||||
|
||||
VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_UPDATES, int *)
|
||||
#define VPX_CTRL_VP8D_GET_LAST_REF_UPDATES
|
||||
VPX_CTRL_USE_TYPE(VP8D_GET_FRAME_CORRUPTED, int *)
|
||||
#define VPX_CTRL_VP8D_GET_FRAME_CORRUPTED
|
||||
VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_USED, int *)
|
||||
#define VPX_CTRL_VP8D_GET_LAST_REF_USED
|
||||
VPX_CTRL_USE_TYPE(VPXD_GET_LAST_QUANTIZER, int *)
|
||||
#define VPX_CTRL_VPXD_GET_LAST_QUANTIZER
|
||||
VPX_CTRL_USE_TYPE(VPXD_SET_DECRYPTOR, vpx_decrypt_init *)
|
||||
#define VPX_CTRL_VPXD_SET_DECRYPTOR
|
||||
VPX_CTRL_USE_TYPE(VP8D_SET_DECRYPTOR, vpx_decrypt_init *)
|
||||
#define VPX_CTRL_VP8D_SET_DECRYPTOR
|
||||
VPX_CTRL_USE_TYPE(VP9D_GET_DISPLAY_SIZE, int *)
|
||||
#define VPX_CTRL_VP9D_GET_DISPLAY_SIZE
|
||||
VPX_CTRL_USE_TYPE(VP9D_GET_BIT_DEPTH, unsigned int *)
|
||||
#define VPX_CTRL_VP9D_GET_BIT_DEPTH
|
||||
VPX_CTRL_USE_TYPE(VP9D_GET_FRAME_SIZE, int *)
|
||||
#define VPX_CTRL_VP9D_GET_FRAME_SIZE
|
||||
VPX_CTRL_USE_TYPE(VP9_INVERT_TILE_DECODE_ORDER, int)
|
||||
#define VPX_CTRL_VP9_INVERT_TILE_DECODE_ORDER
|
||||
#define VPX_CTRL_VP9_DECODE_SVC_SPATIAL_LAYER
|
||||
VPX_CTRL_USE_TYPE(VP9_DECODE_SVC_SPATIAL_LAYER, int)
|
||||
#define VPX_CTRL_VP9_SET_SKIP_LOOP_FILTER
|
||||
VPX_CTRL_USE_TYPE(VP9_SET_SKIP_LOOP_FILTER, int)
|
||||
#define VPX_CTRL_VP9_DECODE_SET_ROW_MT
|
||||
VPX_CTRL_USE_TYPE(VP9D_SET_ROW_MT, int)
|
||||
#define VPX_CTRL_VP9_SET_LOOP_FILTER_OPT
|
||||
VPX_CTRL_USE_TYPE(VP9D_SET_LOOP_FILTER_OPT, int)
|
||||
|
||||
/*!\endcond */
|
||||
/*! @} - end defgroup vp8_decoder */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VP8DX_H_
|
||||
468
vpx-encoder/android_libs/armeabi-v7a/include/vpx/vpx_codec.h
Normal file
468
vpx-encoder/android_libs/armeabi-v7a/include/vpx/vpx_codec.h
Normal file
|
|
@ -0,0 +1,468 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\defgroup codec Common Algorithm Interface
|
||||
* This abstraction allows applications to easily support multiple video
|
||||
* formats with minimal code duplication. This section describes the interface
|
||||
* common to all codecs (both encoders and decoders).
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the codec algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video codec algorithm.
|
||||
*
|
||||
* An application instantiates a specific codec instance by using
|
||||
* vpx_codec_init() and a pointer to the algorithm's interface structure:
|
||||
* <pre>
|
||||
* my_app.c:
|
||||
* extern vpx_codec_iface_t my_codec;
|
||||
* {
|
||||
* vpx_codec_ctx_t algo;
|
||||
* res = vpx_codec_init(&algo, &my_codec);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Once initialized, the instance is manged using other functions from
|
||||
* the vpx_codec_* family.
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_CODEC_H_
|
||||
#define VPX_VPX_VPX_CODEC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_image.h"
|
||||
#include "./vpx_integer.h"
|
||||
|
||||
/*!\brief Decorator indicating a function is deprecated */
|
||||
#ifndef VPX_DEPRECATED
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
#define VPX_DEPRECATED __attribute__((deprecated))
|
||||
#elif defined(_MSC_VER)
|
||||
#define VPX_DEPRECATED
|
||||
#else
|
||||
#define VPX_DEPRECATED
|
||||
#endif
|
||||
#endif /* VPX_DEPRECATED */
|
||||
|
||||
#ifndef VPX_DECLSPEC_DEPRECATED
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
#define VPX_DECLSPEC_DEPRECATED /**< \copydoc #VPX_DEPRECATED */
|
||||
#elif defined(_MSC_VER)
|
||||
/*!\brief \copydoc #VPX_DEPRECATED */
|
||||
#define VPX_DECLSPEC_DEPRECATED __declspec(deprecated)
|
||||
#else
|
||||
#define VPX_DECLSPEC_DEPRECATED /**< \copydoc #VPX_DEPRECATED */
|
||||
#endif
|
||||
#endif /* VPX_DECLSPEC_DEPRECATED */
|
||||
|
||||
/*!\brief Decorator indicating a function is potentially unused */
|
||||
#ifndef VPX_UNUSED
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define VPX_UNUSED __attribute__((unused))
|
||||
#else
|
||||
#define VPX_UNUSED
|
||||
#endif
|
||||
#endif /* VPX_UNUSED */
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_CODEC_ABI_VERSION (4 + VPX_IMAGE_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*!\brief Algorithm return codes */
|
||||
typedef enum {
|
||||
/*!\brief Operation completed without error */
|
||||
VPX_CODEC_OK,
|
||||
|
||||
/*!\brief Unspecified error */
|
||||
VPX_CODEC_ERROR,
|
||||
|
||||
/*!\brief Memory operation failed */
|
||||
VPX_CODEC_MEM_ERROR,
|
||||
|
||||
/*!\brief ABI version mismatch */
|
||||
VPX_CODEC_ABI_MISMATCH,
|
||||
|
||||
/*!\brief Algorithm does not have required capability */
|
||||
VPX_CODEC_INCAPABLE,
|
||||
|
||||
/*!\brief The given bitstream is not supported.
|
||||
*
|
||||
* The bitstream was unable to be parsed at the highest level. The decoder
|
||||
* is unable to proceed. This error \ref SHOULD be treated as fatal to the
|
||||
* stream. */
|
||||
VPX_CODEC_UNSUP_BITSTREAM,
|
||||
|
||||
/*!\brief Encoded bitstream uses an unsupported feature
|
||||
*
|
||||
* The decoder does not implement a feature required by the encoder. This
|
||||
* return code should only be used for features that prevent future
|
||||
* pictures from being properly decoded. This error \ref MAY be treated as
|
||||
* fatal to the stream or \ref MAY be treated as fatal to the current GOP.
|
||||
*/
|
||||
VPX_CODEC_UNSUP_FEATURE,
|
||||
|
||||
/*!\brief The coded data for this stream is corrupt or incomplete
|
||||
*
|
||||
* There was a problem decoding the current frame. This return code
|
||||
* should only be used for failures that prevent future pictures from
|
||||
* being properly decoded. This error \ref MAY be treated as fatal to the
|
||||
* stream or \ref MAY be treated as fatal to the current GOP. If decoding
|
||||
* is continued for the current GOP, artifacts may be present.
|
||||
*/
|
||||
VPX_CODEC_CORRUPT_FRAME,
|
||||
|
||||
/*!\brief An application-supplied parameter is not valid.
|
||||
*
|
||||
*/
|
||||
VPX_CODEC_INVALID_PARAM,
|
||||
|
||||
/*!\brief An iterator reached the end of list.
|
||||
*
|
||||
*/
|
||||
VPX_CODEC_LIST_END
|
||||
|
||||
} vpx_codec_err_t;
|
||||
|
||||
/*! \brief Codec capabilities bitfield
|
||||
*
|
||||
* Each codec advertises the capabilities it supports as part of its
|
||||
* ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
|
||||
* or functionality, and are not required to be supported.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_CAP_* defines.
|
||||
*/
|
||||
typedef long vpx_codec_caps_t;
|
||||
#define VPX_CODEC_CAP_DECODER 0x1 /**< Is a decoder */
|
||||
#define VPX_CODEC_CAP_ENCODER 0x2 /**< Is an encoder */
|
||||
|
||||
/*! Can support images at greater than 8 bitdepth.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_HIGHBITDEPTH 0x4
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow for
|
||||
* proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_USE_* defines.
|
||||
*/
|
||||
typedef long vpx_codec_flags_t;
|
||||
|
||||
/*!\brief Codec interface structure.
|
||||
*
|
||||
* Contains function pointers and other data private to the codec
|
||||
* implementation. This structure is opaque to the application.
|
||||
*/
|
||||
typedef const struct vpx_codec_iface vpx_codec_iface_t;
|
||||
|
||||
/*!\brief Codec private data structure.
|
||||
*
|
||||
* Contains data private to the codec implementation. This structure is opaque
|
||||
* to the application.
|
||||
*/
|
||||
typedef struct vpx_codec_priv vpx_codec_priv_t;
|
||||
|
||||
/*!\brief Iterator
|
||||
*
|
||||
* Opaque storage used for iterating over lists.
|
||||
*/
|
||||
typedef const void *vpx_codec_iter_t;
|
||||
|
||||
/*!\brief Codec context structure
|
||||
*
|
||||
* All codecs \ref MUST support this context structure fully. In general,
|
||||
* this data should be considered private to the codec algorithm, and
|
||||
* not be manipulated or examined by the calling application. Applications
|
||||
* may reference the 'name' member to get a printable description of the
|
||||
* algorithm.
|
||||
*/
|
||||
typedef struct vpx_codec_ctx {
|
||||
const char *name; /**< Printable interface name */
|
||||
vpx_codec_iface_t *iface; /**< Interface pointers */
|
||||
vpx_codec_err_t err; /**< Last returned error */
|
||||
const char *err_detail; /**< Detailed info, if available */
|
||||
vpx_codec_flags_t init_flags; /**< Flags passed at init time */
|
||||
union {
|
||||
/**< Decoder Configuration Pointer */
|
||||
const struct vpx_codec_dec_cfg *dec;
|
||||
/**< Encoder Configuration Pointer */
|
||||
const struct vpx_codec_enc_cfg *enc;
|
||||
const void *raw;
|
||||
} config; /**< Configuration pointer aliasing union */
|
||||
vpx_codec_priv_t *priv; /**< Algorithm private storage */
|
||||
} vpx_codec_ctx_t;
|
||||
|
||||
/*!\brief Bit depth for codec
|
||||
* *
|
||||
* This enumeration determines the bit depth of the codec.
|
||||
*/
|
||||
typedef enum vpx_bit_depth {
|
||||
VPX_BITS_8 = 8, /**< 8 bits */
|
||||
VPX_BITS_10 = 10, /**< 10 bits */
|
||||
VPX_BITS_12 = 12, /**< 12 bits */
|
||||
} vpx_bit_depth_t;
|
||||
|
||||
/*
|
||||
* Library Version Number Interface
|
||||
*
|
||||
* For example, see the following sample return values:
|
||||
* vpx_codec_version() (1<<16 | 2<<8 | 3)
|
||||
* vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
|
||||
* vpx_codec_version_extra_str() "rc1-16-gec6a1ba"
|
||||
*/
|
||||
|
||||
/*!\brief Return the version information (as an integer)
|
||||
*
|
||||
* Returns a packed encoding of the library version number. This will only
|
||||
* include
|
||||
* the major.minor.patch component of the version number. Note that this encoded
|
||||
* value should be accessed through the macros provided, as the encoding may
|
||||
* change
|
||||
* in the future.
|
||||
*
|
||||
*/
|
||||
int vpx_codec_version(void);
|
||||
#define VPX_VERSION_MAJOR(v) \
|
||||
((v >> 16) & 0xff) /**< extract major from packed version */
|
||||
#define VPX_VERSION_MINOR(v) \
|
||||
((v >> 8) & 0xff) /**< extract minor from packed version */
|
||||
#define VPX_VERSION_PATCH(v) \
|
||||
((v >> 0) & 0xff) /**< extract patch from packed version */
|
||||
|
||||
/*!\brief Return the version major number */
|
||||
#define vpx_codec_version_major() ((vpx_codec_version() >> 16) & 0xff)
|
||||
|
||||
/*!\brief Return the version minor number */
|
||||
#define vpx_codec_version_minor() ((vpx_codec_version() >> 8) & 0xff)
|
||||
|
||||
/*!\brief Return the version patch number */
|
||||
#define vpx_codec_version_patch() ((vpx_codec_version() >> 0) & 0xff)
|
||||
|
||||
/*!\brief Return the version information (as a string)
|
||||
*
|
||||
* Returns a printable string containing the full library version number. This
|
||||
* may
|
||||
* contain additional text following the three digit version number, as to
|
||||
* indicate
|
||||
* release candidates, prerelease versions, etc.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_version_str(void);
|
||||
|
||||
/*!\brief Return the version information (as a string)
|
||||
*
|
||||
* Returns a printable "extra string". This is the component of the string
|
||||
* returned
|
||||
* by vpx_codec_version_str() following the three digit version number.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_version_extra_str(void);
|
||||
|
||||
/*!\brief Return the build configuration
|
||||
*
|
||||
* Returns a printable string containing an encoded version of the build
|
||||
* configuration. This may be useful to vpx support.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_build_config(void);
|
||||
|
||||
/*!\brief Return the name for a given interface
|
||||
*
|
||||
* Returns a human readable string for name of the given codec interface.
|
||||
*
|
||||
* \param[in] iface Interface pointer
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_iface_name(vpx_codec_iface_t *iface);
|
||||
|
||||
/*!\brief Convert error number to printable string
|
||||
*
|
||||
* Returns a human readable string for the last error returned by the
|
||||
* algorithm. The returned error will be one line and will not contain
|
||||
* any newline characters.
|
||||
*
|
||||
*
|
||||
* \param[in] err Error number.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_err_to_string(vpx_codec_err_t err);
|
||||
|
||||
/*!\brief Retrieve error synopsis for codec context
|
||||
*
|
||||
* Returns a human readable string for the last error returned by the
|
||||
* algorithm. The returned error will be one line and will not contain
|
||||
* any newline characters.
|
||||
*
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_error(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!\brief Retrieve detailed error information for codec context
|
||||
*
|
||||
* Returns a human readable string providing detailed information about
|
||||
* the last error.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
*
|
||||
* \retval NULL
|
||||
* No detailed information is available.
|
||||
*/
|
||||
const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/* REQUIRED FUNCTIONS
|
||||
*
|
||||
* The following functions are required to be implemented for all codecs.
|
||||
* They represent the base case functionality expected of all codecs.
|
||||
*/
|
||||
|
||||
/*!\brief Destroy a codec instance
|
||||
*
|
||||
* Destroys a codec context, freeing any associated memory buffers.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The codec algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!\brief Get the capabilities of an algorithm.
|
||||
*
|
||||
* Retrieves the capabilities bitfield from the algorithm's interface.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface
|
||||
*
|
||||
*/
|
||||
vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface);
|
||||
|
||||
/*!\brief Control algorithm
|
||||
*
|
||||
* This function is used to exchange algorithm specific data with the codec
|
||||
* instance. This can be used to implement features specific to a particular
|
||||
* algorithm.
|
||||
*
|
||||
* This wrapper function dispatches the request to the helper function
|
||||
* associated with the given ctrl_id. It tries to call this function
|
||||
* transparently, but will return #VPX_CODEC_ERROR if the request could not
|
||||
* be dispatched.
|
||||
*
|
||||
* Note that this function should not be used directly. Call the
|
||||
* #vpx_codec_control wrapper macro instead.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] ctrl_id Algorithm specific control identifier
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The control request was processed.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* The control request was not processed.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* The data was not valid.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx, int ctrl_id, ...);
|
||||
#if defined(VPX_DISABLE_CTRL_TYPECHECKS) && VPX_DISABLE_CTRL_TYPECHECKS
|
||||
#define vpx_codec_control(ctx, id, data) vpx_codec_control_(ctx, id, data)
|
||||
#define VPX_CTRL_USE_TYPE(id, typ)
|
||||
#define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ)
|
||||
#define VPX_CTRL_VOID(id, typ)
|
||||
|
||||
#else
|
||||
/*!\brief vpx_codec_control wrapper macro
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to vpx_codec_control_().
|
||||
*
|
||||
* \internal
|
||||
* It works by dispatching the call to the control function through a wrapper
|
||||
* function named with the id parameter.
|
||||
*/
|
||||
#define vpx_codec_control(ctx, id, data) \
|
||||
vpx_codec_control_##id(ctx, id, data) /**<\hideinitializer*/
|
||||
|
||||
/*!\brief vpx_codec_control type definition macro
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to vpx_codec_control_(). It defines the type of the argument for a given
|
||||
* control identifier.
|
||||
*
|
||||
* \internal
|
||||
* It defines a static function with
|
||||
* the correctly typed arguments as a wrapper to the type-unsafe internal
|
||||
* function.
|
||||
*/
|
||||
#define VPX_CTRL_USE_TYPE(id, typ) \
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *, int, typ) \
|
||||
VPX_UNUSED; \
|
||||
\
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *ctx, \
|
||||
int ctrl_id, typ data) { \
|
||||
return vpx_codec_control_(ctx, ctrl_id, data); \
|
||||
} /**<\hideinitializer*/
|
||||
|
||||
/*!\brief vpx_codec_control deprecated type definition macro
|
||||
*
|
||||
* Like #VPX_CTRL_USE_TYPE, but indicates that the specified control is
|
||||
* deprecated and should not be used. Consult the documentation for your
|
||||
* codec for more information.
|
||||
*
|
||||
* \internal
|
||||
* It defines a static function with the correctly typed arguments as a
|
||||
* wrapper to the type-unsafe internal function.
|
||||
*/
|
||||
#define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \
|
||||
VPX_DECLSPEC_DEPRECATED static vpx_codec_err_t vpx_codec_control_##id( \
|
||||
vpx_codec_ctx_t *, int, typ) VPX_DEPRECATED VPX_UNUSED; \
|
||||
\
|
||||
VPX_DECLSPEC_DEPRECATED static vpx_codec_err_t vpx_codec_control_##id( \
|
||||
vpx_codec_ctx_t *ctx, int ctrl_id, typ data) { \
|
||||
return vpx_codec_control_(ctx, ctrl_id, data); \
|
||||
} /**<\hideinitializer*/
|
||||
|
||||
/*!\brief vpx_codec_control void type definition macro
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to vpx_codec_control_(). It indicates that a given control identifier takes
|
||||
* no argument.
|
||||
*
|
||||
* \internal
|
||||
* It defines a static function without a data argument as a wrapper to the
|
||||
* type-unsafe internal function.
|
||||
*/
|
||||
#define VPX_CTRL_VOID(id) \
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *, int) \
|
||||
VPX_UNUSED; \
|
||||
\
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *ctx, \
|
||||
int ctrl_id) { \
|
||||
return vpx_codec_control_(ctx, ctrl_id); \
|
||||
} /**<\hideinitializer*/
|
||||
|
||||
#endif
|
||||
|
||||
/*!@} - end defgroup codec*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // VPX_VPX_VPX_CODEC_H_
|
||||
365
vpx-encoder/android_libs/armeabi-v7a/include/vpx/vpx_decoder.h
Normal file
365
vpx-encoder/android_libs/armeabi-v7a/include/vpx/vpx_decoder.h
Normal file
|
|
@ -0,0 +1,365 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_DECODER_H_
|
||||
#define VPX_VPX_VPX_DECODER_H_
|
||||
|
||||
/*!\defgroup decoder Decoder Algorithm Interface
|
||||
* \ingroup codec
|
||||
* This abstraction allows applications using this decoder to easily support
|
||||
* multiple video formats with minimal code duplication. This section describes
|
||||
* the interface common to all decoders.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the decoder algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video decoder algorithm.
|
||||
*
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_codec.h"
|
||||
#include "./vpx_frame_buffer.h"
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_DECODER_ABI_VERSION \
|
||||
(3 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*! \brief Decoder capabilities bitfield
|
||||
*
|
||||
* Each decoder advertises the capabilities it supports as part of its
|
||||
* ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
|
||||
* or functionality, and are not required to be supported by a decoder.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_CAP_* defines.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_PUT_SLICE 0x10000 /**< Will issue put_slice callbacks */
|
||||
#define VPX_CODEC_CAP_PUT_FRAME 0x20000 /**< Will issue put_frame callbacks */
|
||||
#define VPX_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */
|
||||
/*!\brief Can conceal errors due to packet loss */
|
||||
#define VPX_CODEC_CAP_ERROR_CONCEALMENT 0x80000
|
||||
/*!\brief Can receive encoded frames one fragment at a time */
|
||||
#define VPX_CODEC_CAP_INPUT_FRAGMENTS 0x100000
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow for
|
||||
* proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_USE_* defines.
|
||||
*/
|
||||
/*!\brief Can support frame-based multi-threading */
|
||||
#define VPX_CODEC_CAP_FRAME_THREADING 0x200000
|
||||
/*!brief Can support external frame buffers */
|
||||
#define VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER 0x400000
|
||||
|
||||
#define VPX_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */
|
||||
/*!\brief Conceal errors in decoded frames */
|
||||
#define VPX_CODEC_USE_ERROR_CONCEALMENT 0x20000
|
||||
/*!\brief The input frame should be passed to the decoder one fragment at a
|
||||
* time */
|
||||
#define VPX_CODEC_USE_INPUT_FRAGMENTS 0x40000
|
||||
/*!\brief Enable frame-based multi-threading */
|
||||
#define VPX_CODEC_USE_FRAME_THREADING 0x80000
|
||||
|
||||
/*!\brief Stream properties
|
||||
*
|
||||
* This structure is used to query or set properties of the decoded
|
||||
* stream. Algorithms may extend this structure with data specific
|
||||
* to their bitstream by setting the sz member appropriately.
|
||||
*/
|
||||
typedef struct vpx_codec_stream_info {
|
||||
unsigned int sz; /**< Size of this structure */
|
||||
unsigned int w; /**< Width (or 0 for unknown/default) */
|
||||
unsigned int h; /**< Height (or 0 for unknown/default) */
|
||||
unsigned int is_kf; /**< Current frame is a keyframe */
|
||||
} vpx_codec_stream_info_t;
|
||||
|
||||
/* REQUIRED FUNCTIONS
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders.
|
||||
* They represent the base case functionality expected of all decoders.
|
||||
*/
|
||||
|
||||
/*!\brief Initialization Configurations
|
||||
*
|
||||
* This structure is used to pass init time configuration options to the
|
||||
* decoder.
|
||||
*/
|
||||
typedef struct vpx_codec_dec_cfg {
|
||||
unsigned int threads; /**< Maximum number of threads to use, default 1 */
|
||||
unsigned int w; /**< Width */
|
||||
unsigned int h; /**< Height */
|
||||
} vpx_codec_dec_cfg_t; /**< alias for struct vpx_codec_dec_cfg */
|
||||
|
||||
/*!\brief Initialize a decoder instance
|
||||
*
|
||||
* Initializes a decoder context using the given interface. Applications
|
||||
* should call the vpx_codec_dec_init convenience macro instead of this
|
||||
* function directly, to ensure that the ABI version number parameter
|
||||
* is properly initialized.
|
||||
*
|
||||
* If the library was configured with --disable-multithread, this call
|
||||
* is not thread safe and should be guarded with a lock if being used
|
||||
* in a multithreaded context.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[in] cfg Configuration to use, if known. May be NULL.
|
||||
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
|
||||
* \param[in] ver ABI version number. Must be set to
|
||||
* VPX_DECODER_ABI_VERSION
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The decoder algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_iface_t *iface,
|
||||
const vpx_codec_dec_cfg_t *cfg,
|
||||
vpx_codec_flags_t flags, int ver);
|
||||
|
||||
/*!\brief Convenience macro for vpx_codec_dec_init_ver()
|
||||
*
|
||||
* Ensures the ABI version parameter is properly set.
|
||||
*/
|
||||
#define vpx_codec_dec_init(ctx, iface, cfg, flags) \
|
||||
vpx_codec_dec_init_ver(ctx, iface, cfg, flags, VPX_DECODER_ABI_VERSION)
|
||||
|
||||
/*!\brief Parse stream info from a buffer
|
||||
*
|
||||
* Performs high level parsing of the bitstream. Construction of a decoder
|
||||
* context is not necessary. Can be used to determine if the bitstream is
|
||||
* of the proper format, and to extract information from the stream.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface
|
||||
* \param[in] data Pointer to a block of data to parse
|
||||
* \param[in] data_sz Size of the data buffer
|
||||
* \param[in,out] si Pointer to stream info to update. The size member
|
||||
* \ref MUST be properly initialized, but \ref MAY be
|
||||
* clobbered by the algorithm. This parameter \ref MAY
|
||||
* be NULL.
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Bitstream is parsable and stream information updated
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface,
|
||||
const uint8_t *data,
|
||||
unsigned int data_sz,
|
||||
vpx_codec_stream_info_t *si);
|
||||
|
||||
/*!\brief Return information about the current stream.
|
||||
*
|
||||
* Returns information about the stream that has been parsed during decoding.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] si Pointer to stream info to update. The size member
|
||||
* \ref MUST be properly initialized, but \ref MAY be
|
||||
* clobbered by the algorithm. This parameter \ref MAY
|
||||
* be NULL.
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Bitstream is parsable and stream information updated
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_stream_info_t *si);
|
||||
|
||||
/*!\brief Decode data
|
||||
*
|
||||
* Processes a buffer of coded data. If the processing results in a new
|
||||
* decoded frame becoming available, PUT_SLICE and PUT_FRAME events may be
|
||||
* generated, as appropriate. Encoded data \ref MUST be passed in DTS (decode
|
||||
* time stamp) order. Frames produced will always be in PTS (presentation
|
||||
* time stamp) order.
|
||||
* If the decoder is configured with VPX_CODEC_USE_INPUT_FRAGMENTS enabled,
|
||||
* data and data_sz can contain a fragment of the encoded frame. Fragment
|
||||
* \#n must contain at least partition \#n, but can also contain subsequent
|
||||
* partitions (\#n+1 - \#n+i), and if so, fragments \#n+1, .., \#n+i must
|
||||
* be empty. When no more data is available, this function should be called
|
||||
* with NULL as data and 0 as data_sz. The memory passed to this function
|
||||
* must be available until the frame has been decoded.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] data Pointer to this block of new coded data. If
|
||||
* NULL, a VPX_CODEC_CB_PUT_FRAME event is posted
|
||||
* for the previously decoded frame.
|
||||
* \param[in] data_sz Size of the coded data, in bytes.
|
||||
* \param[in] user_priv Application specific data to associate with
|
||||
* this frame.
|
||||
* \param[in] deadline Soft deadline the decoder should attempt to meet,
|
||||
* in us. Set to zero for unlimited.
|
||||
*
|
||||
* \return Returns #VPX_CODEC_OK if the coded data was processed completely
|
||||
* and future pictures can be decoded without error. Otherwise,
|
||||
* see the descriptions of the other error codes in ::vpx_codec_err_t
|
||||
* for recoverability capabilities.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, const uint8_t *data,
|
||||
unsigned int data_sz, void *user_priv,
|
||||
long deadline);
|
||||
|
||||
/*!\brief Decoded frames iterator
|
||||
*
|
||||
* Iterates over a list of the frames available for display. The iterator
|
||||
* storage should be initialized to NULL to start the iteration. Iteration is
|
||||
* complete when this function returns NULL.
|
||||
*
|
||||
* The list of available frames becomes valid upon completion of the
|
||||
* vpx_codec_decode call, and remains valid until the next call to
|
||||
* vpx_codec_decode.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] iter Iterator storage, initialized to NULL
|
||||
*
|
||||
* \return Returns a pointer to an image, if one is ready for display. Frames
|
||||
* produced will always be in PTS (presentation time stamp) order.
|
||||
*/
|
||||
vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx, vpx_codec_iter_t *iter);
|
||||
|
||||
/*!\defgroup cap_put_frame Frame-Based Decoding Functions
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders
|
||||
* that advertise the VPX_CODEC_CAP_PUT_FRAME capability. Calling these
|
||||
* functions
|
||||
* for codecs that don't advertise this capability will result in an error
|
||||
* code being returned, usually VPX_CODEC_ERROR
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief put frame callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to notify the application of
|
||||
* the availability of decoded image data.
|
||||
*/
|
||||
typedef void (*vpx_codec_put_frame_cb_fn_t)(void *user_priv,
|
||||
const vpx_image_t *img);
|
||||
|
||||
/*!\brief Register for notification of frame completion.
|
||||
*
|
||||
* Registers a given function to be called when a decoded frame is
|
||||
* available.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb Pointer to the callback function
|
||||
* \param[in] user_priv User's private data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Callback successfully registered.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* Decoder context not initialized, or algorithm not capable of
|
||||
* posting slice completion.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_put_frame_cb_fn_t cb,
|
||||
void *user_priv);
|
||||
|
||||
/*!@} - end defgroup cap_put_frame */
|
||||
|
||||
/*!\defgroup cap_put_slice Slice-Based Decoding Functions
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders
|
||||
* that advertise the VPX_CODEC_CAP_PUT_SLICE capability. Calling these
|
||||
* functions
|
||||
* for codecs that don't advertise this capability will result in an error
|
||||
* code being returned, usually VPX_CODEC_ERROR
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief put slice callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to notify the application of
|
||||
* the availability of partially decoded image data. The
|
||||
*/
|
||||
typedef void (*vpx_codec_put_slice_cb_fn_t)(void *user_priv,
|
||||
const vpx_image_t *img,
|
||||
const vpx_image_rect_t *valid,
|
||||
const vpx_image_rect_t *update);
|
||||
|
||||
/*!\brief Register for notification of slice completion.
|
||||
*
|
||||
* Registers a given function to be called when a decoded slice is
|
||||
* available.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb Pointer to the callback function
|
||||
* \param[in] user_priv User's private data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Callback successfully registered.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* Decoder context not initialized, or algorithm not capable of
|
||||
* posting slice completion.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_register_put_slice_cb(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_put_slice_cb_fn_t cb,
|
||||
void *user_priv);
|
||||
|
||||
/*!@} - end defgroup cap_put_slice*/
|
||||
|
||||
/*!\defgroup cap_external_frame_buffer External Frame Buffer Functions
|
||||
*
|
||||
* The following section is required to be implemented for all decoders
|
||||
* that advertise the VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER capability.
|
||||
* Calling this function for codecs that don't advertise this capability
|
||||
* will result in an error code being returned, usually VPX_CODEC_ERROR.
|
||||
*
|
||||
* \note
|
||||
* Currently this only works with VP9.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief Pass in external frame buffers for the decoder to use.
|
||||
*
|
||||
* Registers functions to be called when libvpx needs a frame buffer
|
||||
* to decode the current frame and a function to be called when libvpx does
|
||||
* not internally reference the frame buffer. This set function must
|
||||
* be called before the first call to decode or libvpx will assume the
|
||||
* default behavior of allocating frame buffers internally.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb_get Pointer to the get callback function
|
||||
* \param[in] cb_release Pointer to the release callback function
|
||||
* \param[in] cb_priv Callback's private data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* External frame buffers will be used by libvpx.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* One or more of the callbacks were NULL.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* Decoder context not initialized, or algorithm not capable of
|
||||
* using external frame buffers.
|
||||
*
|
||||
* \note
|
||||
* When decoding VP9, the application may be required to pass in at least
|
||||
* #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS external frame
|
||||
* buffers.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_set_frame_buffer_functions(
|
||||
vpx_codec_ctx_t *ctx, vpx_get_frame_buffer_cb_fn_t cb_get,
|
||||
vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv);
|
||||
|
||||
/*!@} - end defgroup cap_external_frame_buffer */
|
||||
|
||||
/*!@} - end defgroup decoder*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // VPX_VPX_VPX_DECODER_H_
|
||||
968
vpx-encoder/android_libs/armeabi-v7a/include/vpx/vpx_encoder.h
Normal file
968
vpx-encoder/android_libs/armeabi-v7a/include/vpx/vpx_encoder.h
Normal file
|
|
@ -0,0 +1,968 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_ENCODER_H_
|
||||
#define VPX_VPX_VPX_ENCODER_H_
|
||||
|
||||
/*!\defgroup encoder Encoder Algorithm Interface
|
||||
* \ingroup codec
|
||||
* This abstraction allows applications using this encoder to easily support
|
||||
* multiple video formats with minimal code duplication. This section describes
|
||||
* the interface common to all encoders.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the encoder algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video encoder algorithm.
|
||||
*
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_codec.h"
|
||||
|
||||
/*! Temporal Scalability: Maximum length of the sequence defining frame
|
||||
* layer membership
|
||||
*/
|
||||
#define VPX_TS_MAX_PERIODICITY 16
|
||||
|
||||
/*! Temporal Scalability: Maximum number of coding layers */
|
||||
#define VPX_TS_MAX_LAYERS 5
|
||||
|
||||
/*! Temporal+Spatial Scalability: Maximum number of coding layers */
|
||||
#define VPX_MAX_LAYERS 12 // 3 temporal + 4 spatial layers are allowed.
|
||||
|
||||
/*! Spatial Scalability: Maximum number of coding layers */
|
||||
#define VPX_SS_MAX_LAYERS 5
|
||||
|
||||
/*! Spatial Scalability: Default number of coding layers */
|
||||
#define VPX_SS_DEFAULT_LAYERS 1
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_ENCODER_ABI_VERSION \
|
||||
(14 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*! \brief Encoder capabilities bitfield
|
||||
*
|
||||
* Each encoder advertises the capabilities it supports as part of its
|
||||
* ::vpx_codec_iface_t interface structure. Capabilities are extra
|
||||
* interfaces or functionality, and are not required to be supported
|
||||
* by an encoder.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_CAP_* defines.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_PSNR 0x10000 /**< Can issue PSNR packets */
|
||||
|
||||
/*! Can output one partition at a time. Each partition is returned in its
|
||||
* own VPX_CODEC_CX_FRAME_PKT, with the FRAME_IS_FRAGMENT flag set for
|
||||
* every partition but the last. In this mode all frames are always
|
||||
* returned partition by partition.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_OUTPUT_PARTITION 0x20000
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow
|
||||
* for proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_USE_* defines.
|
||||
*/
|
||||
#define VPX_CODEC_USE_PSNR 0x10000 /**< Calculate PSNR on each frame */
|
||||
/*!\brief Make the encoder output one partition at a time. */
|
||||
#define VPX_CODEC_USE_OUTPUT_PARTITION 0x20000
|
||||
#define VPX_CODEC_USE_HIGHBITDEPTH 0x40000 /**< Use high bitdepth */
|
||||
|
||||
/*!\brief Generic fixed size buffer structure
|
||||
*
|
||||
* This structure is able to hold a reference to any fixed size buffer.
|
||||
*/
|
||||
typedef struct vpx_fixed_buf {
|
||||
void *buf; /**< Pointer to the data */
|
||||
size_t sz; /**< Length of the buffer, in chars */
|
||||
} vpx_fixed_buf_t; /**< alias for struct vpx_fixed_buf */
|
||||
|
||||
/*!\brief Time Stamp Type
|
||||
*
|
||||
* An integer, which when multiplied by the stream's time base, provides
|
||||
* the absolute time of a sample.
|
||||
*/
|
||||
typedef int64_t vpx_codec_pts_t;
|
||||
|
||||
/*!\brief Compressed Frame Flags
|
||||
*
|
||||
* This type represents a bitfield containing information about a compressed
|
||||
* frame that may be useful to an application. The most significant 16 bits
|
||||
* can be used by an algorithm to provide additional detail, for example to
|
||||
* support frame types that are codec specific (MPEG-1 D-frames for example)
|
||||
*/
|
||||
typedef uint32_t vpx_codec_frame_flags_t;
|
||||
#define VPX_FRAME_IS_KEY 0x1 /**< frame is the start of a GOP */
|
||||
/*!\brief frame can be dropped without affecting the stream (no future frame
|
||||
* depends on this one) */
|
||||
#define VPX_FRAME_IS_DROPPABLE 0x2
|
||||
/*!\brief frame should be decoded but will not be shown */
|
||||
#define VPX_FRAME_IS_INVISIBLE 0x4
|
||||
/*!\brief this is a fragment of the encoded frame */
|
||||
#define VPX_FRAME_IS_FRAGMENT 0x8
|
||||
|
||||
/*!\brief Error Resilient flags
|
||||
*
|
||||
* These flags define which error resilient features to enable in the
|
||||
* encoder. The flags are specified through the
|
||||
* vpx_codec_enc_cfg::g_error_resilient variable.
|
||||
*/
|
||||
typedef uint32_t vpx_codec_er_flags_t;
|
||||
/*!\brief Improve resiliency against losses of whole frames */
|
||||
#define VPX_ERROR_RESILIENT_DEFAULT 0x1
|
||||
/*!\brief The frame partitions are independently decodable by the bool decoder,
|
||||
* meaning that partitions can be decoded even though earlier partitions have
|
||||
* been lost. Note that intra prediction is still done over the partition
|
||||
* boundary. */
|
||||
#define VPX_ERROR_RESILIENT_PARTITIONS 0x2
|
||||
|
||||
/*!\brief Encoder output packet variants
|
||||
*
|
||||
* This enumeration lists the different kinds of data packets that can be
|
||||
* returned by calls to vpx_codec_get_cx_data(). Algorithms \ref MAY
|
||||
* extend this list to provide additional functionality.
|
||||
*/
|
||||
enum vpx_codec_cx_pkt_kind {
|
||||
VPX_CODEC_CX_FRAME_PKT, /**< Compressed video frame */
|
||||
VPX_CODEC_STATS_PKT, /**< Two-pass statistics for this frame */
|
||||
VPX_CODEC_FPMB_STATS_PKT, /**< first pass mb statistics for this frame */
|
||||
VPX_CODEC_PSNR_PKT, /**< PSNR statistics for this frame */
|
||||
VPX_CODEC_CUSTOM_PKT = 256 /**< Algorithm extensions */
|
||||
};
|
||||
|
||||
/*!\brief Encoder output packet
|
||||
*
|
||||
* This structure contains the different kinds of output data the encoder
|
||||
* may produce while compressing a frame.
|
||||
*/
|
||||
typedef struct vpx_codec_cx_pkt {
|
||||
enum vpx_codec_cx_pkt_kind kind; /**< packet variant */
|
||||
union {
|
||||
struct {
|
||||
void *buf; /**< compressed data buffer */
|
||||
size_t sz; /**< length of compressed data */
|
||||
/*!\brief time stamp to show frame (in timebase units) */
|
||||
vpx_codec_pts_t pts;
|
||||
/*!\brief duration to show frame (in timebase units) */
|
||||
unsigned long duration;
|
||||
vpx_codec_frame_flags_t flags; /**< flags for this frame */
|
||||
/*!\brief the partition id defines the decoding order of the partitions.
|
||||
* Only applicable when "output partition" mode is enabled. First
|
||||
* partition has id 0.*/
|
||||
int partition_id;
|
||||
/*!\brief Width and height of frames in this packet. VP8 will only use the
|
||||
* first one.*/
|
||||
unsigned int width[VPX_SS_MAX_LAYERS]; /**< frame width */
|
||||
unsigned int height[VPX_SS_MAX_LAYERS]; /**< frame height */
|
||||
/*!\brief Flag to indicate if spatial layer frame in this packet is
|
||||
* encoded or dropped. VP8 will always be set to 1.*/
|
||||
uint8_t spatial_layer_encoded[VPX_SS_MAX_LAYERS];
|
||||
} frame; /**< data for compressed frame packet */
|
||||
vpx_fixed_buf_t twopass_stats; /**< data for two-pass packet */
|
||||
vpx_fixed_buf_t firstpass_mb_stats; /**< first pass mb packet */
|
||||
struct vpx_psnr_pkt {
|
||||
unsigned int samples[4]; /**< Number of samples, total/y/u/v */
|
||||
uint64_t sse[4]; /**< sum squared error, total/y/u/v */
|
||||
double psnr[4]; /**< PSNR, total/y/u/v */
|
||||
} psnr; /**< data for PSNR packet */
|
||||
vpx_fixed_buf_t raw; /**< data for arbitrary packets */
|
||||
|
||||
/* This packet size is fixed to allow codecs to extend this
|
||||
* interface without having to manage storage for raw packets,
|
||||
* i.e., if it's smaller than 128 bytes, you can store in the
|
||||
* packet list directly.
|
||||
*/
|
||||
char pad[128 - sizeof(enum vpx_codec_cx_pkt_kind)]; /**< fixed sz */
|
||||
} data; /**< packet data */
|
||||
} vpx_codec_cx_pkt_t; /**< alias for struct vpx_codec_cx_pkt */
|
||||
|
||||
/*!\brief Encoder return output buffer callback
|
||||
*
|
||||
* This callback function, when registered, returns with packets when each
|
||||
* spatial layer is encoded.
|
||||
*/
|
||||
typedef void (*vpx_codec_enc_output_cx_pkt_cb_fn_t)(vpx_codec_cx_pkt_t *pkt,
|
||||
void *user_data);
|
||||
|
||||
/*!\brief Callback function pointer / user data pair storage */
|
||||
typedef struct vpx_codec_enc_output_cx_cb_pair {
|
||||
vpx_codec_enc_output_cx_pkt_cb_fn_t output_cx_pkt; /**< Callback function */
|
||||
void *user_priv; /**< Pointer to private data */
|
||||
} vpx_codec_priv_output_cx_pkt_cb_pair_t;
|
||||
|
||||
/*!\brief Rational Number
|
||||
*
|
||||
* This structure holds a fractional value.
|
||||
*/
|
||||
typedef struct vpx_rational {
|
||||
int num; /**< fraction numerator */
|
||||
int den; /**< fraction denominator */
|
||||
} vpx_rational_t; /**< alias for struct vpx_rational */
|
||||
|
||||
/*!\brief Multi-pass Encoding Pass */
|
||||
enum vpx_enc_pass {
|
||||
VPX_RC_ONE_PASS, /**< Single pass mode */
|
||||
VPX_RC_FIRST_PASS, /**< First pass of multi-pass mode */
|
||||
VPX_RC_LAST_PASS /**< Final pass of multi-pass mode */
|
||||
};
|
||||
|
||||
/*!\brief Rate control mode */
|
||||
enum vpx_rc_mode {
|
||||
VPX_VBR, /**< Variable Bit Rate (VBR) mode */
|
||||
VPX_CBR, /**< Constant Bit Rate (CBR) mode */
|
||||
VPX_CQ, /**< Constrained Quality (CQ) mode */
|
||||
VPX_Q, /**< Constant Quality (Q) mode */
|
||||
};
|
||||
|
||||
/*!\brief Keyframe placement mode.
|
||||
*
|
||||
* This enumeration determines whether keyframes are placed automatically by
|
||||
* the encoder or whether this behavior is disabled. Older releases of this
|
||||
* SDK were implemented such that VPX_KF_FIXED meant keyframes were disabled.
|
||||
* This name is confusing for this behavior, so the new symbols to be used
|
||||
* are VPX_KF_AUTO and VPX_KF_DISABLED.
|
||||
*/
|
||||
enum vpx_kf_mode {
|
||||
VPX_KF_FIXED, /**< deprecated, implies VPX_KF_DISABLED */
|
||||
VPX_KF_AUTO, /**< Encoder determines optimal placement automatically */
|
||||
VPX_KF_DISABLED = 0 /**< Encoder does not place keyframes. */
|
||||
};
|
||||
|
||||
/*!\brief Encoded Frame Flags
|
||||
*
|
||||
* This type indicates a bitfield to be passed to vpx_codec_encode(), defining
|
||||
* per-frame boolean values. By convention, bits common to all codecs will be
|
||||
* named VPX_EFLAG_*, and bits specific to an algorithm will be named
|
||||
* /algo/_eflag_*. The lower order 16 bits are reserved for common use.
|
||||
*/
|
||||
typedef long vpx_enc_frame_flags_t;
|
||||
#define VPX_EFLAG_FORCE_KF (1 << 0) /**< Force this frame to be a keyframe */
|
||||
|
||||
/*!\brief Encoder configuration structure
|
||||
*
|
||||
* This structure contains the encoder settings that have common representations
|
||||
* across all codecs. This doesn't imply that all codecs support all features,
|
||||
* however.
|
||||
*/
|
||||
typedef struct vpx_codec_enc_cfg {
|
||||
/*
|
||||
* generic settings (g)
|
||||
*/
|
||||
|
||||
/*!\brief Deprecated: Algorithm specific "usage" value
|
||||
*
|
||||
* This value must be zero.
|
||||
*/
|
||||
unsigned int g_usage;
|
||||
|
||||
/*!\brief Maximum number of threads to use
|
||||
*
|
||||
* For multi-threaded implementations, use no more than this number of
|
||||
* threads. The codec may use fewer threads than allowed. The value
|
||||
* 0 is equivalent to the value 1.
|
||||
*/
|
||||
unsigned int g_threads;
|
||||
|
||||
/*!\brief Bitstream profile to use
|
||||
*
|
||||
* Some codecs support a notion of multiple bitstream profiles. Typically
|
||||
* this maps to a set of features that are turned on or off. Often the
|
||||
* profile to use is determined by the features of the intended decoder.
|
||||
* Consult the documentation for the codec to determine the valid values
|
||||
* for this parameter, or set to zero for a sane default.
|
||||
*/
|
||||
unsigned int g_profile; /**< profile of bitstream to use */
|
||||
|
||||
/*!\brief Width of the frame
|
||||
*
|
||||
* This value identifies the presentation resolution of the frame,
|
||||
* in pixels. Note that the frames passed as input to the encoder must
|
||||
* have this resolution. Frames will be presented by the decoder in this
|
||||
* resolution, independent of any spatial resampling the encoder may do.
|
||||
*/
|
||||
unsigned int g_w;
|
||||
|
||||
/*!\brief Height of the frame
|
||||
*
|
||||
* This value identifies the presentation resolution of the frame,
|
||||
* in pixels. Note that the frames passed as input to the encoder must
|
||||
* have this resolution. Frames will be presented by the decoder in this
|
||||
* resolution, independent of any spatial resampling the encoder may do.
|
||||
*/
|
||||
unsigned int g_h;
|
||||
|
||||
/*!\brief Bit-depth of the codec
|
||||
*
|
||||
* This value identifies the bit_depth of the codec,
|
||||
* Only certain bit-depths are supported as identified in the
|
||||
* vpx_bit_depth_t enum.
|
||||
*/
|
||||
vpx_bit_depth_t g_bit_depth;
|
||||
|
||||
/*!\brief Bit-depth of the input frames
|
||||
*
|
||||
* This value identifies the bit_depth of the input frames in bits.
|
||||
* Note that the frames passed as input to the encoder must have
|
||||
* this bit-depth.
|
||||
*/
|
||||
unsigned int g_input_bit_depth;
|
||||
|
||||
/*!\brief Stream timebase units
|
||||
*
|
||||
* Indicates the smallest interval of time, in seconds, used by the stream.
|
||||
* For fixed frame rate material, or variable frame rate material where
|
||||
* frames are timed at a multiple of a given clock (ex: video capture),
|
||||
* the \ref RECOMMENDED method is to set the timebase to the reciprocal
|
||||
* of the frame rate (ex: 1001/30000 for 29.970 Hz NTSC). This allows the
|
||||
* pts to correspond to the frame number, which can be handy. For
|
||||
* re-encoding video from containers with absolute time timestamps, the
|
||||
* \ref RECOMMENDED method is to set the timebase to that of the parent
|
||||
* container or multimedia framework (ex: 1/1000 for ms, as in FLV).
|
||||
*/
|
||||
struct vpx_rational g_timebase;
|
||||
|
||||
/*!\brief Enable error resilient modes.
|
||||
*
|
||||
* The error resilient bitfield indicates to the encoder which features
|
||||
* it should enable to take measures for streaming over lossy or noisy
|
||||
* links.
|
||||
*/
|
||||
vpx_codec_er_flags_t g_error_resilient;
|
||||
|
||||
/*!\brief Multi-pass Encoding Mode
|
||||
*
|
||||
* This value should be set to the current phase for multi-pass encoding.
|
||||
* For single pass, set to #VPX_RC_ONE_PASS.
|
||||
*/
|
||||
enum vpx_enc_pass g_pass;
|
||||
|
||||
/*!\brief Allow lagged encoding
|
||||
*
|
||||
* If set, this value allows the encoder to consume a number of input
|
||||
* frames before producing output frames. This allows the encoder to
|
||||
* base decisions for the current frame on future frames. This does
|
||||
* increase the latency of the encoding pipeline, so it is not appropriate
|
||||
* in all situations (ex: realtime encoding).
|
||||
*
|
||||
* Note that this is a maximum value -- the encoder may produce frames
|
||||
* sooner than the given limit. Set this value to 0 to disable this
|
||||
* feature.
|
||||
*/
|
||||
unsigned int g_lag_in_frames;
|
||||
|
||||
/*
|
||||
* rate control settings (rc)
|
||||
*/
|
||||
|
||||
/*!\brief Temporal resampling configuration, if supported by the codec.
|
||||
*
|
||||
* Temporal resampling allows the codec to "drop" frames as a strategy to
|
||||
* meet its target data rate. This can cause temporal discontinuities in
|
||||
* the encoded video, which may appear as stuttering during playback. This
|
||||
* trade-off is often acceptable, but for many applications is not. It can
|
||||
* be disabled in these cases.
|
||||
*
|
||||
* This threshold is described as a percentage of the target data buffer.
|
||||
* When the data buffer falls below this percentage of fullness, a
|
||||
* dropped frame is indicated. Set the threshold to zero (0) to disable
|
||||
* this feature.
|
||||
*/
|
||||
unsigned int rc_dropframe_thresh;
|
||||
|
||||
/*!\brief Enable/disable spatial resampling, if supported by the codec.
|
||||
*
|
||||
* Spatial resampling allows the codec to compress a lower resolution
|
||||
* version of the frame, which is then upscaled by the encoder to the
|
||||
* correct presentation resolution. This increases visual quality at
|
||||
* low data rates, at the expense of CPU time on the encoder/decoder.
|
||||
*/
|
||||
unsigned int rc_resize_allowed;
|
||||
|
||||
/*!\brief Internal coded frame width.
|
||||
*
|
||||
* If spatial resampling is enabled this specifies the width of the
|
||||
* encoded frame.
|
||||
*/
|
||||
unsigned int rc_scaled_width;
|
||||
|
||||
/*!\brief Internal coded frame height.
|
||||
*
|
||||
* If spatial resampling is enabled this specifies the height of the
|
||||
* encoded frame.
|
||||
*/
|
||||
unsigned int rc_scaled_height;
|
||||
|
||||
/*!\brief Spatial resampling up watermark.
|
||||
*
|
||||
* This threshold is described as a percentage of the target data buffer.
|
||||
* When the data buffer rises above this percentage of fullness, the
|
||||
* encoder will step up to a higher resolution version of the frame.
|
||||
*/
|
||||
unsigned int rc_resize_up_thresh;
|
||||
|
||||
/*!\brief Spatial resampling down watermark.
|
||||
*
|
||||
* This threshold is described as a percentage of the target data buffer.
|
||||
* When the data buffer falls below this percentage of fullness, the
|
||||
* encoder will step down to a lower resolution version of the frame.
|
||||
*/
|
||||
unsigned int rc_resize_down_thresh;
|
||||
|
||||
/*!\brief Rate control algorithm to use.
|
||||
*
|
||||
* Indicates whether the end usage of this stream is to be streamed over
|
||||
* a bandwidth constrained link, indicating that Constant Bit Rate (CBR)
|
||||
* mode should be used, or whether it will be played back on a high
|
||||
* bandwidth link, as from a local disk, where higher variations in
|
||||
* bitrate are acceptable.
|
||||
*/
|
||||
enum vpx_rc_mode rc_end_usage;
|
||||
|
||||
/*!\brief Two-pass stats buffer.
|
||||
*
|
||||
* A buffer containing all of the stats packets produced in the first
|
||||
* pass, concatenated.
|
||||
*/
|
||||
vpx_fixed_buf_t rc_twopass_stats_in;
|
||||
|
||||
/*!\brief first pass mb stats buffer.
|
||||
*
|
||||
* A buffer containing all of the first pass mb stats packets produced
|
||||
* in the first pass, concatenated.
|
||||
*/
|
||||
vpx_fixed_buf_t rc_firstpass_mb_stats_in;
|
||||
|
||||
/*!\brief Target data rate
|
||||
*
|
||||
* Target bandwidth to use for this stream, in kilobits per second.
|
||||
*/
|
||||
unsigned int rc_target_bitrate;
|
||||
|
||||
/*
|
||||
* quantizer settings
|
||||
*/
|
||||
|
||||
/*!\brief Minimum (Best Quality) Quantizer
|
||||
*
|
||||
* The quantizer is the most direct control over the quality of the
|
||||
* encoded image. The range of valid values for the quantizer is codec
|
||||
* specific. Consult the documentation for the codec to determine the
|
||||
* values to use.
|
||||
*/
|
||||
unsigned int rc_min_quantizer;
|
||||
|
||||
/*!\brief Maximum (Worst Quality) Quantizer
|
||||
*
|
||||
* The quantizer is the most direct control over the quality of the
|
||||
* encoded image. The range of valid values for the quantizer is codec
|
||||
* specific. Consult the documentation for the codec to determine the
|
||||
* values to use.
|
||||
*/
|
||||
unsigned int rc_max_quantizer;
|
||||
|
||||
/*
|
||||
* bitrate tolerance
|
||||
*/
|
||||
|
||||
/*!\brief Rate control adaptation undershoot control
|
||||
*
|
||||
* VP8: Expressed as a percentage of the target bitrate,
|
||||
* controls the maximum allowed adaptation speed of the codec.
|
||||
* This factor controls the maximum amount of bits that can
|
||||
* be subtracted from the target bitrate in order to compensate
|
||||
* for prior overshoot.
|
||||
* VP9: Expressed as a percentage of the target bitrate, a threshold
|
||||
* undershoot level (current rate vs target) beyond which more aggressive
|
||||
* corrective measures are taken.
|
||||
* *
|
||||
* Valid values in the range VP8:0-1000 VP9: 0-100.
|
||||
*/
|
||||
unsigned int rc_undershoot_pct;
|
||||
|
||||
/*!\brief Rate control adaptation overshoot control
|
||||
*
|
||||
* VP8: Expressed as a percentage of the target bitrate,
|
||||
* controls the maximum allowed adaptation speed of the codec.
|
||||
* This factor controls the maximum amount of bits that can
|
||||
* be added to the target bitrate in order to compensate for
|
||||
* prior undershoot.
|
||||
* VP9: Expressed as a percentage of the target bitrate, a threshold
|
||||
* overshoot level (current rate vs target) beyond which more aggressive
|
||||
* corrective measures are taken.
|
||||
*
|
||||
* Valid values in the range VP8:0-1000 VP9: 0-100.
|
||||
*/
|
||||
unsigned int rc_overshoot_pct;
|
||||
|
||||
/*
|
||||
* decoder buffer model parameters
|
||||
*/
|
||||
|
||||
/*!\brief Decoder Buffer Size
|
||||
*
|
||||
* This value indicates the amount of data that may be buffered by the
|
||||
* decoding application. Note that this value is expressed in units of
|
||||
* time (milliseconds). For example, a value of 5000 indicates that the
|
||||
* client will buffer (at least) 5000ms worth of encoded data. Use the
|
||||
* target bitrate (#rc_target_bitrate) to convert to bits/bytes, if
|
||||
* necessary.
|
||||
*/
|
||||
unsigned int rc_buf_sz;
|
||||
|
||||
/*!\brief Decoder Buffer Initial Size
|
||||
*
|
||||
* This value indicates the amount of data that will be buffered by the
|
||||
* decoding application prior to beginning playback. This value is
|
||||
* expressed in units of time (milliseconds). Use the target bitrate
|
||||
* (#rc_target_bitrate) to convert to bits/bytes, if necessary.
|
||||
*/
|
||||
unsigned int rc_buf_initial_sz;
|
||||
|
||||
/*!\brief Decoder Buffer Optimal Size
|
||||
*
|
||||
* This value indicates the amount of data that the encoder should try
|
||||
* to maintain in the decoder's buffer. This value is expressed in units
|
||||
* of time (milliseconds). Use the target bitrate (#rc_target_bitrate)
|
||||
* to convert to bits/bytes, if necessary.
|
||||
*/
|
||||
unsigned int rc_buf_optimal_sz;
|
||||
|
||||
/*
|
||||
* 2 pass rate control parameters
|
||||
*/
|
||||
|
||||
/*!\brief Two-pass mode CBR/VBR bias
|
||||
*
|
||||
* Bias, expressed on a scale of 0 to 100, for determining target size
|
||||
* for the current frame. The value 0 indicates the optimal CBR mode
|
||||
* value should be used. The value 100 indicates the optimal VBR mode
|
||||
* value should be used. Values in between indicate which way the
|
||||
* encoder should "lean."
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_bias_pct;
|
||||
|
||||
/*!\brief Two-pass mode per-GOP minimum bitrate
|
||||
*
|
||||
* This value, expressed as a percentage of the target bitrate, indicates
|
||||
* the minimum bitrate to be used for a single GOP (aka "section")
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_minsection_pct;
|
||||
|
||||
/*!\brief Two-pass mode per-GOP maximum bitrate
|
||||
*
|
||||
* This value, expressed as a percentage of the target bitrate, indicates
|
||||
* the maximum bitrate to be used for a single GOP (aka "section")
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_maxsection_pct;
|
||||
|
||||
/*!\brief Two-pass corpus vbr mode complexity control
|
||||
* Used only in VP9: A value representing the corpus midpoint complexity
|
||||
* for corpus vbr mode. This value defaults to 0 which disables corpus vbr
|
||||
* mode in favour of normal vbr mode.
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_corpus_complexity;
|
||||
|
||||
/*
|
||||
* keyframing settings (kf)
|
||||
*/
|
||||
|
||||
/*!\brief Keyframe placement mode
|
||||
*
|
||||
* This value indicates whether the encoder should place keyframes at a
|
||||
* fixed interval, or determine the optimal placement automatically
|
||||
* (as governed by the #kf_min_dist and #kf_max_dist parameters)
|
||||
*/
|
||||
enum vpx_kf_mode kf_mode;
|
||||
|
||||
/*!\brief Keyframe minimum interval
|
||||
*
|
||||
* This value, expressed as a number of frames, prevents the encoder from
|
||||
* placing a keyframe nearer than kf_min_dist to the previous keyframe. At
|
||||
* least kf_min_dist frames non-keyframes will be coded before the next
|
||||
* keyframe. Set kf_min_dist equal to kf_max_dist for a fixed interval.
|
||||
*/
|
||||
unsigned int kf_min_dist;
|
||||
|
||||
/*!\brief Keyframe maximum interval
|
||||
*
|
||||
* This value, expressed as a number of frames, forces the encoder to code
|
||||
* a keyframe if one has not been coded in the last kf_max_dist frames.
|
||||
* A value of 0 implies all frames will be keyframes. Set kf_min_dist
|
||||
* equal to kf_max_dist for a fixed interval.
|
||||
*/
|
||||
unsigned int kf_max_dist;
|
||||
|
||||
/*
|
||||
* Spatial scalability settings (ss)
|
||||
*/
|
||||
|
||||
/*!\brief Number of spatial coding layers.
|
||||
*
|
||||
* This value specifies the number of spatial coding layers to be used.
|
||||
*/
|
||||
unsigned int ss_number_layers;
|
||||
|
||||
/*!\brief Enable auto alt reference flags for each spatial layer.
|
||||
*
|
||||
* These values specify if auto alt reference frame is enabled for each
|
||||
* spatial layer.
|
||||
*/
|
||||
int ss_enable_auto_alt_ref[VPX_SS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Target bitrate for each spatial layer.
|
||||
*
|
||||
* These values specify the target coding bitrate to be used for each
|
||||
* spatial layer.
|
||||
*/
|
||||
unsigned int ss_target_bitrate[VPX_SS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Number of temporal coding layers.
|
||||
*
|
||||
* This value specifies the number of temporal layers to be used.
|
||||
*/
|
||||
unsigned int ts_number_layers;
|
||||
|
||||
/*!\brief Target bitrate for each temporal layer.
|
||||
*
|
||||
* These values specify the target coding bitrate to be used for each
|
||||
* temporal layer.
|
||||
*/
|
||||
unsigned int ts_target_bitrate[VPX_TS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Frame rate decimation factor for each temporal layer.
|
||||
*
|
||||
* These values specify the frame rate decimation factors to apply
|
||||
* to each temporal layer.
|
||||
*/
|
||||
unsigned int ts_rate_decimator[VPX_TS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Length of the sequence defining frame temporal layer membership.
|
||||
*
|
||||
* This value specifies the length of the sequence that defines the
|
||||
* membership of frames to temporal layers. For example, if the
|
||||
* ts_periodicity = 8, then the frames are assigned to coding layers with a
|
||||
* repeated sequence of length 8.
|
||||
*/
|
||||
unsigned int ts_periodicity;
|
||||
|
||||
/*!\brief Template defining the membership of frames to temporal layers.
|
||||
*
|
||||
* This array defines the membership of frames to temporal coding layers.
|
||||
* For a 2-layer encoding that assigns even numbered frames to one temporal
|
||||
* layer (0) and odd numbered frames to a second temporal layer (1) with
|
||||
* ts_periodicity=8, then ts_layer_id = (0,1,0,1,0,1,0,1).
|
||||
*/
|
||||
unsigned int ts_layer_id[VPX_TS_MAX_PERIODICITY];
|
||||
|
||||
/*!\brief Target bitrate for each spatial/temporal layer.
|
||||
*
|
||||
* These values specify the target coding bitrate to be used for each
|
||||
* spatial/temporal layer.
|
||||
*
|
||||
*/
|
||||
unsigned int layer_target_bitrate[VPX_MAX_LAYERS];
|
||||
|
||||
/*!\brief Temporal layering mode indicating which temporal layering scheme to
|
||||
* use.
|
||||
*
|
||||
* The value (refer to VP9E_TEMPORAL_LAYERING_MODE) specifies the
|
||||
* temporal layering mode to use.
|
||||
*
|
||||
*/
|
||||
int temporal_layering_mode;
|
||||
} vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */
|
||||
|
||||
/*!\brief vp9 svc extra configure parameters
|
||||
*
|
||||
* This defines max/min quantizers and scale factors for each layer
|
||||
*
|
||||
*/
|
||||
typedef struct vpx_svc_parameters {
|
||||
int max_quantizers[VPX_MAX_LAYERS]; /**< Max Q for each layer */
|
||||
int min_quantizers[VPX_MAX_LAYERS]; /**< Min Q for each layer */
|
||||
int scaling_factor_num[VPX_MAX_LAYERS]; /**< Scaling factor-numerator */
|
||||
int scaling_factor_den[VPX_MAX_LAYERS]; /**< Scaling factor-denominator */
|
||||
int speed_per_layer[VPX_MAX_LAYERS]; /**< Speed setting for each sl */
|
||||
int temporal_layering_mode; /**< Temporal layering mode */
|
||||
} vpx_svc_extra_cfg_t;
|
||||
|
||||
/*!\brief Initialize an encoder instance
|
||||
*
|
||||
* Initializes a encoder context using the given interface. Applications
|
||||
* should call the vpx_codec_enc_init convenience macro instead of this
|
||||
* function directly, to ensure that the ABI version number parameter
|
||||
* is properly initialized.
|
||||
*
|
||||
* If the library was configured with --disable-multithread, this call
|
||||
* is not thread safe and should be guarded with a lock if being used
|
||||
* in a multithreaded context.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[in] cfg Configuration to use, if known. May be NULL.
|
||||
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
|
||||
* \param[in] ver ABI version number. Must be set to
|
||||
* VPX_ENCODER_ABI_VERSION
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The decoder algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_iface_t *iface,
|
||||
const vpx_codec_enc_cfg_t *cfg,
|
||||
vpx_codec_flags_t flags, int ver);
|
||||
|
||||
/*!\brief Convenience macro for vpx_codec_enc_init_ver()
|
||||
*
|
||||
* Ensures the ABI version parameter is properly set.
|
||||
*/
|
||||
#define vpx_codec_enc_init(ctx, iface, cfg, flags) \
|
||||
vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION)
|
||||
|
||||
/*!\brief Initialize multi-encoder instance
|
||||
*
|
||||
* Initializes multi-encoder context using the given interface.
|
||||
* Applications should call the vpx_codec_enc_init_multi convenience macro
|
||||
* instead of this function directly, to ensure that the ABI version number
|
||||
* parameter is properly initialized.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[in] cfg Configuration to use, if known. May be NULL.
|
||||
* \param[in] num_enc Total number of encoders.
|
||||
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
|
||||
* \param[in] dsf Pointer to down-sampling factors.
|
||||
* \param[in] ver ABI version number. Must be set to
|
||||
* VPX_ENCODER_ABI_VERSION
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The decoder algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_init_multi_ver(
|
||||
vpx_codec_ctx_t *ctx, vpx_codec_iface_t *iface, vpx_codec_enc_cfg_t *cfg,
|
||||
int num_enc, vpx_codec_flags_t flags, vpx_rational_t *dsf, int ver);
|
||||
|
||||
/*!\brief Convenience macro for vpx_codec_enc_init_multi_ver()
|
||||
*
|
||||
* Ensures the ABI version parameter is properly set.
|
||||
*/
|
||||
#define vpx_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \
|
||||
vpx_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \
|
||||
VPX_ENCODER_ABI_VERSION)
|
||||
|
||||
/*!\brief Get a default configuration
|
||||
*
|
||||
* Initializes a encoder configuration structure with default values. Supports
|
||||
* the notion of "usages" so that an algorithm may offer different default
|
||||
* settings depending on the user's intended goal. This function \ref SHOULD
|
||||
* be called by all applications to initialize the configuration structure
|
||||
* before specializing the configuration with application specific values.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[out] cfg Configuration buffer to populate.
|
||||
* \param[in] usage Must be set to 0.
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The configuration was populated.
|
||||
* \retval #VPX_CODEC_INCAPABLE
|
||||
* Interface is not an encoder interface.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, or the usage value was not recognized.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface,
|
||||
vpx_codec_enc_cfg_t *cfg,
|
||||
unsigned int usage);
|
||||
|
||||
/*!\brief Set or change configuration
|
||||
*
|
||||
* Reconfigures an encoder instance according to the given configuration.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cfg Configuration buffer to use
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The configuration was populated.
|
||||
* \retval #VPX_CODEC_INCAPABLE
|
||||
* Interface is not an encoder interface.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, or the usage value was not recognized.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx,
|
||||
const vpx_codec_enc_cfg_t *cfg);
|
||||
|
||||
/*!\brief Get global stream headers
|
||||
*
|
||||
* Retrieves a stream level global header packet, if supported by the codec.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
*
|
||||
* \retval NULL
|
||||
* Encoder does not support global header
|
||||
* \retval Non-NULL
|
||||
* Pointer to buffer containing global header packet
|
||||
*/
|
||||
vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!\brief deadline parameter analogous to VPx REALTIME mode. */
|
||||
#define VPX_DL_REALTIME (1)
|
||||
/*!\brief deadline parameter analogous to VPx GOOD QUALITY mode. */
|
||||
#define VPX_DL_GOOD_QUALITY (1000000)
|
||||
/*!\brief deadline parameter analogous to VPx BEST QUALITY mode. */
|
||||
#define VPX_DL_BEST_QUALITY (0)
|
||||
/*!\brief Encode a frame
|
||||
*
|
||||
* Encodes a video frame at the given "presentation time." The presentation
|
||||
* time stamp (PTS) \ref MUST be strictly increasing.
|
||||
*
|
||||
* The encoder supports the notion of a soft real-time deadline. Given a
|
||||
* non-zero value to the deadline parameter, the encoder will make a "best
|
||||
* effort" guarantee to return before the given time slice expires. It is
|
||||
* implicit that limiting the available time to encode will degrade the
|
||||
* output quality. The encoder can be given an unlimited time to produce the
|
||||
* best possible frame by specifying a deadline of '0'. This deadline
|
||||
* supersedes the VPx notion of "best quality, good quality, realtime".
|
||||
* Applications that wish to map these former settings to the new deadline
|
||||
* based system can use the symbols #VPX_DL_REALTIME, #VPX_DL_GOOD_QUALITY,
|
||||
* and #VPX_DL_BEST_QUALITY.
|
||||
*
|
||||
* When the last frame has been passed to the encoder, this function should
|
||||
* continue to be called, with the img parameter set to NULL. This will
|
||||
* signal the end-of-stream condition to the encoder and allow it to encode
|
||||
* any held buffers. Encoding is complete when vpx_codec_encode() is called
|
||||
* and vpx_codec_get_cx_data() returns no data.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] img Image data to encode, NULL to flush.
|
||||
* \param[in] pts Presentation time stamp, in timebase units.
|
||||
* \param[in] duration Duration to show frame, in timebase units.
|
||||
* \param[in] flags Flags to use for encoding this frame.
|
||||
* \param[in] deadline Time to spend encoding, in microseconds. (0=infinite)
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The configuration was populated.
|
||||
* \retval #VPX_CODEC_INCAPABLE
|
||||
* Interface is not an encoder interface.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, the image format is unsupported, etc.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx, const vpx_image_t *img,
|
||||
vpx_codec_pts_t pts, unsigned long duration,
|
||||
vpx_enc_frame_flags_t flags,
|
||||
unsigned long deadline);
|
||||
|
||||
/*!\brief Set compressed data output buffer
|
||||
*
|
||||
* Sets the buffer that the codec should output the compressed data
|
||||
* into. This call effectively sets the buffer pointer returned in the
|
||||
* next VPX_CODEC_CX_FRAME_PKT packet. Subsequent packets will be
|
||||
* appended into this buffer. The buffer is preserved across frames,
|
||||
* so applications must periodically call this function after flushing
|
||||
* the accumulated compressed data to disk or to the network to reset
|
||||
* the pointer to the buffer's head.
|
||||
*
|
||||
* `pad_before` bytes will be skipped before writing the compressed
|
||||
* data, and `pad_after` bytes will be appended to the packet. The size
|
||||
* of the packet will be the sum of the size of the actual compressed
|
||||
* data, pad_before, and pad_after. The padding bytes will be preserved
|
||||
* (not overwritten).
|
||||
*
|
||||
* Note that calling this function does not guarantee that the returned
|
||||
* compressed data will be placed into the specified buffer. In the
|
||||
* event that the encoded data will not fit into the buffer provided,
|
||||
* the returned packet \ref MAY point to an internal buffer, as it would
|
||||
* if this call were never used. In this event, the output packet will
|
||||
* NOT have any padding, and the application must free space and copy it
|
||||
* to the proper place. This is of particular note in configurations
|
||||
* that may output multiple packets for a single encoded frame (e.g., lagged
|
||||
* encoding) or if the application does not reset the buffer periodically.
|
||||
*
|
||||
* Applications may restore the default behavior of the codec providing
|
||||
* the compressed data buffer by calling this function with a NULL
|
||||
* buffer.
|
||||
*
|
||||
* Applications \ref MUSTNOT call this function during iteration of
|
||||
* vpx_codec_get_cx_data().
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] buf Buffer to store compressed data into
|
||||
* \param[in] pad_before Bytes to skip before writing compressed data
|
||||
* \param[in] pad_after Bytes to skip after writing compressed data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The buffer was set successfully.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, the image format is unsupported, etc.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx,
|
||||
const vpx_fixed_buf_t *buf,
|
||||
unsigned int pad_before,
|
||||
unsigned int pad_after);
|
||||
|
||||
/*!\brief Encoded data iterator
|
||||
*
|
||||
* Iterates over a list of data packets to be passed from the encoder to the
|
||||
* application. The different kinds of packets available are enumerated in
|
||||
* #vpx_codec_cx_pkt_kind.
|
||||
*
|
||||
* #VPX_CODEC_CX_FRAME_PKT packets should be passed to the application's
|
||||
* muxer. Multiple compressed frames may be in the list.
|
||||
* #VPX_CODEC_STATS_PKT packets should be appended to a global buffer.
|
||||
*
|
||||
* The application \ref MUST silently ignore any packet kinds that it does
|
||||
* not recognize or support.
|
||||
*
|
||||
* The data buffers returned from this function are only guaranteed to be
|
||||
* valid until the application makes another call to any vpx_codec_* function.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] iter Iterator storage, initialized to NULL
|
||||
*
|
||||
* \return Returns a pointer to an output data packet (compressed frame data,
|
||||
* two-pass statistics, etc.) or NULL to signal end-of-list.
|
||||
*
|
||||
*/
|
||||
const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_iter_t *iter);
|
||||
|
||||
/*!\brief Get Preview Frame
|
||||
*
|
||||
* Returns an image that can be used as a preview. Shows the image as it would
|
||||
* exist at the decompressor. The application \ref MUST NOT write into this
|
||||
* image buffer.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
*
|
||||
* \return Returns a pointer to a preview image, or NULL if no image is
|
||||
* available.
|
||||
*
|
||||
*/
|
||||
const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!@} - end defgroup encoder*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // VPX_VPX_VPX_ENCODER_H_
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef VPX_VPX_VPX_FRAME_BUFFER_H_
|
||||
#define VPX_VPX_VPX_FRAME_BUFFER_H_
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the decoder external frame buffer interface.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_integer.h"
|
||||
|
||||
/*!\brief The maximum number of work buffers used by libvpx.
|
||||
* Support maximum 4 threads to decode video in parallel.
|
||||
* Each thread will use one work buffer.
|
||||
* TODO(hkuang): Add support to set number of worker threads dynamically.
|
||||
*/
|
||||
#define VPX_MAXIMUM_WORK_BUFFERS 8
|
||||
|
||||
/*!\brief The maximum number of reference buffers that a VP9 encoder may use.
|
||||
*/
|
||||
#define VP9_MAXIMUM_REF_BUFFERS 8
|
||||
|
||||
/*!\brief External frame buffer
|
||||
*
|
||||
* This structure holds allocated frame buffers used by the decoder.
|
||||
*/
|
||||
typedef struct vpx_codec_frame_buffer {
|
||||
uint8_t *data; /**< Pointer to the data buffer */
|
||||
size_t size; /**< Size of data in bytes */
|
||||
void *priv; /**< Frame's private data */
|
||||
} vpx_codec_frame_buffer_t;
|
||||
|
||||
/*!\brief get frame buffer callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to retrieve data for the frame
|
||||
* buffer in order for the decode call to complete. The callback must
|
||||
* allocate at least min_size in bytes and assign it to fb->data. The callback
|
||||
* must zero out all the data allocated. Then the callback must set fb->size
|
||||
* to the allocated size. The application does not need to align the allocated
|
||||
* data. The callback is triggered when the decoder needs a frame buffer to
|
||||
* decode a compressed image into. This function may be called more than once
|
||||
* for every call to vpx_codec_decode. The application may set fb->priv to
|
||||
* some data which will be passed back in the ximage and the release function
|
||||
* call. |fb| is guaranteed to not be NULL. On success the callback must
|
||||
* return 0. Any failure the callback must return a value less than 0.
|
||||
*
|
||||
* \param[in] priv Callback's private data
|
||||
* \param[in] min_size Size in bytes needed by the buffer
|
||||
* \param[in,out] fb Pointer to vpx_codec_frame_buffer_t
|
||||
*/
|
||||
typedef int (*vpx_get_frame_buffer_cb_fn_t)(void *priv, size_t min_size,
|
||||
vpx_codec_frame_buffer_t *fb);
|
||||
|
||||
/*!\brief release frame buffer callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder when the frame buffer is not
|
||||
* referenced by any other buffers. |fb| is guaranteed to not be NULL. On
|
||||
* success the callback must return 0. Any failure the callback must return
|
||||
* a value less than 0.
|
||||
*
|
||||
* \param[in] priv Callback's private data
|
||||
* \param[in] fb Pointer to vpx_codec_frame_buffer_t
|
||||
*/
|
||||
typedef int (*vpx_release_frame_buffer_cb_fn_t)(void *priv,
|
||||
vpx_codec_frame_buffer_t *fb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VPX_FRAME_BUFFER_H_
|
||||
207
vpx-encoder/android_libs/armeabi-v7a/include/vpx/vpx_image.h
Normal file
207
vpx-encoder/android_libs/armeabi-v7a/include/vpx/vpx_image.h
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the vpx image descriptor and associated operations
|
||||
*
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_IMAGE_H_
|
||||
#define VPX_VPX_VPX_IMAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_IMAGE_ABI_VERSION (5) /**<\hideinitializer*/
|
||||
|
||||
#define VPX_IMG_FMT_PLANAR 0x100 /**< Image is a planar format. */
|
||||
#define VPX_IMG_FMT_UV_FLIP 0x200 /**< V plane precedes U in memory. */
|
||||
#define VPX_IMG_FMT_HAS_ALPHA 0x400 /**< Image has an alpha channel. */
|
||||
#define VPX_IMG_FMT_HIGHBITDEPTH 0x800 /**< Image uses 16bit framebuffer. */
|
||||
|
||||
/*!\brief List of supported image formats */
|
||||
typedef enum vpx_img_fmt {
|
||||
VPX_IMG_FMT_NONE,
|
||||
VPX_IMG_FMT_YV12 =
|
||||
VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
|
||||
VPX_IMG_FMT_I420 = VPX_IMG_FMT_PLANAR | 2,
|
||||
VPX_IMG_FMT_I422 = VPX_IMG_FMT_PLANAR | 5,
|
||||
VPX_IMG_FMT_I444 = VPX_IMG_FMT_PLANAR | 6,
|
||||
VPX_IMG_FMT_I440 = VPX_IMG_FMT_PLANAR | 7,
|
||||
VPX_IMG_FMT_I42016 = VPX_IMG_FMT_I420 | VPX_IMG_FMT_HIGHBITDEPTH,
|
||||
VPX_IMG_FMT_I42216 = VPX_IMG_FMT_I422 | VPX_IMG_FMT_HIGHBITDEPTH,
|
||||
VPX_IMG_FMT_I44416 = VPX_IMG_FMT_I444 | VPX_IMG_FMT_HIGHBITDEPTH,
|
||||
VPX_IMG_FMT_I44016 = VPX_IMG_FMT_I440 | VPX_IMG_FMT_HIGHBITDEPTH
|
||||
} vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
|
||||
|
||||
/*!\brief List of supported color spaces */
|
||||
typedef enum vpx_color_space {
|
||||
VPX_CS_UNKNOWN = 0, /**< Unknown */
|
||||
VPX_CS_BT_601 = 1, /**< BT.601 */
|
||||
VPX_CS_BT_709 = 2, /**< BT.709 */
|
||||
VPX_CS_SMPTE_170 = 3, /**< SMPTE.170 */
|
||||
VPX_CS_SMPTE_240 = 4, /**< SMPTE.240 */
|
||||
VPX_CS_BT_2020 = 5, /**< BT.2020 */
|
||||
VPX_CS_RESERVED = 6, /**< Reserved */
|
||||
VPX_CS_SRGB = 7 /**< sRGB */
|
||||
} vpx_color_space_t; /**< alias for enum vpx_color_space */
|
||||
|
||||
/*!\brief List of supported color range */
|
||||
typedef enum vpx_color_range {
|
||||
VPX_CR_STUDIO_RANGE = 0, /**< Y [16..235], UV [16..240] */
|
||||
VPX_CR_FULL_RANGE = 1 /**< YUV/RGB [0..255] */
|
||||
} vpx_color_range_t; /**< alias for enum vpx_color_range */
|
||||
|
||||
/**\brief Image Descriptor */
|
||||
typedef struct vpx_image {
|
||||
vpx_img_fmt_t fmt; /**< Image Format */
|
||||
vpx_color_space_t cs; /**< Color Space */
|
||||
vpx_color_range_t range; /**< Color Range */
|
||||
|
||||
/* Image storage dimensions */
|
||||
unsigned int w; /**< Stored image width */
|
||||
unsigned int h; /**< Stored image height */
|
||||
unsigned int bit_depth; /**< Stored image bit-depth */
|
||||
|
||||
/* Image display dimensions */
|
||||
unsigned int d_w; /**< Displayed image width */
|
||||
unsigned int d_h; /**< Displayed image height */
|
||||
|
||||
/* Image intended rendering dimensions */
|
||||
unsigned int r_w; /**< Intended rendering image width */
|
||||
unsigned int r_h; /**< Intended rendering image height */
|
||||
|
||||
/* Chroma subsampling info */
|
||||
unsigned int x_chroma_shift; /**< subsampling order, X */
|
||||
unsigned int y_chroma_shift; /**< subsampling order, Y */
|
||||
|
||||
/* Image data pointers. */
|
||||
#define VPX_PLANE_PACKED 0 /**< To be used for all packed formats */
|
||||
#define VPX_PLANE_Y 0 /**< Y (Luminance) plane */
|
||||
#define VPX_PLANE_U 1 /**< U (Chroma) plane */
|
||||
#define VPX_PLANE_V 2 /**< V (Chroma) plane */
|
||||
#define VPX_PLANE_ALPHA 3 /**< A (Transparency) plane */
|
||||
unsigned char *planes[4]; /**< pointer to the top left pixel for each plane */
|
||||
int stride[4]; /**< stride between rows for each plane */
|
||||
|
||||
int bps; /**< bits per sample (for packed formats) */
|
||||
|
||||
/*!\brief The following member may be set by the application to associate
|
||||
* data with this image.
|
||||
*/
|
||||
void *user_priv;
|
||||
|
||||
/* The following members should be treated as private. */
|
||||
unsigned char *img_data; /**< private */
|
||||
int img_data_owner; /**< private */
|
||||
int self_allocd; /**< private */
|
||||
|
||||
void *fb_priv; /**< Frame buffer data associated with the image. */
|
||||
} vpx_image_t; /**< alias for struct vpx_image */
|
||||
|
||||
/**\brief Representation of a rectangle on a surface */
|
||||
typedef struct vpx_image_rect {
|
||||
unsigned int x; /**< leftmost column */
|
||||
unsigned int y; /**< topmost row */
|
||||
unsigned int w; /**< width */
|
||||
unsigned int h; /**< height */
|
||||
} vpx_image_rect_t; /**< alias for struct vpx_image_rect */
|
||||
|
||||
/*!\brief Open a descriptor, allocating storage for the underlying image
|
||||
*
|
||||
* Returns a descriptor for storing an image of the given format. The
|
||||
* storage for the descriptor is allocated on the heap.
|
||||
*
|
||||
* \param[in] img Pointer to storage for descriptor. If this parameter
|
||||
* is NULL, the storage for the descriptor will be
|
||||
* allocated on the heap.
|
||||
* \param[in] fmt Format for the image
|
||||
* \param[in] d_w Width of the image
|
||||
* \param[in] d_h Height of the image
|
||||
* \param[in] align Alignment, in bytes, of the image buffer and
|
||||
* each row in the image(stride).
|
||||
*
|
||||
* \return Returns a pointer to the initialized image descriptor. If the img
|
||||
* parameter is non-null, the value of the img parameter will be
|
||||
* returned.
|
||||
*/
|
||||
vpx_image_t *vpx_img_alloc(vpx_image_t *img, vpx_img_fmt_t fmt,
|
||||
unsigned int d_w, unsigned int d_h,
|
||||
unsigned int align);
|
||||
|
||||
/*!\brief Open a descriptor, using existing storage for the underlying image
|
||||
*
|
||||
* Returns a descriptor for storing an image of the given format. The
|
||||
* storage for descriptor has been allocated elsewhere, and a descriptor is
|
||||
* desired to "wrap" that storage.
|
||||
*
|
||||
* \param[in] img Pointer to storage for descriptor. If this
|
||||
* parameter is NULL, the storage for the descriptor
|
||||
* will be allocated on the heap.
|
||||
* \param[in] fmt Format for the image
|
||||
* \param[in] d_w Width of the image
|
||||
* \param[in] d_h Height of the image
|
||||
* \param[in] stride_align Alignment, in bytes, of each row in the image.
|
||||
* \param[in] img_data Storage to use for the image
|
||||
*
|
||||
* \return Returns a pointer to the initialized image descriptor. If the img
|
||||
* parameter is non-null, the value of the img parameter will be
|
||||
* returned.
|
||||
*/
|
||||
vpx_image_t *vpx_img_wrap(vpx_image_t *img, vpx_img_fmt_t fmt, unsigned int d_w,
|
||||
unsigned int d_h, unsigned int stride_align,
|
||||
unsigned char *img_data);
|
||||
|
||||
/*!\brief Set the rectangle identifying the displayed portion of the image
|
||||
*
|
||||
* Updates the displayed rectangle (aka viewport) on the image surface to
|
||||
* match the specified coordinates and size.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
* \param[in] x leftmost column
|
||||
* \param[in] y topmost row
|
||||
* \param[in] w width
|
||||
* \param[in] h height
|
||||
*
|
||||
* \return 0 if the requested rectangle is valid, nonzero otherwise.
|
||||
*/
|
||||
int vpx_img_set_rect(vpx_image_t *img, unsigned int x, unsigned int y,
|
||||
unsigned int w, unsigned int h);
|
||||
|
||||
/*!\brief Flip the image vertically (top for bottom)
|
||||
*
|
||||
* Adjusts the image descriptor's pointers and strides to make the image
|
||||
* be referenced upside-down.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
*/
|
||||
void vpx_img_flip(vpx_image_t *img);
|
||||
|
||||
/*!\brief Close an image descriptor
|
||||
*
|
||||
* Frees all allocated storage associated with an image descriptor.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
*/
|
||||
void vpx_img_free(vpx_image_t *img);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VPX_IMAGE_H_
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef VPX_VPX_VPX_INTEGER_H_
|
||||
#define VPX_VPX_VPX_INTEGER_H_
|
||||
|
||||
/* get ptrdiff_t, size_t, wchar_t, NULL */
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define VPX_FORCE_INLINE __forceinline
|
||||
#define VPX_INLINE __inline
|
||||
#else
|
||||
#define VPX_FORCE_INLINE __inline__ __attribute__((always_inline))
|
||||
// TODO(jbb): Allow a way to force inline off for older compilers.
|
||||
#define VPX_INLINE inline
|
||||
#endif
|
||||
|
||||
/* Assume platforms have the C99 standard integer types. */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#if !defined(__STDC_FORMAT_MACROS)
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#endif
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
#define __STDC_LIMIT_MACROS
|
||||
#endif
|
||||
#endif // __cplusplus
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#endif // VPX_VPX_VPX_INTEGER_H_
|
||||
BIN
vpx-encoder/android_libs/armeabi-v7a/lib/libvpx.a
Normal file
BIN
vpx-encoder/android_libs/armeabi-v7a/lib/libvpx.a
Normal file
Binary file not shown.
14
vpx-encoder/android_libs/armeabi-v7a/lib/pkgconfig/vpx.pc
Normal file
14
vpx-encoder/android_libs/armeabi-v7a/lib/pkgconfig/vpx.pc
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# pkg-config file from libvpx v1.8.0
|
||||
prefix=/Users/andy/go/src/github.com/webmproject/jni/vpx-android/output/android/armeabi-v7a
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: vpx
|
||||
Description: WebM Project VPx codec implementation
|
||||
Version: 1.8.0
|
||||
Requires:
|
||||
Conflicts:
|
||||
Libs: -L${libdir} -lvpx -lm
|
||||
Libs.private: -lm
|
||||
Cflags: -I${includedir}
|
||||
44
vpx-encoder/android_libs/x86/include/common/file_util.h
Normal file
44
vpx-encoder/android_libs/x86/include/common/file_util.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright (c) 2016 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
#ifndef LIBWEBM_COMMON_FILE_UTIL_H_
|
||||
#define LIBWEBM_COMMON_FILE_UTIL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "mkvmuxer/mkvmuxertypes.h" // LIBWEBM_DISALLOW_COPY_AND_ASSIGN()
|
||||
|
||||
namespace libwebm {
|
||||
|
||||
// Returns a temporary file name.
|
||||
std::string GetTempFileName();
|
||||
|
||||
// Returns size of file specified by |file_name|, or 0 upon failure.
|
||||
uint64_t GetFileSize(const std::string& file_name);
|
||||
|
||||
// Gets the contents file_name as a string. Returns false on error.
|
||||
bool GetFileContents(const std::string& file_name, std::string* contents);
|
||||
|
||||
// Manages life of temporary file specified at time of construction. Deletes
|
||||
// file upon destruction.
|
||||
class TempFileDeleter {
|
||||
public:
|
||||
TempFileDeleter();
|
||||
explicit TempFileDeleter(std::string file_name) : file_name_(file_name) {}
|
||||
~TempFileDeleter();
|
||||
const std::string& name() const { return file_name_; }
|
||||
|
||||
private:
|
||||
std::string file_name_;
|
||||
LIBWEBM_DISALLOW_COPY_AND_ASSIGN(TempFileDeleter);
|
||||
};
|
||||
|
||||
} // namespace libwebm
|
||||
|
||||
#endif // LIBWEBM_COMMON_FILE_UTIL_H_
|
||||
71
vpx-encoder/android_libs/x86/include/common/hdr_util.h
Normal file
71
vpx-encoder/android_libs/x86/include/common/hdr_util.h
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
// Copyright (c) 2016 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
#ifndef LIBWEBM_COMMON_HDR_UTIL_H_
|
||||
#define LIBWEBM_COMMON_HDR_UTIL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "mkvmuxer/mkvmuxer.h"
|
||||
|
||||
namespace mkvparser {
|
||||
struct Colour;
|
||||
struct MasteringMetadata;
|
||||
struct PrimaryChromaticity;
|
||||
} // namespace mkvparser
|
||||
|
||||
namespace libwebm {
|
||||
// Utility types and functions for working with the Colour element and its
|
||||
// children. Copiers return true upon success. Presence functions return true
|
||||
// when the specified element is present.
|
||||
|
||||
// TODO(tomfinegan): These should be moved to libwebm_utils once c++11 is
|
||||
// required by libwebm.
|
||||
|
||||
// Features of the VP9 codec that may be set in the CodecPrivate of a VP9 video
|
||||
// stream. A value of kValueNotPresent represents that the value was not set in
|
||||
// the CodecPrivate.
|
||||
struct Vp9CodecFeatures {
|
||||
static const int kValueNotPresent;
|
||||
|
||||
Vp9CodecFeatures()
|
||||
: profile(kValueNotPresent),
|
||||
level(kValueNotPresent),
|
||||
bit_depth(kValueNotPresent),
|
||||
chroma_subsampling(kValueNotPresent) {}
|
||||
~Vp9CodecFeatures() {}
|
||||
|
||||
int profile;
|
||||
int level;
|
||||
int bit_depth;
|
||||
int chroma_subsampling;
|
||||
};
|
||||
|
||||
typedef std::unique_ptr<mkvmuxer::PrimaryChromaticity> PrimaryChromaticityPtr;
|
||||
|
||||
bool CopyPrimaryChromaticity(const mkvparser::PrimaryChromaticity& parser_pc,
|
||||
PrimaryChromaticityPtr* muxer_pc);
|
||||
|
||||
bool MasteringMetadataValuePresent(double value);
|
||||
|
||||
bool CopyMasteringMetadata(const mkvparser::MasteringMetadata& parser_mm,
|
||||
mkvmuxer::MasteringMetadata* muxer_mm);
|
||||
|
||||
bool ColourValuePresent(long long value);
|
||||
|
||||
bool CopyColour(const mkvparser::Colour& parser_colour,
|
||||
mkvmuxer::Colour* muxer_colour);
|
||||
|
||||
// Returns true if |features| is set to one or more valid values.
|
||||
bool ParseVpxCodecPrivate(const uint8_t* private_data, int32_t length,
|
||||
Vp9CodecFeatures* features);
|
||||
|
||||
} // namespace libwebm
|
||||
|
||||
#endif // LIBWEBM_COMMON_HDR_UTIL_H_
|
||||
193
vpx-encoder/android_libs/x86/include/common/webmids.h
Normal file
193
vpx-encoder/android_libs/x86/include/common/webmids.h
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
#ifndef COMMON_WEBMIDS_H_
|
||||
#define COMMON_WEBMIDS_H_
|
||||
|
||||
namespace libwebm {
|
||||
|
||||
enum MkvId {
|
||||
kMkvEBML = 0x1A45DFA3,
|
||||
kMkvEBMLVersion = 0x4286,
|
||||
kMkvEBMLReadVersion = 0x42F7,
|
||||
kMkvEBMLMaxIDLength = 0x42F2,
|
||||
kMkvEBMLMaxSizeLength = 0x42F3,
|
||||
kMkvDocType = 0x4282,
|
||||
kMkvDocTypeVersion = 0x4287,
|
||||
kMkvDocTypeReadVersion = 0x4285,
|
||||
kMkvVoid = 0xEC,
|
||||
kMkvSignatureSlot = 0x1B538667,
|
||||
kMkvSignatureAlgo = 0x7E8A,
|
||||
kMkvSignatureHash = 0x7E9A,
|
||||
kMkvSignaturePublicKey = 0x7EA5,
|
||||
kMkvSignature = 0x7EB5,
|
||||
kMkvSignatureElements = 0x7E5B,
|
||||
kMkvSignatureElementList = 0x7E7B,
|
||||
kMkvSignedElement = 0x6532,
|
||||
// segment
|
||||
kMkvSegment = 0x18538067,
|
||||
// Meta Seek Information
|
||||
kMkvSeekHead = 0x114D9B74,
|
||||
kMkvSeek = 0x4DBB,
|
||||
kMkvSeekID = 0x53AB,
|
||||
kMkvSeekPosition = 0x53AC,
|
||||
// Segment Information
|
||||
kMkvInfo = 0x1549A966,
|
||||
kMkvTimecodeScale = 0x2AD7B1,
|
||||
kMkvDuration = 0x4489,
|
||||
kMkvDateUTC = 0x4461,
|
||||
kMkvTitle = 0x7BA9,
|
||||
kMkvMuxingApp = 0x4D80,
|
||||
kMkvWritingApp = 0x5741,
|
||||
// Cluster
|
||||
kMkvCluster = 0x1F43B675,
|
||||
kMkvTimecode = 0xE7,
|
||||
kMkvPrevSize = 0xAB,
|
||||
kMkvBlockGroup = 0xA0,
|
||||
kMkvBlock = 0xA1,
|
||||
kMkvBlockDuration = 0x9B,
|
||||
kMkvReferenceBlock = 0xFB,
|
||||
kMkvLaceNumber = 0xCC,
|
||||
kMkvSimpleBlock = 0xA3,
|
||||
kMkvBlockAdditions = 0x75A1,
|
||||
kMkvBlockMore = 0xA6,
|
||||
kMkvBlockAddID = 0xEE,
|
||||
kMkvBlockAdditional = 0xA5,
|
||||
kMkvDiscardPadding = 0x75A2,
|
||||
// Track
|
||||
kMkvTracks = 0x1654AE6B,
|
||||
kMkvTrackEntry = 0xAE,
|
||||
kMkvTrackNumber = 0xD7,
|
||||
kMkvTrackUID = 0x73C5,
|
||||
kMkvTrackType = 0x83,
|
||||
kMkvFlagEnabled = 0xB9,
|
||||
kMkvFlagDefault = 0x88,
|
||||
kMkvFlagForced = 0x55AA,
|
||||
kMkvFlagLacing = 0x9C,
|
||||
kMkvDefaultDuration = 0x23E383,
|
||||
kMkvMaxBlockAdditionID = 0x55EE,
|
||||
kMkvName = 0x536E,
|
||||
kMkvLanguage = 0x22B59C,
|
||||
kMkvCodecID = 0x86,
|
||||
kMkvCodecPrivate = 0x63A2,
|
||||
kMkvCodecName = 0x258688,
|
||||
kMkvCodecDelay = 0x56AA,
|
||||
kMkvSeekPreRoll = 0x56BB,
|
||||
// video
|
||||
kMkvVideo = 0xE0,
|
||||
kMkvFlagInterlaced = 0x9A,
|
||||
kMkvStereoMode = 0x53B8,
|
||||
kMkvAlphaMode = 0x53C0,
|
||||
kMkvPixelWidth = 0xB0,
|
||||
kMkvPixelHeight = 0xBA,
|
||||
kMkvPixelCropBottom = 0x54AA,
|
||||
kMkvPixelCropTop = 0x54BB,
|
||||
kMkvPixelCropLeft = 0x54CC,
|
||||
kMkvPixelCropRight = 0x54DD,
|
||||
kMkvDisplayWidth = 0x54B0,
|
||||
kMkvDisplayHeight = 0x54BA,
|
||||
kMkvDisplayUnit = 0x54B2,
|
||||
kMkvAspectRatioType = 0x54B3,
|
||||
kMkvColourSpace = 0x2EB524,
|
||||
kMkvFrameRate = 0x2383E3,
|
||||
// end video
|
||||
// colour
|
||||
kMkvColour = 0x55B0,
|
||||
kMkvMatrixCoefficients = 0x55B1,
|
||||
kMkvBitsPerChannel = 0x55B2,
|
||||
kMkvChromaSubsamplingHorz = 0x55B3,
|
||||
kMkvChromaSubsamplingVert = 0x55B4,
|
||||
kMkvCbSubsamplingHorz = 0x55B5,
|
||||
kMkvCbSubsamplingVert = 0x55B6,
|
||||
kMkvChromaSitingHorz = 0x55B7,
|
||||
kMkvChromaSitingVert = 0x55B8,
|
||||
kMkvRange = 0x55B9,
|
||||
kMkvTransferCharacteristics = 0x55BA,
|
||||
kMkvPrimaries = 0x55BB,
|
||||
kMkvMaxCLL = 0x55BC,
|
||||
kMkvMaxFALL = 0x55BD,
|
||||
// mastering metadata
|
||||
kMkvMasteringMetadata = 0x55D0,
|
||||
kMkvPrimaryRChromaticityX = 0x55D1,
|
||||
kMkvPrimaryRChromaticityY = 0x55D2,
|
||||
kMkvPrimaryGChromaticityX = 0x55D3,
|
||||
kMkvPrimaryGChromaticityY = 0x55D4,
|
||||
kMkvPrimaryBChromaticityX = 0x55D5,
|
||||
kMkvPrimaryBChromaticityY = 0x55D6,
|
||||
kMkvWhitePointChromaticityX = 0x55D7,
|
||||
kMkvWhitePointChromaticityY = 0x55D8,
|
||||
kMkvLuminanceMax = 0x55D9,
|
||||
kMkvLuminanceMin = 0x55DA,
|
||||
// end mastering metadata
|
||||
// end colour
|
||||
// projection
|
||||
kMkvProjection = 0x7670,
|
||||
kMkvProjectionType = 0x7671,
|
||||
kMkvProjectionPrivate = 0x7672,
|
||||
kMkvProjectionPoseYaw = 0x7673,
|
||||
kMkvProjectionPosePitch = 0x7674,
|
||||
kMkvProjectionPoseRoll = 0x7675,
|
||||
// end projection
|
||||
// audio
|
||||
kMkvAudio = 0xE1,
|
||||
kMkvSamplingFrequency = 0xB5,
|
||||
kMkvOutputSamplingFrequency = 0x78B5,
|
||||
kMkvChannels = 0x9F,
|
||||
kMkvBitDepth = 0x6264,
|
||||
// end audio
|
||||
// ContentEncodings
|
||||
kMkvContentEncodings = 0x6D80,
|
||||
kMkvContentEncoding = 0x6240,
|
||||
kMkvContentEncodingOrder = 0x5031,
|
||||
kMkvContentEncodingScope = 0x5032,
|
||||
kMkvContentEncodingType = 0x5033,
|
||||
kMkvContentCompression = 0x5034,
|
||||
kMkvContentCompAlgo = 0x4254,
|
||||
kMkvContentCompSettings = 0x4255,
|
||||
kMkvContentEncryption = 0x5035,
|
||||
kMkvContentEncAlgo = 0x47E1,
|
||||
kMkvContentEncKeyID = 0x47E2,
|
||||
kMkvContentSignature = 0x47E3,
|
||||
kMkvContentSigKeyID = 0x47E4,
|
||||
kMkvContentSigAlgo = 0x47E5,
|
||||
kMkvContentSigHashAlgo = 0x47E6,
|
||||
kMkvContentEncAESSettings = 0x47E7,
|
||||
kMkvAESSettingsCipherMode = 0x47E8,
|
||||
kMkvAESSettingsCipherInitData = 0x47E9,
|
||||
// end ContentEncodings
|
||||
// Cueing Data
|
||||
kMkvCues = 0x1C53BB6B,
|
||||
kMkvCuePoint = 0xBB,
|
||||
kMkvCueTime = 0xB3,
|
||||
kMkvCueTrackPositions = 0xB7,
|
||||
kMkvCueTrack = 0xF7,
|
||||
kMkvCueClusterPosition = 0xF1,
|
||||
kMkvCueBlockNumber = 0x5378,
|
||||
// Chapters
|
||||
kMkvChapters = 0x1043A770,
|
||||
kMkvEditionEntry = 0x45B9,
|
||||
kMkvChapterAtom = 0xB6,
|
||||
kMkvChapterUID = 0x73C4,
|
||||
kMkvChapterStringUID = 0x5654,
|
||||
kMkvChapterTimeStart = 0x91,
|
||||
kMkvChapterTimeEnd = 0x92,
|
||||
kMkvChapterDisplay = 0x80,
|
||||
kMkvChapString = 0x85,
|
||||
kMkvChapLanguage = 0x437C,
|
||||
kMkvChapCountry = 0x437E,
|
||||
// Tags
|
||||
kMkvTags = 0x1254C367,
|
||||
kMkvTag = 0x7373,
|
||||
kMkvSimpleTag = 0x67C8,
|
||||
kMkvTagName = 0x45A3,
|
||||
kMkvTagString = 0x4487
|
||||
};
|
||||
|
||||
} // namespace libwebm
|
||||
|
||||
#endif // COMMON_WEBMIDS_H_
|
||||
1924
vpx-encoder/android_libs/x86/include/mkvmuxer/mkvmuxer.h
Normal file
1924
vpx-encoder/android_libs/x86/include/mkvmuxer/mkvmuxer.h
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
#ifndef MKVMUXER_MKVMUXERTYPES_H_
|
||||
#define MKVMUXER_MKVMUXERTYPES_H_
|
||||
|
||||
namespace mkvmuxer {
|
||||
typedef unsigned char uint8;
|
||||
typedef short int16;
|
||||
typedef int int32;
|
||||
typedef unsigned int uint32;
|
||||
typedef long long int64;
|
||||
typedef unsigned long long uint64;
|
||||
} // namespace mkvmuxer
|
||||
|
||||
// Copied from Chromium basictypes.h
|
||||
// A macro to disallow the copy constructor and operator= functions
|
||||
// This should be used in the private: declarations for a class
|
||||
#define LIBWEBM_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
TypeName(const TypeName&); \
|
||||
void operator=(const TypeName&)
|
||||
|
||||
#endif // MKVMUXER_MKVMUXERTYPES_HPP_
|
||||
112
vpx-encoder/android_libs/x86/include/mkvmuxer/mkvmuxerutil.h
Normal file
112
vpx-encoder/android_libs/x86/include/mkvmuxer/mkvmuxerutil.h
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
#ifndef MKVMUXER_MKVMUXERUTIL_H_
|
||||
#define MKVMUXER_MKVMUXERUTIL_H_
|
||||
|
||||
#include "mkvmuxertypes.h"
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
namespace mkvmuxer {
|
||||
class Cluster;
|
||||
class Frame;
|
||||
class IMkvWriter;
|
||||
|
||||
// TODO(tomfinegan): mkvmuxer:: integer types continue to be used here because
|
||||
// changing them causes pain for downstream projects. It would be nice if a
|
||||
// solution that allows removal of the mkvmuxer:: integer types while avoiding
|
||||
// pain for downstream users of libwebm. Considering that mkvmuxerutil.{cc,h}
|
||||
// are really, for the great majority of cases, EBML size calculation and writer
|
||||
// functions, perhaps a more EBML focused utility would be the way to go as a
|
||||
// first step.
|
||||
|
||||
const uint64 kEbmlUnknownValue = 0x01FFFFFFFFFFFFFFULL;
|
||||
const int64 kMaxBlockTimecode = 0x07FFFLL;
|
||||
|
||||
// Writes out |value| in Big Endian order. Returns 0 on success.
|
||||
int32 SerializeInt(IMkvWriter* writer, int64 value, int32 size);
|
||||
|
||||
// Returns the size in bytes of the element.
|
||||
int32 GetUIntSize(uint64 value);
|
||||
int32 GetIntSize(int64 value);
|
||||
int32 GetCodedUIntSize(uint64 value);
|
||||
uint64 EbmlMasterElementSize(uint64 type, uint64 value);
|
||||
uint64 EbmlElementSize(uint64 type, int64 value);
|
||||
uint64 EbmlElementSize(uint64 type, uint64 value);
|
||||
uint64 EbmlElementSize(uint64 type, float value);
|
||||
uint64 EbmlElementSize(uint64 type, const char* value);
|
||||
uint64 EbmlElementSize(uint64 type, const uint8* value, uint64 size);
|
||||
uint64 EbmlDateElementSize(uint64 type);
|
||||
|
||||
// Returns the size in bytes of the element assuming that the element was
|
||||
// written using |fixed_size| bytes. If |fixed_size| is set to zero, then it
|
||||
// computes the necessary number of bytes based on |value|.
|
||||
uint64 EbmlElementSize(uint64 type, uint64 value, uint64 fixed_size);
|
||||
|
||||
// Creates an EBML coded number from |value| and writes it out. The size of
|
||||
// the coded number is determined by the value of |value|. |value| must not
|
||||
// be in a coded form. Returns 0 on success.
|
||||
int32 WriteUInt(IMkvWriter* writer, uint64 value);
|
||||
|
||||
// Creates an EBML coded number from |value| and writes it out. The size of
|
||||
// the coded number is determined by the value of |size|. |value| must not
|
||||
// be in a coded form. Returns 0 on success.
|
||||
int32 WriteUIntSize(IMkvWriter* writer, uint64 value, int32 size);
|
||||
|
||||
// Output an Mkv master element. Returns true if the element was written.
|
||||
bool WriteEbmlMasterElement(IMkvWriter* writer, uint64 value, uint64 size);
|
||||
|
||||
// Outputs an Mkv ID, calls |IMkvWriter::ElementStartNotify|, and passes the
|
||||
// ID to |SerializeInt|. Returns 0 on success.
|
||||
int32 WriteID(IMkvWriter* writer, uint64 type);
|
||||
|
||||
// Output an Mkv non-master element. Returns true if the element was written.
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, uint64 value);
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, int64 value);
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, float value);
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const char* value);
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const uint8* value,
|
||||
uint64 size);
|
||||
bool WriteEbmlDateElement(IMkvWriter* writer, uint64 type, int64 value);
|
||||
|
||||
// Output an Mkv non-master element using fixed size. The element will be
|
||||
// written out using exactly |fixed_size| bytes. If |fixed_size| is set to zero
|
||||
// then it computes the necessary number of bytes based on |value|. Returns true
|
||||
// if the element was written.
|
||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, uint64 value,
|
||||
uint64 fixed_size);
|
||||
|
||||
// Output a Mkv Frame. It decides the correct element to write (Block vs
|
||||
// SimpleBlock) based on the parameters of the Frame.
|
||||
uint64 WriteFrame(IMkvWriter* writer, const Frame* const frame,
|
||||
Cluster* cluster);
|
||||
|
||||
// Output a void element. |size| must be the entire size in bytes that will be
|
||||
// void. The function will calculate the size of the void header and subtract
|
||||
// it from |size|.
|
||||
uint64 WriteVoidElement(IMkvWriter* writer, uint64 size);
|
||||
|
||||
// Returns the version number of the muxer in |major|, |minor|, |build|,
|
||||
// and |revision|.
|
||||
void GetVersion(int32* major, int32* minor, int32* build, int32* revision);
|
||||
|
||||
// Returns a random number to be used for UID, using |seed| to seed
|
||||
// the random-number generator (see POSIX rand_r() for semantics).
|
||||
uint64 MakeUID(unsigned int* seed);
|
||||
|
||||
// Colour field validation helpers. All return true when |value| is valid.
|
||||
bool IsMatrixCoefficientsValueValid(uint64_t value);
|
||||
bool IsChromaSitingHorzValueValid(uint64_t value);
|
||||
bool IsChromaSitingVertValueValid(uint64_t value);
|
||||
bool IsColourRangeValueValid(uint64_t value);
|
||||
bool IsTransferCharacteristicsValueValid(uint64_t value);
|
||||
bool IsPrimariesValueValid(uint64_t value);
|
||||
|
||||
} // namespace mkvmuxer
|
||||
|
||||
#endif // MKVMUXER_MKVMUXERUTIL_H_
|
||||
51
vpx-encoder/android_libs/x86/include/mkvmuxer/mkvwriter.h
Normal file
51
vpx-encoder/android_libs/x86/include/mkvmuxer/mkvwriter.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
#ifndef MKVMUXER_MKVWRITER_H_
|
||||
#define MKVMUXER_MKVWRITER_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mkvmuxer/mkvmuxer.h"
|
||||
#include "mkvmuxer/mkvmuxertypes.h"
|
||||
|
||||
namespace mkvmuxer {
|
||||
|
||||
// Default implementation of the IMkvWriter interface on Windows.
|
||||
class MkvWriter : public IMkvWriter {
|
||||
public:
|
||||
MkvWriter();
|
||||
explicit MkvWriter(FILE* fp);
|
||||
virtual ~MkvWriter();
|
||||
|
||||
// IMkvWriter interface
|
||||
virtual int64 Position() const;
|
||||
virtual int32 Position(int64 position);
|
||||
virtual bool Seekable() const;
|
||||
virtual int32 Write(const void* buffer, uint32 length);
|
||||
virtual void ElementStartNotify(uint64 element_id, int64 position);
|
||||
|
||||
// Creates and opens a file for writing. |filename| is the name of the file
|
||||
// to open. This function will overwrite the contents of |filename|. Returns
|
||||
// true on success.
|
||||
bool Open(const char* filename);
|
||||
|
||||
// Closes an opened file.
|
||||
void Close();
|
||||
|
||||
private:
|
||||
// File handle to output file.
|
||||
FILE* file_;
|
||||
bool writer_owns_file_;
|
||||
|
||||
LIBWEBM_DISALLOW_COPY_AND_ASSIGN(MkvWriter);
|
||||
};
|
||||
|
||||
} // namespace mkvmuxer
|
||||
|
||||
#endif // MKVMUXER_MKVWRITER_H_
|
||||
1147
vpx-encoder/android_libs/x86/include/mkvparser/mkvparser.h
Normal file
1147
vpx-encoder/android_libs/x86/include/mkvparser/mkvparser.h
Normal file
File diff suppressed because it is too large
Load diff
45
vpx-encoder/android_libs/x86/include/mkvparser/mkvreader.h
Normal file
45
vpx-encoder/android_libs/x86/include/mkvparser/mkvreader.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
#ifndef MKVPARSER_MKVREADER_H_
|
||||
#define MKVPARSER_MKVREADER_H_
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include "mkvparser/mkvparser.h"
|
||||
|
||||
namespace mkvparser {
|
||||
|
||||
class MkvReader : public IMkvReader {
|
||||
public:
|
||||
MkvReader();
|
||||
explicit MkvReader(FILE* fp);
|
||||
virtual ~MkvReader();
|
||||
|
||||
int Open(const char*);
|
||||
void Close();
|
||||
|
||||
virtual int Read(long long position, long length, unsigned char* buffer);
|
||||
virtual int Length(long long* total, long long* available);
|
||||
|
||||
private:
|
||||
MkvReader(const MkvReader&);
|
||||
MkvReader& operator=(const MkvReader&);
|
||||
|
||||
// Determines the size of the file. This is called either by the constructor
|
||||
// or by the Open function depending on file ownership. Returns true on
|
||||
// success.
|
||||
bool GetFileSize();
|
||||
|
||||
long long m_length;
|
||||
FILE* m_file;
|
||||
bool reader_owns_file_;
|
||||
};
|
||||
|
||||
} // namespace mkvparser
|
||||
|
||||
#endif // MKVPARSER_MKVREADER_H_
|
||||
136
vpx-encoder/android_libs/x86/include/vpx/vp8.h
Normal file
136
vpx-encoder/android_libs/x86/include/vpx/vp8.h
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\defgroup vp8 VP8
|
||||
* \ingroup codecs
|
||||
* VP8 is a video compression algorithm that uses motion
|
||||
* compensated prediction, Discrete Cosine Transform (DCT) coding of the
|
||||
* prediction error signal and context dependent entropy coding techniques
|
||||
* based on arithmetic principles. It features:
|
||||
* - YUV 4:2:0 image format
|
||||
* - Macro-block based coding (16x16 luma plus two 8x8 chroma)
|
||||
* - 1/4 (1/8) pixel accuracy motion compensated prediction
|
||||
* - 4x4 DCT transform
|
||||
* - 128 level linear quantizer
|
||||
* - In loop deblocking filter
|
||||
* - Context-based entropy coding
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*!\file
|
||||
* \brief Provides controls common to both the VP8 encoder and decoder.
|
||||
*/
|
||||
#ifndef VPX_VPX_VP8_H_
|
||||
#define VPX_VPX_VP8_H_
|
||||
|
||||
#include "./vpx_codec.h"
|
||||
#include "./vpx_image.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!\brief Control functions
|
||||
*
|
||||
* The set of macros define the control functions of VP8 interface
|
||||
*/
|
||||
enum vp8_com_control_id {
|
||||
/*!\brief pass in an external frame into decoder to be used as reference frame
|
||||
*/
|
||||
VP8_SET_REFERENCE = 1,
|
||||
VP8_COPY_REFERENCE = 2, /**< get a copy of reference frame from the decoder */
|
||||
VP8_SET_POSTPROC = 3, /**< set the decoder's post processing settings */
|
||||
|
||||
/* TODO(jkoleszar): The encoder incorrectly reuses some of these values (5+)
|
||||
* for its control ids. These should be migrated to something like the
|
||||
* VP8_DECODER_CTRL_ID_START range next time we're ready to break the ABI.
|
||||
*/
|
||||
VP9_GET_REFERENCE = 128, /**< get a pointer to a reference frame */
|
||||
VP8_COMMON_CTRL_ID_MAX,
|
||||
VP8_DECODER_CTRL_ID_START = 256
|
||||
};
|
||||
|
||||
/*!\brief post process flags
|
||||
*
|
||||
* The set of macros define VP8 decoder post processing flags
|
||||
*/
|
||||
enum vp8_postproc_level {
|
||||
VP8_NOFILTERING = 0,
|
||||
VP8_DEBLOCK = 1 << 0,
|
||||
VP8_DEMACROBLOCK = 1 << 1,
|
||||
VP8_ADDNOISE = 1 << 2,
|
||||
VP8_MFQE = 1 << 3
|
||||
};
|
||||
|
||||
/*!\brief post process flags
|
||||
*
|
||||
* This define a structure that describe the post processing settings. For
|
||||
* the best objective measure (using the PSNR metric) set post_proc_flag
|
||||
* to VP8_DEBLOCK and deblocking_level to 1.
|
||||
*/
|
||||
|
||||
typedef struct vp8_postproc_cfg {
|
||||
/*!\brief the types of post processing to be done, should be combination of
|
||||
* "vp8_postproc_level" */
|
||||
int post_proc_flag;
|
||||
int deblocking_level; /**< the strength of deblocking, valid range [0, 16] */
|
||||
int noise_level; /**< the strength of additive noise, valid range [0, 16] */
|
||||
} vp8_postproc_cfg_t;
|
||||
|
||||
/*!\brief reference frame type
|
||||
*
|
||||
* The set of macros define the type of VP8 reference frames
|
||||
*/
|
||||
typedef enum vpx_ref_frame_type {
|
||||
VP8_LAST_FRAME = 1,
|
||||
VP8_GOLD_FRAME = 2,
|
||||
VP8_ALTR_FRAME = 4
|
||||
} vpx_ref_frame_type_t;
|
||||
|
||||
/*!\brief reference frame data struct
|
||||
*
|
||||
* Define the data struct to access vp8 reference frames.
|
||||
*/
|
||||
typedef struct vpx_ref_frame {
|
||||
vpx_ref_frame_type_t frame_type; /**< which reference frame */
|
||||
vpx_image_t img; /**< reference frame data in image format */
|
||||
} vpx_ref_frame_t;
|
||||
|
||||
/*!\brief VP9 specific reference frame data struct
|
||||
*
|
||||
* Define the data struct to access vp9 reference frames.
|
||||
*/
|
||||
typedef struct vp9_ref_frame {
|
||||
int idx; /**< frame index to get (input) */
|
||||
vpx_image_t img; /**< img structure to populate (output) */
|
||||
} vp9_ref_frame_t;
|
||||
|
||||
/*!\cond */
|
||||
/*!\brief vp8 decoder control function parameter type
|
||||
*
|
||||
* defines the data type for each of VP8 decoder control function requires
|
||||
*/
|
||||
VPX_CTRL_USE_TYPE(VP8_SET_REFERENCE, vpx_ref_frame_t *)
|
||||
#define VPX_CTRL_VP8_SET_REFERENCE
|
||||
VPX_CTRL_USE_TYPE(VP8_COPY_REFERENCE, vpx_ref_frame_t *)
|
||||
#define VPX_CTRL_VP8_COPY_REFERENCE
|
||||
VPX_CTRL_USE_TYPE(VP8_SET_POSTPROC, vp8_postproc_cfg_t *)
|
||||
#define VPX_CTRL_VP8_SET_POSTPROC
|
||||
VPX_CTRL_USE_TYPE(VP9_GET_REFERENCE, vp9_ref_frame_t *)
|
||||
#define VPX_CTRL_VP9_GET_REFERENCE
|
||||
|
||||
/*!\endcond */
|
||||
/*! @} - end defgroup vp8 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VP8_H_
|
||||
1027
vpx-encoder/android_libs/x86/include/vpx/vp8cx.h
Normal file
1027
vpx-encoder/android_libs/x86/include/vpx/vp8cx.h
Normal file
File diff suppressed because it is too large
Load diff
210
vpx-encoder/android_libs/x86/include/vpx/vp8dx.h
Normal file
210
vpx-encoder/android_libs/x86/include/vpx/vp8dx.h
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\defgroup vp8_decoder WebM VP8/VP9 Decoder
|
||||
* \ingroup vp8
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
/*!\file
|
||||
* \brief Provides definitions for using VP8 or VP9 within the vpx Decoder
|
||||
* interface.
|
||||
*/
|
||||
#ifndef VPX_VPX_VP8DX_H_
|
||||
#define VPX_VPX_VP8DX_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Include controls common to both the encoder and decoder */
|
||||
#include "./vp8.h"
|
||||
|
||||
/*!\name Algorithm interface for VP8
|
||||
*
|
||||
* This interface provides the capability to decode VP8 streams.
|
||||
* @{
|
||||
*/
|
||||
extern vpx_codec_iface_t vpx_codec_vp8_dx_algo;
|
||||
extern vpx_codec_iface_t *vpx_codec_vp8_dx(void);
|
||||
/*!@} - end algorithm interface member group*/
|
||||
|
||||
/*!\name Algorithm interface for VP9
|
||||
*
|
||||
* This interface provides the capability to decode VP9 streams.
|
||||
* @{
|
||||
*/
|
||||
extern vpx_codec_iface_t vpx_codec_vp9_dx_algo;
|
||||
extern vpx_codec_iface_t *vpx_codec_vp9_dx(void);
|
||||
/*!@} - end algorithm interface member group*/
|
||||
|
||||
/*!\enum vp8_dec_control_id
|
||||
* \brief VP8 decoder control functions
|
||||
*
|
||||
* This set of macros define the control functions available for the VP8
|
||||
* decoder interface.
|
||||
*
|
||||
* \sa #vpx_codec_control
|
||||
*/
|
||||
enum vp8_dec_control_id {
|
||||
/** control function to get info on which reference frames were updated
|
||||
* by the last decode
|
||||
*/
|
||||
VP8D_GET_LAST_REF_UPDATES = VP8_DECODER_CTRL_ID_START,
|
||||
|
||||
/** check if the indicated frame is corrupted */
|
||||
VP8D_GET_FRAME_CORRUPTED,
|
||||
|
||||
/** control function to get info on which reference frames were used
|
||||
* by the last decode
|
||||
*/
|
||||
VP8D_GET_LAST_REF_USED,
|
||||
|
||||
/** decryption function to decrypt encoded buffer data immediately
|
||||
* before decoding. Takes a vpx_decrypt_init, which contains
|
||||
* a callback function and opaque context pointer.
|
||||
*/
|
||||
VPXD_SET_DECRYPTOR,
|
||||
VP8D_SET_DECRYPTOR = VPXD_SET_DECRYPTOR,
|
||||
|
||||
/** control function to get the dimensions that the current frame is decoded
|
||||
* at. This may be different to the intended display size for the frame as
|
||||
* specified in the wrapper or frame header (see VP9D_GET_DISPLAY_SIZE). */
|
||||
VP9D_GET_FRAME_SIZE,
|
||||
|
||||
/** control function to get the current frame's intended display dimensions
|
||||
* (as specified in the wrapper or frame header). This may be different to
|
||||
* the decoded dimensions of this frame (see VP9D_GET_FRAME_SIZE). */
|
||||
VP9D_GET_DISPLAY_SIZE,
|
||||
|
||||
/** control function to get the bit depth of the stream. */
|
||||
VP9D_GET_BIT_DEPTH,
|
||||
|
||||
/** control function to set the byte alignment of the planes in the reference
|
||||
* buffers. Valid values are power of 2, from 32 to 1024. A value of 0 sets
|
||||
* legacy alignment. I.e. Y plane is aligned to 32 bytes, U plane directly
|
||||
* follows Y plane, and V plane directly follows U plane. Default value is 0.
|
||||
*/
|
||||
VP9_SET_BYTE_ALIGNMENT,
|
||||
|
||||
/** control function to invert the decoding order to from right to left. The
|
||||
* function is used in a test to confirm the decoding independence of tile
|
||||
* columns. The function may be used in application where this order
|
||||
* of decoding is desired.
|
||||
*
|
||||
* TODO(yaowu): Rework the unit test that uses this control, and in a future
|
||||
* release, this test-only control shall be removed.
|
||||
*/
|
||||
VP9_INVERT_TILE_DECODE_ORDER,
|
||||
|
||||
/** control function to set the skip loop filter flag. Valid values are
|
||||
* integers. The decoder will skip the loop filter when its value is set to
|
||||
* nonzero. If the loop filter is skipped the decoder may accumulate decode
|
||||
* artifacts. The default value is 0.
|
||||
*/
|
||||
VP9_SET_SKIP_LOOP_FILTER,
|
||||
|
||||
/** control function to decode SVC stream up to the x spatial layers,
|
||||
* where x is passed in through the control, and is 0 for base layer.
|
||||
*/
|
||||
VP9_DECODE_SVC_SPATIAL_LAYER,
|
||||
|
||||
/*!\brief Codec control function to get last decoded frame quantizer.
|
||||
*
|
||||
* Return value uses internal quantizer scale defined by the codec.
|
||||
*
|
||||
* Supported in codecs: VP8, VP9
|
||||
*/
|
||||
VPXD_GET_LAST_QUANTIZER,
|
||||
|
||||
/*!\brief Codec control function to set row level multi-threading.
|
||||
*
|
||||
* 0 : off, 1 : on
|
||||
*
|
||||
* Supported in codecs: VP9
|
||||
*/
|
||||
VP9D_SET_ROW_MT,
|
||||
|
||||
/*!\brief Codec control function to set loopfilter optimization.
|
||||
*
|
||||
* 0 : off, Loop filter is done after all tiles have been decoded
|
||||
* 1 : on, Loop filter is done immediately after decode without
|
||||
* waiting for all threads to sync.
|
||||
*
|
||||
* Supported in codecs: VP9
|
||||
*/
|
||||
VP9D_SET_LOOP_FILTER_OPT,
|
||||
|
||||
VP8_DECODER_CTRL_ID_MAX
|
||||
};
|
||||
|
||||
/** Decrypt n bytes of data from input -> output, using the decrypt_state
|
||||
* passed in VPXD_SET_DECRYPTOR.
|
||||
*/
|
||||
typedef void (*vpx_decrypt_cb)(void *decrypt_state, const unsigned char *input,
|
||||
unsigned char *output, int count);
|
||||
|
||||
/*!\brief Structure to hold decryption state
|
||||
*
|
||||
* Defines a structure to hold the decryption state and access function.
|
||||
*/
|
||||
typedef struct vpx_decrypt_init {
|
||||
/*! Decrypt callback. */
|
||||
vpx_decrypt_cb decrypt_cb;
|
||||
|
||||
/*! Decryption state. */
|
||||
void *decrypt_state;
|
||||
} vpx_decrypt_init;
|
||||
|
||||
/*!\cond */
|
||||
/*!\brief VP8 decoder control function parameter type
|
||||
*
|
||||
* Defines the data types that VP8D control functions take. Note that
|
||||
* additional common controls are defined in vp8.h
|
||||
*
|
||||
*/
|
||||
|
||||
VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_UPDATES, int *)
|
||||
#define VPX_CTRL_VP8D_GET_LAST_REF_UPDATES
|
||||
VPX_CTRL_USE_TYPE(VP8D_GET_FRAME_CORRUPTED, int *)
|
||||
#define VPX_CTRL_VP8D_GET_FRAME_CORRUPTED
|
||||
VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_USED, int *)
|
||||
#define VPX_CTRL_VP8D_GET_LAST_REF_USED
|
||||
VPX_CTRL_USE_TYPE(VPXD_GET_LAST_QUANTIZER, int *)
|
||||
#define VPX_CTRL_VPXD_GET_LAST_QUANTIZER
|
||||
VPX_CTRL_USE_TYPE(VPXD_SET_DECRYPTOR, vpx_decrypt_init *)
|
||||
#define VPX_CTRL_VPXD_SET_DECRYPTOR
|
||||
VPX_CTRL_USE_TYPE(VP8D_SET_DECRYPTOR, vpx_decrypt_init *)
|
||||
#define VPX_CTRL_VP8D_SET_DECRYPTOR
|
||||
VPX_CTRL_USE_TYPE(VP9D_GET_DISPLAY_SIZE, int *)
|
||||
#define VPX_CTRL_VP9D_GET_DISPLAY_SIZE
|
||||
VPX_CTRL_USE_TYPE(VP9D_GET_BIT_DEPTH, unsigned int *)
|
||||
#define VPX_CTRL_VP9D_GET_BIT_DEPTH
|
||||
VPX_CTRL_USE_TYPE(VP9D_GET_FRAME_SIZE, int *)
|
||||
#define VPX_CTRL_VP9D_GET_FRAME_SIZE
|
||||
VPX_CTRL_USE_TYPE(VP9_INVERT_TILE_DECODE_ORDER, int)
|
||||
#define VPX_CTRL_VP9_INVERT_TILE_DECODE_ORDER
|
||||
#define VPX_CTRL_VP9_DECODE_SVC_SPATIAL_LAYER
|
||||
VPX_CTRL_USE_TYPE(VP9_DECODE_SVC_SPATIAL_LAYER, int)
|
||||
#define VPX_CTRL_VP9_SET_SKIP_LOOP_FILTER
|
||||
VPX_CTRL_USE_TYPE(VP9_SET_SKIP_LOOP_FILTER, int)
|
||||
#define VPX_CTRL_VP9_DECODE_SET_ROW_MT
|
||||
VPX_CTRL_USE_TYPE(VP9D_SET_ROW_MT, int)
|
||||
#define VPX_CTRL_VP9_SET_LOOP_FILTER_OPT
|
||||
VPX_CTRL_USE_TYPE(VP9D_SET_LOOP_FILTER_OPT, int)
|
||||
|
||||
/*!\endcond */
|
||||
/*! @} - end defgroup vp8_decoder */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VP8DX_H_
|
||||
468
vpx-encoder/android_libs/x86/include/vpx/vpx_codec.h
Normal file
468
vpx-encoder/android_libs/x86/include/vpx/vpx_codec.h
Normal file
|
|
@ -0,0 +1,468 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\defgroup codec Common Algorithm Interface
|
||||
* This abstraction allows applications to easily support multiple video
|
||||
* formats with minimal code duplication. This section describes the interface
|
||||
* common to all codecs (both encoders and decoders).
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the codec algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video codec algorithm.
|
||||
*
|
||||
* An application instantiates a specific codec instance by using
|
||||
* vpx_codec_init() and a pointer to the algorithm's interface structure:
|
||||
* <pre>
|
||||
* my_app.c:
|
||||
* extern vpx_codec_iface_t my_codec;
|
||||
* {
|
||||
* vpx_codec_ctx_t algo;
|
||||
* res = vpx_codec_init(&algo, &my_codec);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Once initialized, the instance is manged using other functions from
|
||||
* the vpx_codec_* family.
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_CODEC_H_
|
||||
#define VPX_VPX_VPX_CODEC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_image.h"
|
||||
#include "./vpx_integer.h"
|
||||
|
||||
/*!\brief Decorator indicating a function is deprecated */
|
||||
#ifndef VPX_DEPRECATED
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
#define VPX_DEPRECATED __attribute__((deprecated))
|
||||
#elif defined(_MSC_VER)
|
||||
#define VPX_DEPRECATED
|
||||
#else
|
||||
#define VPX_DEPRECATED
|
||||
#endif
|
||||
#endif /* VPX_DEPRECATED */
|
||||
|
||||
#ifndef VPX_DECLSPEC_DEPRECATED
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
#define VPX_DECLSPEC_DEPRECATED /**< \copydoc #VPX_DEPRECATED */
|
||||
#elif defined(_MSC_VER)
|
||||
/*!\brief \copydoc #VPX_DEPRECATED */
|
||||
#define VPX_DECLSPEC_DEPRECATED __declspec(deprecated)
|
||||
#else
|
||||
#define VPX_DECLSPEC_DEPRECATED /**< \copydoc #VPX_DEPRECATED */
|
||||
#endif
|
||||
#endif /* VPX_DECLSPEC_DEPRECATED */
|
||||
|
||||
/*!\brief Decorator indicating a function is potentially unused */
|
||||
#ifndef VPX_UNUSED
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define VPX_UNUSED __attribute__((unused))
|
||||
#else
|
||||
#define VPX_UNUSED
|
||||
#endif
|
||||
#endif /* VPX_UNUSED */
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_CODEC_ABI_VERSION (4 + VPX_IMAGE_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*!\brief Algorithm return codes */
|
||||
typedef enum {
|
||||
/*!\brief Operation completed without error */
|
||||
VPX_CODEC_OK,
|
||||
|
||||
/*!\brief Unspecified error */
|
||||
VPX_CODEC_ERROR,
|
||||
|
||||
/*!\brief Memory operation failed */
|
||||
VPX_CODEC_MEM_ERROR,
|
||||
|
||||
/*!\brief ABI version mismatch */
|
||||
VPX_CODEC_ABI_MISMATCH,
|
||||
|
||||
/*!\brief Algorithm does not have required capability */
|
||||
VPX_CODEC_INCAPABLE,
|
||||
|
||||
/*!\brief The given bitstream is not supported.
|
||||
*
|
||||
* The bitstream was unable to be parsed at the highest level. The decoder
|
||||
* is unable to proceed. This error \ref SHOULD be treated as fatal to the
|
||||
* stream. */
|
||||
VPX_CODEC_UNSUP_BITSTREAM,
|
||||
|
||||
/*!\brief Encoded bitstream uses an unsupported feature
|
||||
*
|
||||
* The decoder does not implement a feature required by the encoder. This
|
||||
* return code should only be used for features that prevent future
|
||||
* pictures from being properly decoded. This error \ref MAY be treated as
|
||||
* fatal to the stream or \ref MAY be treated as fatal to the current GOP.
|
||||
*/
|
||||
VPX_CODEC_UNSUP_FEATURE,
|
||||
|
||||
/*!\brief The coded data for this stream is corrupt or incomplete
|
||||
*
|
||||
* There was a problem decoding the current frame. This return code
|
||||
* should only be used for failures that prevent future pictures from
|
||||
* being properly decoded. This error \ref MAY be treated as fatal to the
|
||||
* stream or \ref MAY be treated as fatal to the current GOP. If decoding
|
||||
* is continued for the current GOP, artifacts may be present.
|
||||
*/
|
||||
VPX_CODEC_CORRUPT_FRAME,
|
||||
|
||||
/*!\brief An application-supplied parameter is not valid.
|
||||
*
|
||||
*/
|
||||
VPX_CODEC_INVALID_PARAM,
|
||||
|
||||
/*!\brief An iterator reached the end of list.
|
||||
*
|
||||
*/
|
||||
VPX_CODEC_LIST_END
|
||||
|
||||
} vpx_codec_err_t;
|
||||
|
||||
/*! \brief Codec capabilities bitfield
|
||||
*
|
||||
* Each codec advertises the capabilities it supports as part of its
|
||||
* ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
|
||||
* or functionality, and are not required to be supported.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_CAP_* defines.
|
||||
*/
|
||||
typedef long vpx_codec_caps_t;
|
||||
#define VPX_CODEC_CAP_DECODER 0x1 /**< Is a decoder */
|
||||
#define VPX_CODEC_CAP_ENCODER 0x2 /**< Is an encoder */
|
||||
|
||||
/*! Can support images at greater than 8 bitdepth.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_HIGHBITDEPTH 0x4
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow for
|
||||
* proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_USE_* defines.
|
||||
*/
|
||||
typedef long vpx_codec_flags_t;
|
||||
|
||||
/*!\brief Codec interface structure.
|
||||
*
|
||||
* Contains function pointers and other data private to the codec
|
||||
* implementation. This structure is opaque to the application.
|
||||
*/
|
||||
typedef const struct vpx_codec_iface vpx_codec_iface_t;
|
||||
|
||||
/*!\brief Codec private data structure.
|
||||
*
|
||||
* Contains data private to the codec implementation. This structure is opaque
|
||||
* to the application.
|
||||
*/
|
||||
typedef struct vpx_codec_priv vpx_codec_priv_t;
|
||||
|
||||
/*!\brief Iterator
|
||||
*
|
||||
* Opaque storage used for iterating over lists.
|
||||
*/
|
||||
typedef const void *vpx_codec_iter_t;
|
||||
|
||||
/*!\brief Codec context structure
|
||||
*
|
||||
* All codecs \ref MUST support this context structure fully. In general,
|
||||
* this data should be considered private to the codec algorithm, and
|
||||
* not be manipulated or examined by the calling application. Applications
|
||||
* may reference the 'name' member to get a printable description of the
|
||||
* algorithm.
|
||||
*/
|
||||
typedef struct vpx_codec_ctx {
|
||||
const char *name; /**< Printable interface name */
|
||||
vpx_codec_iface_t *iface; /**< Interface pointers */
|
||||
vpx_codec_err_t err; /**< Last returned error */
|
||||
const char *err_detail; /**< Detailed info, if available */
|
||||
vpx_codec_flags_t init_flags; /**< Flags passed at init time */
|
||||
union {
|
||||
/**< Decoder Configuration Pointer */
|
||||
const struct vpx_codec_dec_cfg *dec;
|
||||
/**< Encoder Configuration Pointer */
|
||||
const struct vpx_codec_enc_cfg *enc;
|
||||
const void *raw;
|
||||
} config; /**< Configuration pointer aliasing union */
|
||||
vpx_codec_priv_t *priv; /**< Algorithm private storage */
|
||||
} vpx_codec_ctx_t;
|
||||
|
||||
/*!\brief Bit depth for codec
|
||||
* *
|
||||
* This enumeration determines the bit depth of the codec.
|
||||
*/
|
||||
typedef enum vpx_bit_depth {
|
||||
VPX_BITS_8 = 8, /**< 8 bits */
|
||||
VPX_BITS_10 = 10, /**< 10 bits */
|
||||
VPX_BITS_12 = 12, /**< 12 bits */
|
||||
} vpx_bit_depth_t;
|
||||
|
||||
/*
|
||||
* Library Version Number Interface
|
||||
*
|
||||
* For example, see the following sample return values:
|
||||
* vpx_codec_version() (1<<16 | 2<<8 | 3)
|
||||
* vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
|
||||
* vpx_codec_version_extra_str() "rc1-16-gec6a1ba"
|
||||
*/
|
||||
|
||||
/*!\brief Return the version information (as an integer)
|
||||
*
|
||||
* Returns a packed encoding of the library version number. This will only
|
||||
* include
|
||||
* the major.minor.patch component of the version number. Note that this encoded
|
||||
* value should be accessed through the macros provided, as the encoding may
|
||||
* change
|
||||
* in the future.
|
||||
*
|
||||
*/
|
||||
int vpx_codec_version(void);
|
||||
#define VPX_VERSION_MAJOR(v) \
|
||||
((v >> 16) & 0xff) /**< extract major from packed version */
|
||||
#define VPX_VERSION_MINOR(v) \
|
||||
((v >> 8) & 0xff) /**< extract minor from packed version */
|
||||
#define VPX_VERSION_PATCH(v) \
|
||||
((v >> 0) & 0xff) /**< extract patch from packed version */
|
||||
|
||||
/*!\brief Return the version major number */
|
||||
#define vpx_codec_version_major() ((vpx_codec_version() >> 16) & 0xff)
|
||||
|
||||
/*!\brief Return the version minor number */
|
||||
#define vpx_codec_version_minor() ((vpx_codec_version() >> 8) & 0xff)
|
||||
|
||||
/*!\brief Return the version patch number */
|
||||
#define vpx_codec_version_patch() ((vpx_codec_version() >> 0) & 0xff)
|
||||
|
||||
/*!\brief Return the version information (as a string)
|
||||
*
|
||||
* Returns a printable string containing the full library version number. This
|
||||
* may
|
||||
* contain additional text following the three digit version number, as to
|
||||
* indicate
|
||||
* release candidates, prerelease versions, etc.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_version_str(void);
|
||||
|
||||
/*!\brief Return the version information (as a string)
|
||||
*
|
||||
* Returns a printable "extra string". This is the component of the string
|
||||
* returned
|
||||
* by vpx_codec_version_str() following the three digit version number.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_version_extra_str(void);
|
||||
|
||||
/*!\brief Return the build configuration
|
||||
*
|
||||
* Returns a printable string containing an encoded version of the build
|
||||
* configuration. This may be useful to vpx support.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_build_config(void);
|
||||
|
||||
/*!\brief Return the name for a given interface
|
||||
*
|
||||
* Returns a human readable string for name of the given codec interface.
|
||||
*
|
||||
* \param[in] iface Interface pointer
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_iface_name(vpx_codec_iface_t *iface);
|
||||
|
||||
/*!\brief Convert error number to printable string
|
||||
*
|
||||
* Returns a human readable string for the last error returned by the
|
||||
* algorithm. The returned error will be one line and will not contain
|
||||
* any newline characters.
|
||||
*
|
||||
*
|
||||
* \param[in] err Error number.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_err_to_string(vpx_codec_err_t err);
|
||||
|
||||
/*!\brief Retrieve error synopsis for codec context
|
||||
*
|
||||
* Returns a human readable string for the last error returned by the
|
||||
* algorithm. The returned error will be one line and will not contain
|
||||
* any newline characters.
|
||||
*
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
*
|
||||
*/
|
||||
const char *vpx_codec_error(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!\brief Retrieve detailed error information for codec context
|
||||
*
|
||||
* Returns a human readable string providing detailed information about
|
||||
* the last error.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
*
|
||||
* \retval NULL
|
||||
* No detailed information is available.
|
||||
*/
|
||||
const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/* REQUIRED FUNCTIONS
|
||||
*
|
||||
* The following functions are required to be implemented for all codecs.
|
||||
* They represent the base case functionality expected of all codecs.
|
||||
*/
|
||||
|
||||
/*!\brief Destroy a codec instance
|
||||
*
|
||||
* Destroys a codec context, freeing any associated memory buffers.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The codec algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!\brief Get the capabilities of an algorithm.
|
||||
*
|
||||
* Retrieves the capabilities bitfield from the algorithm's interface.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface
|
||||
*
|
||||
*/
|
||||
vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface);
|
||||
|
||||
/*!\brief Control algorithm
|
||||
*
|
||||
* This function is used to exchange algorithm specific data with the codec
|
||||
* instance. This can be used to implement features specific to a particular
|
||||
* algorithm.
|
||||
*
|
||||
* This wrapper function dispatches the request to the helper function
|
||||
* associated with the given ctrl_id. It tries to call this function
|
||||
* transparently, but will return #VPX_CODEC_ERROR if the request could not
|
||||
* be dispatched.
|
||||
*
|
||||
* Note that this function should not be used directly. Call the
|
||||
* #vpx_codec_control wrapper macro instead.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] ctrl_id Algorithm specific control identifier
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The control request was processed.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* The control request was not processed.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* The data was not valid.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx, int ctrl_id, ...);
|
||||
#if defined(VPX_DISABLE_CTRL_TYPECHECKS) && VPX_DISABLE_CTRL_TYPECHECKS
|
||||
#define vpx_codec_control(ctx, id, data) vpx_codec_control_(ctx, id, data)
|
||||
#define VPX_CTRL_USE_TYPE(id, typ)
|
||||
#define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ)
|
||||
#define VPX_CTRL_VOID(id, typ)
|
||||
|
||||
#else
|
||||
/*!\brief vpx_codec_control wrapper macro
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to vpx_codec_control_().
|
||||
*
|
||||
* \internal
|
||||
* It works by dispatching the call to the control function through a wrapper
|
||||
* function named with the id parameter.
|
||||
*/
|
||||
#define vpx_codec_control(ctx, id, data) \
|
||||
vpx_codec_control_##id(ctx, id, data) /**<\hideinitializer*/
|
||||
|
||||
/*!\brief vpx_codec_control type definition macro
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to vpx_codec_control_(). It defines the type of the argument for a given
|
||||
* control identifier.
|
||||
*
|
||||
* \internal
|
||||
* It defines a static function with
|
||||
* the correctly typed arguments as a wrapper to the type-unsafe internal
|
||||
* function.
|
||||
*/
|
||||
#define VPX_CTRL_USE_TYPE(id, typ) \
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *, int, typ) \
|
||||
VPX_UNUSED; \
|
||||
\
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *ctx, \
|
||||
int ctrl_id, typ data) { \
|
||||
return vpx_codec_control_(ctx, ctrl_id, data); \
|
||||
} /**<\hideinitializer*/
|
||||
|
||||
/*!\brief vpx_codec_control deprecated type definition macro
|
||||
*
|
||||
* Like #VPX_CTRL_USE_TYPE, but indicates that the specified control is
|
||||
* deprecated and should not be used. Consult the documentation for your
|
||||
* codec for more information.
|
||||
*
|
||||
* \internal
|
||||
* It defines a static function with the correctly typed arguments as a
|
||||
* wrapper to the type-unsafe internal function.
|
||||
*/
|
||||
#define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \
|
||||
VPX_DECLSPEC_DEPRECATED static vpx_codec_err_t vpx_codec_control_##id( \
|
||||
vpx_codec_ctx_t *, int, typ) VPX_DEPRECATED VPX_UNUSED; \
|
||||
\
|
||||
VPX_DECLSPEC_DEPRECATED static vpx_codec_err_t vpx_codec_control_##id( \
|
||||
vpx_codec_ctx_t *ctx, int ctrl_id, typ data) { \
|
||||
return vpx_codec_control_(ctx, ctrl_id, data); \
|
||||
} /**<\hideinitializer*/
|
||||
|
||||
/*!\brief vpx_codec_control void type definition macro
|
||||
*
|
||||
* This macro allows for type safe conversions across the variadic parameter
|
||||
* to vpx_codec_control_(). It indicates that a given control identifier takes
|
||||
* no argument.
|
||||
*
|
||||
* \internal
|
||||
* It defines a static function without a data argument as a wrapper to the
|
||||
* type-unsafe internal function.
|
||||
*/
|
||||
#define VPX_CTRL_VOID(id) \
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *, int) \
|
||||
VPX_UNUSED; \
|
||||
\
|
||||
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *ctx, \
|
||||
int ctrl_id) { \
|
||||
return vpx_codec_control_(ctx, ctrl_id); \
|
||||
} /**<\hideinitializer*/
|
||||
|
||||
#endif
|
||||
|
||||
/*!@} - end defgroup codec*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // VPX_VPX_VPX_CODEC_H_
|
||||
365
vpx-encoder/android_libs/x86/include/vpx/vpx_decoder.h
Normal file
365
vpx-encoder/android_libs/x86/include/vpx/vpx_decoder.h
Normal file
|
|
@ -0,0 +1,365 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_DECODER_H_
|
||||
#define VPX_VPX_VPX_DECODER_H_
|
||||
|
||||
/*!\defgroup decoder Decoder Algorithm Interface
|
||||
* \ingroup codec
|
||||
* This abstraction allows applications using this decoder to easily support
|
||||
* multiple video formats with minimal code duplication. This section describes
|
||||
* the interface common to all decoders.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the decoder algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video decoder algorithm.
|
||||
*
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_codec.h"
|
||||
#include "./vpx_frame_buffer.h"
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_DECODER_ABI_VERSION \
|
||||
(3 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*! \brief Decoder capabilities bitfield
|
||||
*
|
||||
* Each decoder advertises the capabilities it supports as part of its
|
||||
* ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
|
||||
* or functionality, and are not required to be supported by a decoder.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_CAP_* defines.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_PUT_SLICE 0x10000 /**< Will issue put_slice callbacks */
|
||||
#define VPX_CODEC_CAP_PUT_FRAME 0x20000 /**< Will issue put_frame callbacks */
|
||||
#define VPX_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */
|
||||
/*!\brief Can conceal errors due to packet loss */
|
||||
#define VPX_CODEC_CAP_ERROR_CONCEALMENT 0x80000
|
||||
/*!\brief Can receive encoded frames one fragment at a time */
|
||||
#define VPX_CODEC_CAP_INPUT_FRAGMENTS 0x100000
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow for
|
||||
* proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_USE_* defines.
|
||||
*/
|
||||
/*!\brief Can support frame-based multi-threading */
|
||||
#define VPX_CODEC_CAP_FRAME_THREADING 0x200000
|
||||
/*!brief Can support external frame buffers */
|
||||
#define VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER 0x400000
|
||||
|
||||
#define VPX_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */
|
||||
/*!\brief Conceal errors in decoded frames */
|
||||
#define VPX_CODEC_USE_ERROR_CONCEALMENT 0x20000
|
||||
/*!\brief The input frame should be passed to the decoder one fragment at a
|
||||
* time */
|
||||
#define VPX_CODEC_USE_INPUT_FRAGMENTS 0x40000
|
||||
/*!\brief Enable frame-based multi-threading */
|
||||
#define VPX_CODEC_USE_FRAME_THREADING 0x80000
|
||||
|
||||
/*!\brief Stream properties
|
||||
*
|
||||
* This structure is used to query or set properties of the decoded
|
||||
* stream. Algorithms may extend this structure with data specific
|
||||
* to their bitstream by setting the sz member appropriately.
|
||||
*/
|
||||
typedef struct vpx_codec_stream_info {
|
||||
unsigned int sz; /**< Size of this structure */
|
||||
unsigned int w; /**< Width (or 0 for unknown/default) */
|
||||
unsigned int h; /**< Height (or 0 for unknown/default) */
|
||||
unsigned int is_kf; /**< Current frame is a keyframe */
|
||||
} vpx_codec_stream_info_t;
|
||||
|
||||
/* REQUIRED FUNCTIONS
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders.
|
||||
* They represent the base case functionality expected of all decoders.
|
||||
*/
|
||||
|
||||
/*!\brief Initialization Configurations
|
||||
*
|
||||
* This structure is used to pass init time configuration options to the
|
||||
* decoder.
|
||||
*/
|
||||
typedef struct vpx_codec_dec_cfg {
|
||||
unsigned int threads; /**< Maximum number of threads to use, default 1 */
|
||||
unsigned int w; /**< Width */
|
||||
unsigned int h; /**< Height */
|
||||
} vpx_codec_dec_cfg_t; /**< alias for struct vpx_codec_dec_cfg */
|
||||
|
||||
/*!\brief Initialize a decoder instance
|
||||
*
|
||||
* Initializes a decoder context using the given interface. Applications
|
||||
* should call the vpx_codec_dec_init convenience macro instead of this
|
||||
* function directly, to ensure that the ABI version number parameter
|
||||
* is properly initialized.
|
||||
*
|
||||
* If the library was configured with --disable-multithread, this call
|
||||
* is not thread safe and should be guarded with a lock if being used
|
||||
* in a multithreaded context.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[in] cfg Configuration to use, if known. May be NULL.
|
||||
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
|
||||
* \param[in] ver ABI version number. Must be set to
|
||||
* VPX_DECODER_ABI_VERSION
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The decoder algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_iface_t *iface,
|
||||
const vpx_codec_dec_cfg_t *cfg,
|
||||
vpx_codec_flags_t flags, int ver);
|
||||
|
||||
/*!\brief Convenience macro for vpx_codec_dec_init_ver()
|
||||
*
|
||||
* Ensures the ABI version parameter is properly set.
|
||||
*/
|
||||
#define vpx_codec_dec_init(ctx, iface, cfg, flags) \
|
||||
vpx_codec_dec_init_ver(ctx, iface, cfg, flags, VPX_DECODER_ABI_VERSION)
|
||||
|
||||
/*!\brief Parse stream info from a buffer
|
||||
*
|
||||
* Performs high level parsing of the bitstream. Construction of a decoder
|
||||
* context is not necessary. Can be used to determine if the bitstream is
|
||||
* of the proper format, and to extract information from the stream.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface
|
||||
* \param[in] data Pointer to a block of data to parse
|
||||
* \param[in] data_sz Size of the data buffer
|
||||
* \param[in,out] si Pointer to stream info to update. The size member
|
||||
* \ref MUST be properly initialized, but \ref MAY be
|
||||
* clobbered by the algorithm. This parameter \ref MAY
|
||||
* be NULL.
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Bitstream is parsable and stream information updated
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface,
|
||||
const uint8_t *data,
|
||||
unsigned int data_sz,
|
||||
vpx_codec_stream_info_t *si);
|
||||
|
||||
/*!\brief Return information about the current stream.
|
||||
*
|
||||
* Returns information about the stream that has been parsed during decoding.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] si Pointer to stream info to update. The size member
|
||||
* \ref MUST be properly initialized, but \ref MAY be
|
||||
* clobbered by the algorithm. This parameter \ref MAY
|
||||
* be NULL.
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Bitstream is parsable and stream information updated
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_stream_info_t *si);
|
||||
|
||||
/*!\brief Decode data
|
||||
*
|
||||
* Processes a buffer of coded data. If the processing results in a new
|
||||
* decoded frame becoming available, PUT_SLICE and PUT_FRAME events may be
|
||||
* generated, as appropriate. Encoded data \ref MUST be passed in DTS (decode
|
||||
* time stamp) order. Frames produced will always be in PTS (presentation
|
||||
* time stamp) order.
|
||||
* If the decoder is configured with VPX_CODEC_USE_INPUT_FRAGMENTS enabled,
|
||||
* data and data_sz can contain a fragment of the encoded frame. Fragment
|
||||
* \#n must contain at least partition \#n, but can also contain subsequent
|
||||
* partitions (\#n+1 - \#n+i), and if so, fragments \#n+1, .., \#n+i must
|
||||
* be empty. When no more data is available, this function should be called
|
||||
* with NULL as data and 0 as data_sz. The memory passed to this function
|
||||
* must be available until the frame has been decoded.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] data Pointer to this block of new coded data. If
|
||||
* NULL, a VPX_CODEC_CB_PUT_FRAME event is posted
|
||||
* for the previously decoded frame.
|
||||
* \param[in] data_sz Size of the coded data, in bytes.
|
||||
* \param[in] user_priv Application specific data to associate with
|
||||
* this frame.
|
||||
* \param[in] deadline Soft deadline the decoder should attempt to meet,
|
||||
* in us. Set to zero for unlimited.
|
||||
*
|
||||
* \return Returns #VPX_CODEC_OK if the coded data was processed completely
|
||||
* and future pictures can be decoded without error. Otherwise,
|
||||
* see the descriptions of the other error codes in ::vpx_codec_err_t
|
||||
* for recoverability capabilities.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, const uint8_t *data,
|
||||
unsigned int data_sz, void *user_priv,
|
||||
long deadline);
|
||||
|
||||
/*!\brief Decoded frames iterator
|
||||
*
|
||||
* Iterates over a list of the frames available for display. The iterator
|
||||
* storage should be initialized to NULL to start the iteration. Iteration is
|
||||
* complete when this function returns NULL.
|
||||
*
|
||||
* The list of available frames becomes valid upon completion of the
|
||||
* vpx_codec_decode call, and remains valid until the next call to
|
||||
* vpx_codec_decode.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] iter Iterator storage, initialized to NULL
|
||||
*
|
||||
* \return Returns a pointer to an image, if one is ready for display. Frames
|
||||
* produced will always be in PTS (presentation time stamp) order.
|
||||
*/
|
||||
vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx, vpx_codec_iter_t *iter);
|
||||
|
||||
/*!\defgroup cap_put_frame Frame-Based Decoding Functions
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders
|
||||
* that advertise the VPX_CODEC_CAP_PUT_FRAME capability. Calling these
|
||||
* functions
|
||||
* for codecs that don't advertise this capability will result in an error
|
||||
* code being returned, usually VPX_CODEC_ERROR
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief put frame callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to notify the application of
|
||||
* the availability of decoded image data.
|
||||
*/
|
||||
typedef void (*vpx_codec_put_frame_cb_fn_t)(void *user_priv,
|
||||
const vpx_image_t *img);
|
||||
|
||||
/*!\brief Register for notification of frame completion.
|
||||
*
|
||||
* Registers a given function to be called when a decoded frame is
|
||||
* available.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb Pointer to the callback function
|
||||
* \param[in] user_priv User's private data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Callback successfully registered.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* Decoder context not initialized, or algorithm not capable of
|
||||
* posting slice completion.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_put_frame_cb_fn_t cb,
|
||||
void *user_priv);
|
||||
|
||||
/*!@} - end defgroup cap_put_frame */
|
||||
|
||||
/*!\defgroup cap_put_slice Slice-Based Decoding Functions
|
||||
*
|
||||
* The following functions are required to be implemented for all decoders
|
||||
* that advertise the VPX_CODEC_CAP_PUT_SLICE capability. Calling these
|
||||
* functions
|
||||
* for codecs that don't advertise this capability will result in an error
|
||||
* code being returned, usually VPX_CODEC_ERROR
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief put slice callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to notify the application of
|
||||
* the availability of partially decoded image data. The
|
||||
*/
|
||||
typedef void (*vpx_codec_put_slice_cb_fn_t)(void *user_priv,
|
||||
const vpx_image_t *img,
|
||||
const vpx_image_rect_t *valid,
|
||||
const vpx_image_rect_t *update);
|
||||
|
||||
/*!\brief Register for notification of slice completion.
|
||||
*
|
||||
* Registers a given function to be called when a decoded slice is
|
||||
* available.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb Pointer to the callback function
|
||||
* \param[in] user_priv User's private data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* Callback successfully registered.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* Decoder context not initialized, or algorithm not capable of
|
||||
* posting slice completion.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_register_put_slice_cb(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_put_slice_cb_fn_t cb,
|
||||
void *user_priv);
|
||||
|
||||
/*!@} - end defgroup cap_put_slice*/
|
||||
|
||||
/*!\defgroup cap_external_frame_buffer External Frame Buffer Functions
|
||||
*
|
||||
* The following section is required to be implemented for all decoders
|
||||
* that advertise the VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER capability.
|
||||
* Calling this function for codecs that don't advertise this capability
|
||||
* will result in an error code being returned, usually VPX_CODEC_ERROR.
|
||||
*
|
||||
* \note
|
||||
* Currently this only works with VP9.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\brief Pass in external frame buffers for the decoder to use.
|
||||
*
|
||||
* Registers functions to be called when libvpx needs a frame buffer
|
||||
* to decode the current frame and a function to be called when libvpx does
|
||||
* not internally reference the frame buffer. This set function must
|
||||
* be called before the first call to decode or libvpx will assume the
|
||||
* default behavior of allocating frame buffers internally.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cb_get Pointer to the get callback function
|
||||
* \param[in] cb_release Pointer to the release callback function
|
||||
* \param[in] cb_priv Callback's private data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* External frame buffers will be used by libvpx.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* One or more of the callbacks were NULL.
|
||||
* \retval #VPX_CODEC_ERROR
|
||||
* Decoder context not initialized, or algorithm not capable of
|
||||
* using external frame buffers.
|
||||
*
|
||||
* \note
|
||||
* When decoding VP9, the application may be required to pass in at least
|
||||
* #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS external frame
|
||||
* buffers.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_set_frame_buffer_functions(
|
||||
vpx_codec_ctx_t *ctx, vpx_get_frame_buffer_cb_fn_t cb_get,
|
||||
vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv);
|
||||
|
||||
/*!@} - end defgroup cap_external_frame_buffer */
|
||||
|
||||
/*!@} - end defgroup decoder*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // VPX_VPX_VPX_DECODER_H_
|
||||
968
vpx-encoder/android_libs/x86/include/vpx/vpx_encoder.h
Normal file
968
vpx-encoder/android_libs/x86/include/vpx/vpx_encoder.h
Normal file
|
|
@ -0,0 +1,968 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_ENCODER_H_
|
||||
#define VPX_VPX_VPX_ENCODER_H_
|
||||
|
||||
/*!\defgroup encoder Encoder Algorithm Interface
|
||||
* \ingroup codec
|
||||
* This abstraction allows applications using this encoder to easily support
|
||||
* multiple video formats with minimal code duplication. This section describes
|
||||
* the interface common to all encoders.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the encoder algorithm interface to applications.
|
||||
*
|
||||
* This file describes the interface between an application and a
|
||||
* video encoder algorithm.
|
||||
*
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_codec.h"
|
||||
|
||||
/*! Temporal Scalability: Maximum length of the sequence defining frame
|
||||
* layer membership
|
||||
*/
|
||||
#define VPX_TS_MAX_PERIODICITY 16
|
||||
|
||||
/*! Temporal Scalability: Maximum number of coding layers */
|
||||
#define VPX_TS_MAX_LAYERS 5
|
||||
|
||||
/*! Temporal+Spatial Scalability: Maximum number of coding layers */
|
||||
#define VPX_MAX_LAYERS 12 // 3 temporal + 4 spatial layers are allowed.
|
||||
|
||||
/*! Spatial Scalability: Maximum number of coding layers */
|
||||
#define VPX_SS_MAX_LAYERS 5
|
||||
|
||||
/*! Spatial Scalability: Default number of coding layers */
|
||||
#define VPX_SS_DEFAULT_LAYERS 1
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_ENCODER_ABI_VERSION \
|
||||
(14 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
|
||||
|
||||
/*! \brief Encoder capabilities bitfield
|
||||
*
|
||||
* Each encoder advertises the capabilities it supports as part of its
|
||||
* ::vpx_codec_iface_t interface structure. Capabilities are extra
|
||||
* interfaces or functionality, and are not required to be supported
|
||||
* by an encoder.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_CAP_* defines.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_PSNR 0x10000 /**< Can issue PSNR packets */
|
||||
|
||||
/*! Can output one partition at a time. Each partition is returned in its
|
||||
* own VPX_CODEC_CX_FRAME_PKT, with the FRAME_IS_FRAGMENT flag set for
|
||||
* every partition but the last. In this mode all frames are always
|
||||
* returned partition by partition.
|
||||
*/
|
||||
#define VPX_CODEC_CAP_OUTPUT_PARTITION 0x20000
|
||||
|
||||
/*! \brief Initialization-time Feature Enabling
|
||||
*
|
||||
* Certain codec features must be known at initialization time, to allow
|
||||
* for proper memory allocation.
|
||||
*
|
||||
* The available flags are specified by VPX_CODEC_USE_* defines.
|
||||
*/
|
||||
#define VPX_CODEC_USE_PSNR 0x10000 /**< Calculate PSNR on each frame */
|
||||
/*!\brief Make the encoder output one partition at a time. */
|
||||
#define VPX_CODEC_USE_OUTPUT_PARTITION 0x20000
|
||||
#define VPX_CODEC_USE_HIGHBITDEPTH 0x40000 /**< Use high bitdepth */
|
||||
|
||||
/*!\brief Generic fixed size buffer structure
|
||||
*
|
||||
* This structure is able to hold a reference to any fixed size buffer.
|
||||
*/
|
||||
typedef struct vpx_fixed_buf {
|
||||
void *buf; /**< Pointer to the data */
|
||||
size_t sz; /**< Length of the buffer, in chars */
|
||||
} vpx_fixed_buf_t; /**< alias for struct vpx_fixed_buf */
|
||||
|
||||
/*!\brief Time Stamp Type
|
||||
*
|
||||
* An integer, which when multiplied by the stream's time base, provides
|
||||
* the absolute time of a sample.
|
||||
*/
|
||||
typedef int64_t vpx_codec_pts_t;
|
||||
|
||||
/*!\brief Compressed Frame Flags
|
||||
*
|
||||
* This type represents a bitfield containing information about a compressed
|
||||
* frame that may be useful to an application. The most significant 16 bits
|
||||
* can be used by an algorithm to provide additional detail, for example to
|
||||
* support frame types that are codec specific (MPEG-1 D-frames for example)
|
||||
*/
|
||||
typedef uint32_t vpx_codec_frame_flags_t;
|
||||
#define VPX_FRAME_IS_KEY 0x1 /**< frame is the start of a GOP */
|
||||
/*!\brief frame can be dropped without affecting the stream (no future frame
|
||||
* depends on this one) */
|
||||
#define VPX_FRAME_IS_DROPPABLE 0x2
|
||||
/*!\brief frame should be decoded but will not be shown */
|
||||
#define VPX_FRAME_IS_INVISIBLE 0x4
|
||||
/*!\brief this is a fragment of the encoded frame */
|
||||
#define VPX_FRAME_IS_FRAGMENT 0x8
|
||||
|
||||
/*!\brief Error Resilient flags
|
||||
*
|
||||
* These flags define which error resilient features to enable in the
|
||||
* encoder. The flags are specified through the
|
||||
* vpx_codec_enc_cfg::g_error_resilient variable.
|
||||
*/
|
||||
typedef uint32_t vpx_codec_er_flags_t;
|
||||
/*!\brief Improve resiliency against losses of whole frames */
|
||||
#define VPX_ERROR_RESILIENT_DEFAULT 0x1
|
||||
/*!\brief The frame partitions are independently decodable by the bool decoder,
|
||||
* meaning that partitions can be decoded even though earlier partitions have
|
||||
* been lost. Note that intra prediction is still done over the partition
|
||||
* boundary. */
|
||||
#define VPX_ERROR_RESILIENT_PARTITIONS 0x2
|
||||
|
||||
/*!\brief Encoder output packet variants
|
||||
*
|
||||
* This enumeration lists the different kinds of data packets that can be
|
||||
* returned by calls to vpx_codec_get_cx_data(). Algorithms \ref MAY
|
||||
* extend this list to provide additional functionality.
|
||||
*/
|
||||
enum vpx_codec_cx_pkt_kind {
|
||||
VPX_CODEC_CX_FRAME_PKT, /**< Compressed video frame */
|
||||
VPX_CODEC_STATS_PKT, /**< Two-pass statistics for this frame */
|
||||
VPX_CODEC_FPMB_STATS_PKT, /**< first pass mb statistics for this frame */
|
||||
VPX_CODEC_PSNR_PKT, /**< PSNR statistics for this frame */
|
||||
VPX_CODEC_CUSTOM_PKT = 256 /**< Algorithm extensions */
|
||||
};
|
||||
|
||||
/*!\brief Encoder output packet
|
||||
*
|
||||
* This structure contains the different kinds of output data the encoder
|
||||
* may produce while compressing a frame.
|
||||
*/
|
||||
typedef struct vpx_codec_cx_pkt {
|
||||
enum vpx_codec_cx_pkt_kind kind; /**< packet variant */
|
||||
union {
|
||||
struct {
|
||||
void *buf; /**< compressed data buffer */
|
||||
size_t sz; /**< length of compressed data */
|
||||
/*!\brief time stamp to show frame (in timebase units) */
|
||||
vpx_codec_pts_t pts;
|
||||
/*!\brief duration to show frame (in timebase units) */
|
||||
unsigned long duration;
|
||||
vpx_codec_frame_flags_t flags; /**< flags for this frame */
|
||||
/*!\brief the partition id defines the decoding order of the partitions.
|
||||
* Only applicable when "output partition" mode is enabled. First
|
||||
* partition has id 0.*/
|
||||
int partition_id;
|
||||
/*!\brief Width and height of frames in this packet. VP8 will only use the
|
||||
* first one.*/
|
||||
unsigned int width[VPX_SS_MAX_LAYERS]; /**< frame width */
|
||||
unsigned int height[VPX_SS_MAX_LAYERS]; /**< frame height */
|
||||
/*!\brief Flag to indicate if spatial layer frame in this packet is
|
||||
* encoded or dropped. VP8 will always be set to 1.*/
|
||||
uint8_t spatial_layer_encoded[VPX_SS_MAX_LAYERS];
|
||||
} frame; /**< data for compressed frame packet */
|
||||
vpx_fixed_buf_t twopass_stats; /**< data for two-pass packet */
|
||||
vpx_fixed_buf_t firstpass_mb_stats; /**< first pass mb packet */
|
||||
struct vpx_psnr_pkt {
|
||||
unsigned int samples[4]; /**< Number of samples, total/y/u/v */
|
||||
uint64_t sse[4]; /**< sum squared error, total/y/u/v */
|
||||
double psnr[4]; /**< PSNR, total/y/u/v */
|
||||
} psnr; /**< data for PSNR packet */
|
||||
vpx_fixed_buf_t raw; /**< data for arbitrary packets */
|
||||
|
||||
/* This packet size is fixed to allow codecs to extend this
|
||||
* interface without having to manage storage for raw packets,
|
||||
* i.e., if it's smaller than 128 bytes, you can store in the
|
||||
* packet list directly.
|
||||
*/
|
||||
char pad[128 - sizeof(enum vpx_codec_cx_pkt_kind)]; /**< fixed sz */
|
||||
} data; /**< packet data */
|
||||
} vpx_codec_cx_pkt_t; /**< alias for struct vpx_codec_cx_pkt */
|
||||
|
||||
/*!\brief Encoder return output buffer callback
|
||||
*
|
||||
* This callback function, when registered, returns with packets when each
|
||||
* spatial layer is encoded.
|
||||
*/
|
||||
typedef void (*vpx_codec_enc_output_cx_pkt_cb_fn_t)(vpx_codec_cx_pkt_t *pkt,
|
||||
void *user_data);
|
||||
|
||||
/*!\brief Callback function pointer / user data pair storage */
|
||||
typedef struct vpx_codec_enc_output_cx_cb_pair {
|
||||
vpx_codec_enc_output_cx_pkt_cb_fn_t output_cx_pkt; /**< Callback function */
|
||||
void *user_priv; /**< Pointer to private data */
|
||||
} vpx_codec_priv_output_cx_pkt_cb_pair_t;
|
||||
|
||||
/*!\brief Rational Number
|
||||
*
|
||||
* This structure holds a fractional value.
|
||||
*/
|
||||
typedef struct vpx_rational {
|
||||
int num; /**< fraction numerator */
|
||||
int den; /**< fraction denominator */
|
||||
} vpx_rational_t; /**< alias for struct vpx_rational */
|
||||
|
||||
/*!\brief Multi-pass Encoding Pass */
|
||||
enum vpx_enc_pass {
|
||||
VPX_RC_ONE_PASS, /**< Single pass mode */
|
||||
VPX_RC_FIRST_PASS, /**< First pass of multi-pass mode */
|
||||
VPX_RC_LAST_PASS /**< Final pass of multi-pass mode */
|
||||
};
|
||||
|
||||
/*!\brief Rate control mode */
|
||||
enum vpx_rc_mode {
|
||||
VPX_VBR, /**< Variable Bit Rate (VBR) mode */
|
||||
VPX_CBR, /**< Constant Bit Rate (CBR) mode */
|
||||
VPX_CQ, /**< Constrained Quality (CQ) mode */
|
||||
VPX_Q, /**< Constant Quality (Q) mode */
|
||||
};
|
||||
|
||||
/*!\brief Keyframe placement mode.
|
||||
*
|
||||
* This enumeration determines whether keyframes are placed automatically by
|
||||
* the encoder or whether this behavior is disabled. Older releases of this
|
||||
* SDK were implemented such that VPX_KF_FIXED meant keyframes were disabled.
|
||||
* This name is confusing for this behavior, so the new symbols to be used
|
||||
* are VPX_KF_AUTO and VPX_KF_DISABLED.
|
||||
*/
|
||||
enum vpx_kf_mode {
|
||||
VPX_KF_FIXED, /**< deprecated, implies VPX_KF_DISABLED */
|
||||
VPX_KF_AUTO, /**< Encoder determines optimal placement automatically */
|
||||
VPX_KF_DISABLED = 0 /**< Encoder does not place keyframes. */
|
||||
};
|
||||
|
||||
/*!\brief Encoded Frame Flags
|
||||
*
|
||||
* This type indicates a bitfield to be passed to vpx_codec_encode(), defining
|
||||
* per-frame boolean values. By convention, bits common to all codecs will be
|
||||
* named VPX_EFLAG_*, and bits specific to an algorithm will be named
|
||||
* /algo/_eflag_*. The lower order 16 bits are reserved for common use.
|
||||
*/
|
||||
typedef long vpx_enc_frame_flags_t;
|
||||
#define VPX_EFLAG_FORCE_KF (1 << 0) /**< Force this frame to be a keyframe */
|
||||
|
||||
/*!\brief Encoder configuration structure
|
||||
*
|
||||
* This structure contains the encoder settings that have common representations
|
||||
* across all codecs. This doesn't imply that all codecs support all features,
|
||||
* however.
|
||||
*/
|
||||
typedef struct vpx_codec_enc_cfg {
|
||||
/*
|
||||
* generic settings (g)
|
||||
*/
|
||||
|
||||
/*!\brief Deprecated: Algorithm specific "usage" value
|
||||
*
|
||||
* This value must be zero.
|
||||
*/
|
||||
unsigned int g_usage;
|
||||
|
||||
/*!\brief Maximum number of threads to use
|
||||
*
|
||||
* For multi-threaded implementations, use no more than this number of
|
||||
* threads. The codec may use fewer threads than allowed. The value
|
||||
* 0 is equivalent to the value 1.
|
||||
*/
|
||||
unsigned int g_threads;
|
||||
|
||||
/*!\brief Bitstream profile to use
|
||||
*
|
||||
* Some codecs support a notion of multiple bitstream profiles. Typically
|
||||
* this maps to a set of features that are turned on or off. Often the
|
||||
* profile to use is determined by the features of the intended decoder.
|
||||
* Consult the documentation for the codec to determine the valid values
|
||||
* for this parameter, or set to zero for a sane default.
|
||||
*/
|
||||
unsigned int g_profile; /**< profile of bitstream to use */
|
||||
|
||||
/*!\brief Width of the frame
|
||||
*
|
||||
* This value identifies the presentation resolution of the frame,
|
||||
* in pixels. Note that the frames passed as input to the encoder must
|
||||
* have this resolution. Frames will be presented by the decoder in this
|
||||
* resolution, independent of any spatial resampling the encoder may do.
|
||||
*/
|
||||
unsigned int g_w;
|
||||
|
||||
/*!\brief Height of the frame
|
||||
*
|
||||
* This value identifies the presentation resolution of the frame,
|
||||
* in pixels. Note that the frames passed as input to the encoder must
|
||||
* have this resolution. Frames will be presented by the decoder in this
|
||||
* resolution, independent of any spatial resampling the encoder may do.
|
||||
*/
|
||||
unsigned int g_h;
|
||||
|
||||
/*!\brief Bit-depth of the codec
|
||||
*
|
||||
* This value identifies the bit_depth of the codec,
|
||||
* Only certain bit-depths are supported as identified in the
|
||||
* vpx_bit_depth_t enum.
|
||||
*/
|
||||
vpx_bit_depth_t g_bit_depth;
|
||||
|
||||
/*!\brief Bit-depth of the input frames
|
||||
*
|
||||
* This value identifies the bit_depth of the input frames in bits.
|
||||
* Note that the frames passed as input to the encoder must have
|
||||
* this bit-depth.
|
||||
*/
|
||||
unsigned int g_input_bit_depth;
|
||||
|
||||
/*!\brief Stream timebase units
|
||||
*
|
||||
* Indicates the smallest interval of time, in seconds, used by the stream.
|
||||
* For fixed frame rate material, or variable frame rate material where
|
||||
* frames are timed at a multiple of a given clock (ex: video capture),
|
||||
* the \ref RECOMMENDED method is to set the timebase to the reciprocal
|
||||
* of the frame rate (ex: 1001/30000 for 29.970 Hz NTSC). This allows the
|
||||
* pts to correspond to the frame number, which can be handy. For
|
||||
* re-encoding video from containers with absolute time timestamps, the
|
||||
* \ref RECOMMENDED method is to set the timebase to that of the parent
|
||||
* container or multimedia framework (ex: 1/1000 for ms, as in FLV).
|
||||
*/
|
||||
struct vpx_rational g_timebase;
|
||||
|
||||
/*!\brief Enable error resilient modes.
|
||||
*
|
||||
* The error resilient bitfield indicates to the encoder which features
|
||||
* it should enable to take measures for streaming over lossy or noisy
|
||||
* links.
|
||||
*/
|
||||
vpx_codec_er_flags_t g_error_resilient;
|
||||
|
||||
/*!\brief Multi-pass Encoding Mode
|
||||
*
|
||||
* This value should be set to the current phase for multi-pass encoding.
|
||||
* For single pass, set to #VPX_RC_ONE_PASS.
|
||||
*/
|
||||
enum vpx_enc_pass g_pass;
|
||||
|
||||
/*!\brief Allow lagged encoding
|
||||
*
|
||||
* If set, this value allows the encoder to consume a number of input
|
||||
* frames before producing output frames. This allows the encoder to
|
||||
* base decisions for the current frame on future frames. This does
|
||||
* increase the latency of the encoding pipeline, so it is not appropriate
|
||||
* in all situations (ex: realtime encoding).
|
||||
*
|
||||
* Note that this is a maximum value -- the encoder may produce frames
|
||||
* sooner than the given limit. Set this value to 0 to disable this
|
||||
* feature.
|
||||
*/
|
||||
unsigned int g_lag_in_frames;
|
||||
|
||||
/*
|
||||
* rate control settings (rc)
|
||||
*/
|
||||
|
||||
/*!\brief Temporal resampling configuration, if supported by the codec.
|
||||
*
|
||||
* Temporal resampling allows the codec to "drop" frames as a strategy to
|
||||
* meet its target data rate. This can cause temporal discontinuities in
|
||||
* the encoded video, which may appear as stuttering during playback. This
|
||||
* trade-off is often acceptable, but for many applications is not. It can
|
||||
* be disabled in these cases.
|
||||
*
|
||||
* This threshold is described as a percentage of the target data buffer.
|
||||
* When the data buffer falls below this percentage of fullness, a
|
||||
* dropped frame is indicated. Set the threshold to zero (0) to disable
|
||||
* this feature.
|
||||
*/
|
||||
unsigned int rc_dropframe_thresh;
|
||||
|
||||
/*!\brief Enable/disable spatial resampling, if supported by the codec.
|
||||
*
|
||||
* Spatial resampling allows the codec to compress a lower resolution
|
||||
* version of the frame, which is then upscaled by the encoder to the
|
||||
* correct presentation resolution. This increases visual quality at
|
||||
* low data rates, at the expense of CPU time on the encoder/decoder.
|
||||
*/
|
||||
unsigned int rc_resize_allowed;
|
||||
|
||||
/*!\brief Internal coded frame width.
|
||||
*
|
||||
* If spatial resampling is enabled this specifies the width of the
|
||||
* encoded frame.
|
||||
*/
|
||||
unsigned int rc_scaled_width;
|
||||
|
||||
/*!\brief Internal coded frame height.
|
||||
*
|
||||
* If spatial resampling is enabled this specifies the height of the
|
||||
* encoded frame.
|
||||
*/
|
||||
unsigned int rc_scaled_height;
|
||||
|
||||
/*!\brief Spatial resampling up watermark.
|
||||
*
|
||||
* This threshold is described as a percentage of the target data buffer.
|
||||
* When the data buffer rises above this percentage of fullness, the
|
||||
* encoder will step up to a higher resolution version of the frame.
|
||||
*/
|
||||
unsigned int rc_resize_up_thresh;
|
||||
|
||||
/*!\brief Spatial resampling down watermark.
|
||||
*
|
||||
* This threshold is described as a percentage of the target data buffer.
|
||||
* When the data buffer falls below this percentage of fullness, the
|
||||
* encoder will step down to a lower resolution version of the frame.
|
||||
*/
|
||||
unsigned int rc_resize_down_thresh;
|
||||
|
||||
/*!\brief Rate control algorithm to use.
|
||||
*
|
||||
* Indicates whether the end usage of this stream is to be streamed over
|
||||
* a bandwidth constrained link, indicating that Constant Bit Rate (CBR)
|
||||
* mode should be used, or whether it will be played back on a high
|
||||
* bandwidth link, as from a local disk, where higher variations in
|
||||
* bitrate are acceptable.
|
||||
*/
|
||||
enum vpx_rc_mode rc_end_usage;
|
||||
|
||||
/*!\brief Two-pass stats buffer.
|
||||
*
|
||||
* A buffer containing all of the stats packets produced in the first
|
||||
* pass, concatenated.
|
||||
*/
|
||||
vpx_fixed_buf_t rc_twopass_stats_in;
|
||||
|
||||
/*!\brief first pass mb stats buffer.
|
||||
*
|
||||
* A buffer containing all of the first pass mb stats packets produced
|
||||
* in the first pass, concatenated.
|
||||
*/
|
||||
vpx_fixed_buf_t rc_firstpass_mb_stats_in;
|
||||
|
||||
/*!\brief Target data rate
|
||||
*
|
||||
* Target bandwidth to use for this stream, in kilobits per second.
|
||||
*/
|
||||
unsigned int rc_target_bitrate;
|
||||
|
||||
/*
|
||||
* quantizer settings
|
||||
*/
|
||||
|
||||
/*!\brief Minimum (Best Quality) Quantizer
|
||||
*
|
||||
* The quantizer is the most direct control over the quality of the
|
||||
* encoded image. The range of valid values for the quantizer is codec
|
||||
* specific. Consult the documentation for the codec to determine the
|
||||
* values to use.
|
||||
*/
|
||||
unsigned int rc_min_quantizer;
|
||||
|
||||
/*!\brief Maximum (Worst Quality) Quantizer
|
||||
*
|
||||
* The quantizer is the most direct control over the quality of the
|
||||
* encoded image. The range of valid values for the quantizer is codec
|
||||
* specific. Consult the documentation for the codec to determine the
|
||||
* values to use.
|
||||
*/
|
||||
unsigned int rc_max_quantizer;
|
||||
|
||||
/*
|
||||
* bitrate tolerance
|
||||
*/
|
||||
|
||||
/*!\brief Rate control adaptation undershoot control
|
||||
*
|
||||
* VP8: Expressed as a percentage of the target bitrate,
|
||||
* controls the maximum allowed adaptation speed of the codec.
|
||||
* This factor controls the maximum amount of bits that can
|
||||
* be subtracted from the target bitrate in order to compensate
|
||||
* for prior overshoot.
|
||||
* VP9: Expressed as a percentage of the target bitrate, a threshold
|
||||
* undershoot level (current rate vs target) beyond which more aggressive
|
||||
* corrective measures are taken.
|
||||
* *
|
||||
* Valid values in the range VP8:0-1000 VP9: 0-100.
|
||||
*/
|
||||
unsigned int rc_undershoot_pct;
|
||||
|
||||
/*!\brief Rate control adaptation overshoot control
|
||||
*
|
||||
* VP8: Expressed as a percentage of the target bitrate,
|
||||
* controls the maximum allowed adaptation speed of the codec.
|
||||
* This factor controls the maximum amount of bits that can
|
||||
* be added to the target bitrate in order to compensate for
|
||||
* prior undershoot.
|
||||
* VP9: Expressed as a percentage of the target bitrate, a threshold
|
||||
* overshoot level (current rate vs target) beyond which more aggressive
|
||||
* corrective measures are taken.
|
||||
*
|
||||
* Valid values in the range VP8:0-1000 VP9: 0-100.
|
||||
*/
|
||||
unsigned int rc_overshoot_pct;
|
||||
|
||||
/*
|
||||
* decoder buffer model parameters
|
||||
*/
|
||||
|
||||
/*!\brief Decoder Buffer Size
|
||||
*
|
||||
* This value indicates the amount of data that may be buffered by the
|
||||
* decoding application. Note that this value is expressed in units of
|
||||
* time (milliseconds). For example, a value of 5000 indicates that the
|
||||
* client will buffer (at least) 5000ms worth of encoded data. Use the
|
||||
* target bitrate (#rc_target_bitrate) to convert to bits/bytes, if
|
||||
* necessary.
|
||||
*/
|
||||
unsigned int rc_buf_sz;
|
||||
|
||||
/*!\brief Decoder Buffer Initial Size
|
||||
*
|
||||
* This value indicates the amount of data that will be buffered by the
|
||||
* decoding application prior to beginning playback. This value is
|
||||
* expressed in units of time (milliseconds). Use the target bitrate
|
||||
* (#rc_target_bitrate) to convert to bits/bytes, if necessary.
|
||||
*/
|
||||
unsigned int rc_buf_initial_sz;
|
||||
|
||||
/*!\brief Decoder Buffer Optimal Size
|
||||
*
|
||||
* This value indicates the amount of data that the encoder should try
|
||||
* to maintain in the decoder's buffer. This value is expressed in units
|
||||
* of time (milliseconds). Use the target bitrate (#rc_target_bitrate)
|
||||
* to convert to bits/bytes, if necessary.
|
||||
*/
|
||||
unsigned int rc_buf_optimal_sz;
|
||||
|
||||
/*
|
||||
* 2 pass rate control parameters
|
||||
*/
|
||||
|
||||
/*!\brief Two-pass mode CBR/VBR bias
|
||||
*
|
||||
* Bias, expressed on a scale of 0 to 100, for determining target size
|
||||
* for the current frame. The value 0 indicates the optimal CBR mode
|
||||
* value should be used. The value 100 indicates the optimal VBR mode
|
||||
* value should be used. Values in between indicate which way the
|
||||
* encoder should "lean."
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_bias_pct;
|
||||
|
||||
/*!\brief Two-pass mode per-GOP minimum bitrate
|
||||
*
|
||||
* This value, expressed as a percentage of the target bitrate, indicates
|
||||
* the minimum bitrate to be used for a single GOP (aka "section")
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_minsection_pct;
|
||||
|
||||
/*!\brief Two-pass mode per-GOP maximum bitrate
|
||||
*
|
||||
* This value, expressed as a percentage of the target bitrate, indicates
|
||||
* the maximum bitrate to be used for a single GOP (aka "section")
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_maxsection_pct;
|
||||
|
||||
/*!\brief Two-pass corpus vbr mode complexity control
|
||||
* Used only in VP9: A value representing the corpus midpoint complexity
|
||||
* for corpus vbr mode. This value defaults to 0 which disables corpus vbr
|
||||
* mode in favour of normal vbr mode.
|
||||
*/
|
||||
unsigned int rc_2pass_vbr_corpus_complexity;
|
||||
|
||||
/*
|
||||
* keyframing settings (kf)
|
||||
*/
|
||||
|
||||
/*!\brief Keyframe placement mode
|
||||
*
|
||||
* This value indicates whether the encoder should place keyframes at a
|
||||
* fixed interval, or determine the optimal placement automatically
|
||||
* (as governed by the #kf_min_dist and #kf_max_dist parameters)
|
||||
*/
|
||||
enum vpx_kf_mode kf_mode;
|
||||
|
||||
/*!\brief Keyframe minimum interval
|
||||
*
|
||||
* This value, expressed as a number of frames, prevents the encoder from
|
||||
* placing a keyframe nearer than kf_min_dist to the previous keyframe. At
|
||||
* least kf_min_dist frames non-keyframes will be coded before the next
|
||||
* keyframe. Set kf_min_dist equal to kf_max_dist for a fixed interval.
|
||||
*/
|
||||
unsigned int kf_min_dist;
|
||||
|
||||
/*!\brief Keyframe maximum interval
|
||||
*
|
||||
* This value, expressed as a number of frames, forces the encoder to code
|
||||
* a keyframe if one has not been coded in the last kf_max_dist frames.
|
||||
* A value of 0 implies all frames will be keyframes. Set kf_min_dist
|
||||
* equal to kf_max_dist for a fixed interval.
|
||||
*/
|
||||
unsigned int kf_max_dist;
|
||||
|
||||
/*
|
||||
* Spatial scalability settings (ss)
|
||||
*/
|
||||
|
||||
/*!\brief Number of spatial coding layers.
|
||||
*
|
||||
* This value specifies the number of spatial coding layers to be used.
|
||||
*/
|
||||
unsigned int ss_number_layers;
|
||||
|
||||
/*!\brief Enable auto alt reference flags for each spatial layer.
|
||||
*
|
||||
* These values specify if auto alt reference frame is enabled for each
|
||||
* spatial layer.
|
||||
*/
|
||||
int ss_enable_auto_alt_ref[VPX_SS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Target bitrate for each spatial layer.
|
||||
*
|
||||
* These values specify the target coding bitrate to be used for each
|
||||
* spatial layer.
|
||||
*/
|
||||
unsigned int ss_target_bitrate[VPX_SS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Number of temporal coding layers.
|
||||
*
|
||||
* This value specifies the number of temporal layers to be used.
|
||||
*/
|
||||
unsigned int ts_number_layers;
|
||||
|
||||
/*!\brief Target bitrate for each temporal layer.
|
||||
*
|
||||
* These values specify the target coding bitrate to be used for each
|
||||
* temporal layer.
|
||||
*/
|
||||
unsigned int ts_target_bitrate[VPX_TS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Frame rate decimation factor for each temporal layer.
|
||||
*
|
||||
* These values specify the frame rate decimation factors to apply
|
||||
* to each temporal layer.
|
||||
*/
|
||||
unsigned int ts_rate_decimator[VPX_TS_MAX_LAYERS];
|
||||
|
||||
/*!\brief Length of the sequence defining frame temporal layer membership.
|
||||
*
|
||||
* This value specifies the length of the sequence that defines the
|
||||
* membership of frames to temporal layers. For example, if the
|
||||
* ts_periodicity = 8, then the frames are assigned to coding layers with a
|
||||
* repeated sequence of length 8.
|
||||
*/
|
||||
unsigned int ts_periodicity;
|
||||
|
||||
/*!\brief Template defining the membership of frames to temporal layers.
|
||||
*
|
||||
* This array defines the membership of frames to temporal coding layers.
|
||||
* For a 2-layer encoding that assigns even numbered frames to one temporal
|
||||
* layer (0) and odd numbered frames to a second temporal layer (1) with
|
||||
* ts_periodicity=8, then ts_layer_id = (0,1,0,1,0,1,0,1).
|
||||
*/
|
||||
unsigned int ts_layer_id[VPX_TS_MAX_PERIODICITY];
|
||||
|
||||
/*!\brief Target bitrate for each spatial/temporal layer.
|
||||
*
|
||||
* These values specify the target coding bitrate to be used for each
|
||||
* spatial/temporal layer.
|
||||
*
|
||||
*/
|
||||
unsigned int layer_target_bitrate[VPX_MAX_LAYERS];
|
||||
|
||||
/*!\brief Temporal layering mode indicating which temporal layering scheme to
|
||||
* use.
|
||||
*
|
||||
* The value (refer to VP9E_TEMPORAL_LAYERING_MODE) specifies the
|
||||
* temporal layering mode to use.
|
||||
*
|
||||
*/
|
||||
int temporal_layering_mode;
|
||||
} vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */
|
||||
|
||||
/*!\brief vp9 svc extra configure parameters
|
||||
*
|
||||
* This defines max/min quantizers and scale factors for each layer
|
||||
*
|
||||
*/
|
||||
typedef struct vpx_svc_parameters {
|
||||
int max_quantizers[VPX_MAX_LAYERS]; /**< Max Q for each layer */
|
||||
int min_quantizers[VPX_MAX_LAYERS]; /**< Min Q for each layer */
|
||||
int scaling_factor_num[VPX_MAX_LAYERS]; /**< Scaling factor-numerator */
|
||||
int scaling_factor_den[VPX_MAX_LAYERS]; /**< Scaling factor-denominator */
|
||||
int speed_per_layer[VPX_MAX_LAYERS]; /**< Speed setting for each sl */
|
||||
int temporal_layering_mode; /**< Temporal layering mode */
|
||||
} vpx_svc_extra_cfg_t;
|
||||
|
||||
/*!\brief Initialize an encoder instance
|
||||
*
|
||||
* Initializes a encoder context using the given interface. Applications
|
||||
* should call the vpx_codec_enc_init convenience macro instead of this
|
||||
* function directly, to ensure that the ABI version number parameter
|
||||
* is properly initialized.
|
||||
*
|
||||
* If the library was configured with --disable-multithread, this call
|
||||
* is not thread safe and should be guarded with a lock if being used
|
||||
* in a multithreaded context.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[in] cfg Configuration to use, if known. May be NULL.
|
||||
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
|
||||
* \param[in] ver ABI version number. Must be set to
|
||||
* VPX_ENCODER_ABI_VERSION
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The decoder algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_iface_t *iface,
|
||||
const vpx_codec_enc_cfg_t *cfg,
|
||||
vpx_codec_flags_t flags, int ver);
|
||||
|
||||
/*!\brief Convenience macro for vpx_codec_enc_init_ver()
|
||||
*
|
||||
* Ensures the ABI version parameter is properly set.
|
||||
*/
|
||||
#define vpx_codec_enc_init(ctx, iface, cfg, flags) \
|
||||
vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION)
|
||||
|
||||
/*!\brief Initialize multi-encoder instance
|
||||
*
|
||||
* Initializes multi-encoder context using the given interface.
|
||||
* Applications should call the vpx_codec_enc_init_multi convenience macro
|
||||
* instead of this function directly, to ensure that the ABI version number
|
||||
* parameter is properly initialized.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context.
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[in] cfg Configuration to use, if known. May be NULL.
|
||||
* \param[in] num_enc Total number of encoders.
|
||||
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
|
||||
* \param[in] dsf Pointer to down-sampling factors.
|
||||
* \param[in] ver ABI version number. Must be set to
|
||||
* VPX_ENCODER_ABI_VERSION
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The decoder algorithm initialized.
|
||||
* \retval #VPX_CODEC_MEM_ERROR
|
||||
* Memory allocation failed.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_init_multi_ver(
|
||||
vpx_codec_ctx_t *ctx, vpx_codec_iface_t *iface, vpx_codec_enc_cfg_t *cfg,
|
||||
int num_enc, vpx_codec_flags_t flags, vpx_rational_t *dsf, int ver);
|
||||
|
||||
/*!\brief Convenience macro for vpx_codec_enc_init_multi_ver()
|
||||
*
|
||||
* Ensures the ABI version parameter is properly set.
|
||||
*/
|
||||
#define vpx_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \
|
||||
vpx_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \
|
||||
VPX_ENCODER_ABI_VERSION)
|
||||
|
||||
/*!\brief Get a default configuration
|
||||
*
|
||||
* Initializes a encoder configuration structure with default values. Supports
|
||||
* the notion of "usages" so that an algorithm may offer different default
|
||||
* settings depending on the user's intended goal. This function \ref SHOULD
|
||||
* be called by all applications to initialize the configuration structure
|
||||
* before specializing the configuration with application specific values.
|
||||
*
|
||||
* \param[in] iface Pointer to the algorithm interface to use.
|
||||
* \param[out] cfg Configuration buffer to populate.
|
||||
* \param[in] usage Must be set to 0.
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The configuration was populated.
|
||||
* \retval #VPX_CODEC_INCAPABLE
|
||||
* Interface is not an encoder interface.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, or the usage value was not recognized.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface,
|
||||
vpx_codec_enc_cfg_t *cfg,
|
||||
unsigned int usage);
|
||||
|
||||
/*!\brief Set or change configuration
|
||||
*
|
||||
* Reconfigures an encoder instance according to the given configuration.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] cfg Configuration buffer to use
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The configuration was populated.
|
||||
* \retval #VPX_CODEC_INCAPABLE
|
||||
* Interface is not an encoder interface.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, or the usage value was not recognized.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx,
|
||||
const vpx_codec_enc_cfg_t *cfg);
|
||||
|
||||
/*!\brief Get global stream headers
|
||||
*
|
||||
* Retrieves a stream level global header packet, if supported by the codec.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
*
|
||||
* \retval NULL
|
||||
* Encoder does not support global header
|
||||
* \retval Non-NULL
|
||||
* Pointer to buffer containing global header packet
|
||||
*/
|
||||
vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!\brief deadline parameter analogous to VPx REALTIME mode. */
|
||||
#define VPX_DL_REALTIME (1)
|
||||
/*!\brief deadline parameter analogous to VPx GOOD QUALITY mode. */
|
||||
#define VPX_DL_GOOD_QUALITY (1000000)
|
||||
/*!\brief deadline parameter analogous to VPx BEST QUALITY mode. */
|
||||
#define VPX_DL_BEST_QUALITY (0)
|
||||
/*!\brief Encode a frame
|
||||
*
|
||||
* Encodes a video frame at the given "presentation time." The presentation
|
||||
* time stamp (PTS) \ref MUST be strictly increasing.
|
||||
*
|
||||
* The encoder supports the notion of a soft real-time deadline. Given a
|
||||
* non-zero value to the deadline parameter, the encoder will make a "best
|
||||
* effort" guarantee to return before the given time slice expires. It is
|
||||
* implicit that limiting the available time to encode will degrade the
|
||||
* output quality. The encoder can be given an unlimited time to produce the
|
||||
* best possible frame by specifying a deadline of '0'. This deadline
|
||||
* supersedes the VPx notion of "best quality, good quality, realtime".
|
||||
* Applications that wish to map these former settings to the new deadline
|
||||
* based system can use the symbols #VPX_DL_REALTIME, #VPX_DL_GOOD_QUALITY,
|
||||
* and #VPX_DL_BEST_QUALITY.
|
||||
*
|
||||
* When the last frame has been passed to the encoder, this function should
|
||||
* continue to be called, with the img parameter set to NULL. This will
|
||||
* signal the end-of-stream condition to the encoder and allow it to encode
|
||||
* any held buffers. Encoding is complete when vpx_codec_encode() is called
|
||||
* and vpx_codec_get_cx_data() returns no data.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] img Image data to encode, NULL to flush.
|
||||
* \param[in] pts Presentation time stamp, in timebase units.
|
||||
* \param[in] duration Duration to show frame, in timebase units.
|
||||
* \param[in] flags Flags to use for encoding this frame.
|
||||
* \param[in] deadline Time to spend encoding, in microseconds. (0=infinite)
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The configuration was populated.
|
||||
* \retval #VPX_CODEC_INCAPABLE
|
||||
* Interface is not an encoder interface.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, the image format is unsupported, etc.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx, const vpx_image_t *img,
|
||||
vpx_codec_pts_t pts, unsigned long duration,
|
||||
vpx_enc_frame_flags_t flags,
|
||||
unsigned long deadline);
|
||||
|
||||
/*!\brief Set compressed data output buffer
|
||||
*
|
||||
* Sets the buffer that the codec should output the compressed data
|
||||
* into. This call effectively sets the buffer pointer returned in the
|
||||
* next VPX_CODEC_CX_FRAME_PKT packet. Subsequent packets will be
|
||||
* appended into this buffer. The buffer is preserved across frames,
|
||||
* so applications must periodically call this function after flushing
|
||||
* the accumulated compressed data to disk or to the network to reset
|
||||
* the pointer to the buffer's head.
|
||||
*
|
||||
* `pad_before` bytes will be skipped before writing the compressed
|
||||
* data, and `pad_after` bytes will be appended to the packet. The size
|
||||
* of the packet will be the sum of the size of the actual compressed
|
||||
* data, pad_before, and pad_after. The padding bytes will be preserved
|
||||
* (not overwritten).
|
||||
*
|
||||
* Note that calling this function does not guarantee that the returned
|
||||
* compressed data will be placed into the specified buffer. In the
|
||||
* event that the encoded data will not fit into the buffer provided,
|
||||
* the returned packet \ref MAY point to an internal buffer, as it would
|
||||
* if this call were never used. In this event, the output packet will
|
||||
* NOT have any padding, and the application must free space and copy it
|
||||
* to the proper place. This is of particular note in configurations
|
||||
* that may output multiple packets for a single encoded frame (e.g., lagged
|
||||
* encoding) or if the application does not reset the buffer periodically.
|
||||
*
|
||||
* Applications may restore the default behavior of the codec providing
|
||||
* the compressed data buffer by calling this function with a NULL
|
||||
* buffer.
|
||||
*
|
||||
* Applications \ref MUSTNOT call this function during iteration of
|
||||
* vpx_codec_get_cx_data().
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in] buf Buffer to store compressed data into
|
||||
* \param[in] pad_before Bytes to skip before writing compressed data
|
||||
* \param[in] pad_after Bytes to skip after writing compressed data
|
||||
*
|
||||
* \retval #VPX_CODEC_OK
|
||||
* The buffer was set successfully.
|
||||
* \retval #VPX_CODEC_INVALID_PARAM
|
||||
* A parameter was NULL, the image format is unsupported, etc.
|
||||
*/
|
||||
vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx,
|
||||
const vpx_fixed_buf_t *buf,
|
||||
unsigned int pad_before,
|
||||
unsigned int pad_after);
|
||||
|
||||
/*!\brief Encoded data iterator
|
||||
*
|
||||
* Iterates over a list of data packets to be passed from the encoder to the
|
||||
* application. The different kinds of packets available are enumerated in
|
||||
* #vpx_codec_cx_pkt_kind.
|
||||
*
|
||||
* #VPX_CODEC_CX_FRAME_PKT packets should be passed to the application's
|
||||
* muxer. Multiple compressed frames may be in the list.
|
||||
* #VPX_CODEC_STATS_PKT packets should be appended to a global buffer.
|
||||
*
|
||||
* The application \ref MUST silently ignore any packet kinds that it does
|
||||
* not recognize or support.
|
||||
*
|
||||
* The data buffers returned from this function are only guaranteed to be
|
||||
* valid until the application makes another call to any vpx_codec_* function.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
* \param[in,out] iter Iterator storage, initialized to NULL
|
||||
*
|
||||
* \return Returns a pointer to an output data packet (compressed frame data,
|
||||
* two-pass statistics, etc.) or NULL to signal end-of-list.
|
||||
*
|
||||
*/
|
||||
const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx,
|
||||
vpx_codec_iter_t *iter);
|
||||
|
||||
/*!\brief Get Preview Frame
|
||||
*
|
||||
* Returns an image that can be used as a preview. Shows the image as it would
|
||||
* exist at the decompressor. The application \ref MUST NOT write into this
|
||||
* image buffer.
|
||||
*
|
||||
* \param[in] ctx Pointer to this instance's context
|
||||
*
|
||||
* \return Returns a pointer to a preview image, or NULL if no image is
|
||||
* available.
|
||||
*
|
||||
*/
|
||||
const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx);
|
||||
|
||||
/*!@} - end defgroup encoder*/
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // VPX_VPX_VPX_ENCODER_H_
|
||||
83
vpx-encoder/android_libs/x86/include/vpx/vpx_frame_buffer.h
Normal file
83
vpx-encoder/android_libs/x86/include/vpx/vpx_frame_buffer.h
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef VPX_VPX_VPX_FRAME_BUFFER_H_
|
||||
#define VPX_VPX_VPX_FRAME_BUFFER_H_
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the decoder external frame buffer interface.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "./vpx_integer.h"
|
||||
|
||||
/*!\brief The maximum number of work buffers used by libvpx.
|
||||
* Support maximum 4 threads to decode video in parallel.
|
||||
* Each thread will use one work buffer.
|
||||
* TODO(hkuang): Add support to set number of worker threads dynamically.
|
||||
*/
|
||||
#define VPX_MAXIMUM_WORK_BUFFERS 8
|
||||
|
||||
/*!\brief The maximum number of reference buffers that a VP9 encoder may use.
|
||||
*/
|
||||
#define VP9_MAXIMUM_REF_BUFFERS 8
|
||||
|
||||
/*!\brief External frame buffer
|
||||
*
|
||||
* This structure holds allocated frame buffers used by the decoder.
|
||||
*/
|
||||
typedef struct vpx_codec_frame_buffer {
|
||||
uint8_t *data; /**< Pointer to the data buffer */
|
||||
size_t size; /**< Size of data in bytes */
|
||||
void *priv; /**< Frame's private data */
|
||||
} vpx_codec_frame_buffer_t;
|
||||
|
||||
/*!\brief get frame buffer callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder to retrieve data for the frame
|
||||
* buffer in order for the decode call to complete. The callback must
|
||||
* allocate at least min_size in bytes and assign it to fb->data. The callback
|
||||
* must zero out all the data allocated. Then the callback must set fb->size
|
||||
* to the allocated size. The application does not need to align the allocated
|
||||
* data. The callback is triggered when the decoder needs a frame buffer to
|
||||
* decode a compressed image into. This function may be called more than once
|
||||
* for every call to vpx_codec_decode. The application may set fb->priv to
|
||||
* some data which will be passed back in the ximage and the release function
|
||||
* call. |fb| is guaranteed to not be NULL. On success the callback must
|
||||
* return 0. Any failure the callback must return a value less than 0.
|
||||
*
|
||||
* \param[in] priv Callback's private data
|
||||
* \param[in] min_size Size in bytes needed by the buffer
|
||||
* \param[in,out] fb Pointer to vpx_codec_frame_buffer_t
|
||||
*/
|
||||
typedef int (*vpx_get_frame_buffer_cb_fn_t)(void *priv, size_t min_size,
|
||||
vpx_codec_frame_buffer_t *fb);
|
||||
|
||||
/*!\brief release frame buffer callback prototype
|
||||
*
|
||||
* This callback is invoked by the decoder when the frame buffer is not
|
||||
* referenced by any other buffers. |fb| is guaranteed to not be NULL. On
|
||||
* success the callback must return 0. Any failure the callback must return
|
||||
* a value less than 0.
|
||||
*
|
||||
* \param[in] priv Callback's private data
|
||||
* \param[in] fb Pointer to vpx_codec_frame_buffer_t
|
||||
*/
|
||||
typedef int (*vpx_release_frame_buffer_cb_fn_t)(void *priv,
|
||||
vpx_codec_frame_buffer_t *fb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VPX_FRAME_BUFFER_H_
|
||||
207
vpx-encoder/android_libs/x86/include/vpx/vpx_image.h
Normal file
207
vpx-encoder/android_libs/x86/include/vpx/vpx_image.h
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
/*!\file
|
||||
* \brief Describes the vpx image descriptor and associated operations
|
||||
*
|
||||
*/
|
||||
#ifndef VPX_VPX_VPX_IMAGE_H_
|
||||
#define VPX_VPX_VPX_IMAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!\brief Current ABI version number
|
||||
*
|
||||
* \internal
|
||||
* If this file is altered in any way that changes the ABI, this value
|
||||
* must be bumped. Examples include, but are not limited to, changing
|
||||
* types, removing or reassigning enums, adding/removing/rearranging
|
||||
* fields to structures
|
||||
*/
|
||||
#define VPX_IMAGE_ABI_VERSION (5) /**<\hideinitializer*/
|
||||
|
||||
#define VPX_IMG_FMT_PLANAR 0x100 /**< Image is a planar format. */
|
||||
#define VPX_IMG_FMT_UV_FLIP 0x200 /**< V plane precedes U in memory. */
|
||||
#define VPX_IMG_FMT_HAS_ALPHA 0x400 /**< Image has an alpha channel. */
|
||||
#define VPX_IMG_FMT_HIGHBITDEPTH 0x800 /**< Image uses 16bit framebuffer. */
|
||||
|
||||
/*!\brief List of supported image formats */
|
||||
typedef enum vpx_img_fmt {
|
||||
VPX_IMG_FMT_NONE,
|
||||
VPX_IMG_FMT_YV12 =
|
||||
VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
|
||||
VPX_IMG_FMT_I420 = VPX_IMG_FMT_PLANAR | 2,
|
||||
VPX_IMG_FMT_I422 = VPX_IMG_FMT_PLANAR | 5,
|
||||
VPX_IMG_FMT_I444 = VPX_IMG_FMT_PLANAR | 6,
|
||||
VPX_IMG_FMT_I440 = VPX_IMG_FMT_PLANAR | 7,
|
||||
VPX_IMG_FMT_I42016 = VPX_IMG_FMT_I420 | VPX_IMG_FMT_HIGHBITDEPTH,
|
||||
VPX_IMG_FMT_I42216 = VPX_IMG_FMT_I422 | VPX_IMG_FMT_HIGHBITDEPTH,
|
||||
VPX_IMG_FMT_I44416 = VPX_IMG_FMT_I444 | VPX_IMG_FMT_HIGHBITDEPTH,
|
||||
VPX_IMG_FMT_I44016 = VPX_IMG_FMT_I440 | VPX_IMG_FMT_HIGHBITDEPTH
|
||||
} vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
|
||||
|
||||
/*!\brief List of supported color spaces */
|
||||
typedef enum vpx_color_space {
|
||||
VPX_CS_UNKNOWN = 0, /**< Unknown */
|
||||
VPX_CS_BT_601 = 1, /**< BT.601 */
|
||||
VPX_CS_BT_709 = 2, /**< BT.709 */
|
||||
VPX_CS_SMPTE_170 = 3, /**< SMPTE.170 */
|
||||
VPX_CS_SMPTE_240 = 4, /**< SMPTE.240 */
|
||||
VPX_CS_BT_2020 = 5, /**< BT.2020 */
|
||||
VPX_CS_RESERVED = 6, /**< Reserved */
|
||||
VPX_CS_SRGB = 7 /**< sRGB */
|
||||
} vpx_color_space_t; /**< alias for enum vpx_color_space */
|
||||
|
||||
/*!\brief List of supported color range */
|
||||
typedef enum vpx_color_range {
|
||||
VPX_CR_STUDIO_RANGE = 0, /**< Y [16..235], UV [16..240] */
|
||||
VPX_CR_FULL_RANGE = 1 /**< YUV/RGB [0..255] */
|
||||
} vpx_color_range_t; /**< alias for enum vpx_color_range */
|
||||
|
||||
/**\brief Image Descriptor */
|
||||
typedef struct vpx_image {
|
||||
vpx_img_fmt_t fmt; /**< Image Format */
|
||||
vpx_color_space_t cs; /**< Color Space */
|
||||
vpx_color_range_t range; /**< Color Range */
|
||||
|
||||
/* Image storage dimensions */
|
||||
unsigned int w; /**< Stored image width */
|
||||
unsigned int h; /**< Stored image height */
|
||||
unsigned int bit_depth; /**< Stored image bit-depth */
|
||||
|
||||
/* Image display dimensions */
|
||||
unsigned int d_w; /**< Displayed image width */
|
||||
unsigned int d_h; /**< Displayed image height */
|
||||
|
||||
/* Image intended rendering dimensions */
|
||||
unsigned int r_w; /**< Intended rendering image width */
|
||||
unsigned int r_h; /**< Intended rendering image height */
|
||||
|
||||
/* Chroma subsampling info */
|
||||
unsigned int x_chroma_shift; /**< subsampling order, X */
|
||||
unsigned int y_chroma_shift; /**< subsampling order, Y */
|
||||
|
||||
/* Image data pointers. */
|
||||
#define VPX_PLANE_PACKED 0 /**< To be used for all packed formats */
|
||||
#define VPX_PLANE_Y 0 /**< Y (Luminance) plane */
|
||||
#define VPX_PLANE_U 1 /**< U (Chroma) plane */
|
||||
#define VPX_PLANE_V 2 /**< V (Chroma) plane */
|
||||
#define VPX_PLANE_ALPHA 3 /**< A (Transparency) plane */
|
||||
unsigned char *planes[4]; /**< pointer to the top left pixel for each plane */
|
||||
int stride[4]; /**< stride between rows for each plane */
|
||||
|
||||
int bps; /**< bits per sample (for packed formats) */
|
||||
|
||||
/*!\brief The following member may be set by the application to associate
|
||||
* data with this image.
|
||||
*/
|
||||
void *user_priv;
|
||||
|
||||
/* The following members should be treated as private. */
|
||||
unsigned char *img_data; /**< private */
|
||||
int img_data_owner; /**< private */
|
||||
int self_allocd; /**< private */
|
||||
|
||||
void *fb_priv; /**< Frame buffer data associated with the image. */
|
||||
} vpx_image_t; /**< alias for struct vpx_image */
|
||||
|
||||
/**\brief Representation of a rectangle on a surface */
|
||||
typedef struct vpx_image_rect {
|
||||
unsigned int x; /**< leftmost column */
|
||||
unsigned int y; /**< topmost row */
|
||||
unsigned int w; /**< width */
|
||||
unsigned int h; /**< height */
|
||||
} vpx_image_rect_t; /**< alias for struct vpx_image_rect */
|
||||
|
||||
/*!\brief Open a descriptor, allocating storage for the underlying image
|
||||
*
|
||||
* Returns a descriptor for storing an image of the given format. The
|
||||
* storage for the descriptor is allocated on the heap.
|
||||
*
|
||||
* \param[in] img Pointer to storage for descriptor. If this parameter
|
||||
* is NULL, the storage for the descriptor will be
|
||||
* allocated on the heap.
|
||||
* \param[in] fmt Format for the image
|
||||
* \param[in] d_w Width of the image
|
||||
* \param[in] d_h Height of the image
|
||||
* \param[in] align Alignment, in bytes, of the image buffer and
|
||||
* each row in the image(stride).
|
||||
*
|
||||
* \return Returns a pointer to the initialized image descriptor. If the img
|
||||
* parameter is non-null, the value of the img parameter will be
|
||||
* returned.
|
||||
*/
|
||||
vpx_image_t *vpx_img_alloc(vpx_image_t *img, vpx_img_fmt_t fmt,
|
||||
unsigned int d_w, unsigned int d_h,
|
||||
unsigned int align);
|
||||
|
||||
/*!\brief Open a descriptor, using existing storage for the underlying image
|
||||
*
|
||||
* Returns a descriptor for storing an image of the given format. The
|
||||
* storage for descriptor has been allocated elsewhere, and a descriptor is
|
||||
* desired to "wrap" that storage.
|
||||
*
|
||||
* \param[in] img Pointer to storage for descriptor. If this
|
||||
* parameter is NULL, the storage for the descriptor
|
||||
* will be allocated on the heap.
|
||||
* \param[in] fmt Format for the image
|
||||
* \param[in] d_w Width of the image
|
||||
* \param[in] d_h Height of the image
|
||||
* \param[in] stride_align Alignment, in bytes, of each row in the image.
|
||||
* \param[in] img_data Storage to use for the image
|
||||
*
|
||||
* \return Returns a pointer to the initialized image descriptor. If the img
|
||||
* parameter is non-null, the value of the img parameter will be
|
||||
* returned.
|
||||
*/
|
||||
vpx_image_t *vpx_img_wrap(vpx_image_t *img, vpx_img_fmt_t fmt, unsigned int d_w,
|
||||
unsigned int d_h, unsigned int stride_align,
|
||||
unsigned char *img_data);
|
||||
|
||||
/*!\brief Set the rectangle identifying the displayed portion of the image
|
||||
*
|
||||
* Updates the displayed rectangle (aka viewport) on the image surface to
|
||||
* match the specified coordinates and size.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
* \param[in] x leftmost column
|
||||
* \param[in] y topmost row
|
||||
* \param[in] w width
|
||||
* \param[in] h height
|
||||
*
|
||||
* \return 0 if the requested rectangle is valid, nonzero otherwise.
|
||||
*/
|
||||
int vpx_img_set_rect(vpx_image_t *img, unsigned int x, unsigned int y,
|
||||
unsigned int w, unsigned int h);
|
||||
|
||||
/*!\brief Flip the image vertically (top for bottom)
|
||||
*
|
||||
* Adjusts the image descriptor's pointers and strides to make the image
|
||||
* be referenced upside-down.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
*/
|
||||
void vpx_img_flip(vpx_image_t *img);
|
||||
|
||||
/*!\brief Close an image descriptor
|
||||
*
|
||||
* Frees all allocated storage associated with an image descriptor.
|
||||
*
|
||||
* \param[in] img Image descriptor
|
||||
*/
|
||||
void vpx_img_free(vpx_image_t *img);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // VPX_VPX_VPX_IMAGE_H_
|
||||
40
vpx-encoder/android_libs/x86/include/vpx/vpx_integer.h
Normal file
40
vpx-encoder/android_libs/x86/include/vpx/vpx_integer.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef VPX_VPX_VPX_INTEGER_H_
|
||||
#define VPX_VPX_VPX_INTEGER_H_
|
||||
|
||||
/* get ptrdiff_t, size_t, wchar_t, NULL */
|
||||
#include <stddef.h>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define VPX_FORCE_INLINE __forceinline
|
||||
#define VPX_INLINE __inline
|
||||
#else
|
||||
#define VPX_FORCE_INLINE __inline__ __attribute__((always_inline))
|
||||
// TODO(jbb): Allow a way to force inline off for older compilers.
|
||||
#define VPX_INLINE inline
|
||||
#endif
|
||||
|
||||
/* Assume platforms have the C99 standard integer types. */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#if !defined(__STDC_FORMAT_MACROS)
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#endif
|
||||
#if !defined(__STDC_LIMIT_MACROS)
|
||||
#define __STDC_LIMIT_MACROS
|
||||
#endif
|
||||
#endif // __cplusplus
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#endif // VPX_VPX_VPX_INTEGER_H_
|
||||
BIN
vpx-encoder/android_libs/x86/lib/libvpx.a
Normal file
BIN
vpx-encoder/android_libs/x86/lib/libvpx.a
Normal file
Binary file not shown.
14
vpx-encoder/android_libs/x86/lib/pkgconfig/vpx.pc
Normal file
14
vpx-encoder/android_libs/x86/lib/pkgconfig/vpx.pc
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# pkg-config file from libvpx v1.8.0
|
||||
prefix=/Users/andy/go/src/github.com/webmproject/jni/vpx-android/output/android/x86
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: vpx
|
||||
Description: WebM Project VPx codec implementation
|
||||
Version: 1.8.0
|
||||
Requires:
|
||||
Conflicts:
|
||||
Libs: -L${libdir} -lvpx -lm
|
||||
Libs.private: -lm
|
||||
Cflags: -I${includedir}
|
||||
44
vpx-encoder/android_libs/x86_64/include/common/file_util.h
Normal file
44
vpx-encoder/android_libs/x86_64/include/common/file_util.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright (c) 2016 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
#ifndef LIBWEBM_COMMON_FILE_UTIL_H_
|
||||
#define LIBWEBM_COMMON_FILE_UTIL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "mkvmuxer/mkvmuxertypes.h" // LIBWEBM_DISALLOW_COPY_AND_ASSIGN()
|
||||
|
||||
namespace libwebm {
|
||||
|
||||
// Returns a temporary file name.
|
||||
std::string GetTempFileName();
|
||||
|
||||
// Returns size of file specified by |file_name|, or 0 upon failure.
|
||||
uint64_t GetFileSize(const std::string& file_name);
|
||||
|
||||
// Gets the contents file_name as a string. Returns false on error.
|
||||
bool GetFileContents(const std::string& file_name, std::string* contents);
|
||||
|
||||
// Manages life of temporary file specified at time of construction. Deletes
|
||||
// file upon destruction.
|
||||
class TempFileDeleter {
|
||||
public:
|
||||
TempFileDeleter();
|
||||
explicit TempFileDeleter(std::string file_name) : file_name_(file_name) {}
|
||||
~TempFileDeleter();
|
||||
const std::string& name() const { return file_name_; }
|
||||
|
||||
private:
|
||||
std::string file_name_;
|
||||
LIBWEBM_DISALLOW_COPY_AND_ASSIGN(TempFileDeleter);
|
||||
};
|
||||
|
||||
} // namespace libwebm
|
||||
|
||||
#endif // LIBWEBM_COMMON_FILE_UTIL_H_
|
||||
71
vpx-encoder/android_libs/x86_64/include/common/hdr_util.h
Normal file
71
vpx-encoder/android_libs/x86_64/include/common/hdr_util.h
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
// Copyright (c) 2016 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
#ifndef LIBWEBM_COMMON_HDR_UTIL_H_
|
||||
#define LIBWEBM_COMMON_HDR_UTIL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "mkvmuxer/mkvmuxer.h"
|
||||
|
||||
namespace mkvparser {
|
||||
struct Colour;
|
||||
struct MasteringMetadata;
|
||||
struct PrimaryChromaticity;
|
||||
} // namespace mkvparser
|
||||
|
||||
namespace libwebm {
|
||||
// Utility types and functions for working with the Colour element and its
|
||||
// children. Copiers return true upon success. Presence functions return true
|
||||
// when the specified element is present.
|
||||
|
||||
// TODO(tomfinegan): These should be moved to libwebm_utils once c++11 is
|
||||
// required by libwebm.
|
||||
|
||||
// Features of the VP9 codec that may be set in the CodecPrivate of a VP9 video
|
||||
// stream. A value of kValueNotPresent represents that the value was not set in
|
||||
// the CodecPrivate.
|
||||
struct Vp9CodecFeatures {
|
||||
static const int kValueNotPresent;
|
||||
|
||||
Vp9CodecFeatures()
|
||||
: profile(kValueNotPresent),
|
||||
level(kValueNotPresent),
|
||||
bit_depth(kValueNotPresent),
|
||||
chroma_subsampling(kValueNotPresent) {}
|
||||
~Vp9CodecFeatures() {}
|
||||
|
||||
int profile;
|
||||
int level;
|
||||
int bit_depth;
|
||||
int chroma_subsampling;
|
||||
};
|
||||
|
||||
typedef std::unique_ptr<mkvmuxer::PrimaryChromaticity> PrimaryChromaticityPtr;
|
||||
|
||||
bool CopyPrimaryChromaticity(const mkvparser::PrimaryChromaticity& parser_pc,
|
||||
PrimaryChromaticityPtr* muxer_pc);
|
||||
|
||||
bool MasteringMetadataValuePresent(double value);
|
||||
|
||||
bool CopyMasteringMetadata(const mkvparser::MasteringMetadata& parser_mm,
|
||||
mkvmuxer::MasteringMetadata* muxer_mm);
|
||||
|
||||
bool ColourValuePresent(long long value);
|
||||
|
||||
bool CopyColour(const mkvparser::Colour& parser_colour,
|
||||
mkvmuxer::Colour* muxer_colour);
|
||||
|
||||
// Returns true if |features| is set to one or more valid values.
|
||||
bool ParseVpxCodecPrivate(const uint8_t* private_data, int32_t length,
|
||||
Vp9CodecFeatures* features);
|
||||
|
||||
} // namespace libwebm
|
||||
|
||||
#endif // LIBWEBM_COMMON_HDR_UTIL_H_
|
||||
193
vpx-encoder/android_libs/x86_64/include/common/webmids.h
Normal file
193
vpx-encoder/android_libs/x86_64/include/common/webmids.h
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
#ifndef COMMON_WEBMIDS_H_
|
||||
#define COMMON_WEBMIDS_H_
|
||||
|
||||
namespace libwebm {
|
||||
|
||||
enum MkvId {
|
||||
kMkvEBML = 0x1A45DFA3,
|
||||
kMkvEBMLVersion = 0x4286,
|
||||
kMkvEBMLReadVersion = 0x42F7,
|
||||
kMkvEBMLMaxIDLength = 0x42F2,
|
||||
kMkvEBMLMaxSizeLength = 0x42F3,
|
||||
kMkvDocType = 0x4282,
|
||||
kMkvDocTypeVersion = 0x4287,
|
||||
kMkvDocTypeReadVersion = 0x4285,
|
||||
kMkvVoid = 0xEC,
|
||||
kMkvSignatureSlot = 0x1B538667,
|
||||
kMkvSignatureAlgo = 0x7E8A,
|
||||
kMkvSignatureHash = 0x7E9A,
|
||||
kMkvSignaturePublicKey = 0x7EA5,
|
||||
kMkvSignature = 0x7EB5,
|
||||
kMkvSignatureElements = 0x7E5B,
|
||||
kMkvSignatureElementList = 0x7E7B,
|
||||
kMkvSignedElement = 0x6532,
|
||||
// segment
|
||||
kMkvSegment = 0x18538067,
|
||||
// Meta Seek Information
|
||||
kMkvSeekHead = 0x114D9B74,
|
||||
kMkvSeek = 0x4DBB,
|
||||
kMkvSeekID = 0x53AB,
|
||||
kMkvSeekPosition = 0x53AC,
|
||||
// Segment Information
|
||||
kMkvInfo = 0x1549A966,
|
||||
kMkvTimecodeScale = 0x2AD7B1,
|
||||
kMkvDuration = 0x4489,
|
||||
kMkvDateUTC = 0x4461,
|
||||
kMkvTitle = 0x7BA9,
|
||||
kMkvMuxingApp = 0x4D80,
|
||||
kMkvWritingApp = 0x5741,
|
||||
// Cluster
|
||||
kMkvCluster = 0x1F43B675,
|
||||
kMkvTimecode = 0xE7,
|
||||
kMkvPrevSize = 0xAB,
|
||||
kMkvBlockGroup = 0xA0,
|
||||
kMkvBlock = 0xA1,
|
||||
kMkvBlockDuration = 0x9B,
|
||||
kMkvReferenceBlock = 0xFB,
|
||||
kMkvLaceNumber = 0xCC,
|
||||
kMkvSimpleBlock = 0xA3,
|
||||
kMkvBlockAdditions = 0x75A1,
|
||||
kMkvBlockMore = 0xA6,
|
||||
kMkvBlockAddID = 0xEE,
|
||||
kMkvBlockAdditional = 0xA5,
|
||||
kMkvDiscardPadding = 0x75A2,
|
||||
// Track
|
||||
kMkvTracks = 0x1654AE6B,
|
||||
kMkvTrackEntry = 0xAE,
|
||||
kMkvTrackNumber = 0xD7,
|
||||
kMkvTrackUID = 0x73C5,
|
||||
kMkvTrackType = 0x83,
|
||||
kMkvFlagEnabled = 0xB9,
|
||||
kMkvFlagDefault = 0x88,
|
||||
kMkvFlagForced = 0x55AA,
|
||||
kMkvFlagLacing = 0x9C,
|
||||
kMkvDefaultDuration = 0x23E383,
|
||||
kMkvMaxBlockAdditionID = 0x55EE,
|
||||
kMkvName = 0x536E,
|
||||
kMkvLanguage = 0x22B59C,
|
||||
kMkvCodecID = 0x86,
|
||||
kMkvCodecPrivate = 0x63A2,
|
||||
kMkvCodecName = 0x258688,
|
||||
kMkvCodecDelay = 0x56AA,
|
||||
kMkvSeekPreRoll = 0x56BB,
|
||||
// video
|
||||
kMkvVideo = 0xE0,
|
||||
kMkvFlagInterlaced = 0x9A,
|
||||
kMkvStereoMode = 0x53B8,
|
||||
kMkvAlphaMode = 0x53C0,
|
||||
kMkvPixelWidth = 0xB0,
|
||||
kMkvPixelHeight = 0xBA,
|
||||
kMkvPixelCropBottom = 0x54AA,
|
||||
kMkvPixelCropTop = 0x54BB,
|
||||
kMkvPixelCropLeft = 0x54CC,
|
||||
kMkvPixelCropRight = 0x54DD,
|
||||
kMkvDisplayWidth = 0x54B0,
|
||||
kMkvDisplayHeight = 0x54BA,
|
||||
kMkvDisplayUnit = 0x54B2,
|
||||
kMkvAspectRatioType = 0x54B3,
|
||||
kMkvColourSpace = 0x2EB524,
|
||||
kMkvFrameRate = 0x2383E3,
|
||||
// end video
|
||||
// colour
|
||||
kMkvColour = 0x55B0,
|
||||
kMkvMatrixCoefficients = 0x55B1,
|
||||
kMkvBitsPerChannel = 0x55B2,
|
||||
kMkvChromaSubsamplingHorz = 0x55B3,
|
||||
kMkvChromaSubsamplingVert = 0x55B4,
|
||||
kMkvCbSubsamplingHorz = 0x55B5,
|
||||
kMkvCbSubsamplingVert = 0x55B6,
|
||||
kMkvChromaSitingHorz = 0x55B7,
|
||||
kMkvChromaSitingVert = 0x55B8,
|
||||
kMkvRange = 0x55B9,
|
||||
kMkvTransferCharacteristics = 0x55BA,
|
||||
kMkvPrimaries = 0x55BB,
|
||||
kMkvMaxCLL = 0x55BC,
|
||||
kMkvMaxFALL = 0x55BD,
|
||||
// mastering metadata
|
||||
kMkvMasteringMetadata = 0x55D0,
|
||||
kMkvPrimaryRChromaticityX = 0x55D1,
|
||||
kMkvPrimaryRChromaticityY = 0x55D2,
|
||||
kMkvPrimaryGChromaticityX = 0x55D3,
|
||||
kMkvPrimaryGChromaticityY = 0x55D4,
|
||||
kMkvPrimaryBChromaticityX = 0x55D5,
|
||||
kMkvPrimaryBChromaticityY = 0x55D6,
|
||||
kMkvWhitePointChromaticityX = 0x55D7,
|
||||
kMkvWhitePointChromaticityY = 0x55D8,
|
||||
kMkvLuminanceMax = 0x55D9,
|
||||
kMkvLuminanceMin = 0x55DA,
|
||||
// end mastering metadata
|
||||
// end colour
|
||||
// projection
|
||||
kMkvProjection = 0x7670,
|
||||
kMkvProjectionType = 0x7671,
|
||||
kMkvProjectionPrivate = 0x7672,
|
||||
kMkvProjectionPoseYaw = 0x7673,
|
||||
kMkvProjectionPosePitch = 0x7674,
|
||||
kMkvProjectionPoseRoll = 0x7675,
|
||||
// end projection
|
||||
// audio
|
||||
kMkvAudio = 0xE1,
|
||||
kMkvSamplingFrequency = 0xB5,
|
||||
kMkvOutputSamplingFrequency = 0x78B5,
|
||||
kMkvChannels = 0x9F,
|
||||
kMkvBitDepth = 0x6264,
|
||||
// end audio
|
||||
// ContentEncodings
|
||||
kMkvContentEncodings = 0x6D80,
|
||||
kMkvContentEncoding = 0x6240,
|
||||
kMkvContentEncodingOrder = 0x5031,
|
||||
kMkvContentEncodingScope = 0x5032,
|
||||
kMkvContentEncodingType = 0x5033,
|
||||
kMkvContentCompression = 0x5034,
|
||||
kMkvContentCompAlgo = 0x4254,
|
||||
kMkvContentCompSettings = 0x4255,
|
||||
kMkvContentEncryption = 0x5035,
|
||||
kMkvContentEncAlgo = 0x47E1,
|
||||
kMkvContentEncKeyID = 0x47E2,
|
||||
kMkvContentSignature = 0x47E3,
|
||||
kMkvContentSigKeyID = 0x47E4,
|
||||
kMkvContentSigAlgo = 0x47E5,
|
||||
kMkvContentSigHashAlgo = 0x47E6,
|
||||
kMkvContentEncAESSettings = 0x47E7,
|
||||
kMkvAESSettingsCipherMode = 0x47E8,
|
||||
kMkvAESSettingsCipherInitData = 0x47E9,
|
||||
// end ContentEncodings
|
||||
// Cueing Data
|
||||
kMkvCues = 0x1C53BB6B,
|
||||
kMkvCuePoint = 0xBB,
|
||||
kMkvCueTime = 0xB3,
|
||||
kMkvCueTrackPositions = 0xB7,
|
||||
kMkvCueTrack = 0xF7,
|
||||
kMkvCueClusterPosition = 0xF1,
|
||||
kMkvCueBlockNumber = 0x5378,
|
||||
// Chapters
|
||||
kMkvChapters = 0x1043A770,
|
||||
kMkvEditionEntry = 0x45B9,
|
||||
kMkvChapterAtom = 0xB6,
|
||||
kMkvChapterUID = 0x73C4,
|
||||
kMkvChapterStringUID = 0x5654,
|
||||
kMkvChapterTimeStart = 0x91,
|
||||
kMkvChapterTimeEnd = 0x92,
|
||||
kMkvChapterDisplay = 0x80,
|
||||
kMkvChapString = 0x85,
|
||||
kMkvChapLanguage = 0x437C,
|
||||
kMkvChapCountry = 0x437E,
|
||||
// Tags
|
||||
kMkvTags = 0x1254C367,
|
||||
kMkvTag = 0x7373,
|
||||
kMkvSimpleTag = 0x67C8,
|
||||
kMkvTagName = 0x45A3,
|
||||
kMkvTagString = 0x4487
|
||||
};
|
||||
|
||||
} // namespace libwebm
|
||||
|
||||
#endif // COMMON_WEBMIDS_H_
|
||||
1924
vpx-encoder/android_libs/x86_64/include/mkvmuxer/mkvmuxer.h
Normal file
1924
vpx-encoder/android_libs/x86_64/include/mkvmuxer/mkvmuxer.h
Normal file
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue