parent
4bfa114fe9
commit
06ad4eb190
|
@ -119,6 +119,11 @@ public class MediaSessionMgr : IDisposable {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static bool defaultsSetBandwidthVideoUploadMax(int bw_video_up_max_kbps) {
|
||||
bool ret = tinyWRAPPINVOKE.MediaSessionMgr_defaultsSetBandwidthVideoUploadMax(bw_video_up_max_kbps);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static bool defaultsSetPrefVideoSize(tmedia_pref_video_size_t pref_video_size) {
|
||||
bool ret = tinyWRAPPINVOKE.MediaSessionMgr_defaultsSetPrefVideoSize((int)pref_video_size);
|
||||
return ret;
|
||||
|
|
|
@ -336,6 +336,9 @@ class tinyWRAPPINVOKE {
|
|||
[DllImport("tinyWRAP", EntryPoint="CSharp_MediaSessionMgr_defaultsGetBandwidthLevel")]
|
||||
public static extern int MediaSessionMgr_defaultsGetBandwidthLevel();
|
||||
|
||||
[DllImport("tinyWRAP", EntryPoint="CSharp_MediaSessionMgr_defaultsSetBandwidthVideoUploadMax")]
|
||||
public static extern bool MediaSessionMgr_defaultsSetBandwidthVideoUploadMax(int jarg1);
|
||||
|
||||
[DllImport("tinyWRAP", EntryPoint="CSharp_MediaSessionMgr_defaultsSetPrefVideoSize")]
|
||||
public static extern bool MediaSessionMgr_defaultsSetPrefVideoSize(int jarg1);
|
||||
|
||||
|
|
|
@ -1806,6 +1806,18 @@ SWIGEXPORT int SWIGSTDCALL CSharp_MediaSessionMgr_defaultsGetBandwidthLevel() {
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT unsigned int SWIGSTDCALL CSharp_MediaSessionMgr_defaultsSetBandwidthVideoUploadMax(int jarg1) {
|
||||
unsigned int jresult ;
|
||||
int32_t arg1 ;
|
||||
bool result;
|
||||
|
||||
arg1 = (int32_t)jarg1;
|
||||
result = (bool)MediaSessionMgr::defaultsSetBandwidthVideoUploadMax(arg1);
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT unsigned int SWIGSTDCALL CSharp_MediaSessionMgr_defaultsSetPrefVideoSize(int jarg1) {
|
||||
unsigned int jresult ;
|
||||
tmedia_pref_video_size_t arg1 ;
|
||||
|
|
|
@ -98,6 +98,10 @@ public class MediaSessionMgr {
|
|||
return tmedia_bandwidth_level_t.swigToEnum(tinyWRAPJNI.MediaSessionMgr_defaultsGetBandwidthLevel());
|
||||
}
|
||||
|
||||
public static boolean defaultsSetBandwidthVideoUploadMax(int bw_video_up_max_kbps) {
|
||||
return tinyWRAPJNI.MediaSessionMgr_defaultsSetBandwidthVideoUploadMax(bw_video_up_max_kbps);
|
||||
}
|
||||
|
||||
public static boolean defaultsSetPrefVideoSize(tmedia_pref_video_size_t pref_video_size) {
|
||||
return tinyWRAPJNI.MediaSessionMgr_defaultsSetPrefVideoSize(pref_video_size.swigValue());
|
||||
}
|
||||
|
|
|
@ -98,6 +98,10 @@ public class MediaSessionMgr {
|
|||
return tmedia_bandwidth_level_t.swigToEnum(tinyWRAPJNI.MediaSessionMgr_defaultsGetBandwidthLevel());
|
||||
}
|
||||
|
||||
public static boolean defaultsSetBandwidthVideoUploadMax(int bw_video_up_max_kbps) {
|
||||
return tinyWRAPJNI.MediaSessionMgr_defaultsSetBandwidthVideoUploadMax(bw_video_up_max_kbps);
|
||||
}
|
||||
|
||||
public static boolean defaultsSetPrefVideoSize(tmedia_pref_video_size_t pref_video_size) {
|
||||
return tinyWRAPJNI.MediaSessionMgr_defaultsSetPrefVideoSize(pref_video_size.swigValue());
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ public class tinyWRAPJNI {
|
|||
public final static native int MediaSessionMgr_defaultsGetProfile();
|
||||
public final static native boolean MediaSessionMgr_defaultsSetBandwidthLevel(int jarg1);
|
||||
public final static native int MediaSessionMgr_defaultsGetBandwidthLevel();
|
||||
public final static native boolean MediaSessionMgr_defaultsSetBandwidthVideoUploadMax(int jarg1);
|
||||
public final static native boolean MediaSessionMgr_defaultsSetPrefVideoSize(int jarg1);
|
||||
public final static native boolean MediaSessionMgr_defaultsSetJbMargin(long jarg1);
|
||||
public final static native boolean MediaSessionMgr_defaultsSetJbMaxLateRate(long jarg1);
|
||||
|
|
|
@ -2841,6 +2841,20 @@ SWIGEXPORT jint JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetBandwidthVideoUploadMax(JNIEnv *jenv, jclass jcls, jint jarg1) {
|
||||
jboolean jresult = 0 ;
|
||||
int32_t arg1 ;
|
||||
bool result;
|
||||
|
||||
(void)jenv;
|
||||
(void)jcls;
|
||||
arg1 = (int32_t)jarg1;
|
||||
result = (bool)MediaSessionMgr::defaultsSetBandwidthVideoUploadMax(arg1);
|
||||
jresult = (jboolean)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetPrefVideoSize(JNIEnv *jenv, jclass jcls, jint jarg1) {
|
||||
jboolean jresult = 0 ;
|
||||
tmedia_pref_video_size_t arg1 ;
|
||||
|
|
|
@ -59,6 +59,7 @@ public class tinyWRAPJNI {
|
|||
public final static native int MediaSessionMgr_defaultsGetProfile();
|
||||
public final static native boolean MediaSessionMgr_defaultsSetBandwidthLevel(int jarg1);
|
||||
public final static native int MediaSessionMgr_defaultsGetBandwidthLevel();
|
||||
public final static native boolean MediaSessionMgr_defaultsSetBandwidthVideoUploadMax(int jarg1);
|
||||
public final static native boolean MediaSessionMgr_defaultsSetPrefVideoSize(int jarg1);
|
||||
public final static native boolean MediaSessionMgr_defaultsSetJbMargin(long jarg1);
|
||||
public final static native boolean MediaSessionMgr_defaultsSetJbMaxLateRate(long jarg1);
|
||||
|
|
|
@ -2841,6 +2841,20 @@ SWIGEXPORT jint JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1
|
|||
}
|
||||
|
||||
|
||||
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetBandwidthVideoUploadMax(JNIEnv *jenv, jclass jcls, jint jarg1) {
|
||||
jboolean jresult = 0 ;
|
||||
int32_t arg1 ;
|
||||
bool result;
|
||||
|
||||
(void)jenv;
|
||||
(void)jcls;
|
||||
arg1 = (int32_t)jarg1;
|
||||
result = (bool)MediaSessionMgr::defaultsSetBandwidthVideoUploadMax(arg1);
|
||||
jresult = (jboolean)result;
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT jboolean JNICALL Java_org_doubango_tinyWRAP_tinyWRAPJNI_MediaSessionMgr_1defaultsSetPrefVideoSize(JNIEnv *jenv, jclass jcls, jint jarg1) {
|
||||
jboolean jresult = 0 ;
|
||||
tmedia_pref_video_size_t arg1 ;
|
||||
|
|
|
@ -246,6 +246,7 @@ sub DESTROY {
|
|||
*defaultsGetProfile = *tinyWRAPc::MediaSessionMgr_defaultsGetProfile;
|
||||
*defaultsSetBandwidthLevel = *tinyWRAPc::MediaSessionMgr_defaultsSetBandwidthLevel;
|
||||
*defaultsGetBandwidthLevel = *tinyWRAPc::MediaSessionMgr_defaultsGetBandwidthLevel;
|
||||
*defaultsSetBandwidthVideoUploadMax = *tinyWRAPc::MediaSessionMgr_defaultsSetBandwidthVideoUploadMax;
|
||||
*defaultsSetPrefVideoSize = *tinyWRAPc::MediaSessionMgr_defaultsSetPrefVideoSize;
|
||||
*defaultsSetJbMargin = *tinyWRAPc::MediaSessionMgr_defaultsSetJbMargin;
|
||||
*defaultsSetJbMaxLateRate = *tinyWRAPc::MediaSessionMgr_defaultsSetJbMaxLateRate;
|
||||
|
|
|
@ -3976,6 +3976,34 @@ XS(_wrap_MediaSessionMgr_defaultsGetBandwidthLevel) {
|
|||
}
|
||||
|
||||
|
||||
XS(_wrap_MediaSessionMgr_defaultsSetBandwidthVideoUploadMax) {
|
||||
{
|
||||
int32_t arg1 ;
|
||||
int val1 ;
|
||||
int ecode1 = 0 ;
|
||||
int argvi = 0;
|
||||
bool result;
|
||||
dXSARGS;
|
||||
|
||||
if ((items < 1) || (items > 1)) {
|
||||
SWIG_croak("Usage: MediaSessionMgr_defaultsSetBandwidthVideoUploadMax(bw_video_up_max_kbps);");
|
||||
}
|
||||
ecode1 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(0), &val1);
|
||||
if (!SWIG_IsOK(ecode1)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MediaSessionMgr_defaultsSetBandwidthVideoUploadMax" "', argument " "1"" of type '" "int32_t""'");
|
||||
}
|
||||
arg1 = static_cast< int32_t >(val1);
|
||||
result = (bool)MediaSessionMgr::defaultsSetBandwidthVideoUploadMax(arg1);
|
||||
ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ;
|
||||
|
||||
XSRETURN(argvi);
|
||||
fail:
|
||||
|
||||
SWIG_croak_null();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
XS(_wrap_MediaSessionMgr_defaultsSetPrefVideoSize) {
|
||||
{
|
||||
tmedia_pref_video_size_t arg1 ;
|
||||
|
@ -26852,6 +26880,7 @@ static swig_command_info swig_commands[] = {
|
|||
{"tinyWRAPc::MediaSessionMgr_defaultsGetProfile", _wrap_MediaSessionMgr_defaultsGetProfile},
|
||||
{"tinyWRAPc::MediaSessionMgr_defaultsSetBandwidthLevel", _wrap_MediaSessionMgr_defaultsSetBandwidthLevel},
|
||||
{"tinyWRAPc::MediaSessionMgr_defaultsGetBandwidthLevel", _wrap_MediaSessionMgr_defaultsGetBandwidthLevel},
|
||||
{"tinyWRAPc::MediaSessionMgr_defaultsSetBandwidthVideoUploadMax", _wrap_MediaSessionMgr_defaultsSetBandwidthVideoUploadMax},
|
||||
{"tinyWRAPc::MediaSessionMgr_defaultsSetPrefVideoSize", _wrap_MediaSessionMgr_defaultsSetPrefVideoSize},
|
||||
{"tinyWRAPc::MediaSessionMgr_defaultsSetJbMargin", _wrap_MediaSessionMgr_defaultsSetJbMargin},
|
||||
{"tinyWRAPc::MediaSessionMgr_defaultsSetJbMaxLateRate", _wrap_MediaSessionMgr_defaultsSetJbMaxLateRate},
|
||||
|
|
|
@ -199,6 +199,8 @@ class MediaSessionMgr(_object):
|
|||
if _newclass:defaultsSetBandwidthLevel = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetBandwidthLevel)
|
||||
__swig_getmethods__["defaultsGetBandwidthLevel"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsGetBandwidthLevel
|
||||
if _newclass:defaultsGetBandwidthLevel = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsGetBandwidthLevel)
|
||||
__swig_getmethods__["defaultsSetBandwidthVideoUploadMax"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsSetBandwidthVideoUploadMax
|
||||
if _newclass:defaultsSetBandwidthVideoUploadMax = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetBandwidthVideoUploadMax)
|
||||
__swig_getmethods__["defaultsSetPrefVideoSize"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsSetPrefVideoSize
|
||||
if _newclass:defaultsSetPrefVideoSize = staticmethod(_tinyWRAP.MediaSessionMgr_defaultsSetPrefVideoSize)
|
||||
__swig_getmethods__["defaultsSetJbMargin"] = lambda x: _tinyWRAP.MediaSessionMgr_defaultsSetJbMargin
|
||||
|
@ -322,6 +324,10 @@ def MediaSessionMgr_defaultsGetBandwidthLevel():
|
|||
return _tinyWRAP.MediaSessionMgr_defaultsGetBandwidthLevel()
|
||||
MediaSessionMgr_defaultsGetBandwidthLevel = _tinyWRAP.MediaSessionMgr_defaultsGetBandwidthLevel
|
||||
|
||||
def MediaSessionMgr_defaultsSetBandwidthVideoUploadMax(*args):
|
||||
return _tinyWRAP.MediaSessionMgr_defaultsSetBandwidthVideoUploadMax(*args)
|
||||
MediaSessionMgr_defaultsSetBandwidthVideoUploadMax = _tinyWRAP.MediaSessionMgr_defaultsSetBandwidthVideoUploadMax
|
||||
|
||||
def MediaSessionMgr_defaultsSetPrefVideoSize(*args):
|
||||
return _tinyWRAP.MediaSessionMgr_defaultsSetPrefVideoSize(*args)
|
||||
MediaSessionMgr_defaultsSetPrefVideoSize = _tinyWRAP.MediaSessionMgr_defaultsSetPrefVideoSize
|
||||
|
|
|
@ -6993,6 +6993,28 @@ fail:
|
|||
}
|
||||
|
||||
|
||||
SWIGINTERN PyObject *_wrap_MediaSessionMgr_defaultsSetBandwidthVideoUploadMax(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
|
||||
PyObject *resultobj = 0;
|
||||
int32_t arg1 ;
|
||||
int val1 ;
|
||||
int ecode1 = 0 ;
|
||||
PyObject * obj0 = 0 ;
|
||||
bool result;
|
||||
|
||||
if (!PyArg_ParseTuple(args,(char *)"O:MediaSessionMgr_defaultsSetBandwidthVideoUploadMax",&obj0)) SWIG_fail;
|
||||
ecode1 = SWIG_AsVal_int(obj0, &val1);
|
||||
if (!SWIG_IsOK(ecode1)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "MediaSessionMgr_defaultsSetBandwidthVideoUploadMax" "', argument " "1"" of type '" "int32_t""'");
|
||||
}
|
||||
arg1 = static_cast< int32_t >(val1);
|
||||
result = (bool)MediaSessionMgr::defaultsSetBandwidthVideoUploadMax(arg1);
|
||||
resultobj = SWIG_From_bool(static_cast< bool >(result));
|
||||
return resultobj;
|
||||
fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
SWIGINTERN PyObject *_wrap_MediaSessionMgr_defaultsSetPrefVideoSize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
|
||||
PyObject *resultobj = 0;
|
||||
tmedia_pref_video_size_t arg1 ;
|
||||
|
@ -25407,6 +25429,7 @@ static PyMethodDef SwigMethods[] = {
|
|||
{ (char *)"MediaSessionMgr_defaultsGetProfile", _wrap_MediaSessionMgr_defaultsGetProfile, METH_VARARGS, NULL},
|
||||
{ (char *)"MediaSessionMgr_defaultsSetBandwidthLevel", _wrap_MediaSessionMgr_defaultsSetBandwidthLevel, METH_VARARGS, NULL},
|
||||
{ (char *)"MediaSessionMgr_defaultsGetBandwidthLevel", _wrap_MediaSessionMgr_defaultsGetBandwidthLevel, METH_VARARGS, NULL},
|
||||
{ (char *)"MediaSessionMgr_defaultsSetBandwidthVideoUploadMax", _wrap_MediaSessionMgr_defaultsSetBandwidthVideoUploadMax, METH_VARARGS, NULL},
|
||||
{ (char *)"MediaSessionMgr_defaultsSetPrefVideoSize", _wrap_MediaSessionMgr_defaultsSetPrefVideoSize, METH_VARARGS, NULL},
|
||||
{ (char *)"MediaSessionMgr_defaultsSetJbMargin", _wrap_MediaSessionMgr_defaultsSetJbMargin, METH_VARARGS, NULL},
|
||||
{ (char *)"MediaSessionMgr_defaultsSetJbMaxLateRate", _wrap_MediaSessionMgr_defaultsSetJbMaxLateRate, METH_VARARGS, NULL},
|
||||
|
|
|
@ -1,208 +0,0 @@
|
|||
/********************************************************************
|
||||
* *
|
||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* *
|
||||
********************************************************************
|
||||
|
||||
function: toplevel libogg include
|
||||
last mod: $Id: ogg.h 16051 2009-05-27 05:00:06Z xiphmont $
|
||||
|
||||
********************************************************************/
|
||||
#ifndef _OGG_H
|
||||
#define _OGG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <ogg/os_types.h>
|
||||
|
||||
typedef struct {
|
||||
void *iov_base;
|
||||
size_t iov_len;
|
||||
} ogg_iovec_t;
|
||||
|
||||
typedef struct {
|
||||
long endbyte;
|
||||
int endbit;
|
||||
|
||||
unsigned char *buffer;
|
||||
unsigned char *ptr;
|
||||
long storage;
|
||||
} oggpack_buffer;
|
||||
|
||||
/* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
|
||||
|
||||
typedef struct {
|
||||
unsigned char *header;
|
||||
long header_len;
|
||||
unsigned char *body;
|
||||
long body_len;
|
||||
} ogg_page;
|
||||
|
||||
/* ogg_stream_state contains the current encode/decode state of a logical
|
||||
Ogg bitstream **********************************************************/
|
||||
|
||||
typedef struct {
|
||||
unsigned char *body_data; /* bytes from packet bodies */
|
||||
long body_storage; /* storage elements allocated */
|
||||
long body_fill; /* elements stored; fill mark */
|
||||
long body_returned; /* elements of fill returned */
|
||||
|
||||
|
||||
int *lacing_vals; /* The values that will go to the segment table */
|
||||
ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
|
||||
this way, but it is simple coupled to the
|
||||
lacing fifo */
|
||||
long lacing_storage;
|
||||
long lacing_fill;
|
||||
long lacing_packet;
|
||||
long lacing_returned;
|
||||
|
||||
unsigned char header[282]; /* working space for header encode */
|
||||
int header_fill;
|
||||
|
||||
int e_o_s; /* set when we have buffered the last packet in the
|
||||
logical bitstream */
|
||||
int b_o_s; /* set after we've written the initial page
|
||||
of a logical bitstream */
|
||||
long serialno;
|
||||
long pageno;
|
||||
ogg_int64_t packetno; /* sequence number for decode; the framing
|
||||
knows where there's a hole in the data,
|
||||
but we need coupling so that the codec
|
||||
(which is in a seperate abstraction
|
||||
layer) also knows about the gap */
|
||||
ogg_int64_t granulepos;
|
||||
|
||||
} ogg_stream_state;
|
||||
|
||||
/* ogg_packet is used to encapsulate the data and metadata belonging
|
||||
to a single raw Ogg/Vorbis packet *************************************/
|
||||
|
||||
typedef struct {
|
||||
unsigned char *packet;
|
||||
long bytes;
|
||||
long b_o_s;
|
||||
long e_o_s;
|
||||
|
||||
ogg_int64_t granulepos;
|
||||
|
||||
ogg_int64_t packetno; /* sequence number for decode; the framing
|
||||
knows where there's a hole in the data,
|
||||
but we need coupling so that the codec
|
||||
(which is in a seperate abstraction
|
||||
layer) also knows about the gap */
|
||||
} ogg_packet;
|
||||
|
||||
typedef struct {
|
||||
unsigned char *data;
|
||||
int storage;
|
||||
int fill;
|
||||
int returned;
|
||||
|
||||
int unsynced;
|
||||
int headerbytes;
|
||||
int bodybytes;
|
||||
} ogg_sync_state;
|
||||
|
||||
/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
|
||||
|
||||
extern void oggpack_writeinit(oggpack_buffer *b);
|
||||
extern int oggpack_writecheck(oggpack_buffer *b);
|
||||
extern void oggpack_writetrunc(oggpack_buffer *b,long bits);
|
||||
extern void oggpack_writealign(oggpack_buffer *b);
|
||||
extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits);
|
||||
extern void oggpack_reset(oggpack_buffer *b);
|
||||
extern void oggpack_writeclear(oggpack_buffer *b);
|
||||
extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
|
||||
extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
|
||||
extern long oggpack_look(oggpack_buffer *b,int bits);
|
||||
extern long oggpack_look1(oggpack_buffer *b);
|
||||
extern void oggpack_adv(oggpack_buffer *b,int bits);
|
||||
extern void oggpack_adv1(oggpack_buffer *b);
|
||||
extern long oggpack_read(oggpack_buffer *b,int bits);
|
||||
extern long oggpack_read1(oggpack_buffer *b);
|
||||
extern long oggpack_bytes(oggpack_buffer *b);
|
||||
extern long oggpack_bits(oggpack_buffer *b);
|
||||
extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
|
||||
|
||||
extern void oggpackB_writeinit(oggpack_buffer *b);
|
||||
extern int oggpackB_writecheck(oggpack_buffer *b);
|
||||
extern void oggpackB_writetrunc(oggpack_buffer *b,long bits);
|
||||
extern void oggpackB_writealign(oggpack_buffer *b);
|
||||
extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits);
|
||||
extern void oggpackB_reset(oggpack_buffer *b);
|
||||
extern void oggpackB_writeclear(oggpack_buffer *b);
|
||||
extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
|
||||
extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits);
|
||||
extern long oggpackB_look(oggpack_buffer *b,int bits);
|
||||
extern long oggpackB_look1(oggpack_buffer *b);
|
||||
extern void oggpackB_adv(oggpack_buffer *b,int bits);
|
||||
extern void oggpackB_adv1(oggpack_buffer *b);
|
||||
extern long oggpackB_read(oggpack_buffer *b,int bits);
|
||||
extern long oggpackB_read1(oggpack_buffer *b);
|
||||
extern long oggpackB_bytes(oggpack_buffer *b);
|
||||
extern long oggpackB_bits(oggpack_buffer *b);
|
||||
extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b);
|
||||
|
||||
/* Ogg BITSTREAM PRIMITIVES: encoding **************************/
|
||||
|
||||
extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
|
||||
extern int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov,
|
||||
int count, long e_o_s, ogg_int64_t granulepos);
|
||||
extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
|
||||
extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
|
||||
|
||||
/* Ogg BITSTREAM PRIMITIVES: decoding **************************/
|
||||
|
||||
extern int ogg_sync_init(ogg_sync_state *oy);
|
||||
extern int ogg_sync_clear(ogg_sync_state *oy);
|
||||
extern int ogg_sync_reset(ogg_sync_state *oy);
|
||||
extern int ogg_sync_destroy(ogg_sync_state *oy);
|
||||
extern int ogg_sync_check(ogg_sync_state *oy);
|
||||
|
||||
extern char *ogg_sync_buffer(ogg_sync_state *oy, long size);
|
||||
extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
|
||||
extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
|
||||
extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
|
||||
extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
|
||||
extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
|
||||
extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
|
||||
|
||||
/* Ogg BITSTREAM PRIMITIVES: general ***************************/
|
||||
|
||||
extern int ogg_stream_init(ogg_stream_state *os,int serialno);
|
||||
extern int ogg_stream_clear(ogg_stream_state *os);
|
||||
extern int ogg_stream_reset(ogg_stream_state *os);
|
||||
extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
|
||||
extern int ogg_stream_destroy(ogg_stream_state *os);
|
||||
extern int ogg_stream_check(ogg_stream_state *os);
|
||||
extern int ogg_stream_eos(ogg_stream_state *os);
|
||||
|
||||
extern void ogg_page_checksum_set(ogg_page *og);
|
||||
|
||||
extern int ogg_page_version(const ogg_page *og);
|
||||
extern int ogg_page_continued(const ogg_page *og);
|
||||
extern int ogg_page_bos(const ogg_page *og);
|
||||
extern int ogg_page_eos(const ogg_page *og);
|
||||
extern ogg_int64_t ogg_page_granulepos(const ogg_page *og);
|
||||
extern int ogg_page_serialno(const ogg_page *og);
|
||||
extern long ogg_page_pageno(const ogg_page *og);
|
||||
extern int ogg_page_packets(const ogg_page *og);
|
||||
|
||||
extern void ogg_packet_clear(ogg_packet *op);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _OGG_H */
|
|
@ -1,139 +0,0 @@
|
|||
/********************************************************************
|
||||
* *
|
||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* *
|
||||
********************************************************************
|
||||
|
||||
function: #ifdef jail to whip a few platforms into the UNIX ideal.
|
||||
last mod: $Id: os_types.h 14997 2008-06-04 03:27:18Z ivo $
|
||||
|
||||
********************************************************************/
|
||||
#ifndef _OS_TYPES_H
|
||||
#define _OS_TYPES_H
|
||||
|
||||
/* make it easy on the folks that want to compile the libs with a
|
||||
different malloc than stdlib */
|
||||
#define _ogg_malloc malloc
|
||||
#define _ogg_calloc calloc
|
||||
#define _ogg_realloc realloc
|
||||
#define _ogg_free free
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
# if defined(__CYGWIN__)
|
||||
# include <stdint.h>
|
||||
typedef int16_t ogg_int16_t;
|
||||
typedef uint16_t ogg_uint16_t;
|
||||
typedef int32_t ogg_int32_t;
|
||||
typedef uint32_t ogg_uint32_t;
|
||||
typedef int64_t ogg_int64_t;
|
||||
typedef uint64_t ogg_uint64_t;
|
||||
# elif defined(__MINGW32__)
|
||||
# include <sys/types.h>
|
||||
typedef short ogg_int16_t;
|
||||
typedef unsigned short ogg_uint16_t;
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long ogg_int64_t;
|
||||
typedef unsigned long long ogg_uint64_t;
|
||||
# elif defined(__MWERKS__)
|
||||
typedef long long ogg_int64_t;
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef short ogg_int16_t;
|
||||
typedef unsigned short ogg_uint16_t;
|
||||
# else
|
||||
/* MSVC/Borland */
|
||||
typedef __int64 ogg_int64_t;
|
||||
typedef __int32 ogg_int32_t;
|
||||
typedef unsigned __int32 ogg_uint32_t;
|
||||
typedef __int16 ogg_int16_t;
|
||||
typedef unsigned __int16 ogg_uint16_t;
|
||||
# endif
|
||||
|
||||
#elif defined(__MACOS__)
|
||||
|
||||
# include <sys/types.h>
|
||||
typedef SInt16 ogg_int16_t;
|
||||
typedef UInt16 ogg_uint16_t;
|
||||
typedef SInt32 ogg_int32_t;
|
||||
typedef UInt32 ogg_uint32_t;
|
||||
typedef SInt64 ogg_int64_t;
|
||||
|
||||
#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
|
||||
|
||||
# include <sys/types.h>
|
||||
typedef int16_t ogg_int16_t;
|
||||
typedef u_int16_t ogg_uint16_t;
|
||||
typedef int32_t ogg_int32_t;
|
||||
typedef u_int32_t ogg_uint32_t;
|
||||
typedef int64_t ogg_int64_t;
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
|
||||
/* Haiku */
|
||||
# include <sys/types.h>
|
||||
typedef short ogg_int16_t;
|
||||
typedef unsigned short ogg_uint16_t;
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long ogg_int64_t;
|
||||
|
||||
#elif defined(__BEOS__)
|
||||
|
||||
/* Be */
|
||||
# include <inttypes.h>
|
||||
typedef int16_t ogg_int16_t;
|
||||
typedef u_int16_t ogg_uint16_t;
|
||||
typedef int32_t ogg_int32_t;
|
||||
typedef u_int32_t ogg_uint32_t;
|
||||
typedef int64_t ogg_int64_t;
|
||||
|
||||
#elif defined (__EMX__)
|
||||
|
||||
/* OS/2 GCC */
|
||||
typedef short ogg_int16_t;
|
||||
typedef unsigned short ogg_uint16_t;
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long ogg_int64_t;
|
||||
|
||||
#elif defined (DJGPP)
|
||||
|
||||
/* DJGPP */
|
||||
typedef short ogg_int16_t;
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long ogg_int64_t;
|
||||
|
||||
#elif defined(R5900)
|
||||
|
||||
/* PS2 EE */
|
||||
typedef long ogg_int64_t;
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned ogg_uint32_t;
|
||||
typedef short ogg_int16_t;
|
||||
|
||||
#elif defined(__SYMBIAN32__)
|
||||
|
||||
/* Symbian GCC */
|
||||
typedef signed short ogg_int16_t;
|
||||
typedef unsigned short ogg_uint16_t;
|
||||
typedef signed int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long int ogg_int64_t;
|
||||
|
||||
#else
|
||||
|
||||
# include <sys/types.h>
|
||||
# include <ogg/config_types.h>
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _OS_TYPES_H */
|
|
@ -1,784 +0,0 @@
|
|||
/********************************************************************
|
||||
* *
|
||||
* THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
|
||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* *
|
||||
********************************************************************
|
||||
|
||||
function:
|
||||
last mod: $Id: theora.h,v 1.17 2003/12/06 18:06:19 arc Exp $
|
||||
|
||||
********************************************************************/
|
||||
|
||||
#ifndef _O_THEORA_H_
|
||||
#define _O_THEORA_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <stddef.h> /* for size_t */
|
||||
|
||||
#include <ogg/ogg.h>
|
||||
|
||||
/** \file
|
||||
* The libtheora pre-1.0 legacy C API.
|
||||
*
|
||||
* \ingroup oldfuncs
|
||||
*
|
||||
* \section intro Introduction
|
||||
*
|
||||
* This is the documentation for the libtheora legacy C API, declared in
|
||||
* the theora.h header, which describes the old interface used before
|
||||
* the 1.0 release. This API was widely deployed for several years and
|
||||
* remains supported, but for new code we recommend the cleaner API
|
||||
* declared in theoradec.h and theoraenc.h.
|
||||
*
|
||||
* libtheora is the reference implementation for
|
||||
* <a href="http://www.theora.org/">Theora</a>, a free video codec.
|
||||
* Theora is derived from On2's VP3 codec with improved integration with
|
||||
* Ogg multimedia formats by <a href="http://www.xiph.org/">Xiph.Org</a>.
|
||||
*
|
||||
* \section overview Overview
|
||||
*
|
||||
* This library will both decode and encode theora packets to/from raw YUV
|
||||
* frames. In either case, the packets will most likely either come from or
|
||||
* need to be embedded in an Ogg stream. Use
|
||||
* <a href="http://xiph.org/ogg/">libogg</a> or
|
||||
* <a href="http://www.annodex.net/software/liboggz/index.html">liboggz</a>
|
||||
* to extract/package these packets.
|
||||
*
|
||||
* \section decoding Decoding Process
|
||||
*
|
||||
* Decoding can be separated into the following steps:
|
||||
* -# initialise theora_info and theora_comment structures using
|
||||
* theora_info_init() and theora_comment_init():
|
||||
\verbatim
|
||||
theora_info info;
|
||||
theora_comment comment;
|
||||
|
||||
theora_info_init(&info);
|
||||
theora_comment_init(&comment);
|
||||
\endverbatim
|
||||
* -# retrieve header packets from Ogg stream (there should be 3) and decode
|
||||
* into theora_info and theora_comment structures using
|
||||
* theora_decode_header(). See \ref identification for more information on
|
||||
* identifying which packets are theora packets.
|
||||
\verbatim
|
||||
int i;
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
(get a theora packet "op" from the Ogg stream)
|
||||
theora_decode_header(&info, &comment, op);
|
||||
}
|
||||
\endverbatim
|
||||
* -# initialise the decoder based on the information retrieved into the
|
||||
* theora_info struct by theora_decode_header(). You will need a
|
||||
* theora_state struct.
|
||||
\verbatim
|
||||
theora_state state;
|
||||
|
||||
theora_decode_init(&state, &info);
|
||||
\endverbatim
|
||||
* -# pass in packets and retrieve decoded frames! See the yuv_buffer
|
||||
* documentation for information on how to retrieve raw YUV data.
|
||||
\verbatim
|
||||
yuf_buffer buffer;
|
||||
while (last packet was not e_o_s) {
|
||||
(get a theora packet "op" from the Ogg stream)
|
||||
theora_decode_packetin(&state, op);
|
||||
theora_decode_YUVout(&state, &buffer);
|
||||
}
|
||||
\endverbatim
|
||||
*
|
||||
*
|
||||
* \subsection identification Identifying Theora Packets
|
||||
*
|
||||
* All streams inside an Ogg file have a unique serial_no attached to the
|
||||
* stream. Typically, you will want to
|
||||
* - retrieve the serial_no for each b_o_s (beginning of stream) page
|
||||
* encountered within the Ogg file;
|
||||
* - test the first (only) packet on that page to determine if it is a theora
|
||||
* packet;
|
||||
* - once you have found a theora b_o_s page then use the retrieved serial_no
|
||||
* to identify future packets belonging to the same theora stream.
|
||||
*
|
||||
* Note that you \e cannot use theora_packet_isheader() to determine if a
|
||||
* packet is a theora packet or not, as this function does not perform any
|
||||
* checking beyond whether a header bit is present. Instead, use the
|
||||
* theora_decode_header() function and check the return value; or examine the
|
||||
* header bytes at the beginning of the Ogg page.
|
||||
*/
|
||||
|
||||
|
||||
/** \defgroup oldfuncs Legacy pre-1.0 C API */
|
||||
/* @{ */
|
||||
|
||||
/**
|
||||
* A YUV buffer for passing uncompressed frames to and from the codec.
|
||||
* This holds a Y'CbCr frame in planar format. The CbCr planes can be
|
||||
* subsampled and have their own separate dimensions and row stride
|
||||
* offsets. Note that the strides may be negative in some
|
||||
* configurations. For theora the width and height of the largest plane
|
||||
* must be a multiple of 16. The actual meaningful picture size and
|
||||
* offset are stored in the theora_info structure; frames returned by
|
||||
* the decoder may need to be cropped for display.
|
||||
*
|
||||
* All samples are 8 bits. Within each plane samples are ordered by
|
||||
* row from the top of the frame to the bottom. Within each row samples
|
||||
* are ordered from left to right.
|
||||
*
|
||||
* During decode, the yuv_buffer struct is allocated by the user, but all
|
||||
* fields (including luma and chroma pointers) are filled by the library.
|
||||
* These pointers address library-internal memory and their contents should
|
||||
* not be modified.
|
||||
*
|
||||
* Conversely, during encode the user allocates the struct and fills out all
|
||||
* fields. The user also manages the data addressed by the luma and chroma
|
||||
* pointers. See the encoder_example.c and dump_video.c example files in
|
||||
* theora/examples/ for more information.
|
||||
*/
|
||||
typedef struct {
|
||||
int y_width; /**< Width of the Y' luminance plane */
|
||||
int y_height; /**< Height of the luminance plane */
|
||||
int y_stride; /**< Offset in bytes between successive rows */
|
||||
|
||||
int uv_width; /**< Width of the Cb and Cr chroma planes */
|
||||
int uv_height; /**< Height of the chroma planes */
|
||||
int uv_stride; /**< Offset between successive chroma rows */
|
||||
unsigned char *y; /**< Pointer to start of luminance data */
|
||||
unsigned char *u; /**< Pointer to start of Cb data */
|
||||
unsigned char *v; /**< Pointer to start of Cr data */
|
||||
|
||||
} yuv_buffer;
|
||||
|
||||
/**
|
||||
* A Colorspace.
|
||||
*/
|
||||
typedef enum {
|
||||
OC_CS_UNSPECIFIED, /**< The colorspace is unknown or unspecified */
|
||||
OC_CS_ITU_REC_470M, /**< This is the best option for 'NTSC' content */
|
||||
OC_CS_ITU_REC_470BG, /**< This is the best option for 'PAL' content */
|
||||
OC_CS_NSPACES /**< This marks the end of the defined colorspaces */
|
||||
} theora_colorspace;
|
||||
|
||||
/**
|
||||
* A Chroma subsampling
|
||||
*
|
||||
* These enumerate the available chroma subsampling options supported
|
||||
* by the theora format. See Section 4.4 of the specification for
|
||||
* exact definitions.
|
||||
*/
|
||||
typedef enum {
|
||||
OC_PF_420, /**< Chroma subsampling by 2 in each direction (4:2:0) */
|
||||
OC_PF_RSVD, /**< Reserved value */
|
||||
OC_PF_422, /**< Horizonatal chroma subsampling by 2 (4:2:2) */
|
||||
OC_PF_444 /**< No chroma subsampling at all (4:4:4) */
|
||||
} theora_pixelformat;
|
||||
|
||||
/**
|
||||
* Theora bitstream info.
|
||||
* Contains the basic playback parameters for a stream,
|
||||
* corresponding to the initial 'info' header packet.
|
||||
*
|
||||
* Encoded theora frames must be a multiple of 16 in width and height.
|
||||
* To handle other frame sizes, a crop rectangle is specified in
|
||||
* frame_height and frame_width, offset_x and * offset_y. The offset
|
||||
* and size should still be a multiple of 2 to avoid chroma sampling
|
||||
* shifts. Offset values in this structure are measured from the
|
||||
* upper left of the image.
|
||||
*
|
||||
* Frame rate, in frames per second, is stored as a rational
|
||||
* fraction. Aspect ratio is also stored as a rational fraction, and
|
||||
* refers to the aspect ratio of the frame pixels, not of the
|
||||
* overall frame itself.
|
||||
*
|
||||
* See <a href="http://svn.xiph.org/trunk/theora/examples/encoder_example.c">
|
||||
* examples/encoder_example.c</a> for usage examples of the
|
||||
* other paramters and good default settings for the encoder parameters.
|
||||
*/
|
||||
typedef struct {
|
||||
ogg_uint32_t width; /**< encoded frame width */
|
||||
ogg_uint32_t height; /**< encoded frame height */
|
||||
ogg_uint32_t frame_width; /**< display frame width */
|
||||
ogg_uint32_t frame_height; /**< display frame height */
|
||||
ogg_uint32_t offset_x; /**< horizontal offset of the displayed frame */
|
||||
ogg_uint32_t offset_y; /**< vertical offset of the displayed frame */
|
||||
ogg_uint32_t fps_numerator; /**< frame rate numerator **/
|
||||
ogg_uint32_t fps_denominator; /**< frame rate denominator **/
|
||||
ogg_uint32_t aspect_numerator; /**< pixel aspect ratio numerator */
|
||||
ogg_uint32_t aspect_denominator; /**< pixel aspect ratio denominator */
|
||||
theora_colorspace colorspace; /**< colorspace */
|
||||
int target_bitrate; /**< nominal bitrate in bits per second */
|
||||
int quality; /**< Nominal quality setting, 0-63 */
|
||||
int quick_p; /**< Quick encode/decode */
|
||||
|
||||
/* decode only */
|
||||
unsigned char version_major;
|
||||
unsigned char version_minor;
|
||||
unsigned char version_subminor;
|
||||
|
||||
void *codec_setup;
|
||||
|
||||
/* encode only */
|
||||
int dropframes_p;
|
||||
int keyframe_auto_p;
|
||||
ogg_uint32_t keyframe_frequency;
|
||||
ogg_uint32_t keyframe_frequency_force; /* also used for decode init to
|
||||
get granpos shift correct */
|
||||
ogg_uint32_t keyframe_data_target_bitrate;
|
||||
ogg_int32_t keyframe_auto_threshold;
|
||||
ogg_uint32_t keyframe_mindistance;
|
||||
ogg_int32_t noise_sensitivity;
|
||||
ogg_int32_t sharpness;
|
||||
|
||||
theora_pixelformat pixelformat; /**< chroma subsampling mode to expect */
|
||||
|
||||
} theora_info;
|
||||
|
||||
/** Codec internal state and context.
|
||||
*/
|
||||
typedef struct{
|
||||
theora_info *i;
|
||||
ogg_int64_t granulepos;
|
||||
|
||||
void *internal_encode;
|
||||
void *internal_decode;
|
||||
|
||||
} theora_state;
|
||||
|
||||
/**
|
||||
* Comment header metadata.
|
||||
*
|
||||
* This structure holds the in-stream metadata corresponding to
|
||||
* the 'comment' header packet.
|
||||
*
|
||||
* Meta data is stored as a series of (tag, value) pairs, in
|
||||
* length-encoded string vectors. The first occurence of the
|
||||
* '=' character delimits the tag and value. A particular tag
|
||||
* may occur more than once. The character set encoding for
|
||||
* the strings is always UTF-8, but the tag names are limited
|
||||
* to case-insensitive ASCII. See the spec for details.
|
||||
*
|
||||
* In filling in this structure, theora_decode_header() will
|
||||
* null-terminate the user_comment strings for safety. However,
|
||||
* the bitstream format itself treats them as 8-bit clean,
|
||||
* and so the length array should be treated as authoritative
|
||||
* for their length.
|
||||
*/
|
||||
typedef struct theora_comment{
|
||||
char **user_comments; /**< An array of comment string vectors */
|
||||
int *comment_lengths; /**< An array of corresponding string vector lengths in bytes */
|
||||
int comments; /**< The total number of comment string vectors */
|
||||
char *vendor; /**< The vendor string identifying the encoder, null terminated */
|
||||
|
||||
} theora_comment;
|
||||
|
||||
|
||||
/**\name theora_control() codes */
|
||||
/* \anchor decctlcodes_old
|
||||
* These are the available request codes for theora_control()
|
||||
* when called with a decoder instance.
|
||||
* By convention decoder control codes are odd, to distinguish
|
||||
* them from \ref encctlcodes_old "encoder control codes" which
|
||||
* are even.
|
||||
*
|
||||
* Note that since the 1.0 release, both the legacy and the final
|
||||
* implementation accept all the same control codes, but only the
|
||||
* final API declares the newer codes.
|
||||
*
|
||||
* Keep any experimental or vendor-specific values above \c 0x8000.*/
|
||||
|
||||
/*@{*/
|
||||
|
||||
/**Get the maximum post-processing level.
|
||||
* The decoder supports a post-processing filter that can improve
|
||||
* the appearance of the decoded images. This returns the highest
|
||||
* level setting for this post-processor, corresponding to maximum
|
||||
* improvement and computational expense.
|
||||
*/
|
||||
#define TH_DECCTL_GET_PPLEVEL_MAX (1)
|
||||
|
||||
/**Set the post-processing level.
|
||||
* Sets the level of post-processing to use when decoding the
|
||||
* compressed stream. This must be a value between zero (off)
|
||||
* and the maximum returned by TH_DECCTL_GET_PPLEVEL_MAX.
|
||||
*/
|
||||
#define TH_DECCTL_SET_PPLEVEL (3)
|
||||
|
||||
/**Sets the maximum distance between key frames.
|
||||
* This can be changed during an encode, but will be bounded by
|
||||
* <tt>1<<th_info#keyframe_granule_shift</tt>.
|
||||
* If it is set before encoding begins, th_info#keyframe_granule_shift will
|
||||
* be enlarged appropriately.
|
||||
*
|
||||
* \param[in] buf <tt>ogg_uint32_t</tt>: The maximum distance between key
|
||||
* frames.
|
||||
* \param[out] buf <tt>ogg_uint32_t</tt>: The actual maximum distance set.
|
||||
* \retval OC_FAULT \a theora_state or \a buf is <tt>NULL</tt>.
|
||||
* \retval OC_EINVAL \a buf_sz is not <tt>sizeof(ogg_uint32_t)</tt>.
|
||||
* \retval OC_IMPL Not supported by this implementation.*/
|
||||
#define TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE (4)
|
||||
|
||||
/**Set the granule position.
|
||||
* Call this after a seek, to update the internal granulepos
|
||||
* in the decoder, to insure that subsequent frames are marked
|
||||
* properly. If you track timestamps yourself and do not use
|
||||
* the granule postion returned by the decoder, then you do
|
||||
* not need to use this control.
|
||||
*/
|
||||
#define TH_DECCTL_SET_GRANPOS (5)
|
||||
|
||||
/**\anchor encctlcodes_old */
|
||||
|
||||
/**Sets the quantization parameters to use.
|
||||
* The parameters are copied, not stored by reference, so they can be freed
|
||||
* after this call.
|
||||
* <tt>NULL</tt> may be specified to revert to the default parameters.
|
||||
*
|
||||
* \param[in] buf #th_quant_info
|
||||
* \retval OC_FAULT \a theora_state is <tt>NULL</tt>.
|
||||
* \retval OC_EINVAL Encoding has already begun, the quantization parameters
|
||||
* are not acceptable to this version of the encoder,
|
||||
* \a buf is <tt>NULL</tt> and \a buf_sz is not zero,
|
||||
* or \a buf is non-<tt>NULL</tt> and \a buf_sz is
|
||||
* not <tt>sizeof(#th_quant_info)</tt>.
|
||||
* \retval OC_IMPL Not supported by this implementation.*/
|
||||
#define TH_ENCCTL_SET_QUANT_PARAMS (2)
|
||||
|
||||
/**Disables any encoder features that would prevent lossless transcoding back
|
||||
* to VP3.
|
||||
* This primarily means disabling block-level QI values and not using 4MV mode
|
||||
* when any of the luma blocks in a macro block are not coded.
|
||||
* It also includes using the VP3 quantization tables and Huffman codes; if you
|
||||
* set them explicitly after calling this function, the resulting stream will
|
||||
* not be VP3-compatible.
|
||||
* If you enable VP3-compatibility when encoding 4:2:2 or 4:4:4 source
|
||||
* material, or when using a picture region smaller than the full frame (e.g.
|
||||
* a non-multiple-of-16 width or height), then non-VP3 bitstream features will
|
||||
* still be disabled, but the stream will still not be VP3-compatible, as VP3
|
||||
* was not capable of encoding such formats.
|
||||
* If you call this after encoding has already begun, then the quantization
|
||||
* tables and codebooks cannot be changed, but the frame-level features will
|
||||
* be enabled or disabled as requested.
|
||||
*
|
||||
* \param[in] buf <tt>int</tt>: a non-zero value to enable VP3 compatibility,
|
||||
* or 0 to disable it (the default).
|
||||
* \param[out] buf <tt>int</tt>: 1 if all bitstream features required for
|
||||
* VP3-compatibility could be set, and 0 otherwise.
|
||||
* The latter will be returned if the pixel format is not
|
||||
* 4:2:0, the picture region is smaller than the full frame,
|
||||
* or if encoding has begun, preventing the quantization
|
||||
* tables and codebooks from being set.
|
||||
* \retval OC_FAULT \a theora_state or \a buf is <tt>NULL</tt>.
|
||||
* \retval OC_EINVAL \a buf_sz is not <tt>sizeof(int)</tt>.
|
||||
* \retval OC_IMPL Not supported by this implementation.*/
|
||||
#define TH_ENCCTL_SET_VP3_COMPATIBLE (10)
|
||||
|
||||
/**Gets the maximum speed level.
|
||||
* Higher speed levels favor quicker encoding over better quality per bit.
|
||||
* Depending on the encoding mode, and the internal algorithms used, quality
|
||||
* may actually improve, but in this case bitrate will also likely increase.
|
||||
* In any case, overall rate/distortion performance will probably decrease.
|
||||
* The maximum value, and the meaning of each value, may change depending on
|
||||
* the current encoding mode (VBR vs. CQI, etc.).
|
||||
*
|
||||
* \param[out] buf int: The maximum encoding speed level.
|
||||
* \retval OC_FAULT \a theora_state or \a buf is <tt>NULL</tt>.
|
||||
* \retval OC_EINVAL \a buf_sz is not <tt>sizeof(int)</tt>.
|
||||
* \retval OC_IMPL Not supported by this implementation in the current
|
||||
* encoding mode.*/
|
||||
#define TH_ENCCTL_GET_SPLEVEL_MAX (12)
|
||||
|
||||
/**Sets the speed level.
|
||||
* By default a speed value of 1 is used.
|
||||
*
|
||||
* \param[in] buf int: The new encoding speed level.
|
||||
* 0 is slowest, larger values use less CPU.
|
||||
* \retval OC_FAULT \a theora_state or \a buf is <tt>NULL</tt>.
|
||||
* \retval OC_EINVAL \a buf_sz is not <tt>sizeof(int)</tt>, or the
|
||||
* encoding speed level is out of bounds.
|
||||
* The maximum encoding speed level may be
|
||||
* implementation- and encoding mode-specific, and can be
|
||||
* obtained via #TH_ENCCTL_GET_SPLEVEL_MAX.
|
||||
* \retval OC_IMPL Not supported by this implementation in the current
|
||||
* encoding mode.*/
|
||||
#define TH_ENCCTL_SET_SPLEVEL (14)
|
||||
|
||||
/*@}*/
|
||||
|
||||
#define OC_FAULT -1 /**< General failure */
|
||||
#define OC_EINVAL -10 /**< Library encountered invalid internal data */
|
||||
#define OC_DISABLED -11 /**< Requested action is disabled */
|
||||
#define OC_BADHEADER -20 /**< Header packet was corrupt/invalid */
|
||||
#define OC_NOTFORMAT -21 /**< Packet is not a theora packet */
|
||||
#define OC_VERSION -22 /**< Bitstream version is not handled */
|
||||
#define OC_IMPL -23 /**< Feature or action not implemented */
|
||||
#define OC_BADPACKET -24 /**< Packet is corrupt */
|
||||
#define OC_NEWPACKET -25 /**< Packet is an (ignorable) unhandled extension */
|
||||
#define OC_DUPFRAME 1 /**< Packet is a dropped frame */
|
||||
|
||||
/**
|
||||
* Retrieve a human-readable string to identify the encoder vendor and version.
|
||||
* \returns A version string.
|
||||
*/
|
||||
extern const char *theora_version_string(void);
|
||||
|
||||
/**
|
||||
* Retrieve a 32-bit version number.
|
||||
* This number is composed of a 16-bit major version, 8-bit minor version
|
||||
* and 8 bit sub-version, composed as follows:
|
||||
<pre>
|
||||
(VERSION_MAJOR<<16) + (VERSION_MINOR<<8) + (VERSION_SUB)
|
||||
</pre>
|
||||
* \returns The version number.
|
||||
*/
|
||||
extern ogg_uint32_t theora_version_number(void);
|
||||
|
||||
/**
|
||||
* Initialize the theora encoder.
|
||||
* \param th The theora_state handle to initialize for encoding.
|
||||
* \param ti A theora_info struct filled with the desired encoding parameters.
|
||||
* \retval 0 Success
|
||||
*/
|
||||
extern int theora_encode_init(theora_state *th, theora_info *ti);
|
||||
|
||||
/**
|
||||
* Submit a YUV buffer to the theora encoder.
|
||||
* \param t A theora_state handle previously initialized for encoding.
|
||||
* \param yuv A buffer of YUV data to encode. Note that both the yuv_buffer
|
||||
* struct and the luma/chroma buffers within should be allocated by
|
||||
* the user.
|
||||
* \retval OC_EINVAL Encoder is not ready, or is finished.
|
||||
* \retval -1 The size of the given frame differs from those previously input
|
||||
* \retval 0 Success
|
||||
*/
|
||||
extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv);
|
||||
|
||||
/**
|
||||
* Request the next packet of encoded video.
|
||||
* The encoded data is placed in a user-provided ogg_packet structure.
|
||||
* \param t A theora_state handle previously initialized for encoding.
|
||||
* \param last_p whether this is the last packet the encoder should produce.
|
||||
* \param op An ogg_packet structure to fill. libtheora will set all
|
||||
* elements of this structure, including a pointer to encoded
|
||||
* data. The memory for the encoded data is owned by libtheora.
|
||||
* \retval 0 No internal storage exists OR no packet is ready
|
||||
* \retval -1 The encoding process has completed
|
||||
* \retval 1 Success
|
||||
*/
|
||||
extern int theora_encode_packetout( theora_state *t, int last_p,
|
||||
ogg_packet *op);
|
||||
|
||||
/**
|
||||
* Request a packet containing the initial header.
|
||||
* A pointer to the header data is placed in a user-provided ogg_packet
|
||||
* structure.
|
||||
* \param t A theora_state handle previously initialized for encoding.
|
||||
* \param op An ogg_packet structure to fill. libtheora will set all
|
||||
* elements of this structure, including a pointer to the header
|
||||
* data. The memory for the header data is owned by libtheora.
|
||||
* \retval 0 Success
|
||||
*/
|
||||
extern int theora_encode_header(theora_state *t, ogg_packet *op);
|
||||
|
||||
/**
|
||||
* Request a comment header packet from provided metadata.
|
||||
* A pointer to the comment data is placed in a user-provided ogg_packet
|
||||
* structure.
|
||||
* \param tc A theora_comment structure filled with the desired metadata
|
||||
* \param op An ogg_packet structure to fill. libtheora will set all
|
||||
* elements of this structure, including a pointer to the encoded
|
||||
* comment data. The memory for the comment data is owned by
|
||||
* libtheora.
|
||||
* \retval 0 Success
|
||||
*/
|
||||
extern int theora_encode_comment(theora_comment *tc, ogg_packet *op);
|
||||
|
||||
/**
|
||||
* Request a packet containing the codebook tables for the stream.
|
||||
* A pointer to the codebook data is placed in a user-provided ogg_packet
|
||||
* structure.
|
||||
* \param t A theora_state handle previously initialized for encoding.
|
||||
* \param op An ogg_packet structure to fill. libtheora will set all
|
||||
* elements of this structure, including a pointer to the codebook
|
||||
* data. The memory for the header data is owned by libtheora.
|
||||
* \retval 0 Success
|
||||
*/
|
||||
extern int theora_encode_tables(theora_state *t, ogg_packet *op);
|
||||
|
||||
/**
|
||||
* Decode an Ogg packet, with the expectation that the packet contains
|
||||
* an initial header, comment data or codebook tables.
|
||||
*
|
||||
* \param ci A theora_info structure to fill. This must have been previously
|
||||
* initialized with theora_info_init(). If \a op contains an initial
|
||||
* header, theora_decode_header() will fill \a ci with the
|
||||
* parsed header values. If \a op contains codebook tables,
|
||||
* theora_decode_header() will parse these and attach an internal
|
||||
* representation to \a ci->codec_setup.
|
||||
* \param cc A theora_comment structure to fill. If \a op contains comment
|
||||
* data, theora_decode_header() will fill \a cc with the parsed
|
||||
* comments.
|
||||
* \param op An ogg_packet structure which you expect contains an initial
|
||||
* header, comment data or codebook tables.
|
||||
*
|
||||
* \retval OC_BADHEADER \a op is NULL; OR the first byte of \a op->packet
|
||||
* has the signature of an initial packet, but op is
|
||||
* not a b_o_s packet; OR this packet has the signature
|
||||
* of an initial header packet, but an initial header
|
||||
* packet has already been seen; OR this packet has the
|
||||
* signature of a comment packet, but the initial header
|
||||
* has not yet been seen; OR this packet has the signature
|
||||
* of a comment packet, but contains invalid data; OR
|
||||
* this packet has the signature of codebook tables,
|
||||
* but the initial header or comments have not yet
|
||||
* been seen; OR this packet has the signature of codebook
|
||||
* tables, but contains invalid data;
|
||||
* OR the stream being decoded has a compatible version
|
||||
* but this packet does not have the signature of a
|
||||
* theora initial header, comments, or codebook packet
|
||||
* \retval OC_VERSION The packet data of \a op is an initial header with
|
||||
* a version which is incompatible with this version of
|
||||
* libtheora.
|
||||
* \retval OC_NEWPACKET the stream being decoded has an incompatible (future)
|
||||
* version and contains an unknown signature.
|
||||
* \retval 0 Success
|
||||
*
|
||||
* \note The normal usage is that theora_decode_header() be called on the
|
||||
* first three packets of a theora logical bitstream in succession.
|
||||
*/
|
||||
extern int theora_decode_header(theora_info *ci, theora_comment *cc,
|
||||
ogg_packet *op);
|
||||
|
||||
/**
|
||||
* Initialize a theora_state handle for decoding.
|
||||
* \param th The theora_state handle to initialize.
|
||||
* \param c A theora_info struct filled with the desired decoding parameters.
|
||||
* This is of course usually obtained from a previous call to
|
||||
* theora_decode_header().
|
||||
* \retval 0 Success
|
||||
*/
|
||||
extern int theora_decode_init(theora_state *th, theora_info *c);
|
||||
|
||||
/**
|
||||
* Input a packet containing encoded data into the theora decoder.
|
||||
* \param th A theora_state handle previously initialized for decoding.
|
||||
* \param op An ogg_packet containing encoded theora data.
|
||||
* \retval 0 Success
|
||||
* \retval OC_BADPACKET \a op does not contain encoded video data
|
||||
*/
|
||||
extern int theora_decode_packetin(theora_state *th,ogg_packet *op);
|
||||
|
||||
/**
|
||||
* Output the next available frame of decoded YUV data.
|
||||
* \param th A theora_state handle previously initialized for decoding.
|
||||
* \param yuv A yuv_buffer in which libtheora should place the decoded data.
|
||||
* Note that the buffer struct itself is allocated by the user, but
|
||||
* that the luma and chroma pointers will be filled in by the
|
||||
* library. Also note that these luma and chroma regions should be
|
||||
* considered read-only by the user.
|
||||
* \retval 0 Success
|
||||
*/
|
||||
extern int theora_decode_YUVout(theora_state *th,yuv_buffer *yuv);
|
||||
|
||||
/**
|
||||
* Report whether a theora packet is a header or not
|
||||
* This function does no verification beyond checking the header
|
||||
* flag bit so it should not be used for bitstream identification;
|
||||
* use theora_decode_header() for that.
|
||||
*
|
||||
* \param op An ogg_packet containing encoded theora data.
|
||||
* \retval 1 The packet is a header packet
|
||||
* \retval 0 The packet is not a header packet (and so contains frame data)
|
||||
*
|
||||
* Thus function was added in the 1.0alpha4 release.
|
||||
*/
|
||||
extern int theora_packet_isheader(ogg_packet *op);
|
||||
|
||||
/**
|
||||
* Report whether a theora packet is a keyframe or not
|
||||
*
|
||||
* \param op An ogg_packet containing encoded theora data.
|
||||
* \retval 1 The packet contains a keyframe image
|
||||
* \retval 0 The packet is contains an interframe delta
|
||||
* \retval -1 The packet is not an image data packet at all
|
||||
*
|
||||
* Thus function was added in the 1.0alpha4 release.
|
||||
*/
|
||||
extern int theora_packet_iskeyframe(ogg_packet *op);
|
||||
|
||||
/**
|
||||
* Report the granulepos shift radix
|
||||
*
|
||||
* When embedded in Ogg, Theora uses a two-part granulepos,
|
||||
* splitting the 64-bit field into two pieces. The more-significant
|
||||
* section represents the frame count at the last keyframe,
|
||||
* and the less-significant section represents the count of
|
||||
* frames since the last keyframe. In this way the overall
|
||||
* field is still non-decreasing with time, but usefully encodes
|
||||
* a pointer to the last keyframe, which is necessary for
|
||||
* correctly restarting decode after a seek.
|
||||
*
|
||||
* This function reports the number of bits used to represent
|
||||
* the distance to the last keyframe, and thus how the granulepos
|
||||
* field must be shifted or masked to obtain the two parts.
|
||||
*
|
||||
* Since libtheora returns compressed data in an ogg_packet
|
||||
* structure, this may be generally useful even if the Theora
|
||||
* packets are not being used in an Ogg container.
|
||||
*
|
||||
* \param ti A previously initialized theora_info struct
|
||||
* \returns The bit shift dividing the two granulepos fields
|
||||
*
|
||||
* This function was added in the 1.0alpha5 release.
|
||||
*/
|
||||
int theora_granule_shift(theora_info *ti);
|
||||
|
||||
/**
|
||||
* Convert a granulepos to an absolute frame index, starting at 0.
|
||||
* The granulepos is interpreted in the context of a given theora_state handle.
|
||||
*
|
||||
* Note that while the granulepos encodes the frame count (i.e. starting
|
||||
* from 1) this call returns the frame index, starting from zero. Thus
|
||||
* One can calculate the presentation time by multiplying the index by
|
||||
* the rate.
|
||||
*
|
||||
* \param th A previously initialized theora_state handle (encode or decode)
|
||||
* \param granulepos The granulepos to convert.
|
||||
* \returns The frame index corresponding to \a granulepos.
|
||||
* \retval -1 The given granulepos is undefined (i.e. negative)
|
||||
*
|
||||
* Thus function was added in the 1.0alpha4 release.
|
||||
*/
|
||||
extern ogg_int64_t theora_granule_frame(theora_state *th,ogg_int64_t granulepos);
|
||||
|
||||
/**
|
||||
* Convert a granulepos to absolute time in seconds. The granulepos is
|
||||
* interpreted in the context of a given theora_state handle, and gives
|
||||
* the end time of a frame's presentation as used in Ogg mux ordering.
|
||||
*
|
||||
* \param th A previously initialized theora_state handle (encode or decode)
|
||||
* \param granulepos The granulepos to convert.
|
||||
* \returns The absolute time in seconds corresponding to \a granulepos.
|
||||
* This is the "end time" for the frame, or the latest time it should
|
||||
* be displayed.
|
||||
* It is not the presentation time.
|
||||
* \retval -1. The given granulepos is undefined (i.e. negative), or
|
||||
* \retval -1. The function has been disabled because floating
|
||||
* point support is not available.
|
||||
*/
|
||||
extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos);
|
||||
|
||||
/**
|
||||
* Initialize a theora_info structure. All values within the given theora_info
|
||||
* structure are initialized, and space is allocated within libtheora for
|
||||
* internal codec setup data.
|
||||
* \param c A theora_info struct to initialize.
|
||||
*/
|
||||
extern void theora_info_init(theora_info *c);
|
||||
|
||||
/**
|
||||
* Clear a theora_info structure. All values within the given theora_info
|
||||
* structure are cleared, and associated internal codec setup data is freed.
|
||||
* \param c A theora_info struct to initialize.
|
||||
*/
|
||||
extern void theora_info_clear(theora_info *c);
|
||||
|
||||
/**
|
||||
* Free all internal data associated with a theora_state handle.
|
||||
* \param t A theora_state handle.
|
||||
*/
|
||||
extern void theora_clear(theora_state *t);
|
||||
|
||||
/**
|
||||
* Initialize an allocated theora_comment structure
|
||||
* \param tc An allocated theora_comment structure
|
||||
**/
|
||||
extern void theora_comment_init(theora_comment *tc);
|
||||
|
||||
/**
|
||||
* Add a comment to an initialized theora_comment structure
|
||||
* \param tc A previously initialized theora comment structure
|
||||
* \param comment A null-terminated string encoding the comment in the form
|
||||
* "TAG=the value"
|
||||
*
|
||||
* Neither theora_comment_add() nor theora_comment_add_tag() support
|
||||
* comments containing null values, although the bitstream format
|
||||
* supports this. To add such comments you will need to manipulate
|
||||
* the theora_comment structure directly.
|
||||
**/
|
||||
|
||||
extern void theora_comment_add(theora_comment *tc, char *comment);
|
||||
|
||||
/**
|
||||
* Add a comment to an initialized theora_comment structure.
|
||||
* \param tc A previously initialized theora comment structure
|
||||
* \param tag A null-terminated string containing the tag
|
||||
* associated with the comment.
|
||||
* \param value The corresponding value as a null-terminated string
|
||||
*
|
||||
* Neither theora_comment_add() nor theora_comment_add_tag() support
|
||||
* comments containing null values, although the bitstream format
|
||||
* supports this. To add such comments you will need to manipulate
|
||||
* the theora_comment structure directly.
|
||||
**/
|
||||
extern void theora_comment_add_tag(theora_comment *tc,
|
||||
char *tag, char *value);
|
||||
|
||||
/**
|
||||
* Look up a comment value by tag.
|
||||
* \param tc Tn initialized theora_comment structure
|
||||
* \param tag The tag to look up
|
||||
* \param count The instance of the tag. The same tag can appear multiple
|
||||
* times, each with a distinct and ordered value, so an index
|
||||
* is required to retrieve them all.
|
||||
* \returns A pointer to the queried tag's value
|
||||
* \retval NULL No matching tag is found
|
||||
*
|
||||
* \note Use theora_comment_query_count() to get the legal range for the
|
||||
* count parameter.
|
||||
**/
|
||||
|
||||
extern char *theora_comment_query(theora_comment *tc, char *tag, int count);
|
||||
|
||||
/** Look up the number of instances of a tag.
|
||||
* \param tc An initialized theora_comment structure
|
||||
* \param tag The tag to look up
|
||||
* \returns The number on instances of a particular tag.
|
||||
*
|
||||
* Call this first when querying for a specific tag and then interate
|
||||
* over the number of instances with separate calls to
|
||||
* theora_comment_query() to retrieve all instances in order.
|
||||
**/
|
||||
extern int theora_comment_query_count(theora_comment *tc, char *tag);
|
||||
|
||||
/**
|
||||
* Clear an allocated theora_comment struct so that it can be freed.
|
||||
* \param tc An allocated theora_comment structure.
|
||||
**/
|
||||
extern void theora_comment_clear(theora_comment *tc);
|
||||
|
||||
/**Encoder control function.
|
||||
* This is used to provide advanced control the encoding process.
|
||||
* \param th A #theora_state handle.
|
||||
* \param req The control code to process.
|
||||
* See \ref encctlcodes_old "the list of available
|
||||
* control codes" for details.
|
||||
* \param buf The parameters for this control code.
|
||||
* \param buf_sz The size of the parameter buffer.*/
|
||||
extern int theora_control(theora_state *th,int req,void *buf,size_t buf_sz);
|
||||
|
||||
/* @} */ /* end oldfuncs doxygen group */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _O_THEORA_H_ */
|
|
@ -1,500 +0,0 @@
|
|||
/********************************************************************
|
||||
* *
|
||||
* THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
|
||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* *
|
||||
********************************************************************
|
||||
|
||||
function:
|
||||
last mod: $Id: theora.h,v 1.8 2004/03/15 22:17:32 derf Exp $
|
||||
|
||||
********************************************************************/
|
||||
|
||||
/**\file
|
||||
* The <tt>libtheoraenc</tt> C encoding API.*/
|
||||
|
||||
#if !defined(_O_THEORA_THEORAENC_H_)
|
||||
# define _O_THEORA_THEORAENC_H_ (1)
|
||||
# include <stddef.h>
|
||||
# include <ogg/ogg.h>
|
||||
# include "codec.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**\name th_encode_ctl() codes
|
||||
* \anchor encctlcodes
|
||||
* These are the available request codes for th_encode_ctl().
|
||||
* By convention, these are even, to distinguish them from the
|
||||
* \ref decctlcodes "decoder control codes".
|
||||
* Keep any experimental or vendor-specific values above \c 0x8000.*/
|
||||
/*@{*/
|
||||
/**Sets the Huffman tables to use.
|
||||
* The tables are copied, not stored by reference, so they can be freed after
|
||||
* this call.
|
||||
* <tt>NULL</tt> may be specified to revert to the default tables.
|
||||
*
|
||||
* \param[in] _buf <tt>#th_huff_code[#TH_NHUFFMAN_TABLES][#TH_NDCT_TOKENS]</tt>
|
||||
* \retval TH_EFAULT \a _enc_ctx is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL Encoding has already begun or one or more of the given
|
||||
* tables is not full or prefix-free, \a _buf is
|
||||
* <tt>NULL</tt> and \a _buf_sz is not zero, or \a _buf is
|
||||
* non-<tt>NULL</tt> and \a _buf_sz is not
|
||||
* <tt>sizeof(#th_huff_code)*#TH_NHUFFMAN_TABLES*#TH_NDCT_TOKENS</tt>.
|
||||
* \retval TH_EIMPL Not supported by this implementation.*/
|
||||
#define TH_ENCCTL_SET_HUFFMAN_CODES (0)
|
||||
/**Sets the quantization parameters to use.
|
||||
* The parameters are copied, not stored by reference, so they can be freed
|
||||
* after this call.
|
||||
* <tt>NULL</tt> may be specified to revert to the default parameters.
|
||||
*
|
||||
* \param[in] _buf #th_quant_info
|
||||
* \retval TH_EFAULT \a _enc_ctx is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL Encoding has already begun, \a _buf is
|
||||
* <tt>NULL</tt> and \a _buf_sz is not zero,
|
||||
* or \a _buf is non-<tt>NULL</tt> and
|
||||
* \a _buf_sz is not <tt>sizeof(#th_quant_info)</tt>.
|
||||
* \retval TH_EIMPL Not supported by this implementation.*/
|
||||
#define TH_ENCCTL_SET_QUANT_PARAMS (2)
|
||||
/**Sets the maximum distance between key frames.
|
||||
* This can be changed during an encode, but will be bounded by
|
||||
* <tt>1<<th_info#keyframe_granule_shift</tt>.
|
||||
* If it is set before encoding begins, th_info#keyframe_granule_shift will
|
||||
* be enlarged appropriately.
|
||||
*
|
||||
* \param[in] _buf <tt>ogg_uint32_t</tt>: The maximum distance between key
|
||||
* frames.
|
||||
* \param[out] _buf <tt>ogg_uint32_t</tt>: The actual maximum distance set.
|
||||
* \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(ogg_uint32_t)</tt>.
|
||||
* \retval TH_EIMPL Not supported by this implementation.*/
|
||||
#define TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE (4)
|
||||
/**Disables any encoder features that would prevent lossless transcoding back
|
||||
* to VP3.
|
||||
* This primarily means disabling block-adaptive quantization and always coding
|
||||
* all four luma blocks in a macro block when 4MV is used.
|
||||
* It also includes using the VP3 quantization tables and Huffman codes; if you
|
||||
* set them explicitly after calling this function, the resulting stream will
|
||||
* not be VP3-compatible.
|
||||
* If you enable VP3-compatibility when encoding 4:2:2 or 4:4:4 source
|
||||
* material, or when using a picture region smaller than the full frame (e.g.
|
||||
* a non-multiple-of-16 width or height), then non-VP3 bitstream features will
|
||||
* still be disabled, but the stream will still not be VP3-compatible, as VP3
|
||||
* was not capable of encoding such formats.
|
||||
* If you call this after encoding has already begun, then the quantization
|
||||
* tables and codebooks cannot be changed, but the frame-level features will
|
||||
* be enabled or disabled as requested.
|
||||
*
|
||||
* \param[in] _buf <tt>int</tt>: a non-zero value to enable VP3 compatibility,
|
||||
* or 0 to disable it (the default).
|
||||
* \param[out] _buf <tt>int</tt>: 1 if all bitstream features required for
|
||||
* VP3-compatibility could be set, and 0 otherwise.
|
||||
* The latter will be returned if the pixel format is not
|
||||
* 4:2:0, the picture region is smaller than the full frame,
|
||||
* or if encoding has begun, preventing the quantization
|
||||
* tables and codebooks from being set.
|
||||
* \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>.
|
||||
* \retval TH_EIMPL Not supported by this implementation.*/
|
||||
#define TH_ENCCTL_SET_VP3_COMPATIBLE (10)
|
||||
/**Gets the maximum speed level.
|
||||
* Higher speed levels favor quicker encoding over better quality per bit.
|
||||
* Depending on the encoding mode, and the internal algorithms used, quality
|
||||
* may actually improve, but in this case bitrate will also likely increase.
|
||||
* In any case, overall rate/distortion performance will probably decrease.
|
||||
* The maximum value, and the meaning of each value, may change depending on
|
||||
* the current encoding mode (VBR vs. constant quality, etc.).
|
||||
*
|
||||
* \param[out] _buf <tt>int</tt>: The maximum encoding speed level.
|
||||
* \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>.
|
||||
* \retval TH_EIMPL Not supported by this implementation in the current
|
||||
* encoding mode.*/
|
||||
#define TH_ENCCTL_GET_SPLEVEL_MAX (12)
|
||||
/**Sets the speed level.
|
||||
* The current speed level may be retrieved using #TH_ENCCTL_GET_SPLEVEL.
|
||||
*
|
||||
* \param[in] _buf <tt>int</tt>: The new encoding speed level.
|
||||
* 0 is slowest, larger values use less CPU.
|
||||
* \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>, or the
|
||||
* encoding speed level is out of bounds.
|
||||
* The maximum encoding speed level may be
|
||||
* implementation- and encoding mode-specific, and can be
|
||||
* obtained via #TH_ENCCTL_GET_SPLEVEL_MAX.
|
||||
* \retval TH_EIMPL Not supported by this implementation in the current
|
||||
* encoding mode.*/
|
||||
#define TH_ENCCTL_SET_SPLEVEL (14)
|
||||
/**Gets the current speed level.
|
||||
* The default speed level may vary according to encoder implementation, but if
|
||||
* this control code is not supported (it returns #TH_EIMPL), the default may
|
||||
* be assumed to be the slowest available speed (0).
|
||||
* The maximum encoding speed level may be implementation- and encoding
|
||||
* mode-specific, and can be obtained via #TH_ENCCTL_GET_SPLEVEL_MAX.
|
||||
*
|
||||
* \param[out] _buf <tt>int</tt>: The current encoding speed level.
|
||||
* 0 is slowest, larger values use less CPU.
|
||||
* \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>.
|
||||
* \retval TH_EIMPL Not supported by this implementation in the current
|
||||
* encoding mode.*/
|
||||
#define TH_ENCCTL_GET_SPLEVEL (16)
|
||||
/**Sets the number of duplicates of the next frame to produce.
|
||||
* Although libtheora can encode duplicate frames very cheaply, it costs some
|
||||
* amount of CPU to detect them, and a run of duplicates cannot span a
|
||||
* keyframe boundary.
|
||||
* This control code tells the encoder to produce the specified number of extra
|
||||
* duplicates of the next frame.
|
||||
* This allows the encoder to make smarter keyframe placement decisions and
|
||||
* rate control decisions, and reduces CPU usage as well, when compared to
|
||||
* just submitting the same frame for encoding multiple times.
|
||||
* This setting only applies to the next frame submitted for encoding.
|
||||
* You MUST call th_encode_packetout() repeatedly until it returns 0, or the
|
||||
* extra duplicate frames will be lost.
|
||||
*
|
||||
* \param[in] _buf <tt>int</tt>: The number of duplicates to produce.
|
||||
* If this is negative or zero, no duplicates will be produced.
|
||||
* \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>, or the
|
||||
* number of duplicates is greater than or equal to the
|
||||
* maximum keyframe interval.
|
||||
* In the latter case, NO duplicate frames will be produced.
|
||||
* You must ensure that the maximum keyframe interval is set
|
||||
* larger than the maximum number of duplicates you will
|
||||
* ever wish to insert prior to encoding.
|
||||
* \retval TH_EIMPL Not supported by this implementation in the current
|
||||
* encoding mode.*/
|
||||
#define TH_ENCCTL_SET_DUP_COUNT (18)
|
||||
/**Modifies the default bitrate management behavior.
|
||||
* Use to allow or disallow frame dropping, and to enable or disable capping
|
||||
* bit reservoir overflows and underflows.
|
||||
* See \ref encctlcodes "the list of available flags".
|
||||
* The flags are set by default to
|
||||
* <tt>#TH_RATECTL_DROP_FRAMES|#TH_RATECTL_CAP_OVERFLOW</tt>.
|
||||
*
|
||||
* \param[in] _buf <tt>int</tt>: Any combination of
|
||||
* \ref ratectlflags "the available flags":
|
||||
* - #TH_RATECTL_DROP_FRAMES: Enable frame dropping.
|
||||
* - #TH_RATECTL_CAP_OVERFLOW: Don't bank excess bits for later
|
||||
* use.
|
||||
* - #TH_RATECTL_CAP_UNDERFLOW: Don't try to make up shortfalls
|
||||
* later.
|
||||
* \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt> or rate control
|
||||
* is not enabled.
|
||||
* \retval TH_EIMPL Not supported by this implementation in the current
|
||||
* encoding mode.*/
|
||||
#define TH_ENCCTL_SET_RATE_FLAGS (20)
|
||||
/**Sets the size of the bitrate management bit reservoir as a function
|
||||
* of number of frames.
|
||||
* The reservoir size affects how quickly bitrate management reacts to
|
||||
* instantaneous changes in the video complexity.
|
||||
* Larger reservoirs react more slowly, and provide better overall quality, but
|
||||
* require more buffering by a client, adding more latency to live streams.
|
||||
* By default, libtheora sets the reservoir to the maximum distance between
|
||||
* keyframes, subject to a minimum and maximum limit.
|
||||
* This call may be used to increase or decrease the reservoir, increasing or
|
||||
* decreasing the allowed temporary variance in bitrate.
|
||||
* An implementation may impose some limits on the size of a reservoir it can
|
||||
* handle, in which case the actual reservoir size may not be exactly what was
|
||||
* requested.
|
||||
* The actual value set will be returned.
|
||||
*
|
||||
* \param[in] _buf <tt>int</tt>: Requested size of the reservoir measured in
|
||||
* frames.
|
||||
* \param[out] _buf <tt>int</tt>: The actual size of the reservoir set.
|
||||
* \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>, or rate control
|
||||
* is not enabled. The buffer has an implementation
|
||||
* defined minimum and maximum size and the value in _buf
|
||||
* will be adjusted to match the actual value set.
|
||||
* \retval TH_EIMPL Not supported by this implementation in the current
|
||||
* encoding mode.*/
|
||||
#define TH_ENCCTL_SET_RATE_BUFFER (22)
|
||||
/**Enable pass 1 of two-pass encoding mode and retrieve the first pass metrics.
|
||||
* Pass 1 mode must be enabled before the first frame is encoded, and a target
|
||||
* bitrate must have already been specified to the encoder.
|
||||
* Although this does not have to be the exact rate that will be used in the
|
||||
* second pass, closer values may produce better results.
|
||||
* The first call returns the size of the two-pass header data, along with some
|
||||
* placeholder content, and sets the encoder into pass 1 mode implicitly.
|
||||
* This call sets the encoder to pass 1 mode implicitly.
|
||||
* Then, a subsequent call must be made after each call to
|
||||
* th_encode_ycbcr_in() to retrieve the metrics for that frame.
|
||||
* An additional, final call must be made to retrieve the summary data,
|
||||
* containing such information as the total number of frames, etc.
|
||||
* This must be stored in place of the placeholder data that was returned
|
||||
* in the first call, before the frame metrics data.
|
||||
* All of this data must be presented back to the encoder during pass 2 using
|
||||
* #TH_ENCCTL_2PASS_IN.
|
||||
*
|
||||
* \param[out] <tt>char *</tt>_buf: Returns a pointer to internal storage
|
||||
* containing the two pass metrics data.
|
||||
* This storage is only valid until the next call, or until the
|
||||
* encoder context is freed, and must be copied by the
|
||||
* application.
|
||||
* \retval >=0 The number of bytes of metric data available in the
|
||||
* returned buffer.
|
||||
* \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(char *)</tt>, no target
|
||||
* bitrate has been set, or the first call was made after
|
||||
* the first frame was submitted for encoding.
|
||||
* \retval TH_EIMPL Not supported by this implementation.*/
|
||||
#define TH_ENCCTL_2PASS_OUT (24)
|
||||
/**Submits two-pass encoding metric data collected the first encoding pass to
|
||||
* the second pass.
|
||||
* The first call must be made before the first frame is encoded, and a target
|
||||
* bitrate must have already been specified to the encoder.
|
||||
* It sets the encoder to pass 2 mode implicitly; this cannot be disabled.
|
||||
* The encoder may require reading data from some or all of the frames in
|
||||
* advance, depending on, e.g., the reservoir size used in the second pass.
|
||||
* You must call this function repeatedly before each frame to provide data
|
||||
* until either a) it fails to consume all of the data presented or b) all of
|
||||
* the pass 1 data has been consumed.
|
||||
* In the first case, you must save the remaining data to be presented after
|
||||
* the next frame.
|
||||
* You can call this function with a NULL argument to get an upper bound on
|
||||
* the number of bytes that will be required before the next frame.
|
||||
*
|
||||
* When pass 2 is first enabled, the default bit reservoir is set to the entire
|
||||
* file; this gives maximum flexibility but can lead to very high peak rates.
|
||||
* You can subsequently set it to another value with #TH_ENCCTL_SET_RATE_BUFFER
|
||||
* (e.g., to set it to the keyframe interval for non-live streaming), however,
|
||||
* you may then need to provide more data before the next frame.
|
||||
*
|
||||
* \param[in] _buf <tt>char[]</tt>: A buffer containing the data returned by
|
||||
* #TH_ENCCTL_2PASS_OUT in pass 1.
|
||||
* You may pass <tt>NULL</tt> for \a _buf to return an upper
|
||||
* bound on the number of additional bytes needed before the
|
||||
* next frame.
|
||||
* The summary data returned at the end of pass 1 must be at
|
||||
* the head of the buffer on the first call with a
|
||||
* non-<tt>NULL</tt> \a _buf, and the placeholder data
|
||||
* returned at the start of pass 1 should be omitted.
|
||||
* After each call you should advance this buffer by the number
|
||||
* of bytes consumed.
|
||||
* \retval >0 The number of bytes of metric data required/consumed.
|
||||
* \retval 0 No more data is required before the next frame.
|
||||
* \retval TH_EFAULT \a _enc_ctx is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL No target bitrate has been set, or the first call was
|
||||
* made after the first frame was submitted for
|
||||
* encoding.
|
||||
* \retval TH_ENOTFORMAT The data did not appear to be pass 1 from a compatible
|
||||
* implementation of this library.
|
||||
* \retval TH_EBADHEADER The data was invalid; this may be returned when
|
||||
* attempting to read an aborted pass 1 file that still
|
||||
* has the placeholder data in place of the summary
|
||||
* data.
|
||||
* \retval TH_EIMPL Not supported by this implementation.*/
|
||||
#define TH_ENCCTL_2PASS_IN (26)
|
||||
/**Sets the current encoding quality.
|
||||
* This is only valid so long as no bitrate has been specified, either through
|
||||
* the #th_info struct used to initialize the encoder or through
|
||||
* #TH_ENCCTL_SET_BITRATE (this restriction may be relaxed in a future
|
||||
* version).
|
||||
* If it is set before the headers are emitted, the target quality encoded in
|
||||
* them will be updated.
|
||||
*
|
||||
* \param[in] _buf <tt>int</tt>: The new target quality, in the range 0...63,
|
||||
* inclusive.
|
||||
* \retval 0 Success.
|
||||
* \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL A target bitrate has already been specified, or the
|
||||
* quality index was not in the range 0...63.
|
||||
* \retval TH_EIMPL Not supported by this implementation.*/
|
||||
#define TH_ENCCTL_SET_QUALITY (28)
|
||||
/**Sets the current encoding bitrate.
|
||||
* Once a bitrate is set, the encoder must use a rate-controlled mode for all
|
||||
* future frames (this restriction may be relaxed in a future version).
|
||||
* If it is set before the headers are emitted, the target bitrate encoded in
|
||||
* them will be updated.
|
||||
* Due to the buffer delay, the exact bitrate of each section of the encode is
|
||||
* not guaranteed.
|
||||
* The encoder may have already used more bits than allowed for the frames it
|
||||
* has encoded, expecting to make them up in future frames, or it may have
|
||||
* used fewer, holding the excess in reserve.
|
||||
* The exact transition between the two bitrates is not well-defined by this
|
||||
* API, but may be affected by flags set with #TH_ENCCTL_SET_RATE_FLAGS.
|
||||
* After a number of frames equal to the buffer delay, one may expect further
|
||||
* output to average at the target bitrate.
|
||||
*
|
||||
* \param[in] _buf <tt>long</tt>: The new target bitrate, in bits per second.
|
||||
* \retval 0 Success.
|
||||
* \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL The target bitrate was not positive.
|
||||
* \retval TH_EIMPL Not supported by this implementation.*/
|
||||
#define TH_ENCCTL_SET_BITRATE (30)
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**\name TH_ENCCTL_SET_RATE_FLAGS flags
|
||||
* \anchor ratectlflags
|
||||
* These are the flags available for use with #TH_ENCCTL_SET_RATE_FLAGS.*/
|
||||
/*@{*/
|
||||
/**Drop frames to keep within bitrate buffer constraints.
|
||||
* This can have a severe impact on quality, but is the only way to ensure that
|
||||
* bitrate targets are met at low rates during sudden bursts of activity.*/
|
||||
#define TH_RATECTL_DROP_FRAMES (0x1)
|
||||
/**Ignore bitrate buffer overflows.
|
||||
* If the encoder uses so few bits that the reservoir of available bits
|
||||
* overflows, ignore the excess.
|
||||
* The encoder will not try to use these extra bits in future frames.
|
||||
* At high rates this may cause the result to be undersized, but allows a
|
||||
* client to play the stream using a finite buffer; it should normally be
|
||||
* enabled.*/
|
||||
#define TH_RATECTL_CAP_OVERFLOW (0x2)
|
||||
/**Ignore bitrate buffer underflows.
|
||||
* If the encoder uses so many bits that the reservoir of available bits
|
||||
* underflows, ignore the deficit.
|
||||
* The encoder will not try to make up these extra bits in future frames.
|
||||
* At low rates this may cause the result to be oversized; it should normally
|
||||
* be disabled.*/
|
||||
#define TH_RATECTL_CAP_UNDERFLOW (0x4)
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
||||
/**The quantization parameters used by VP3.*/
|
||||
extern const th_quant_info TH_VP31_QUANT_INFO;
|
||||
|
||||
/**The Huffman tables used by VP3.*/
|
||||
extern const th_huff_code
|
||||
TH_VP31_HUFF_CODES[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS];
|
||||
|
||||
|
||||
|
||||
/**\name Encoder state
|
||||
The following data structure is opaque, and its contents are not publicly
|
||||
defined by this API.
|
||||
Referring to its internals directly is unsupported, and may break without
|
||||
warning.*/
|
||||
/*@{*/
|
||||
/**The encoder context.*/
|
||||
typedef struct th_enc_ctx th_enc_ctx;
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
||||
/**\defgroup encfuncs Functions for Encoding*/
|
||||
/*@{*/
|
||||
/**\name Functions for encoding
|
||||
* You must link to <tt>libtheoraenc</tt> and <tt>libtheoradec</tt>
|
||||
* if you use any of the functions in this section.
|
||||
*
|
||||
* The functions are listed in the order they are used in a typical encode.
|
||||
* The basic steps are:
|
||||
* - Fill in a #th_info structure with details on the format of the video you
|
||||
* wish to encode.
|
||||
* - Allocate a #th_enc_ctx handle with th_encode_alloc().
|
||||
* - Perform any additional encoder configuration required with
|
||||
* th_encode_ctl().
|
||||
* - Repeatedly call th_encode_flushheader() to retrieve all the header
|
||||
* packets.
|
||||
* - For each uncompressed frame:
|
||||
* - Submit the uncompressed frame via th_encode_ycbcr_in()
|
||||
* - Repeatedly call th_encode_packetout() to retrieve any video data packets
|
||||
* that are ready.
|
||||
* - Call th_encode_free() to release all encoder memory.*/
|
||||
/*@{*/
|
||||
/**Allocates an encoder instance.
|
||||
* \param _info A #th_info struct filled with the desired encoding parameters.
|
||||
* \return The initialized #th_enc_ctx handle.
|
||||
* \retval NULL If the encoding parameters were invalid.*/
|
||||
extern th_enc_ctx *th_encode_alloc(const th_info *_info);
|
||||
/**Encoder control function.
|
||||
* This is used to provide advanced control the encoding process.
|
||||
* \param _enc A #th_enc_ctx handle.
|
||||
* \param _req The control code to process.
|
||||
* See \ref encctlcodes "the list of available control codes"
|
||||
* for details.
|
||||
* \param _buf The parameters for this control code.
|
||||
* \param _buf_sz The size of the parameter buffer.*/
|
||||
extern int th_encode_ctl(th_enc_ctx *_enc,int _req,void *_buf,size_t _buf_sz);
|
||||
/**Outputs the next header packet.
|
||||
* This should be called repeatedly after encoder initialization until it
|
||||
* returns 0 in order to get all of the header packets, in order, before
|
||||
* encoding actual video data.
|
||||
* \param _enc A #th_enc_ctx handle.
|
||||
* \param _comments The metadata to place in the comment header, when it is
|
||||
* encoded.
|
||||
* \param _op An <tt>ogg_packet</tt> structure to fill.
|
||||
* All of the elements of this structure will be set,
|
||||
* including a pointer to the header data.
|
||||
* The memory for the header data is owned by
|
||||
* <tt>libtheoraenc</tt>, and may be invalidated when the
|
||||
* next encoder function is called.
|
||||
* \return A positive value indicates that a header packet was successfully
|
||||
* produced.
|
||||
* \retval 0 No packet was produced, and no more header packets remain.
|
||||
* \retval TH_EFAULT \a _enc, \a _comments, or \a _op was <tt>NULL</tt>.*/
|
||||
extern int th_encode_flushheader(th_enc_ctx *_enc,
|
||||
th_comment *_comments,ogg_packet *_op);
|
||||
/**Submits an uncompressed frame to the encoder.
|
||||
* \param _enc A #th_enc_ctx handle.
|
||||
* \param _ycbcr A buffer of Y'CbCr data to encode.
|
||||
* If the width and height of the buffer matches the frame size
|
||||
* the encoder was initialized with, the encoder will only
|
||||
* reference the portion inside the picture region.
|
||||
* Any data outside this region will be ignored, and need not map
|
||||
* to a valid address.
|
||||
* Alternatively, you can pass a buffer equal to the size of the
|
||||
* picture region, if this is less than the full frame size.
|
||||
* When using subsampled chroma planes, odd picture sizes or odd
|
||||
* picture offsets may require an unexpected chroma plane size,
|
||||
* and their use is generally discouraged, as they will not be
|
||||
* well-supported by players and other media frameworks.
|
||||
* See Section 4.4 of
|
||||
* <a href="http://www.theora.org/doc/Theora.pdf">the Theora
|
||||
* specification</a> for details if you wish to use them anyway.
|
||||
* \retval 0 Success.
|
||||
* \retval TH_EFAULT \a _enc or \a _ycbcr is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL The buffer size matches neither the frame size nor the
|
||||
* picture size the encoder was initialized with, or
|
||||
* encoding has already completed.*/
|
||||
extern int th_encode_ycbcr_in(th_enc_ctx *_enc,th_ycbcr_buffer _ycbcr);
|
||||
/**Retrieves encoded video data packets.
|
||||
* This should be called repeatedly after each frame is submitted to flush any
|
||||
* encoded packets, until it returns 0.
|
||||
* The encoder will not buffer these packets as subsequent frames are
|
||||
* compressed, so a failure to do so will result in lost video data.
|
||||
* \note Currently the encoder operates in a one-frame-in, one-packet-out
|
||||
* manner.
|
||||
* However, this may be changed in the future.
|
||||
* \param _enc A #th_enc_ctx handle.
|
||||
* \param _last Set this flag to a non-zero value if no more uncompressed
|
||||
* frames will be submitted.
|
||||
* This ensures that a proper EOS flag is set on the last packet.
|
||||
* \param _op An <tt>ogg_packet</tt> structure to fill.
|
||||
* All of the elements of this structure will be set, including a
|
||||
* pointer to the video data.
|
||||
* The memory for the video data is owned by
|
||||
* <tt>libtheoraenc</tt>, and may be invalidated when the next
|
||||
* encoder function is called.
|
||||
* \return A positive value indicates that a video data packet was successfully
|
||||
* produced.
|
||||
* \retval 0 No packet was produced, and no more encoded video data
|
||||
* remains.
|
||||
* \retval TH_EFAULT \a _enc or \a _op was <tt>NULL</tt>.*/
|
||||
extern int th_encode_packetout(th_enc_ctx *_enc,int _last,ogg_packet *_op);
|
||||
/**Frees an allocated encoder instance.
|
||||
* \param _enc A #th_enc_ctx handle.*/
|
||||
extern void th_encode_free(th_enc_ctx *_enc);
|
||||
/*@}*/
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,112 +0,0 @@
|
|||
/********************************************************************
|
||||
* *
|
||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* *
|
||||
********************************************************************
|
||||
|
||||
function: vorbis encode-engine setup
|
||||
last mod: $Id: vorbisenc.h 16037 2009-05-26 21:10:58Z xiphmont $
|
||||
|
||||
********************************************************************/
|
||||
|
||||
#ifndef _OV_ENC_H_
|
||||
#define _OV_ENC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "codec.h"
|
||||
|
||||
extern int vorbis_encode_init(vorbis_info *vi,
|
||||
long channels,
|
||||
long rate,
|
||||
|
||||
long max_bitrate,
|
||||
long nominal_bitrate,
|
||||
long min_bitrate);
|
||||
|
||||
extern int vorbis_encode_setup_managed(vorbis_info *vi,
|
||||
long channels,
|
||||
long rate,
|
||||
|
||||
long max_bitrate,
|
||||
long nominal_bitrate,
|
||||
long min_bitrate);
|
||||
|
||||
extern int vorbis_encode_setup_vbr(vorbis_info *vi,
|
||||
long channels,
|
||||
long rate,
|
||||
|
||||
float quality /* quality level from 0. (lo) to 1. (hi) */
|
||||
);
|
||||
|
||||
extern int vorbis_encode_init_vbr(vorbis_info *vi,
|
||||
long channels,
|
||||
long rate,
|
||||
|
||||
float base_quality /* quality level from 0. (lo) to 1. (hi) */
|
||||
);
|
||||
|
||||
extern int vorbis_encode_setup_init(vorbis_info *vi);
|
||||
|
||||
extern int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg);
|
||||
|
||||
/* deprecated rate management supported only for compatability */
|
||||
#define OV_ECTL_RATEMANAGE_GET 0x10
|
||||
#define OV_ECTL_RATEMANAGE_SET 0x11
|
||||
#define OV_ECTL_RATEMANAGE_AVG 0x12
|
||||
#define OV_ECTL_RATEMANAGE_HARD 0x13
|
||||
|
||||
struct ovectl_ratemanage_arg {
|
||||
int management_active;
|
||||
|
||||
long bitrate_hard_min;
|
||||
long bitrate_hard_max;
|
||||
double bitrate_hard_window;
|
||||
|
||||
long bitrate_av_lo;
|
||||
long bitrate_av_hi;
|
||||
double bitrate_av_window;
|
||||
double bitrate_av_window_center;
|
||||
};
|
||||
|
||||
|
||||
/* new rate setup */
|
||||
#define OV_ECTL_RATEMANAGE2_GET 0x14
|
||||
#define OV_ECTL_RATEMANAGE2_SET 0x15
|
||||
|
||||
struct ovectl_ratemanage2_arg {
|
||||
int management_active;
|
||||
|
||||
long bitrate_limit_min_kbps;
|
||||
long bitrate_limit_max_kbps;
|
||||
long bitrate_limit_reservoir_bits;
|
||||
double bitrate_limit_reservoir_bias;
|
||||
|
||||
long bitrate_average_kbps;
|
||||
double bitrate_average_damping;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define OV_ECTL_LOWPASS_GET 0x20
|
||||
#define OV_ECTL_LOWPASS_SET 0x21
|
||||
|
||||
#define OV_ECTL_IBLOCK_GET 0x30
|
||||
#define OV_ECTL_IBLOCK_SET 0x31
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,206 +0,0 @@
|
|||
/********************************************************************
|
||||
* *
|
||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* *
|
||||
********************************************************************
|
||||
|
||||
function: stdio-based convenience library for opening/seeking/decoding
|
||||
last mod: $Id: vorbisfile.h 16243 2009-07-10 02:49:31Z xiphmont $
|
||||
|
||||
********************************************************************/
|
||||
|
||||
#ifndef _OV_FILE_H_
|
||||
#define _OV_FILE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "codec.h"
|
||||
|
||||
/* The function prototypes for the callbacks are basically the same as for
|
||||
* the stdio functions fread, fseek, fclose, ftell.
|
||||
* The one difference is that the FILE * arguments have been replaced with
|
||||
* a void * - this is to be used as a pointer to whatever internal data these
|
||||
* functions might need. In the stdio case, it's just a FILE * cast to a void *
|
||||
*
|
||||
* If you use other functions, check the docs for these functions and return
|
||||
* the right values. For seek_func(), you *MUST* return -1 if the stream is
|
||||
* unseekable
|
||||
*/
|
||||
typedef struct {
|
||||
size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource);
|
||||
int (*seek_func) (void *datasource, ogg_int64_t offset, int whence);
|
||||
int (*close_func) (void *datasource);
|
||||
long (*tell_func) (void *datasource);
|
||||
} ov_callbacks;
|
||||
|
||||
#ifndef OV_EXCLUDE_STATIC_CALLBACKS
|
||||
|
||||
/* a few sets of convenient callbacks, especially for use under
|
||||
* Windows where ov_open_callbacks() should always be used instead of
|
||||
* ov_open() to avoid problems with incompatable crt.o version linking
|
||||
* issues. */
|
||||
|
||||
static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){
|
||||
if(f==NULL)return(-1);
|
||||
|
||||
#ifdef __MINGW32__
|
||||
return fseeko64(f,off,whence);
|
||||
#elif defined (_WIN32)
|
||||
return _fseeki64(f,off,whence);
|
||||
#else
|
||||
return fseek(f,off,whence);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* These structs below (OV_CALLBACKS_DEFAULT etc) are defined here as
|
||||
* static data. That means that every file which includes this header
|
||||
* will get its own copy of these structs whether it uses them or
|
||||
* not unless it #defines OV_EXCLUDE_STATIC_CALLBACKS.
|
||||
* These static symbols are essential on platforms such as Windows on
|
||||
* which several different versions of stdio support may be linked to
|
||||
* by different DLLs, and we need to be certain we know which one
|
||||
* we're using (the same one as the main application).
|
||||
*/
|
||||
|
||||
static ov_callbacks OV_CALLBACKS_DEFAULT = {
|
||||
(size_t (*)(void *, size_t, size_t, void *)) fread,
|
||||
(int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap,
|
||||
(int (*)(void *)) fclose,
|
||||
(long (*)(void *)) ftell
|
||||
};
|
||||
|
||||
static ov_callbacks OV_CALLBACKS_NOCLOSE = {
|
||||
(size_t (*)(void *, size_t, size_t, void *)) fread,
|
||||
(int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap,
|
||||
(int (*)(void *)) NULL,
|
||||
(long (*)(void *)) ftell
|
||||
};
|
||||
|
||||
static ov_callbacks OV_CALLBACKS_STREAMONLY = {
|
||||
(size_t (*)(void *, size_t, size_t, void *)) fread,
|
||||
(int (*)(void *, ogg_int64_t, int)) NULL,
|
||||
(int (*)(void *)) fclose,
|
||||
(long (*)(void *)) NULL
|
||||
};
|
||||
|
||||
static ov_callbacks OV_CALLBACKS_STREAMONLY_NOCLOSE = {
|
||||
(size_t (*)(void *, size_t, size_t, void *)) fread,
|
||||
(int (*)(void *, ogg_int64_t, int)) NULL,
|
||||
(int (*)(void *)) NULL,
|
||||
(long (*)(void *)) NULL
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#define NOTOPEN 0
|
||||
#define PARTOPEN 1
|
||||
#define OPENED 2
|
||||
#define STREAMSET 3
|
||||
#define INITSET 4
|
||||
|
||||
typedef struct OggVorbis_File {
|
||||
void *datasource; /* Pointer to a FILE *, etc. */
|
||||
int seekable;
|
||||
ogg_int64_t offset;
|
||||
ogg_int64_t end;
|
||||
ogg_sync_state oy;
|
||||
|
||||
/* If the FILE handle isn't seekable (eg, a pipe), only the current
|
||||
stream appears */
|
||||
int links;
|
||||
ogg_int64_t *offsets;
|
||||
ogg_int64_t *dataoffsets;
|
||||
long *serialnos;
|
||||
ogg_int64_t *pcmlengths; /* overloaded to maintain binary
|
||||
compatability; x2 size, stores both
|
||||
beginning and end values */
|
||||
vorbis_info *vi;
|
||||
vorbis_comment *vc;
|
||||
|
||||
/* Decoding working state local storage */
|
||||
ogg_int64_t pcm_offset;
|
||||
int ready_state;
|
||||
long current_serialno;
|
||||
int current_link;
|
||||
|
||||
double bittrack;
|
||||
double samptrack;
|
||||
|
||||
ogg_stream_state os; /* take physical pages, weld into a logical
|
||||
stream of packets */
|
||||
vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
|
||||
vorbis_block vb; /* local working space for packet->PCM decode */
|
||||
|
||||
ov_callbacks callbacks;
|
||||
|
||||
} OggVorbis_File;
|
||||
|
||||
|
||||
extern int ov_clear(OggVorbis_File *vf);
|
||||
extern int ov_fopen(char *path,OggVorbis_File *vf);
|
||||
extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
|
||||
extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
|
||||
char *initial, long ibytes, ov_callbacks callbacks);
|
||||
|
||||
extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
|
||||
extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
|
||||
char *initial, long ibytes, ov_callbacks callbacks);
|
||||
extern int ov_test_open(OggVorbis_File *vf);
|
||||
|
||||
extern long ov_bitrate(OggVorbis_File *vf,int i);
|
||||
extern long ov_bitrate_instant(OggVorbis_File *vf);
|
||||
extern long ov_streams(OggVorbis_File *vf);
|
||||
extern long ov_seekable(OggVorbis_File *vf);
|
||||
extern long ov_serialnumber(OggVorbis_File *vf,int i);
|
||||
|
||||
extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i);
|
||||
extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);
|
||||
extern double ov_time_total(OggVorbis_File *vf,int i);
|
||||
|
||||
extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos);
|
||||
extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos);
|
||||
extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
|
||||
extern int ov_time_seek(OggVorbis_File *vf,double pos);
|
||||
extern int ov_time_seek_page(OggVorbis_File *vf,double pos);
|
||||
|
||||
extern int ov_raw_seek_lap(OggVorbis_File *vf,ogg_int64_t pos);
|
||||
extern int ov_pcm_seek_lap(OggVorbis_File *vf,ogg_int64_t pos);
|
||||
extern int ov_pcm_seek_page_lap(OggVorbis_File *vf,ogg_int64_t pos);
|
||||
extern int ov_time_seek_lap(OggVorbis_File *vf,double pos);
|
||||
extern int ov_time_seek_page_lap(OggVorbis_File *vf,double pos);
|
||||
|
||||
extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf);
|
||||
extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf);
|
||||
extern double ov_time_tell(OggVorbis_File *vf);
|
||||
|
||||
extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
|
||||
extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
|
||||
|
||||
extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int samples,
|
||||
int *bitstream);
|
||||
extern long ov_read_filter(OggVorbis_File *vf,char *buffer,int length,
|
||||
int bigendianp,int word,int sgned,int *bitstream,
|
||||
void (*filter)(float **pcm,long channels,long samples,void *filter_param),void *filter_param);
|
||||
extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
|
||||
int bigendianp,int word,int sgned,int *bitstream);
|
||||
extern int ov_crosslap(OggVorbis_File *vf1,OggVorbis_File *vf2);
|
||||
|
||||
extern int ov_halfrate(OggVorbis_File *vf,int flag);
|
||||
extern int ov_halfrate_p(OggVorbis_File *vf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
|
@ -2,6 +2,20 @@
|
|||
#define __CONFIG_TYPES_H__
|
||||
|
||||
/* these are filled in by configure */
|
||||
#define INCLUDE_INTTYPES_H 1
|
||||
#define INCLUDE_STDINT_H 1
|
||||
#define INCLUDE_SYS_TYPES_H 1
|
||||
|
||||
#if INCLUDE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
#if INCLUDE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#if INCLUDE_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
typedef short ogg_int16_t;
|
||||
typedef unsigned short ogg_uint16_t;
|
||||
typedef int ogg_int32_t;
|
|
@ -11,7 +11,7 @@
|
|||
********************************************************************
|
||||
|
||||
function: toplevel libogg include
|
||||
last mod: $Id: ogg.h 16051 2009-05-27 05:00:06Z xiphmont $
|
||||
last mod: $Id: ogg.h 17571 2010-10-27 13:28:20Z xiphmont $
|
||||
|
||||
********************************************************************/
|
||||
#ifndef _OGG_H
|
||||
|
@ -78,7 +78,7 @@ typedef struct {
|
|||
ogg_int64_t packetno; /* sequence number for decode; the framing
|
||||
knows where there's a hole in the data,
|
||||
but we need coupling so that the codec
|
||||
(which is in a seperate abstraction
|
||||
(which is in a separate abstraction
|
||||
layer) also knows about the gap */
|
||||
ogg_int64_t granulepos;
|
||||
|
||||
|
@ -98,7 +98,7 @@ typedef struct {
|
|||
ogg_int64_t packetno; /* sequence number for decode; the framing
|
||||
knows where there's a hole in the data,
|
||||
but we need coupling so that the codec
|
||||
(which is in a seperate abstraction
|
||||
(which is in a separate abstraction
|
||||
layer) also knows about the gap */
|
||||
} ogg_packet;
|
||||
|
||||
|
@ -159,6 +159,7 @@ extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
|
|||
extern int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov,
|
||||
int count, long e_o_s, ogg_int64_t granulepos);
|
||||
extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
|
||||
extern int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill);
|
||||
extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
|
||||
|
||||
/* Ogg BITSTREAM PRIMITIVES: decoding **************************/
|
|
@ -11,7 +11,7 @@
|
|||
********************************************************************
|
||||
|
||||
function: #ifdef jail to whip a few platforms into the UNIX ideal.
|
||||
last mod: $Id: os_types.h 14997 2008-06-04 03:27:18Z ivo $
|
||||
last mod: $Id: os_types.h 17712 2010-12-03 17:10:02Z xiphmont $
|
||||
|
||||
********************************************************************/
|
||||
#ifndef _OS_TYPES_H
|
||||
|
@ -68,11 +68,11 @@
|
|||
|
||||
#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
|
||||
|
||||
# include <sys/types.h>
|
||||
# include <inttypes.h>
|
||||
typedef int16_t ogg_int16_t;
|
||||
typedef u_int16_t ogg_uint16_t;
|
||||
typedef uint16_t ogg_uint16_t;
|
||||
typedef int32_t ogg_int32_t;
|
||||
typedef u_int32_t ogg_uint32_t;
|
||||
typedef uint32_t ogg_uint32_t;
|
||||
typedef int64_t ogg_int64_t;
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
|
@ -90,9 +90,9 @@
|
|||
/* Be */
|
||||
# include <inttypes.h>
|
||||
typedef int16_t ogg_int16_t;
|
||||
typedef u_int16_t ogg_uint16_t;
|
||||
typedef uint16_t ogg_uint16_t;
|
||||
typedef int32_t ogg_int32_t;
|
||||
typedef u_int32_t ogg_uint32_t;
|
||||
typedef uint32_t ogg_uint32_t;
|
||||
typedef int64_t ogg_int64_t;
|
||||
|
||||
#elif defined (__EMX__)
|
||||
|
@ -129,9 +129,17 @@
|
|||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long int ogg_int64_t;
|
||||
|
||||
#elif defined(__TMS320C6X__)
|
||||
|
||||
/* TI C64x compiler */
|
||||
typedef signed short ogg_int16_t;
|
||||
typedef unsigned short ogg_uint16_t;
|
||||
typedef signed int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long int ogg_int64_t;
|
||||
|
||||
#else
|
||||
|
||||
# include <sys/types.h>
|
||||
# include <ogg/config_types.h>
|
||||
|
||||
#endif
|
|
@ -11,7 +11,7 @@
|
|||
********************************************************************
|
||||
|
||||
function: libvorbis codec headers
|
||||
last mod: $Id: codec.h 16037 2009-05-26 21:10:58Z xiphmont $
|
||||
last mod: $Id: codec.h 17021 2010-03-24 09:29:41Z xiphmont $
|
||||
|
||||
********************************************************************/
|
||||
|
||||
|
@ -121,7 +121,7 @@ typedef struct vorbis_block{
|
|||
|
||||
/* vorbis_block is a single block of data to be processed as part of
|
||||
the analysis/synthesis stream; it belongs to a specific logical
|
||||
bitstream, but is independant from other vorbis_blocks belonging to
|
||||
bitstream, but is independent from other vorbis_blocks belonging to
|
||||
that logical bitstream. *************************************************/
|
||||
|
||||
struct alloc_chain{
|
|
@ -0,0 +1,436 @@
|
|||
/********************************************************************
|
||||
* *
|
||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* *
|
||||
********************************************************************
|
||||
|
||||
function: vorbis encode-engine setup
|
||||
last mod: $Id: vorbisenc.h 17021 2010-03-24 09:29:41Z xiphmont $
|
||||
|
||||
********************************************************************/
|
||||
|
||||
/** \file
|
||||
* Libvorbisenc is a convenient API for setting up an encoding
|
||||
* environment using libvorbis. Libvorbisenc encapsulates the
|
||||
* actions needed to set up the encoder properly.
|
||||
*/
|
||||
|
||||
#ifndef _OV_ENC_H_
|
||||
#define _OV_ENC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "codec.h"
|
||||
|
||||
/**
|
||||
* This is the primary function within libvorbisenc for setting up managed
|
||||
* bitrate modes.
|
||||
*
|
||||
* Before this function is called, the \ref vorbis_info
|
||||
* struct should be initialized by using vorbis_info_init() from the libvorbis
|
||||
* API. After encoding, vorbis_info_clear() should be called.
|
||||
*
|
||||
* The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set
|
||||
* constraints for the encoded file. This function uses these settings to
|
||||
* select the appropriate encoding mode and set it up.
|
||||
*
|
||||
* \param vi Pointer to an initialized \ref vorbis_info struct.
|
||||
* \param channels The number of channels to be encoded.
|
||||
* \param rate The sampling rate of the source audio.
|
||||
* \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset.
|
||||
* \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset.
|
||||
* \param min_bitrate Desired minimum bitrate. -1 indicates unset.
|
||||
*
|
||||
* \return Zero for success, and negative values for failure.
|
||||
*
|
||||
* \retval 0 Success.
|
||||
* \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption.
|
||||
* \retval OV_EINVAL Invalid setup request, eg, out of range argument.
|
||||
* \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request.
|
||||
*/
|
||||
extern int vorbis_encode_init(vorbis_info *vi,
|
||||
long channels,
|
||||
long rate,
|
||||
|
||||
long max_bitrate,
|
||||
long nominal_bitrate,
|
||||
long min_bitrate);
|
||||
|
||||
/**
|
||||
* This function performs step-one of a three-step bitrate-managed encode
|
||||
* setup. It functions similarly to the one-step setup performed by \ref
|
||||
* vorbis_encode_init but allows an application to make further encode setup
|
||||
* tweaks using \ref vorbis_encode_ctl before finally calling \ref
|
||||
* vorbis_encode_setup_init to complete the setup process.
|
||||
*
|
||||
* Before this function is called, the \ref vorbis_info struct should be
|
||||
* initialized by using vorbis_info_init() from the libvorbis API. After
|
||||
* encoding, vorbis_info_clear() should be called.
|
||||
*
|
||||
* The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set
|
||||
* constraints for the encoded file. This function uses these settings to
|
||||
* select the appropriate encoding mode and set it up.
|
||||
*
|
||||
* \param vi Pointer to an initialized vorbis_info struct.
|
||||
* \param channels The number of channels to be encoded.
|
||||
* \param rate The sampling rate of the source audio.
|
||||
* \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset.
|
||||
* \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset.
|
||||
* \param min_bitrate Desired minimum bitrate. -1 indicates unset.
|
||||
*
|
||||
* \return Zero for success, and negative for failure.
|
||||
*
|
||||
* \retval 0 Success
|
||||
* \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption.
|
||||
* \retval OV_EINVAL Invalid setup request, eg, out of range argument.
|
||||
* \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request.
|
||||
*/
|
||||
extern int vorbis_encode_setup_managed(vorbis_info *vi,
|
||||
long channels,
|
||||
long rate,
|
||||
|
||||
long max_bitrate,
|
||||
long nominal_bitrate,
|
||||
long min_bitrate);
|
||||
|
||||
/**
|
||||
* This function performs step-one of a three-step variable bitrate
|
||||
* (quality-based) encode setup. It functions similarly to the one-step setup
|
||||
* performed by \ref vorbis_encode_init_vbr() but allows an application to
|
||||
* make further encode setup tweaks using \ref vorbis_encode_ctl() before
|
||||
* finally calling \ref vorbis_encode_setup_init to complete the setup
|
||||
* process.
|
||||
*
|
||||
* Before this function is called, the \ref vorbis_info struct should be
|
||||
* initialized by using \ref vorbis_info_init() from the libvorbis API. After
|
||||
* encoding, vorbis_info_clear() should be called.
|
||||
*
|
||||
* \param vi Pointer to an initialized vorbis_info struct.
|
||||
* \param channels The number of channels to be encoded.
|
||||
* \param rate The sampling rate of the source audio.
|
||||
* \param quality Desired quality level, currently from -0.1 to 1.0 (lo to hi).
|
||||
*
|
||||
* \return Zero for success, and negative values for failure.
|
||||
*
|
||||
* \retval 0 Success
|
||||
* \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption.
|
||||
* \retval OV_EINVAL Invalid setup request, eg, out of range argument.
|
||||
* \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request.
|
||||
*/
|
||||
extern int vorbis_encode_setup_vbr(vorbis_info *vi,
|
||||
long channels,
|
||||
long rate,
|
||||
|
||||
float quality
|
||||
);
|
||||
|
||||
/**
|
||||
* This is the primary function within libvorbisenc for setting up variable
|
||||
* bitrate ("quality" based) modes.
|
||||
*
|
||||
*
|
||||
* Before this function is called, the vorbis_info struct should be
|
||||
* initialized by using vorbis_info_init() from the libvorbis API. After
|
||||
* encoding, vorbis_info_clear() should be called.
|
||||
*
|
||||
* \param vi Pointer to an initialized vorbis_info struct.
|
||||
* \param channels The number of channels to be encoded.
|
||||
* \param rate The sampling rate of the source audio.
|
||||
* \param base_quality Desired quality level, currently from -0.1 to 1.0 (lo to hi).
|
||||
*
|
||||
*
|
||||
* \return Zero for success, or a negative number for failure.
|
||||
*
|
||||
* \retval 0 Success
|
||||
* \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption.
|
||||
* \retval OV_EINVAL Invalid setup request, eg, out of range argument.
|
||||
* \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request.
|
||||
*/
|
||||
extern int vorbis_encode_init_vbr(vorbis_info *vi,
|
||||
long channels,
|
||||
long rate,
|
||||
|
||||
float base_quality
|
||||
);
|
||||
|
||||
/**
|
||||
* This function performs the last stage of three-step encoding setup, as
|
||||
* described in the API overview under managed bitrate modes.
|
||||
*
|
||||
* Before this function is called, the \ref vorbis_info struct should be
|
||||
* initialized by using vorbis_info_init() from the libvorbis API, one of
|
||||
* \ref vorbis_encode_setup_managed() or \ref vorbis_encode_setup_vbr() called to
|
||||
* initialize the high-level encoding setup, and \ref vorbis_encode_ctl()
|
||||
* called if necessary to make encoding setup changes.
|
||||
* vorbis_encode_setup_init() finalizes the highlevel encoding structure into
|
||||
* a complete encoding setup after which the application may make no further
|
||||
* setup changes.
|
||||
*
|
||||
* After encoding, vorbis_info_clear() should be called.
|
||||
*
|
||||
* \param vi Pointer to an initialized \ref vorbis_info struct.
|
||||
*
|
||||
* \return Zero for success, and negative values for failure.
|
||||
*
|
||||
* \retval 0 Success.
|
||||
* \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption.
|
||||
*
|
||||
* \retval OV_EINVAL Attempt to use vorbis_encode_setup_init() without first
|
||||
* calling one of vorbis_encode_setup_managed() or vorbis_encode_setup_vbr() to
|
||||
* initialize the high-level encoding setup
|
||||
*
|
||||
*/
|
||||
extern int vorbis_encode_setup_init(vorbis_info *vi);
|
||||
|
||||
/**
|
||||
* This function implements a generic interface to miscellaneous encoder
|
||||
* settings similar to the classic UNIX 'ioctl()' system call. Applications
|
||||
* may use vorbis_encode_ctl() to query or set bitrate management or quality
|
||||
* mode details by using one of several \e request arguments detailed below.
|
||||
* vorbis_encode_ctl() must be called after one of
|
||||
* vorbis_encode_setup_managed() or vorbis_encode_setup_vbr(). When used
|
||||
* to modify settings, \ref vorbis_encode_ctl() must be called before \ref
|
||||
* vorbis_encode_setup_init().
|
||||
*
|
||||
* \param vi Pointer to an initialized vorbis_info struct.
|
||||
*
|
||||
* \param number Specifies the desired action; See \ref encctlcodes "the list
|
||||
* of available requests".
|
||||
*
|
||||
* \param arg void * pointing to a data structure matching the request
|
||||
* argument.
|
||||
*
|
||||
* \retval 0 Success. Any further return information (such as the result of a
|
||||
* query) is placed into the storage pointed to by *arg.
|
||||
*
|
||||
* \retval OV_EINVAL Invalid argument, or an attempt to modify a setting after
|
||||
* calling vorbis_encode_setup_init().
|
||||
*
|
||||
* \retval OV_EIMPL Unimplemented or unknown request
|
||||
*/
|
||||
extern int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg);
|
||||
|
||||
/**
|
||||
* \deprecated This is a deprecated interface. Please use vorbis_encode_ctl()
|
||||
* with the \ref ovectl_ratemanage2_arg struct and \ref
|
||||
* OV_ECTL_RATEMANAGE2_GET and \ref OV_ECTL_RATEMANAGE2_SET calls in new code.
|
||||
*
|
||||
* The \ref ovectl_ratemanage_arg structure is used with vorbis_encode_ctl()
|
||||
* and the \ref OV_ECTL_RATEMANAGE_GET, \ref OV_ECTL_RATEMANAGE_SET, \ref
|
||||
* OV_ECTL_RATEMANAGE_AVG, \ref OV_ECTL_RATEMANAGE_HARD calls in order to
|
||||
* query and modify specifics of the encoder's bitrate management
|
||||
* configuration.
|
||||
*/
|
||||
struct ovectl_ratemanage_arg {
|
||||
int management_active; /**< nonzero if bitrate management is active*/
|
||||
/** hard lower limit (in kilobits per second) below which the stream bitrate
|
||||
will never be allowed for any given bitrate_hard_window seconds of time.*/
|
||||
long bitrate_hard_min;
|
||||
/** hard upper limit (in kilobits per second) above which the stream bitrate
|
||||
will never be allowed for any given bitrate_hard_window seconds of time.*/
|
||||
long bitrate_hard_max;
|
||||
/** the window period (in seconds) used to regulate the hard bitrate minimum
|
||||
and maximum*/
|
||||
double bitrate_hard_window;
|
||||
/** soft lower limit (in kilobits per second) below which the average bitrate
|
||||
tracker will start nudging the bitrate higher.*/
|
||||
long bitrate_av_lo;
|
||||
/** soft upper limit (in kilobits per second) above which the average bitrate
|
||||
tracker will start nudging the bitrate lower.*/
|
||||
long bitrate_av_hi;
|
||||
/** the window period (in seconds) used to regulate the average bitrate
|
||||
minimum and maximum.*/
|
||||
double bitrate_av_window;
|
||||
/** Regulates the relative centering of the average and hard windows; in
|
||||
libvorbis 1.0 and 1.0.1, the hard window regulation overlapped but
|
||||
followed the average window regulation. In libvorbis 1.1 a bit-reservoir
|
||||
interface replaces the old windowing interface; the older windowing
|
||||
interface is simulated and this field has no effect.*/
|
||||
double bitrate_av_window_center;
|
||||
};
|
||||
|
||||
/**
|
||||
* \name struct ovectl_ratemanage2_arg
|
||||
*
|
||||
* The ovectl_ratemanage2_arg structure is used with vorbis_encode_ctl() and
|
||||
* the OV_ECTL_RATEMANAGE2_GET and OV_ECTL_RATEMANAGE2_SET calls in order to
|
||||
* query and modify specifics of the encoder's bitrate management
|
||||
* configuration.
|
||||
*
|
||||
*/
|
||||
struct ovectl_ratemanage2_arg {
|
||||
int management_active; /**< nonzero if bitrate management is active */
|
||||
/** Lower allowed bitrate limit in kilobits per second */
|
||||
long bitrate_limit_min_kbps;
|
||||
/** Upper allowed bitrate limit in kilobits per second */
|
||||
long bitrate_limit_max_kbps;
|
||||
long bitrate_limit_reservoir_bits; /**<Size of the bitrate reservoir in bits */
|
||||
/** Regulates the bitrate reservoir's preferred fill level in a range from 0.0
|
||||
* to 1.0; 0.0 tries to bank bits to buffer against future bitrate spikes, 1.0
|
||||
* buffers against future sudden drops in instantaneous bitrate. Default is
|
||||
* 0.1
|
||||
*/
|
||||
double bitrate_limit_reservoir_bias;
|
||||
/** Average bitrate setting in kilobits per second */
|
||||
long bitrate_average_kbps;
|
||||
/** Slew rate limit setting for average bitrate adjustment; sets the minimum
|
||||
* time in seconds the bitrate tracker may swing from one extreme to the
|
||||
* other when boosting or damping average bitrate.
|
||||
*/
|
||||
double bitrate_average_damping;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \name vorbis_encode_ctl() codes
|
||||
*
|
||||
* \anchor encctlcodes
|
||||
*
|
||||
* These values are passed as the \c number parameter of vorbis_encode_ctl().
|
||||
* The type of the referent of that function's \c arg pointer depends on these
|
||||
* codes.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* Query the current encoder bitrate management setting.
|
||||
*
|
||||
*Argument: <tt>struct ovectl_ratemanage2_arg *</tt>
|
||||
*
|
||||
* Used to query the current encoder bitrate management setting. Also used to
|
||||
* initialize fields of an ovectl_ratemanage2_arg structure for use with
|
||||
* \ref OV_ECTL_RATEMANAGE2_SET.
|
||||
*/
|
||||
#define OV_ECTL_RATEMANAGE2_GET 0x14
|
||||
|
||||
/**
|
||||
* Set the current encoder bitrate management settings.
|
||||
*
|
||||
* Argument: <tt>struct ovectl_ratemanage2_arg *</tt>
|
||||
*
|
||||
* Used to set the current encoder bitrate management settings to the values
|
||||
* listed in the ovectl_ratemanage2_arg. Passing a NULL pointer will disable
|
||||
* bitrate management.
|
||||
*/
|
||||
#define OV_ECTL_RATEMANAGE2_SET 0x15
|
||||
|
||||
/**
|
||||
* Returns the current encoder hard-lowpass setting (kHz) in the double
|
||||
* pointed to by arg.
|
||||
*
|
||||
* Argument: <tt>double *</tt>
|
||||
*/
|
||||
#define OV_ECTL_LOWPASS_GET 0x20
|
||||
|
||||
/**
|
||||
* Sets the encoder hard-lowpass to the value (kHz) pointed to by arg. Valid
|
||||
* lowpass settings range from 2 to 99.
|
||||
*
|
||||
* Argument: <tt>double *</tt>
|
||||
*/
|
||||
#define OV_ECTL_LOWPASS_SET 0x21
|
||||
|
||||
/**
|
||||
* Returns the current encoder impulse block setting in the double pointed
|
||||
* to by arg.
|
||||
*
|
||||
* Argument: <tt>double *</tt>
|
||||
*/
|
||||
#define OV_ECTL_IBLOCK_GET 0x30
|
||||
|
||||
/**
|
||||
* Sets the impulse block bias to the the value pointed to by arg.
|
||||
*
|
||||
* Argument: <tt>double *</tt>
|
||||
*
|
||||
* Valid range is -15.0 to 0.0 [default]. A negative impulse block bias will
|
||||
* direct to encoder to use more bits when incoding short blocks that contain
|
||||
* strong impulses, thus improving the accuracy of impulse encoding.
|
||||
*/
|
||||
#define OV_ECTL_IBLOCK_SET 0x31
|
||||
|
||||
/**
|
||||
* Returns the current encoder coupling setting in the int pointed
|
||||
* to by arg.
|
||||
*
|
||||
* Argument: <tt>int *</tt>
|
||||
*/
|
||||
#define OV_ECTL_COUPLING_GET 0x40
|
||||
|
||||
/**
|
||||
* Enables/disables channel coupling in multichannel encoding according to arg.
|
||||
*
|
||||
* Argument: <tt>int *</tt>
|
||||
*
|
||||
* Zero disables channel coupling for multichannel inputs, nonzer enables
|
||||
* channel coupling. Setting has no effect on monophonic encoding or
|
||||
* multichannel counts that do not offer coupling. At present, coupling is
|
||||
* available for stereo and 5.1 encoding.
|
||||
*/
|
||||
#define OV_ECTL_COUPLING_SET 0x41
|
||||
|
||||
/* deprecated rate management supported only for compatibility */
|
||||
|
||||
/**
|
||||
* Old interface to querying bitrate management settings.
|
||||
*
|
||||
* Deprecated after move to bit-reservoir style management in 1.1 rendered
|
||||
* this interface partially obsolete.
|
||||
|
||||
* \deprecated Please use \ref OV_ECTL_RATEMANAGE2_GET instead.
|
||||
*
|
||||
* Argument: <tt>struct ovectl_ratemanage_arg *</tt>
|
||||
*/
|
||||
#define OV_ECTL_RATEMANAGE_GET 0x10
|
||||
/**
|
||||
* Old interface to modifying bitrate management settings.
|
||||
*
|
||||
* deprecated after move to bit-reservoir style management in 1.1 rendered
|
||||
* this interface partially obsolete.
|
||||
*
|
||||
* \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead.
|
||||
*
|
||||
* Argument: <tt>struct ovectl_ratemanage_arg *</tt>
|
||||
*/
|
||||
#define OV_ECTL_RATEMANAGE_SET 0x11
|
||||
/**
|
||||
* Old interface to setting average-bitrate encoding mode.
|
||||
*
|
||||
* Deprecated after move to bit-reservoir style management in 1.1 rendered
|
||||
* this interface partially obsolete.
|
||||
*
|
||||
* \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead.
|
||||
*
|
||||
* Argument: <tt>struct ovectl_ratemanage_arg *</tt>
|
||||
*/
|
||||
#define OV_ECTL_RATEMANAGE_AVG 0x12
|
||||
/**
|
||||
* Old interface to setting bounded-bitrate encoding modes.
|
||||
*
|
||||
* deprecated after move to bit-reservoir style management in 1.1 rendered
|
||||
* this interface partially obsolete.
|
||||
*
|
||||
* \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead.
|
||||
*
|
||||
* Argument: <tt>struct ovectl_ratemanage_arg *</tt>
|
||||
*/
|
||||
#define OV_ECTL_RATEMANAGE_HARD 0x13
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
|
@ -11,7 +11,7 @@
|
|||
********************************************************************
|
||||
|
||||
function: stdio-based convenience library for opening/seeking/decoding
|
||||
last mod: $Id: vorbisfile.h 16243 2009-07-10 02:49:31Z xiphmont $
|
||||
last mod: $Id: vorbisfile.h 17182 2010-04-29 03:48:32Z xiphmont $
|
||||
|
||||
********************************************************************/
|
||||
|
||||
|
@ -47,7 +47,7 @@ typedef struct {
|
|||
|
||||
/* a few sets of convenient callbacks, especially for use under
|
||||
* Windows where ov_open_callbacks() should always be used instead of
|
||||
* ov_open() to avoid problems with incompatable crt.o version linking
|
||||
* ov_open() to avoid problems with incompatible crt.o version linking
|
||||
* issues. */
|
||||
|
||||
static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){
|
||||
|
@ -122,7 +122,7 @@ typedef struct OggVorbis_File {
|
|||
ogg_int64_t *dataoffsets;
|
||||
long *serialnos;
|
||||
ogg_int64_t *pcmlengths; /* overloaded to maintain binary
|
||||
compatability; x2 size, stores both
|
||||
compatibility; x2 size, stores both
|
||||
beginning and end values */
|
||||
vorbis_info *vi;
|
||||
vorbis_comment *vc;
|
||||
|
@ -147,14 +147,14 @@ typedef struct OggVorbis_File {
|
|||
|
||||
|
||||
extern int ov_clear(OggVorbis_File *vf);
|
||||
extern int ov_fopen(char *path,OggVorbis_File *vf);
|
||||
extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
|
||||
extern int ov_fopen(const char *path,OggVorbis_File *vf);
|
||||
extern int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes);
|
||||
extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
|
||||
char *initial, long ibytes, ov_callbacks callbacks);
|
||||
const char *initial, long ibytes, ov_callbacks callbacks);
|
||||
|
||||
extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
|
||||
extern int ov_test(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes);
|
||||
extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
|
||||
char *initial, long ibytes, ov_callbacks callbacks);
|
||||
const char *initial, long ibytes, ov_callbacks callbacks);
|
||||
extern int ov_test_open(OggVorbis_File *vf);
|
||||
|
||||
extern long ov_bitrate(OggVorbis_File *vf,int i);
|
|
@ -1,11 +0,0 @@
|
|||
#ifndef __CONFIG_TYPES_H__
|
||||
#define __CONFIG_TYPES_H__
|
||||
|
||||
/* these are filled in by configure */
|
||||
typedef int16_t ogg_int16_t;
|
||||
typedef u_int16_t ogg_uint16_t;
|
||||
typedef int32_t ogg_int32_t;
|
||||
typedef u_int32_t ogg_uint32_t;
|
||||
typedef int64_t ogg_int64_t;
|
||||
|
||||
#endif
|
|
@ -1,208 +0,0 @@
|
|||
/********************************************************************
|
||||
* *
|
||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* *
|
||||
********************************************************************
|
||||
|
||||
function: toplevel libogg include
|
||||
last mod: $Id: ogg.h 16051 2009-05-27 05:00:06Z xiphmont $
|
||||
|
||||
********************************************************************/
|
||||
#ifndef _OGG_H
|
||||
#define _OGG_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <ogg/os_types.h>
|
||||
|
||||
typedef struct {
|
||||
void *iov_base;
|
||||
size_t iov_len;
|
||||
} ogg_iovec_t;
|
||||
|
||||
typedef struct {
|
||||
long endbyte;
|
||||
int endbit;
|
||||
|
||||
unsigned char *buffer;
|
||||
unsigned char *ptr;
|
||||
long storage;
|
||||
} oggpack_buffer;
|
||||
|
||||
/* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
|
||||
|
||||
typedef struct {
|
||||
unsigned char *header;
|
||||
long header_len;
|
||||
unsigned char *body;
|
||||
long body_len;
|
||||
} ogg_page;
|
||||
|
||||
/* ogg_stream_state contains the current encode/decode state of a logical
|
||||
Ogg bitstream **********************************************************/
|
||||
|
||||
typedef struct {
|
||||
unsigned char *body_data; /* bytes from packet bodies */
|
||||
long body_storage; /* storage elements allocated */
|
||||
long body_fill; /* elements stored; fill mark */
|
||||
long body_returned; /* elements of fill returned */
|
||||
|
||||
|
||||
int *lacing_vals; /* The values that will go to the segment table */
|
||||
ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
|
||||
this way, but it is simple coupled to the
|
||||
lacing fifo */
|
||||
long lacing_storage;
|
||||
long lacing_fill;
|
||||
long lacing_packet;
|
||||
long lacing_returned;
|
||||
|
||||
unsigned char header[282]; /* working space for header encode */
|
||||
int header_fill;
|
||||
|
||||
int e_o_s; /* set when we have buffered the last packet in the
|
||||
logical bitstream */
|
||||
int b_o_s; /* set after we've written the initial page
|
||||
of a logical bitstream */
|
||||
long serialno;
|
||||
long pageno;
|
||||
ogg_int64_t packetno; /* sequence number for decode; the framing
|
||||
knows where there's a hole in the data,
|
||||
but we need coupling so that the codec
|
||||
(which is in a seperate abstraction
|
||||
layer) also knows about the gap */
|
||||
ogg_int64_t granulepos;
|
||||
|
||||
} ogg_stream_state;
|
||||
|
||||
/* ogg_packet is used to encapsulate the data and metadata belonging
|
||||
to a single raw Ogg/Vorbis packet *************************************/
|
||||
|
||||
typedef struct {
|
||||
unsigned char *packet;
|
||||
long bytes;
|
||||
long b_o_s;
|
||||
long e_o_s;
|
||||
|
||||
ogg_int64_t granulepos;
|
||||
|
||||
ogg_int64_t packetno; /* sequence number for decode; the framing
|
||||
knows where there's a hole in the data,
|
||||
but we need coupling so that the codec
|
||||
(which is in a seperate abstraction
|
||||
layer) also knows about the gap */
|
||||
} ogg_packet;
|
||||
|
||||
typedef struct {
|
||||
unsigned char *data;
|
||||
int storage;
|
||||
int fill;
|
||||
int returned;
|
||||
|
||||
int unsynced;
|
||||
int headerbytes;
|
||||
int bodybytes;
|
||||
} ogg_sync_state;
|
||||
|
||||
/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
|
||||
|
||||
extern void oggpack_writeinit(oggpack_buffer *b);
|
||||
extern int oggpack_writecheck(oggpack_buffer *b);
|
||||
extern void oggpack_writetrunc(oggpack_buffer *b,long bits);
|
||||
extern void oggpack_writealign(oggpack_buffer *b);
|
||||
extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits);
|
||||
extern void oggpack_reset(oggpack_buffer *b);
|
||||
extern void oggpack_writeclear(oggpack_buffer *b);
|
||||
extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
|
||||
extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
|
||||
extern long oggpack_look(oggpack_buffer *b,int bits);
|
||||
extern long oggpack_look1(oggpack_buffer *b);
|
||||
extern void oggpack_adv(oggpack_buffer *b,int bits);
|
||||
extern void oggpack_adv1(oggpack_buffer *b);
|
||||
extern long oggpack_read(oggpack_buffer *b,int bits);
|
||||
extern long oggpack_read1(oggpack_buffer *b);
|
||||
extern long oggpack_bytes(oggpack_buffer *b);
|
||||
extern long oggpack_bits(oggpack_buffer *b);
|
||||
extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
|
||||
|
||||
extern void oggpackB_writeinit(oggpack_buffer *b);
|
||||
extern int oggpackB_writecheck(oggpack_buffer *b);
|
||||
extern void oggpackB_writetrunc(oggpack_buffer *b,long bits);
|
||||
extern void oggpackB_writealign(oggpack_buffer *b);
|
||||
extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits);
|
||||
extern void oggpackB_reset(oggpack_buffer *b);
|
||||
extern void oggpackB_writeclear(oggpack_buffer *b);
|
||||
extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
|
||||
extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits);
|
||||
extern long oggpackB_look(oggpack_buffer *b,int bits);
|
||||
extern long oggpackB_look1(oggpack_buffer *b);
|
||||
extern void oggpackB_adv(oggpack_buffer *b,int bits);
|
||||
extern void oggpackB_adv1(oggpack_buffer *b);
|
||||
extern long oggpackB_read(oggpack_buffer *b,int bits);
|
||||
extern long oggpackB_read1(oggpack_buffer *b);
|
||||
extern long oggpackB_bytes(oggpack_buffer *b);
|
||||
extern long oggpackB_bits(oggpack_buffer *b);
|
||||
extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b);
|
||||
|
||||
/* Ogg BITSTREAM PRIMITIVES: encoding **************************/
|
||||
|
||||
extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
|
||||
extern int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov,
|
||||
int count, long e_o_s, ogg_int64_t granulepos);
|
||||
extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
|
||||
extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
|
||||
|
||||
/* Ogg BITSTREAM PRIMITIVES: decoding **************************/
|
||||
|
||||
extern int ogg_sync_init(ogg_sync_state *oy);
|
||||
extern int ogg_sync_clear(ogg_sync_state *oy);
|
||||
extern int ogg_sync_reset(ogg_sync_state *oy);
|
||||
extern int ogg_sync_destroy(ogg_sync_state *oy);
|
||||
extern int ogg_sync_check(ogg_sync_state *oy);
|
||||
|
||||
extern char *ogg_sync_buffer(ogg_sync_state *oy, long size);
|
||||
extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
|
||||
extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
|
||||
extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
|
||||
extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
|
||||
extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
|
||||
extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
|
||||
|
||||
/* Ogg BITSTREAM PRIMITIVES: general ***************************/
|
||||
|
||||
extern int ogg_stream_init(ogg_stream_state *os,int serialno);
|
||||
extern int ogg_stream_clear(ogg_stream_state *os);
|
||||
extern int ogg_stream_reset(ogg_stream_state *os);
|
||||
extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
|
||||
extern int ogg_stream_destroy(ogg_stream_state *os);
|
||||
extern int ogg_stream_check(ogg_stream_state *os);
|
||||
extern int ogg_stream_eos(ogg_stream_state *os);
|
||||
|
||||
extern void ogg_page_checksum_set(ogg_page *og);
|
||||
|
||||
extern int ogg_page_version(const ogg_page *og);
|
||||
extern int ogg_page_continued(const ogg_page *og);
|
||||
extern int ogg_page_bos(const ogg_page *og);
|
||||
extern int ogg_page_eos(const ogg_page *og);
|
||||
extern ogg_int64_t ogg_page_granulepos(const ogg_page *og);
|
||||
extern int ogg_page_serialno(const ogg_page *og);
|
||||
extern long ogg_page_pageno(const ogg_page *og);
|
||||
extern int ogg_page_packets(const ogg_page *og);
|
||||
|
||||
extern void ogg_packet_clear(ogg_packet *op);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _OGG_H */
|
|
@ -1,139 +0,0 @@
|
|||
/********************************************************************
|
||||
* *
|
||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* *
|
||||
********************************************************************
|
||||
|
||||
function: #ifdef jail to whip a few platforms into the UNIX ideal.
|
||||
last mod: $Id: os_types.h 14997 2008-06-04 03:27:18Z ivo $
|
||||
|
||||
********************************************************************/
|
||||
#ifndef _OS_TYPES_H
|
||||
#define _OS_TYPES_H
|
||||
|
||||
/* make it easy on the folks that want to compile the libs with a
|
||||
different malloc than stdlib */
|
||||
#define _ogg_malloc malloc
|
||||
#define _ogg_calloc calloc
|
||||
#define _ogg_realloc realloc
|
||||
#define _ogg_free free
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
# if defined(__CYGWIN__)
|
||||
# include <stdint.h>
|
||||
typedef int16_t ogg_int16_t;
|
||||
typedef uint16_t ogg_uint16_t;
|
||||
typedef int32_t ogg_int32_t;
|
||||
typedef uint32_t ogg_uint32_t;
|
||||
typedef int64_t ogg_int64_t;
|
||||
typedef uint64_t ogg_uint64_t;
|
||||
# elif defined(__MINGW32__)
|
||||
# include <sys/types.h>
|
||||
typedef short ogg_int16_t;
|
||||
typedef unsigned short ogg_uint16_t;
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long ogg_int64_t;
|
||||
typedef unsigned long long ogg_uint64_t;
|
||||
# elif defined(__MWERKS__)
|
||||
typedef long long ogg_int64_t;
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef short ogg_int16_t;
|
||||
typedef unsigned short ogg_uint16_t;
|
||||
# else
|
||||
/* MSVC/Borland */
|
||||
typedef __int64 ogg_int64_t;
|
||||
typedef __int32 ogg_int32_t;
|
||||
typedef unsigned __int32 ogg_uint32_t;
|
||||
typedef __int16 ogg_int16_t;
|
||||
typedef unsigned __int16 ogg_uint16_t;
|
||||
# endif
|
||||
|
||||
#elif defined(__MACOS__)
|
||||
|
||||
# include <sys/types.h>
|
||||
typedef SInt16 ogg_int16_t;
|
||||
typedef UInt16 ogg_uint16_t;
|
||||
typedef SInt32 ogg_int32_t;
|
||||
typedef UInt32 ogg_uint32_t;
|
||||
typedef SInt64 ogg_int64_t;
|
||||
|
||||
#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
|
||||
|
||||
# include <sys/types.h>
|
||||
typedef int16_t ogg_int16_t;
|
||||
typedef u_int16_t ogg_uint16_t;
|
||||
typedef int32_t ogg_int32_t;
|
||||
typedef u_int32_t ogg_uint32_t;
|
||||
typedef int64_t ogg_int64_t;
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
|
||||
/* Haiku */
|
||||
# include <sys/types.h>
|
||||
typedef short ogg_int16_t;
|
||||
typedef unsigned short ogg_uint16_t;
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long ogg_int64_t;
|
||||
|
||||
#elif defined(__BEOS__)
|
||||
|
||||
/* Be */
|
||||
# include <inttypes.h>
|
||||
typedef int16_t ogg_int16_t;
|
||||
typedef u_int16_t ogg_uint16_t;
|
||||
typedef int32_t ogg_int32_t;
|
||||
typedef u_int32_t ogg_uint32_t;
|
||||
typedef int64_t ogg_int64_t;
|
||||
|
||||
#elif defined (__EMX__)
|
||||
|
||||
/* OS/2 GCC */
|
||||
typedef short ogg_int16_t;
|
||||
typedef unsigned short ogg_uint16_t;
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long ogg_int64_t;
|
||||
|
||||
#elif defined (DJGPP)
|
||||
|
||||
/* DJGPP */
|
||||
typedef short ogg_int16_t;
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long ogg_int64_t;
|
||||
|
||||
#elif defined(R5900)
|
||||
|
||||
/* PS2 EE */
|
||||
typedef long ogg_int64_t;
|
||||
typedef int ogg_int32_t;
|
||||
typedef unsigned ogg_uint32_t;
|
||||
typedef short ogg_int16_t;
|
||||
|
||||
#elif defined(__SYMBIAN32__)
|
||||
|
||||
/* Symbian GCC */
|
||||
typedef signed short ogg_int16_t;
|
||||
typedef unsigned short ogg_uint16_t;
|
||||
typedef signed int ogg_int32_t;
|
||||
typedef unsigned int ogg_uint32_t;
|
||||
typedef long long int ogg_int64_t;
|
||||
|
||||
#else
|
||||
|
||||
# include <sys/types.h>
|
||||
# include <ogg/config_types.h>
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _OS_TYPES_H */
|
|
@ -1,591 +0,0 @@
|
|||
/********************************************************************
|
||||
* *
|
||||
* THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
|
||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* *
|
||||
********************************************************************
|
||||
|
||||
function:
|
||||
last mod: $Id: theora.h,v 1.8 2004/03/15 22:17:32 derf Exp $
|
||||
|
||||
********************************************************************/
|
||||
|
||||
/**\mainpage
|
||||
*
|
||||
* \section intro Introduction
|
||||
*
|
||||
* This is the documentation for <tt>libtheora</tt> C API.
|
||||
* The current reference
|
||||
* implementation for <a href="http://www.theora.org/">Theora</a>, a free,
|
||||
* patent-unencumbered video codec.
|
||||
* Theora is derived from On2's VP3 codec with additional features and
|
||||
* integration with Ogg multimedia formats by
|
||||
* <a href="http://www.xiph.org/">the Xiph.Org Foundation</a>.
|
||||
* Complete documentation of the format itself is available in
|
||||
* <a href="http://www.theora.org/doc/Theora.pdf">the Theora
|
||||
* specification</a>.
|
||||
*
|
||||
* \subsection Organization
|
||||
*
|
||||
* The functions documented here are actually subdivided into three
|
||||
* separate libraries:
|
||||
* - <tt>libtheoraenc</tt> contains the encoder interface,
|
||||
* described in \ref encfuncs.
|
||||
* - <tt>libtheoradec</tt> contains the decoder interface and
|
||||
* routines shared with the encoder.
|
||||
* You must also link to this if you link to <tt>libtheoraenc</tt>.
|
||||
* The routines in this library are described in \ref decfuncs and
|
||||
* \ref basefuncs.
|
||||
* - <tt>libtheora</tt> contains the \ref oldfuncs.
|
||||
*
|
||||
* New code should link to <tt>libtheoradec</tt> and, if using encoder
|
||||
* features, <tt>libtheoraenc</tt>. Together these two export both
|
||||
* the standard and the legacy API, so this is all that is needed by
|
||||
* any code. The older <tt>libtheora</tt> library is provided just for
|
||||
* compatibility with older build configurations.
|
||||
*
|
||||
* In general the recommended 1.x API symbols can be distinguished
|
||||
* by their <tt>th_</tt> or <tt>TH_</tt> namespace prefix.
|
||||
* The older, legacy API uses <tt>theora_</tt> or <tt>OC_</tt>
|
||||
* prefixes instead.
|
||||
*/
|
||||
|
||||
/**\file
|
||||
* The shared <tt>libtheoradec</tt> and <tt>libtheoraenc</tt> C API.
|
||||
* You don't need to include this directly.*/
|
||||
|
||||
#if !defined(_O_THEORA_CODEC_H_)
|
||||
# define _O_THEORA_CODEC_H_ (1)
|
||||
# include <ogg/ogg.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**\name Return codes*/
|
||||
/*@{*/
|
||||
/**An invalid pointer was provided.*/
|
||||
#define TH_EFAULT (-1)
|
||||
/**An invalid argument was provided.*/
|
||||
#define TH_EINVAL (-10)
|
||||
/**The contents of the header were incomplete, invalid, or unexpected.*/
|
||||
#define TH_EBADHEADER (-20)
|
||||
/**The header does not belong to a Theora stream.*/
|
||||
#define TH_ENOTFORMAT (-21)
|
||||
/**The bitstream version is too high.*/
|
||||
#define TH_EVERSION (-22)
|
||||
/**The specified function is not implemented.*/
|
||||
#define TH_EIMPL (-23)
|
||||
/**There were errors in the video data packet.*/
|
||||
#define TH_EBADPACKET (-24)
|
||||
/**The decoded packet represented a dropped frame.
|
||||
The player can continue to display the current frame, as the contents of the
|
||||
decoded frame buffer have not changed.*/
|
||||
#define TH_DUPFRAME (1)
|
||||
/*@}*/
|
||||
|
||||
/**The currently defined color space tags.
|
||||
* See <a href="http://www.theora.org/doc/Theora.pdf">the Theora
|
||||
* specification</a>, Chapter 4, for exact details on the meaning
|
||||
* of each of these color spaces.*/
|
||||
typedef enum{
|
||||
/**The color space was not specified at the encoder.
|
||||
It may be conveyed by an external means.*/
|
||||
TH_CS_UNSPECIFIED,
|
||||
/**A color space designed for NTSC content.*/
|
||||
TH_CS_ITU_REC_470M,
|
||||
/**A color space designed for PAL/SECAM content.*/
|
||||
TH_CS_ITU_REC_470BG,
|
||||
/**The total number of currently defined color spaces.*/
|
||||
TH_CS_NSPACES
|
||||
}th_colorspace;
|
||||
|
||||
/**The currently defined pixel format tags.
|
||||
* See <a href="http://www.theora.org/doc/Theora.pdf">the Theora
|
||||
* specification</a>, Section 4.4, for details on the precise sample
|
||||
* locations.*/
|
||||
typedef enum{
|
||||
/**Chroma decimation by 2 in both the X and Y directions (4:2:0).
|
||||
The Cb and Cr chroma planes are half the width and half the
|
||||
height of the luma plane.*/
|
||||
TH_PF_420,
|
||||
/**Currently reserved.*/
|
||||
TH_PF_RSVD,
|
||||
/**Chroma decimation by 2 in the X direction (4:2:2).
|
||||
The Cb and Cr chroma planes are half the width of the luma plane, but full
|
||||
height.*/
|
||||
TH_PF_422,
|
||||
/**No chroma decimation (4:4:4).
|
||||
The Cb and Cr chroma planes are full width and full height.*/
|
||||
TH_PF_444,
|
||||
/**The total number of currently defined pixel formats.*/
|
||||
TH_PF_NFORMATS
|
||||
}th_pixel_fmt;
|
||||
|
||||
|
||||
|
||||
/**A buffer for a single color plane in an uncompressed image.
|
||||
* This contains the image data in a left-to-right, top-down format.
|
||||
* Each row of pixels is stored contiguously in memory, but successive
|
||||
* rows need not be.
|
||||
* Use \a stride to compute the offset of the next row.
|
||||
* The encoder accepts both positive \a stride values (top-down in memory)
|
||||
* and negative (bottom-up in memory).
|
||||
* The decoder currently always generates images with positive strides.*/
|
||||
typedef struct{
|
||||
/**The width of this plane.*/
|
||||
int width;
|
||||
/**The height of this plane.*/
|
||||
int height;
|
||||
/**The offset in bytes between successive rows.*/
|
||||
int stride;
|
||||
/**A pointer to the beginning of the first row.*/
|
||||
unsigned char *data;
|
||||
}th_img_plane;
|
||||
|
||||
/**A complete image buffer for an uncompressed frame.
|
||||
* The chroma planes may be decimated by a factor of two in either
|
||||
* direction, as indicated by th_info#pixel_fmt.
|
||||
* The width and height of the Y' plane must be multiples of 16.
|
||||
* They may need to be cropped for display, using the rectangle
|
||||
* specified by th_info#pic_x, th_info#pic_y, th_info#pic_width,
|
||||
* and th_info#pic_height.
|
||||
* All samples are 8 bits.
|
||||
* \note The term YUV often used to describe a colorspace is ambiguous.
|
||||
* The exact parameters of the RGB to YUV conversion process aside, in
|
||||
* many contexts the U and V channels actually have opposite meanings.
|
||||
* To avoid this confusion, we are explicit: the name of the color
|
||||
* channels are Y'CbCr, and they appear in that order, always.
|
||||
* The prime symbol denotes that the Y channel is non-linear.
|
||||
* Cb and Cr stand for "Chroma blue" and "Chroma red", respectively.*/
|
||||
typedef th_img_plane th_ycbcr_buffer[3];
|
||||
|
||||
/**Theora bitstream information.
|
||||
* This contains the basic playback parameters for a stream, and corresponds to
|
||||
* the initial 'info' header packet.
|
||||
* To initialize an encoder, the application fills in this structure and
|
||||
* passes it to th_encode_alloc().
|
||||
* A default encoding mode is chosen based on the values of the #quality and
|
||||
* #target_bitrate fields.
|
||||
* On decode, it is filled in by th_decode_headerin(), and then passed to
|
||||
* th_decode_alloc().
|
||||
*
|
||||
* Encoded Theora frames must be a multiple of 16 in size;
|
||||
* this is what the #frame_width and #frame_height members represent.
|
||||
* To handle arbitrary picture sizes, a crop rectangle is specified in the
|
||||
* #pic_x, #pic_y, #pic_width and #pic_height members.
|
||||
*
|
||||
* All frame buffers contain pointers to the full, padded frame.
|
||||
* However, the current encoder <em>will not</em> reference pixels outside of
|
||||
* the cropped picture region, and the application does not need to fill them
|
||||
* in.
|
||||
* The decoder <em>will</em> allocate storage for a full frame, but the
|
||||
* application <em>should not</em> rely on the padding containing sensible
|
||||
* data.
|
||||
*
|
||||
* It is also generally recommended that the offsets and sizes should still be
|
||||
* multiples of 2 to avoid chroma sampling shifts when chroma is sub-sampled.
|
||||
* See <a href="http://www.theora.org/doc/Theora.pdf">the Theora
|
||||
* specification</a>, Section 4.4, for more details.
|
||||
*
|
||||
* Frame rate, in frames per second, is stored as a rational fraction, as is
|
||||
* the pixel aspect ratio.
|
||||
* Note that this refers to the aspect ratio of the individual pixels, not of
|
||||
* the overall frame itself.
|
||||
* The frame aspect ratio can be computed from pixel aspect ratio using the
|
||||
* image dimensions.*/
|
||||
typedef struct{
|
||||
/**\name Theora version
|
||||
* Bitstream version information.*/
|
||||
/*@{*/
|
||||
unsigned char version_major;
|
||||
unsigned char version_minor;
|
||||
unsigned char version_subminor;
|
||||
/*@}*/
|
||||
/**The encoded frame width.
|
||||
* This must be a multiple of 16, and less than 1048576.*/
|
||||
ogg_uint32_t frame_width;
|
||||
/**The encoded frame height.
|
||||
* This must be a multiple of 16, and less than 1048576.*/
|
||||
ogg_uint32_t frame_height;
|
||||
/**The displayed picture width.
|
||||
* This must be no larger than width.*/
|
||||
ogg_uint32_t pic_width;
|
||||
/**The displayed picture height.
|
||||
* This must be no larger than height.*/
|
||||
ogg_uint32_t pic_height;
|
||||
/**The X offset of the displayed picture.
|
||||
* This must be no larger than #frame_width-#pic_width or 255, whichever is
|
||||
* smaller.*/
|
||||
ogg_uint32_t pic_x;
|
||||
/**The Y offset of the displayed picture.
|
||||
* This must be no larger than #frame_height-#pic_height, and
|
||||
* #frame_height-#pic_height-#pic_y must be no larger than 255.
|
||||
* This slightly funny restriction is due to the fact that the offset is
|
||||
* specified from the top of the image for consistency with the standard
|
||||
* graphics left-handed coordinate system used throughout this API, while
|
||||
* it is stored in the encoded stream as an offset from the bottom.*/
|
||||
ogg_uint32_t pic_y;
|
||||
/**\name Frame rate
|
||||
* The frame rate, as a fraction.
|
||||
* If either is 0, the frame rate is undefined.*/
|
||||
/*@{*/
|
||||
ogg_uint32_t fps_numerator;
|
||||
ogg_uint32_t fps_denominator;
|
||||
/*@}*/
|
||||
/**\name Aspect ratio
|
||||
* The aspect ratio of the pixels.
|
||||
* If either value is zero, the aspect ratio is undefined.
|
||||
* If not specified by any external means, 1:1 should be assumed.
|
||||
* The aspect ratio of the full picture can be computed as
|
||||
* \code
|
||||
* aspect_numerator*pic_width/(aspect_denominator*pic_height).
|
||||
* \endcode */
|
||||
/*@{*/
|
||||
ogg_uint32_t aspect_numerator;
|
||||
ogg_uint32_t aspect_denominator;
|
||||
/*@}*/
|
||||
/**The color space.*/
|
||||
th_colorspace colorspace;
|
||||
/**The pixel format.*/
|
||||
th_pixel_fmt pixel_fmt;
|
||||
/**The target bit-rate in bits per second.
|
||||
If initializing an encoder with this struct, set this field to a non-zero
|
||||
value to activate CBR encoding by default.*/
|
||||
int target_bitrate;
|
||||
/**The target quality level.
|
||||
Valid values range from 0 to 63, inclusive, with higher values giving
|
||||
higher quality.
|
||||
If initializing an encoder with this struct, and #target_bitrate is set
|
||||
to zero, VBR encoding at this quality will be activated by default.*/
|
||||
/*Currently this is set so that a qi of 0 corresponds to distortions of 24
|
||||
times the JND, and each increase by 16 halves that value.
|
||||
This gives us fine discrimination at low qualities, yet effective rate
|
||||
control at high qualities.
|
||||
The qi value 63 is special, however.
|
||||
For this, the highest quality, we use one half of a JND for our threshold.
|
||||
Due to the lower bounds placed on allowable quantizers in Theora, we will
|
||||
not actually be able to achieve quality this good, but this should
|
||||
provide as close to visually lossless quality as Theora is capable of.
|
||||
We could lift the quantizer restrictions without breaking VP3.1
|
||||
compatibility, but this would result in quantized coefficients that are
|
||||
too large for the current bitstream to be able to store.
|
||||
We'd have to redesign the token syntax to store these large coefficients,
|
||||
which would make transcoding complex.*/
|
||||
int quality;
|
||||
/**The amount to shift to extract the last keyframe number from the granule
|
||||
* position.
|
||||
* This can be at most 31.
|
||||
* th_info_init() will set this to a default value (currently <tt>6</tt>,
|
||||
* which is good for streaming applications), but you can set it to 0 to
|
||||
* make every frame a keyframe.
|
||||
* The maximum distance between key frames is
|
||||
* <tt>1<<#keyframe_granule_shift</tt>.
|
||||
* The keyframe frequency can be more finely controlled with
|
||||
* #TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE, which can also be adjusted
|
||||
* during encoding (for example, to force the next frame to be a keyframe),
|
||||
* but it cannot be set larger than the amount permitted by this field after
|
||||
* the headers have been output.*/
|
||||
int keyframe_granule_shift;
|
||||
}th_info;
|
||||
|
||||
/**The comment information.
|
||||
*
|
||||
* This structure holds the in-stream metadata corresponding to
|
||||
* the 'comment' header packet.
|
||||
* The comment header is meant to be used much like someone jotting a quick
|
||||
* note on the label of a video.
|
||||
* It should be a short, to the point text note that can be more than a couple
|
||||
* words, but not more than a short paragraph.
|
||||
*
|
||||
* The metadata is stored as a series of (tag, value) pairs, in
|
||||
* length-encoded string vectors.
|
||||
* The first occurrence of the '=' character delimits the tag and value.
|
||||
* A particular tag may occur more than once, and order is significant.
|
||||
* The character set encoding for the strings is always UTF-8, but the tag
|
||||
* names are limited to ASCII, and treated as case-insensitive.
|
||||
* See <a href="http://www.theora.org/doc/Theora.pdf">the Theora
|
||||
* specification</a>, Section 6.3.3 for details.
|
||||
*
|
||||
* In filling in this structure, th_decode_headerin() will null-terminate
|
||||
* the user_comment strings for safety.
|
||||
* However, the bitstream format itself treats them as 8-bit clean vectors,
|
||||
* possibly containing null characters, and so the length array should be
|
||||
* treated as their authoritative length.
|
||||
*/
|
||||
typedef struct th_comment{
|
||||
/**The array of comment string vectors.*/
|
||||
char **user_comments;
|
||||
/**An array of the corresponding length of each vector, in bytes.*/
|
||||
int *comment_lengths;
|
||||
/**The total number of comment strings.*/
|
||||
int comments;
|
||||
/**The null-terminated vendor string.
|
||||
This identifies the software used to encode the stream.*/
|
||||
char *vendor;
|
||||
}th_comment;
|
||||
|
||||
|
||||
|
||||
/**A single base matrix.*/
|
||||
typedef unsigned char th_quant_base[64];
|
||||
|
||||
/**A set of \a qi ranges.*/
|
||||
typedef struct{
|
||||
/**The number of ranges in the set.*/
|
||||
int nranges;
|
||||
/**The size of each of the #nranges ranges.
|
||||
These must sum to 63.*/
|
||||
const int *sizes;
|
||||
/**#nranges <tt>+1</tt> base matrices.
|
||||
Matrices \a i and <tt>i+1</tt> form the endpoints of range \a i.*/
|
||||
const th_quant_base *base_matrices;
|
||||
}th_quant_ranges;
|
||||
|
||||
/**A complete set of quantization parameters.
|
||||
The quantizer for each coefficient is calculated as:
|
||||
\code
|
||||
Q=MAX(MIN(qmin[qti][ci!=0],scale[ci!=0][qi]*base[qti][pli][qi][ci]/100),
|
||||
1024).
|
||||
\endcode
|
||||
|
||||
\a qti is the quantization type index: 0 for intra, 1 for inter.
|
||||
<tt>ci!=0</tt> is 0 for the DC coefficient and 1 for AC coefficients.
|
||||
\a qi is the quality index, ranging between 0 (low quality) and 63 (high
|
||||
quality).
|
||||
\a pli is the color plane index: 0 for Y', 1 for Cb, 2 for Cr.
|
||||
\a ci is the DCT coefficient index.
|
||||
Coefficient indices correspond to the normal 2D DCT block
|
||||
ordering--row-major with low frequencies first--\em not zig-zag order.
|
||||
|
||||
Minimum quantizers are constant, and are given by:
|
||||
\code
|
||||
qmin[2][2]={{4,2},{8,4}}.
|
||||
\endcode
|
||||
|
||||
Parameters that can be stored in the bitstream are as follows:
|
||||
- The two scale matrices ac_scale and dc_scale.
|
||||
\code
|
||||
scale[2][64]={dc_scale,ac_scale}.
|
||||
\endcode
|
||||
- The base matrices for each \a qi, \a qti and \a pli (up to 384 in all).
|
||||
In order to avoid storing a full 384 base matrices, only a sparse set of
|
||||
matrices are stored, and the rest are linearly interpolated.
|
||||
This is done as follows.
|
||||
For each \a qti and \a pli, a series of \a n \a qi ranges is defined.
|
||||
The size of each \a qi range can vary arbitrarily, but they must sum to
|
||||
63.
|
||||
Then, <tt>n+1</tt> matrices are specified, one for each endpoint of the
|
||||
ranges.
|
||||
For interpolation purposes, each range's endpoints are the first \a qi
|
||||
value it contains and one past the last \a qi value it contains.
|
||||
Fractional values are rounded to the nearest integer, with ties rounded
|
||||
away from zero.
|
||||
|
||||
Base matrices are stored by reference, so if the same matrices are used
|
||||
multiple times, they will only appear once in the bitstream.
|
||||
The bitstream is also capable of omitting an entire set of ranges and
|
||||
its associated matrices if they are the same as either the previous
|
||||
set (indexed in row-major order) or if the inter set is the same as the
|
||||
intra set.
|
||||
|
||||
- Loop filter limit values.
|
||||
The same limits are used for the loop filter in all color planes, despite
|
||||
potentially differing levels of quantization in each.
|
||||
|
||||
For the current encoder, <tt>scale[ci!=0][qi]</tt> must be no greater
|
||||
than <tt>scale[ci!=0][qi-1]</tt> and <tt>base[qti][pli][qi][ci]</tt> must
|
||||
be no greater than <tt>base[qti][pli][qi-1][ci]</tt>.
|
||||
These two conditions ensure that the actual quantizer for a given \a qti,
|
||||
\a pli, and \a ci does not increase as \a qi increases.
|
||||
This is not required by the decoder.*/
|
||||
typedef struct{
|
||||
/**The DC scaling factors.*/
|
||||
ogg_uint16_t dc_scale[64];
|
||||
/**The AC scaling factors.*/
|
||||
ogg_uint16_t ac_scale[64];
|
||||
/**The loop filter limit values.*/
|
||||
unsigned char loop_filter_limits[64];
|
||||
/**The \a qi ranges for each \a ci and \a pli.*/
|
||||
th_quant_ranges qi_ranges[2][3];
|
||||
}th_quant_info;
|
||||
|
||||
|
||||
|
||||
/**The number of Huffman tables used by Theora.*/
|
||||
#define TH_NHUFFMAN_TABLES (80)
|
||||
/**The number of DCT token values in each table.*/
|
||||
#define TH_NDCT_TOKENS (32)
|
||||
|
||||
/**A Huffman code for a Theora DCT token.
|
||||
* Each set of Huffman codes in a given table must form a complete, prefix-free
|
||||
* code.
|
||||
* There is no requirement that all the tokens in a table have a valid code,
|
||||
* but the current encoder is not optimized to take advantage of this.
|
||||
* If each of the five grouops of 16 tables does not contain at least one table
|
||||
* with a code for every token, then the encoder may fail to encode certain
|
||||
* frames.
|
||||
* The complete table in the first group of 16 does not have to be in the same
|
||||
* place as the complete table in the other groups, but the complete tables in
|
||||
* the remaining four groups must all be in the same place.*/
|
||||
typedef struct{
|
||||
/**The bit pattern for the code, with the LSbit of the pattern aligned in
|
||||
* the LSbit of the word.*/
|
||||
ogg_uint32_t pattern;
|
||||
/**The number of bits in the code.
|
||||
* This must be between 0 and 32, inclusive.*/
|
||||
int nbits;
|
||||
}th_huff_code;
|
||||
|
||||
|
||||
|
||||
/**\defgroup basefuncs Functions Shared by Encode and Decode*/
|
||||
/*@{*/
|
||||
/**\name Basic shared functions*/
|
||||
/*@{*/
|
||||
/**Retrieves a human-readable string to identify the library vendor and
|
||||
* version.
|
||||
* \return the version string.*/
|
||||
extern const char *th_version_string(void);
|
||||
/**Retrieves the library version number.
|
||||
* This is the highest bitstream version that the encoder library will produce,
|
||||
* or that the decoder library can decode.
|
||||
* This number is composed of a 16-bit major version, 8-bit minor version
|
||||
* and 8 bit sub-version, composed as follows:
|
||||
* \code
|
||||
* (VERSION_MAJOR<<16)+(VERSION_MINOR<<8)+(VERSION_SUBMINOR)
|
||||
* \endcode
|
||||
* \return the version number.*/
|
||||
extern ogg_uint32_t th_version_number(void);
|
||||
/**Converts a granule position to an absolute frame index, starting at
|
||||
* <tt>0</tt>.
|
||||
* The granule position is interpreted in the context of a given
|
||||
* #th_enc_ctx or #th_dec_ctx handle (either will suffice).
|
||||
* \param _encdec A previously allocated #th_enc_ctx or #th_dec_ctx
|
||||
* handle.
|
||||
* \param _granpos The granule position to convert.
|
||||
* \returns The absolute frame index corresponding to \a _granpos.
|
||||
* \retval -1 The given granule position was invalid (i.e. negative).*/
|
||||
extern ogg_int64_t th_granule_frame(void *_encdec,ogg_int64_t _granpos);
|
||||
/**Converts a granule position to an absolute time in seconds.
|
||||
* The granule position is interpreted in the context of a given
|
||||
* #th_enc_ctx or #th_dec_ctx handle (either will suffice).
|
||||
* \param _encdec A previously allocated #th_enc_ctx or #th_dec_ctx
|
||||
* handle.
|
||||
* \param _granpos The granule position to convert.
|
||||
* \return The absolute time in seconds corresponding to \a _granpos.
|
||||
* This is the "end time" for the frame, or the latest time it should
|
||||
* be displayed.
|
||||
* It is not the presentation time.
|
||||
* \retval -1 The given granule position was invalid (i.e. negative).*/
|
||||
extern double th_granule_time(void *_encdec,ogg_int64_t _granpos);
|
||||
/**Determines whether a Theora packet is a header or not.
|
||||
* This function does no verification beyond checking the packet type bit, so
|
||||
* it should not be used for bitstream identification; use
|
||||
* th_decode_headerin() for that.
|
||||
* As per the Theora specification, an empty (0-byte) packet is treated as a
|
||||
* data packet (a delta frame with no coded blocks).
|
||||
* \param _op An <tt>ogg_packet</tt> containing encoded Theora data.
|
||||
* \retval 1 The packet is a header packet
|
||||
* \retval 0 The packet is a video data packet.*/
|
||||
extern int th_packet_isheader(ogg_packet *_op);
|
||||
/**Determines whether a theora packet is a key frame or not.
|
||||
* This function does no verification beyond checking the packet type and
|
||||
* key frame bits, so it should not be used for bitstream identification; use
|
||||
* th_decode_headerin() for that.
|
||||
* As per the Theora specification, an empty (0-byte) packet is treated as a
|
||||
* delta frame (with no coded blocks).
|
||||
* \param _op An <tt>ogg_packet</tt> containing encoded Theora data.
|
||||
* \retval 1 The packet contains a key frame.
|
||||
* \retval 0 The packet contains a delta frame.
|
||||
* \retval -1 The packet is not a video data packet.*/
|
||||
extern int th_packet_iskeyframe(ogg_packet *_op);
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**\name Functions for manipulating header data*/
|
||||
/*@{*/
|
||||
/**Initializes a th_info structure.
|
||||
* This should be called on a freshly allocated #th_info structure before
|
||||
* attempting to use it.
|
||||
* \param _info The #th_info struct to initialize.*/
|
||||
extern void th_info_init(th_info *_info);
|
||||
/**Clears a #th_info structure.
|
||||
* This should be called on a #th_info structure after it is no longer
|
||||
* needed.
|
||||
* \param _info The #th_info struct to clear.*/
|
||||
extern void th_info_clear(th_info *_info);
|
||||
|
||||
/**Initialize a #th_comment structure.
|
||||
* This should be called on a freshly allocated #th_comment structure
|
||||
* before attempting to use it.
|
||||
* \param _tc The #th_comment struct to initialize.*/
|
||||
extern void th_comment_init(th_comment *_tc);
|
||||
/**Add a comment to an initialized #th_comment structure.
|
||||
* \note Neither th_comment_add() nor th_comment_add_tag() support
|
||||
* comments containing null values, although the bitstream format does
|
||||
* support them.
|
||||
* To add such comments you will need to manipulate the #th_comment
|
||||
* structure directly.
|
||||
* \param _tc The #th_comment struct to add the comment to.
|
||||
* \param _comment Must be a null-terminated UTF-8 string containing the
|
||||
* comment in "TAG=the value" form.*/
|
||||
extern void th_comment_add(th_comment *_tc, char *_comment);
|
||||
/**Add a comment to an initialized #th_comment structure.
|
||||
* \note Neither th_comment_add() nor th_comment_add_tag() support
|
||||
* comments containing null values, although the bitstream format does
|
||||
* support them.
|
||||
* To add such comments you will need to manipulate the #th_comment
|
||||
* structure directly.
|
||||
* \param _tc The #th_comment struct to add the comment to.
|
||||
* \param _tag A null-terminated string containing the tag associated with
|
||||
* the comment.
|
||||
* \param _val The corresponding value as a null-terminated string.*/
|
||||
extern void th_comment_add_tag(th_comment *_tc,char *_tag,char *_val);
|
||||
/**Look up a comment value by its tag.
|
||||
* \param _tc An initialized #th_comment structure.
|
||||
* \param _tag The tag to look up.
|
||||
* \param _count The instance of the tag.
|
||||
* The same tag can appear multiple times, each with a distinct
|
||||
* value, so an index is required to retrieve them all.
|
||||
* The order in which these values appear is significant and
|
||||
* should be preserved.
|
||||
* Use th_comment_query_count() to get the legal range for
|
||||
* the \a _count parameter.
|
||||
* \return A pointer to the queried tag's value.
|
||||
* This points directly to data in the #th_comment structure.
|
||||
* It should not be modified or freed by the application, and
|
||||
* modifications to the structure may invalidate the pointer.
|
||||
* \retval NULL If no matching tag is found.*/
|
||||
extern char *th_comment_query(th_comment *_tc,char *_tag,int _count);
|
||||
/**Look up the number of instances of a tag.
|
||||
* Call this first when querying for a specific tag and then iterate over the
|
||||
* number of instances with separate calls to th_comment_query() to
|
||||
* retrieve all the values for that tag in order.
|
||||
* \param _tc An initialized #th_comment structure.
|
||||
* \param _tag The tag to look up.
|
||||
* \return The number on instances of this particular tag.*/
|
||||
extern int th_comment_query_count(th_comment *_tc,char *_tag);
|
||||
/**Clears a #th_comment structure.
|
||||
* This should be called on a #th_comment structure after it is no longer
|
||||
* needed.
|
||||
* It will free all memory used by the structure members.
|
||||
* \param _tc The #th_comment struct to clear.*/
|
||||
extern void th_comment_clear(th_comment *_tc);
|
||||
/*@}*/
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,325 +0,0 @@
|
|||
/********************************************************************
|
||||
* *
|
||||
* THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
|
||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* *
|
||||
********************************************************************
|
||||
|
||||
function:
|
||||
last mod: $Id: theora.h,v 1.8 2004/03/15 22:17:32 derf Exp $
|
||||
|
||||
********************************************************************/
|
||||
|
||||
/**\file
|
||||
* The <tt>libtheoradec</tt> C decoding API.*/
|
||||
|
||||
#if !defined(_O_THEORA_THEORADEC_H_)
|
||||
# define _O_THEORA_THEORADEC_H_ (1)
|
||||
# include <stddef.h>
|
||||
# include <ogg/ogg.h>
|
||||
# include "codec.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**\name th_decode_ctl() codes
|
||||
* \anchor decctlcodes
|
||||
* These are the available request codes for th_decode_ctl().
|
||||
* By convention, these are odd, to distinguish them from the
|
||||
* \ref encctlcodes "encoder control codes".
|
||||
* Keep any experimental or vendor-specific values above \c 0x8000.*/
|
||||
/*@{*/
|
||||
/**Gets the maximum post-processing level.
|
||||
* The decoder supports a post-processing filter that can improve
|
||||
* the appearance of the decoded images. This returns the highest
|
||||
* level setting for this post-processor, corresponding to maximum
|
||||
* improvement and computational expense.
|
||||
*
|
||||
* \param[out] _buf int: The maximum post-processing level.
|
||||
* \retval TH_EFAULT \a _dec_ctx or \a _buf is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>.
|
||||
* \retval TH_EIMPL Not supported by this implementation.*/
|
||||
#define TH_DECCTL_GET_PPLEVEL_MAX (1)
|
||||
/**Sets the post-processing level.
|
||||
* By default, post-processing is disabled.
|
||||
*
|
||||
* Sets the level of post-processing to use when decoding the
|
||||
* compressed stream. This must be a value between zero (off)
|
||||
* and the maximum returned by TH_DECCTL_GET_PPLEVEL_MAX.
|
||||
*
|
||||
* \param[in] _buf int: The new post-processing level.
|
||||
* 0 to disable; larger values use more CPU.
|
||||
* \retval TH_EFAULT \a _dec_ctx or \a _buf is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>, or the
|
||||
* post-processing level is out of bounds.
|
||||
* The maximum post-processing level may be
|
||||
* implementation-specific, and can be obtained via
|
||||
* #TH_DECCTL_GET_PPLEVEL_MAX.
|
||||
* \retval TH_EIMPL Not supported by this implementation.*/
|
||||
#define TH_DECCTL_SET_PPLEVEL (3)
|
||||
/**Sets the granule position.
|
||||
* Call this after a seek, before decoding the first frame, to ensure that the
|
||||
* proper granule position is returned for all subsequent frames.
|
||||
* If you track timestamps yourself and do not use the granule position
|
||||
* returned by the decoder, then you need not call this function.
|
||||
*
|
||||
* \param[in] _buf <tt>ogg_int64_t</tt>: The granule position of the next
|
||||
* frame.
|
||||
* \retval TH_EFAULT \a _dec_ctx or \a _buf is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(ogg_int64_t)</tt>, or the
|
||||
* granule position is negative.*/
|
||||
#define TH_DECCTL_SET_GRANPOS (5)
|
||||
/**Sets the striped decode callback function.
|
||||
* If set, this function will be called as each piece of a frame is fully
|
||||
* decoded in th_decode_packetin().
|
||||
* You can pass in a #th_stripe_callback with
|
||||
* th_stripe_callback#stripe_decoded set to <tt>NULL</tt> to disable the
|
||||
* callbacks at any point.
|
||||
* Enabling striped decode does not prevent you from calling
|
||||
* th_decode_ycbcr_out() after the frame is fully decoded.
|
||||
*
|
||||
* \param[in] _buf #th_stripe_callback: The callback parameters.
|
||||
* \retval TH_EFAULT \a _dec_ctx or \a _buf is <tt>NULL</tt>.
|
||||
* \retval TH_EINVAL \a _buf_sz is not
|
||||
* <tt>sizeof(th_stripe_callback)</tt>.*/
|
||||
#define TH_DECCTL_SET_STRIPE_CB (7)
|
||||
|
||||
/**Enables telemetry and sets the macroblock display mode */
|
||||
#define TH_DECCTL_SET_TELEMETRY_MBMODE (9)
|
||||
/**Enables telemetry and sets the motion vector display mode */
|
||||
#define TH_DECCTL_SET_TELEMETRY_MV (11)
|
||||
/**Enables telemetry and sets the adaptive quantization display mode */
|
||||
#define TH_DECCTL_SET_TELEMETRY_QI (13)
|
||||
/**Enables telemetry and sets the bitstream breakdown visualization mode */
|
||||
#define TH_DECCTL_SET_TELEMETRY_BITS (15)
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
||||
/**A callback function for striped decode.
|
||||
* This is a function pointer to an application-provided function that will be
|
||||
* called each time a section of the image is fully decoded in
|
||||
* th_decode_packetin().
|
||||
* This allows the application to process the section immediately, while it is
|
||||
* still in cache.
|
||||
* Note that the frame is decoded bottom to top, so \a _yfrag0 will steadily
|
||||
* decrease with each call until it reaches 0, at which point the full frame
|
||||
* is decoded.
|
||||
* The number of fragment rows made available in each call depends on the pixel
|
||||
* format and the number of post-processing filters enabled, and may not even
|
||||
* be constant for the entire frame.
|
||||
* If a non-<tt>NULL</tt> \a _granpos pointer is passed to
|
||||
* th_decode_packetin(), the granule position for the frame will be stored
|
||||
* in it before the first callback is made.
|
||||
* If an entire frame is dropped (a 0-byte packet), then no callbacks will be
|
||||
* made at all for that frame.
|
||||
* \param _ctx An application-provided context pointer.
|
||||
* \param _buf The image buffer for the decoded frame.
|
||||
* \param _yfrag0 The Y coordinate of the first row of 8x8 fragments
|
||||
* decoded.
|
||||
* Multiply this by 8 to obtain the pixel row number in the
|
||||
* luma plane.
|
||||
* If the chroma planes are subsampled in the Y direction,
|
||||
* this will always be divisible by two.
|
||||
* \param _yfrag_end The Y coordinate of the first row of 8x8 fragments past
|
||||
* the newly decoded section.
|
||||
* If the chroma planes are subsampled in the Y direction,
|
||||
* this will always be divisible by two.
|
||||
* I.e., this section contains fragment rows
|
||||
* <tt>\a _yfrag0 ...\a _yfrag_end -1</tt>.*/
|
||||
typedef void (*th_stripe_decoded_func)(void *_ctx,th_ycbcr_buffer _buf,
|
||||
int _yfrag0,int _yfrag_end);
|
||||
|
||||
/**The striped decode callback data to pass to #TH_DECCTL_SET_STRIPE_CB.*/
|
||||
typedef struct{
|
||||
/**An application-provided context pointer.
|
||||
* This will be passed back verbatim to the application.*/
|
||||
void *ctx;
|
||||
/**The callback function pointer.*/
|
||||
th_stripe_decoded_func stripe_decoded;
|
||||
}th_stripe_callback;
|
||||
|
||||
|
||||
|
||||
/**\name Decoder state
|
||||
The following data structures are opaque, and their contents are not
|
||||
publicly defined by this API.
|
||||
Referring to their internals directly is unsupported, and may break without
|
||||
warning.*/
|
||||
/*@{*/
|
||||
/**The decoder context.*/
|
||||
typedef struct th_dec_ctx th_dec_ctx;
|
||||
/**Setup information.
|
||||
This contains auxiliary information (Huffman tables and quantization
|
||||
parameters) decoded from the setup header by th_decode_headerin() to be
|
||||
passed to th_decode_alloc().
|
||||
It can be re-used to initialize any number of decoders, and can be freed
|
||||
via th_setup_free() at any time.*/
|
||||
typedef struct th_setup_info th_setup_info;
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
||||
/**\defgroup decfuncs Functions for Decoding*/
|
||||
/*@{*/
|
||||
/**\name Functions for decoding
|
||||
* You must link to <tt>libtheoradec</tt> if you use any of the
|
||||
* functions in this section.
|
||||
*
|
||||
* The functions are listed in the order they are used in a typical decode.
|
||||
* The basic steps are:
|
||||
* - Parse the header packets by repeatedly calling th_decode_headerin().
|
||||
* - Allocate a #th_dec_ctx handle with th_decode_alloc().
|
||||
* - Call th_setup_free() to free any memory used for codec setup
|
||||
* information.
|
||||
* - Perform any additional decoder configuration with th_decode_ctl().
|
||||
* - For each video data packet:
|
||||
* - Submit the packet to the decoder via th_decode_packetin().
|
||||
* - Retrieve the uncompressed video data via th_decode_ycbcr_out().
|
||||
* - Call th_decode_free() to release all decoder memory.*/
|
||||
/*@{*/
|
||||
/**Decodes the header packets of a Theora stream.
|
||||
* This should be called on the initial packets of the stream, in succession,
|
||||
* until it returns <tt>0</tt>, indicating that all headers have been
|
||||
* processed, or an error is encountered.
|
||||
* At least three header packets are required, and additional optional header
|
||||
* packets may follow.
|
||||
* This can be used on the first packet of any logical stream to determine if
|
||||
* that stream is a Theora stream.
|
||||
* \param _info A #th_info structure to fill in.
|
||||
* This must have been previously initialized with
|
||||
* th_info_init().
|
||||
* The application may immediately begin using the contents of
|
||||
* this structure after the first header is decoded, though it
|
||||
* must continue to be passed in on all subsequent calls.
|
||||
* \param _tc A #th_comment structure to fill in.
|
||||
* The application may immediately begin using the contents of
|
||||
* this structure after the second header is decoded, though it
|
||||
* must continue to be passed in on all subsequent calls.
|
||||
* \param _setup Returns a pointer to additional, private setup information
|
||||
* needed by the decoder.
|
||||
* The contents of this pointer must be initialized to
|
||||
* <tt>NULL</tt> on the first call, and the returned value must
|
||||
* continue to be passed in on all subsequent calls.
|
||||
* \param _op An <tt>ogg_packet</tt> structure which contains one of the
|
||||
* initial packets of an Ogg logical stream.
|
||||
* \return A positive value indicates that a Theora header was successfully
|
||||
* processed.
|
||||
* \retval 0 The first video data packet was encountered after all
|
||||
* required header packets were parsed.
|
||||
* The packet just passed in on this call should be saved
|
||||
* and fed to th_decode_packetin() to begin decoding
|
||||
* video data.
|
||||
* \retval TH_EFAULT One of \a _info, \a _tc, or \a _setup was
|
||||
* <tt>NULL</tt>.
|
||||
* \retval TH_EBADHEADER \a _op was <tt>NULL</tt>, the packet was not the next
|
||||
* header packet in the expected sequence, or the format
|
||||
* of the header data was invalid.
|
||||
* \retval TH_EVERSION The packet data was a Theora info header, but for a
|
||||
* bitstream version not decodable with this version of
|
||||
* <tt>libtheoradec</tt>.
|
||||
* \retval TH_ENOTFORMAT The packet was not a Theora header.
|
||||
*/
|
||||
extern int th_decode_headerin(th_info *_info,th_comment *_tc,
|
||||
th_setup_info **_setup,ogg_packet *_op);
|
||||
/**Allocates a decoder instance.
|
||||
*
|
||||
* <b>Security Warning:</b> The Theora format supports very large frame sizes,
|
||||
* potentially even larger than the address space of a 32-bit machine, and
|
||||
* creating a decoder context allocates the space for several frames of data.
|
||||
* If the allocation fails here, your program will crash, possibly at some
|
||||
* future point because the OS kernel returned a valid memory range and will
|
||||
* only fail when it tries to map the pages in it the first time they are
|
||||
* used.
|
||||
* Even if it succeeds, you may experience a denial of service if the frame
|
||||
* size is large enough to cause excessive paging.
|
||||
* If you are integrating libtheora in a larger application where such things
|
||||
* are undesirable, it is highly recommended that you check the frame size in
|
||||
* \a _info before calling this function and refuse to decode streams where it
|
||||
* is larger than some reasonable maximum.
|
||||
* libtheora will not check this for you, because there may be machines that
|
||||
* can handle such streams and applications that wish to.
|
||||
* \param _info A #th_info struct filled via th_decode_headerin().
|
||||
* \param _setup A #th_setup_info handle returned via
|
||||
* th_decode_headerin().
|
||||
* \return The initialized #th_dec_ctx handle.
|
||||
* \retval NULL If the decoding parameters were invalid.*/
|
||||
extern th_dec_ctx *th_decode_alloc(const th_info *_info,
|
||||
const th_setup_info *_setup);
|
||||
/**Releases all storage used for the decoder setup information.
|
||||
* This should be called after you no longer want to create any decoders for
|
||||
* a stream whose headers you have parsed with th_decode_headerin().
|
||||
* \param _setup The setup information to free.
|
||||
* This can safely be <tt>NULL</tt>.*/
|
||||
extern void th_setup_free(th_setup_info *_setup);
|
||||
/**Decoder control function.
|
||||
* This is used to provide advanced control of the decoding process.
|
||||
* \param _dec A #th_dec_ctx handle.
|
||||
* \param _req The control code to process.
|
||||
* See \ref decctlcodes "the list of available control codes"
|
||||
* for details.
|
||||
* \param _buf The parameters for this control code.
|
||||
* \param _buf_sz The size of the parameter buffer.*/
|
||||
extern int th_decode_ctl(th_dec_ctx *_dec,int _req,void *_buf,
|
||||
size_t _buf_sz);
|
||||
/**Submits a packet containing encoded video data to the decoder.
|
||||
* \param _dec A #th_dec_ctx handle.
|
||||
* \param _op An <tt>ogg_packet</tt> containing encoded video data.
|
||||
* \param _granpos Returns the granule position of the decoded packet.
|
||||
* If non-<tt>NULL</tt>, the granule position for this specific
|
||||
* packet is stored in this location.
|
||||
* This is computed incrementally from previously decoded
|
||||
* packets.
|
||||
* After a seek, the correct granule position must be set via
|
||||
* #TH_DECCTL_SET_GRANPOS for this to work properly.
|
||||
* \retval 0 Success.
|
||||
* A new decoded frame can be retrieved by calling
|
||||
* th_decode_ycbcr_out().
|
||||
* \retval TH_DUPFRAME The packet represented a dropped (0-byte) frame.
|
||||
* The player can skip the call to th_decode_ycbcr_out(),
|
||||
* as the contents of the decoded frame buffer have not
|
||||
* changed.
|
||||
* \retval TH_EFAULT \a _dec or \a _op was <tt>NULL</tt>.
|
||||
* \retval TH_EBADPACKET \a _op does not contain encoded video data.
|
||||
* \retval TH_EIMPL The video data uses bitstream features which this
|
||||
* library does not support.*/
|
||||
extern int th_decode_packetin(th_dec_ctx *_dec,const ogg_packet *_op,
|
||||
ogg_int64_t *_granpos);
|
||||
/**Outputs the next available frame of decoded Y'CbCr data.
|
||||
* If a striped decode callback has been set with #TH_DECCTL_SET_STRIPE_CB,
|
||||
* then the application does not need to call this function.
|
||||
* \param _dec A #th_dec_ctx handle.
|
||||
* \param _ycbcr A video buffer structure to fill in.
|
||||
* <tt>libtheoradec</tt> will fill in all the members of this
|
||||
* structure, including the pointers to the uncompressed video
|
||||
* data.
|
||||
* The memory for this video data is owned by
|
||||
* <tt>libtheoradec</tt>.
|
||||
* It may be freed or overwritten without notification when
|
||||
* subsequent frames are decoded.
|
||||
* \retval 0 Success
|
||||
* \retval TH_EFAULT \a _dec or \a _ycbcr was <tt>NULL</tt>.
|
||||
*/
|
||||
extern int th_decode_ycbcr_out(th_dec_ctx *_dec,
|
||||
th_ycbcr_buffer _ycbcr);
|
||||
/**Frees an allocated decoder instance.
|
||||
* \param _dec A #th_dec_ctx handle.*/
|
||||
extern void th_decode_free(th_dec_ctx *_dec);
|
||||
/*@}*/
|
||||
/*@}*/
|
||||
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,243 +0,0 @@
|
|||
/********************************************************************
|
||||
* *
|
||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
|
||||
********************************************************************
|
||||
|
||||
function: libvorbis codec headers
|
||||
last mod: $Id: codec.h 16037 2009-05-26 21:10:58Z xiphmont $
|
||||
|
||||
********************************************************************/
|
||||
|
||||
#ifndef _vorbis_codec_h_
|
||||
#define _vorbis_codec_h_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include <ogg/ogg.h>
|
||||
|
||||
typedef struct vorbis_info{
|
||||
int version;
|
||||
int channels;
|
||||
long rate;
|
||||
|
||||
/* The below bitrate declarations are *hints*.
|
||||
Combinations of the three values carry the following implications:
|
||||
|
||||
all three set to the same value:
|
||||
implies a fixed rate bitstream
|
||||
only nominal set:
|
||||
implies a VBR stream that averages the nominal bitrate. No hard
|
||||
upper/lower limit
|
||||
upper and or lower set:
|
||||
implies a VBR bitstream that obeys the bitrate limits. nominal
|
||||
may also be set to give a nominal rate.
|
||||
none set:
|
||||
the coder does not care to speculate.
|
||||
*/
|
||||
|
||||
long bitrate_upper;
|
||||
long bitrate_nominal;
|
||||
long bitrate_lower;
|
||||
long bitrate_window;
|
||||
|
||||
void *codec_setup;
|
||||
} vorbis_info;
|
||||
|
||||
/* vorbis_dsp_state buffers the current vorbis audio
|
||||
analysis/synthesis state. The DSP state belongs to a specific
|
||||
logical bitstream ****************************************************/
|
||||
typedef struct vorbis_dsp_state{
|
||||
int analysisp;
|
||||
vorbis_info *vi;
|
||||
|
||||
float **pcm;
|
||||
float **pcmret;
|
||||
int pcm_storage;
|
||||
int pcm_current;
|
||||
int pcm_returned;
|
||||
|
||||
int preextrapolate;
|
||||
int eofflag;
|
||||
|
||||
long lW;
|
||||
long W;
|
||||
long nW;
|
||||
long centerW;
|
||||
|
||||
ogg_int64_t granulepos;
|
||||
ogg_int64_t sequence;
|
||||
|
||||
ogg_int64_t glue_bits;
|
||||
ogg_int64_t time_bits;
|
||||
ogg_int64_t floor_bits;
|
||||
ogg_int64_t res_bits;
|
||||
|
||||
void *backend_state;
|
||||
} vorbis_dsp_state;
|
||||
|
||||
typedef struct vorbis_block{
|
||||
/* necessary stream state for linking to the framing abstraction */
|
||||
float **pcm; /* this is a pointer into local storage */
|
||||
oggpack_buffer opb;
|
||||
|
||||
long lW;
|
||||
long W;
|
||||
long nW;
|
||||
int pcmend;
|
||||
int mode;
|
||||
|
||||
int eofflag;
|
||||
ogg_int64_t granulepos;
|
||||
ogg_int64_t sequence;
|
||||
vorbis_dsp_state *vd; /* For read-only access of configuration */
|
||||
|
||||
/* local storage to avoid remallocing; it's up to the mapping to
|
||||
structure it */
|
||||
void *localstore;
|
||||
long localtop;
|
||||
long localalloc;
|
||||
long totaluse;
|
||||
struct alloc_chain *reap;
|
||||
|
||||
/* bitmetrics for the frame */
|
||||
long glue_bits;
|
||||
long time_bits;
|
||||
long floor_bits;
|
||||
long res_bits;
|
||||
|
||||
void *internal;
|
||||
|
||||
} vorbis_block;
|
||||
|
||||
/* vorbis_block is a single block of data to be processed as part of
|
||||
the analysis/synthesis stream; it belongs to a specific logical
|
||||
bitstream, but is independant from other vorbis_blocks belonging to
|
||||
that logical bitstream. *************************************************/
|
||||
|
||||
struct alloc_chain{
|
||||
void *ptr;
|
||||
struct alloc_chain *next;
|
||||
};
|
||||
|
||||
/* vorbis_info contains all the setup information specific to the
|
||||
specific compression/decompression mode in progress (eg,
|
||||
psychoacoustic settings, channel setup, options, codebook
|
||||
etc). vorbis_info and substructures are in backends.h.
|
||||
*********************************************************************/
|
||||
|
||||
/* the comments are not part of vorbis_info so that vorbis_info can be
|
||||
static storage */
|
||||
typedef struct vorbis_comment{
|
||||
/* unlimited user comment fields. libvorbis writes 'libvorbis'
|
||||
whatever vendor is set to in encode */
|
||||
char **user_comments;
|
||||
int *comment_lengths;
|
||||
int comments;
|
||||
char *vendor;
|
||||
|
||||
} vorbis_comment;
|
||||
|
||||
|
||||
/* libvorbis encodes in two abstraction layers; first we perform DSP
|
||||
and produce a packet (see docs/analysis.txt). The packet is then
|
||||
coded into a framed OggSquish bitstream by the second layer (see
|
||||
docs/framing.txt). Decode is the reverse process; we sync/frame
|
||||
the bitstream and extract individual packets, then decode the
|
||||
packet back into PCM audio.
|
||||
|
||||
The extra framing/packetizing is used in streaming formats, such as
|
||||
files. Over the net (such as with UDP), the framing and
|
||||
packetization aren't necessary as they're provided by the transport
|
||||
and the streaming layer is not used */
|
||||
|
||||
/* Vorbis PRIMITIVES: general ***************************************/
|
||||
|
||||
extern void vorbis_info_init(vorbis_info *vi);
|
||||
extern void vorbis_info_clear(vorbis_info *vi);
|
||||
extern int vorbis_info_blocksize(vorbis_info *vi,int zo);
|
||||
extern void vorbis_comment_init(vorbis_comment *vc);
|
||||
extern void vorbis_comment_add(vorbis_comment *vc, const char *comment);
|
||||
extern void vorbis_comment_add_tag(vorbis_comment *vc,
|
||||
const char *tag, const char *contents);
|
||||
extern char *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count);
|
||||
extern int vorbis_comment_query_count(vorbis_comment *vc, const char *tag);
|
||||
extern void vorbis_comment_clear(vorbis_comment *vc);
|
||||
|
||||
extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
|
||||
extern int vorbis_block_clear(vorbis_block *vb);
|
||||
extern void vorbis_dsp_clear(vorbis_dsp_state *v);
|
||||
extern double vorbis_granule_time(vorbis_dsp_state *v,
|
||||
ogg_int64_t granulepos);
|
||||
|
||||
extern const char *vorbis_version_string(void);
|
||||
|
||||
/* Vorbis PRIMITIVES: analysis/DSP layer ****************************/
|
||||
|
||||
extern int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi);
|
||||
extern int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op);
|
||||
extern int vorbis_analysis_headerout(vorbis_dsp_state *v,
|
||||
vorbis_comment *vc,
|
||||
ogg_packet *op,
|
||||
ogg_packet *op_comm,
|
||||
ogg_packet *op_code);
|
||||
extern float **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals);
|
||||
extern int vorbis_analysis_wrote(vorbis_dsp_state *v,int vals);
|
||||
extern int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb);
|
||||
extern int vorbis_analysis(vorbis_block *vb,ogg_packet *op);
|
||||
|
||||
extern int vorbis_bitrate_addblock(vorbis_block *vb);
|
||||
extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd,
|
||||
ogg_packet *op);
|
||||
|
||||
/* Vorbis PRIMITIVES: synthesis layer *******************************/
|
||||
extern int vorbis_synthesis_idheader(ogg_packet *op);
|
||||
extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,
|
||||
ogg_packet *op);
|
||||
|
||||
extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
|
||||
extern int vorbis_synthesis_restart(vorbis_dsp_state *v);
|
||||
extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op);
|
||||
extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op);
|
||||
extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
|
||||
extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm);
|
||||
extern int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm);
|
||||
extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples);
|
||||
extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op);
|
||||
|
||||
extern int vorbis_synthesis_halfrate(vorbis_info *v,int flag);
|
||||
extern int vorbis_synthesis_halfrate_p(vorbis_info *v);
|
||||
|
||||
/* Vorbis ERRORS and return codes ***********************************/
|
||||
|
||||
#define OV_FALSE -1
|
||||
#define OV_EOF -2
|
||||
#define OV_HOLE -3
|
||||
|
||||
#define OV_EREAD -128
|
||||
#define OV_EFAULT -129
|
||||
#define OV_EIMPL -130
|
||||
#define OV_EINVAL -131
|
||||
#define OV_ENOTVORBIS -132
|
||||
#define OV_EBADHEADER -133
|
||||
#define OV_EVERSION -134
|
||||
#define OV_ENOTAUDIO -135
|
||||
#define OV_EBADPACKET -136
|
||||
#define OV_EBADLINK -137
|
||||
#define OV_ENOSEEK -138
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
/********************************************************************
|
||||
* *
|
||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
|
||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
|
||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
|
||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
|
||||
* *
|
||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
|
||||
* by the Xiph.Org Foundation http://www.xiph.org/ *
|
||||
* *
|
||||
********************************************************************
|
||||
|
||||
function: vorbis encode-engine setup
|
||||
last mod: $Id: vorbisenc.h 16037 2009-05-26 21:10:58Z xiphmont $
|
||||
|
||||
********************************************************************/
|
||||
|
||||
#ifndef _OV_ENC_H_
|
||||
#define _OV_ENC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "codec.h"
|
||||
|
||||
extern int vorbis_encode_init(vorbis_info *vi,
|
||||
long channels,
|
||||
long rate,
|
||||
|
||||
long max_bitrate,
|
||||
long nominal_bitrate,
|
||||
long min_bitrate);
|
||||
|
||||
extern int vorbis_encode_setup_managed(vorbis_info *vi,
|
||||
long channels,
|
||||
long rate,
|
||||
|
||||
long max_bitrate,
|
||||
long nominal_bitrate,
|
||||
long min_bitrate);
|
||||
|
||||
extern int vorbis_encode_setup_vbr(vorbis_info *vi,
|
||||
long channels,
|
||||
long rate,
|
||||
|
||||
float quality /* quality level from 0. (lo) to 1. (hi) */
|
||||
);
|
||||
|
||||
extern int vorbis_encode_init_vbr(vorbis_info *vi,
|
||||
long channels,
|
||||
long rate,
|
||||
|
||||
float base_quality /* quality level from 0. (lo) to 1. (hi) */
|
||||
);
|
||||
|
||||
extern int vorbis_encode_setup_init(vorbis_info *vi);
|
||||
|
||||
extern int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg);
|
||||
|
||||
/* deprecated rate management supported only for compatability */
|
||||
#define OV_ECTL_RATEMANAGE_GET 0x10
|
||||
#define OV_ECTL_RATEMANAGE_SET 0x11
|
||||
#define OV_ECTL_RATEMANAGE_AVG 0x12
|
||||
#define OV_ECTL_RATEMANAGE_HARD 0x13
|
||||
|
||||
struct ovectl_ratemanage_arg {
|
||||
int management_active;
|
||||
|
||||
long bitrate_hard_min;
|
||||
long bitrate_hard_max;
|
||||
double bitrate_hard_window;
|
||||
|
||||
long bitrate_av_lo;
|
||||
long bitrate_av_hi;
|
||||
double bitrate_av_window;
|
||||
double bitrate_av_window_center;
|
||||
};
|
||||
|
||||
|
||||
/* new rate setup */
|
||||
#define OV_ECTL_RATEMANAGE2_GET 0x14
|
||||
#define OV_ECTL_RATEMANAGE2_SET 0x15
|
||||
|
||||
struct ovectl_ratemanage2_arg {
|
||||
int management_active;
|
||||
|
||||
long bitrate_limit_min_kbps;
|
||||
long bitrate_limit_max_kbps;
|
||||
long bitrate_limit_reservoir_bits;
|
||||
double bitrate_limit_reservoir_bias;
|
||||
|
||||
long bitrate_average_kbps;
|
||||
double bitrate_average_damping;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define OV_ECTL_LOWPASS_GET 0x20
|
||||
#define OV_ECTL_LOWPASS_SET 0x21
|
||||
|
||||
#define OV_ECTL_IBLOCK_GET 0x30
|
||||
#define OV_ECTL_IBLOCK_SET 0x31
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -19,6 +19,19 @@
|
|||
#ifndef AVCODEC_AVFFT_H
|
||||
#define AVCODEC_AVFFT_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_fft
|
||||
* FFT functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lavc_fft FFT functions
|
||||
* @ingroup lavc_misc
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef float FFTSample;
|
||||
|
||||
typedef struct FFTComplex {
|
||||
|
@ -85,7 +98,7 @@ enum DCTTransformType {
|
|||
};
|
||||
|
||||
/**
|
||||
* Sets up DCT.
|
||||
* Set up DCT.
|
||||
* @param nbits size of the input array:
|
||||
* (1 << nbits) for DCT-II, DCT-III and DST-I
|
||||
* (1 << nbits) + 1 for DCT-I
|
||||
|
@ -96,4 +109,8 @@ DCTContext *av_dct_init(int nbits, enum DCTTransformType type);
|
|||
void av_dct_calc(DCTContext *s, FFTSample *data);
|
||||
void av_dct_end (DCTContext *s);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_AVFFT_H */
|
||||
|
|
|
@ -23,10 +23,33 @@
|
|||
#ifndef AVCODEC_DXVA_H
|
||||
#define AVCODEC_DXVA_H
|
||||
|
||||
#include <stdint.h>
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_dxva2
|
||||
* Public libavcodec DXVA2 header.
|
||||
*/
|
||||
|
||||
#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0600
|
||||
#undef _WIN32_WINNT
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32_WINNT)
|
||||
#define _WIN32_WINNT 0x0600
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <d3d9.h>
|
||||
#include <dxva2api.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_dxva2 DXVA2
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards
|
||||
|
||||
/**
|
||||
* This structure is used to provides the necessary configurations and data
|
||||
* to the DXVA2 FFmpeg HWAccel implementation.
|
||||
|
@ -65,4 +88,8 @@ struct dxva_context {
|
|||
unsigned report_id;
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_DXVA_H */
|
||||
|
|
|
@ -0,0 +1,398 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_OLD_CODEC_IDS_H
|
||||
#define AVCODEC_OLD_CODEC_IDS_H
|
||||
|
||||
#include "libavutil/common.h"
|
||||
|
||||
/*
|
||||
* This header exists to prevent new codec IDs from being accidentally added to
|
||||
* the deprecated list.
|
||||
* Do not include it directly. It will be removed on next major bump
|
||||
*
|
||||
* Do not add new items to this list. Use the AVCodecID enum instead.
|
||||
*/
|
||||
|
||||
CODEC_ID_NONE = AV_CODEC_ID_NONE,
|
||||
|
||||
/* video codecs */
|
||||
CODEC_ID_MPEG1VIDEO,
|
||||
CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding
|
||||
CODEC_ID_MPEG2VIDEO_XVMC,
|
||||
CODEC_ID_H261,
|
||||
CODEC_ID_H263,
|
||||
CODEC_ID_RV10,
|
||||
CODEC_ID_RV20,
|
||||
CODEC_ID_MJPEG,
|
||||
CODEC_ID_MJPEGB,
|
||||
CODEC_ID_LJPEG,
|
||||
CODEC_ID_SP5X,
|
||||
CODEC_ID_JPEGLS,
|
||||
CODEC_ID_MPEG4,
|
||||
CODEC_ID_RAWVIDEO,
|
||||
CODEC_ID_MSMPEG4V1,
|
||||
CODEC_ID_MSMPEG4V2,
|
||||
CODEC_ID_MSMPEG4V3,
|
||||
CODEC_ID_WMV1,
|
||||
CODEC_ID_WMV2,
|
||||
CODEC_ID_H263P,
|
||||
CODEC_ID_H263I,
|
||||
CODEC_ID_FLV1,
|
||||
CODEC_ID_SVQ1,
|
||||
CODEC_ID_SVQ3,
|
||||
CODEC_ID_DVVIDEO,
|
||||
CODEC_ID_HUFFYUV,
|
||||
CODEC_ID_CYUV,
|
||||
CODEC_ID_H264,
|
||||
CODEC_ID_INDEO3,
|
||||
CODEC_ID_VP3,
|
||||
CODEC_ID_THEORA,
|
||||
CODEC_ID_ASV1,
|
||||
CODEC_ID_ASV2,
|
||||
CODEC_ID_FFV1,
|
||||
CODEC_ID_4XM,
|
||||
CODEC_ID_VCR1,
|
||||
CODEC_ID_CLJR,
|
||||
CODEC_ID_MDEC,
|
||||
CODEC_ID_ROQ,
|
||||
CODEC_ID_INTERPLAY_VIDEO,
|
||||
CODEC_ID_XAN_WC3,
|
||||
CODEC_ID_XAN_WC4,
|
||||
CODEC_ID_RPZA,
|
||||
CODEC_ID_CINEPAK,
|
||||
CODEC_ID_WS_VQA,
|
||||
CODEC_ID_MSRLE,
|
||||
CODEC_ID_MSVIDEO1,
|
||||
CODEC_ID_IDCIN,
|
||||
CODEC_ID_8BPS,
|
||||
CODEC_ID_SMC,
|
||||
CODEC_ID_FLIC,
|
||||
CODEC_ID_TRUEMOTION1,
|
||||
CODEC_ID_VMDVIDEO,
|
||||
CODEC_ID_MSZH,
|
||||
CODEC_ID_ZLIB,
|
||||
CODEC_ID_QTRLE,
|
||||
CODEC_ID_SNOW,
|
||||
CODEC_ID_TSCC,
|
||||
CODEC_ID_ULTI,
|
||||
CODEC_ID_QDRAW,
|
||||
CODEC_ID_VIXL,
|
||||
CODEC_ID_QPEG,
|
||||
CODEC_ID_PNG,
|
||||
CODEC_ID_PPM,
|
||||
CODEC_ID_PBM,
|
||||
CODEC_ID_PGM,
|
||||
CODEC_ID_PGMYUV,
|
||||
CODEC_ID_PAM,
|
||||
CODEC_ID_FFVHUFF,
|
||||
CODEC_ID_RV30,
|
||||
CODEC_ID_RV40,
|
||||
CODEC_ID_VC1,
|
||||
CODEC_ID_WMV3,
|
||||
CODEC_ID_LOCO,
|
||||
CODEC_ID_WNV1,
|
||||
CODEC_ID_AASC,
|
||||
CODEC_ID_INDEO2,
|
||||
CODEC_ID_FRAPS,
|
||||
CODEC_ID_TRUEMOTION2,
|
||||
CODEC_ID_BMP,
|
||||
CODEC_ID_CSCD,
|
||||
CODEC_ID_MMVIDEO,
|
||||
CODEC_ID_ZMBV,
|
||||
CODEC_ID_AVS,
|
||||
CODEC_ID_SMACKVIDEO,
|
||||
CODEC_ID_NUV,
|
||||
CODEC_ID_KMVC,
|
||||
CODEC_ID_FLASHSV,
|
||||
CODEC_ID_CAVS,
|
||||
CODEC_ID_JPEG2000,
|
||||
CODEC_ID_VMNC,
|
||||
CODEC_ID_VP5,
|
||||
CODEC_ID_VP6,
|
||||
CODEC_ID_VP6F,
|
||||
CODEC_ID_TARGA,
|
||||
CODEC_ID_DSICINVIDEO,
|
||||
CODEC_ID_TIERTEXSEQVIDEO,
|
||||
CODEC_ID_TIFF,
|
||||
CODEC_ID_GIF,
|
||||
CODEC_ID_DXA,
|
||||
CODEC_ID_DNXHD,
|
||||
CODEC_ID_THP,
|
||||
CODEC_ID_SGI,
|
||||
CODEC_ID_C93,
|
||||
CODEC_ID_BETHSOFTVID,
|
||||
CODEC_ID_PTX,
|
||||
CODEC_ID_TXD,
|
||||
CODEC_ID_VP6A,
|
||||
CODEC_ID_AMV,
|
||||
CODEC_ID_VB,
|
||||
CODEC_ID_PCX,
|
||||
CODEC_ID_SUNRAST,
|
||||
CODEC_ID_INDEO4,
|
||||
CODEC_ID_INDEO5,
|
||||
CODEC_ID_MIMIC,
|
||||
CODEC_ID_RL2,
|
||||
CODEC_ID_ESCAPE124,
|
||||
CODEC_ID_DIRAC,
|
||||
CODEC_ID_BFI,
|
||||
CODEC_ID_CMV,
|
||||
CODEC_ID_MOTIONPIXELS,
|
||||
CODEC_ID_TGV,
|
||||
CODEC_ID_TGQ,
|
||||
CODEC_ID_TQI,
|
||||
CODEC_ID_AURA,
|
||||
CODEC_ID_AURA2,
|
||||
CODEC_ID_V210X,
|
||||
CODEC_ID_TMV,
|
||||
CODEC_ID_V210,
|
||||
CODEC_ID_DPX,
|
||||
CODEC_ID_MAD,
|
||||
CODEC_ID_FRWU,
|
||||
CODEC_ID_FLASHSV2,
|
||||
CODEC_ID_CDGRAPHICS,
|
||||
CODEC_ID_R210,
|
||||
CODEC_ID_ANM,
|
||||
CODEC_ID_BINKVIDEO,
|
||||
CODEC_ID_IFF_ILBM,
|
||||
CODEC_ID_IFF_BYTERUN1,
|
||||
CODEC_ID_KGV1,
|
||||
CODEC_ID_YOP,
|
||||
CODEC_ID_VP8,
|
||||
CODEC_ID_PICTOR,
|
||||
CODEC_ID_ANSI,
|
||||
CODEC_ID_A64_MULTI,
|
||||
CODEC_ID_A64_MULTI5,
|
||||
CODEC_ID_R10K,
|
||||
CODEC_ID_MXPEG,
|
||||
CODEC_ID_LAGARITH,
|
||||
CODEC_ID_PRORES,
|
||||
CODEC_ID_JV,
|
||||
CODEC_ID_DFA,
|
||||
CODEC_ID_WMV3IMAGE,
|
||||
CODEC_ID_VC1IMAGE,
|
||||
CODEC_ID_UTVIDEO,
|
||||
CODEC_ID_BMV_VIDEO,
|
||||
CODEC_ID_VBLE,
|
||||
CODEC_ID_DXTORY,
|
||||
CODEC_ID_V410,
|
||||
CODEC_ID_XWD,
|
||||
CODEC_ID_CDXL,
|
||||
CODEC_ID_XBM,
|
||||
CODEC_ID_ZEROCODEC,
|
||||
CODEC_ID_MSS1,
|
||||
CODEC_ID_MSA1,
|
||||
CODEC_ID_TSCC2,
|
||||
CODEC_ID_MTS2,
|
||||
CODEC_ID_CLLC,
|
||||
CODEC_ID_Y41P = MKBETAG('Y','4','1','P'),
|
||||
CODEC_ID_ESCAPE130 = MKBETAG('E','1','3','0'),
|
||||
CODEC_ID_EXR = MKBETAG('0','E','X','R'),
|
||||
CODEC_ID_AVRP = MKBETAG('A','V','R','P'),
|
||||
|
||||
CODEC_ID_G2M = MKBETAG( 0 ,'G','2','M'),
|
||||
CODEC_ID_AVUI = MKBETAG('A','V','U','I'),
|
||||
CODEC_ID_AYUV = MKBETAG('A','Y','U','V'),
|
||||
CODEC_ID_V308 = MKBETAG('V','3','0','8'),
|
||||
CODEC_ID_V408 = MKBETAG('V','4','0','8'),
|
||||
CODEC_ID_YUV4 = MKBETAG('Y','U','V','4'),
|
||||
CODEC_ID_SANM = MKBETAG('S','A','N','M'),
|
||||
CODEC_ID_PAF_VIDEO = MKBETAG('P','A','F','V'),
|
||||
|
||||
/* various PCM "codecs" */
|
||||
CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
|
||||
CODEC_ID_PCM_S16LE = 0x10000,
|
||||
CODEC_ID_PCM_S16BE,
|
||||
CODEC_ID_PCM_U16LE,
|
||||
CODEC_ID_PCM_U16BE,
|
||||
CODEC_ID_PCM_S8,
|
||||
CODEC_ID_PCM_U8,
|
||||
CODEC_ID_PCM_MULAW,
|
||||
CODEC_ID_PCM_ALAW,
|
||||
CODEC_ID_PCM_S32LE,
|
||||
CODEC_ID_PCM_S32BE,
|
||||
CODEC_ID_PCM_U32LE,
|
||||
CODEC_ID_PCM_U32BE,
|
||||
CODEC_ID_PCM_S24LE,
|
||||
CODEC_ID_PCM_S24BE,
|
||||
CODEC_ID_PCM_U24LE,
|
||||
CODEC_ID_PCM_U24BE,
|
||||
CODEC_ID_PCM_S24DAUD,
|
||||
CODEC_ID_PCM_ZORK,
|
||||
CODEC_ID_PCM_S16LE_PLANAR,
|
||||
CODEC_ID_PCM_DVD,
|
||||
CODEC_ID_PCM_F32BE,
|
||||
CODEC_ID_PCM_F32LE,
|
||||
CODEC_ID_PCM_F64BE,
|
||||
CODEC_ID_PCM_F64LE,
|
||||
CODEC_ID_PCM_BLURAY,
|
||||
CODEC_ID_PCM_LXF,
|
||||
CODEC_ID_S302M,
|
||||
CODEC_ID_PCM_S8_PLANAR,
|
||||
|
||||
/* various ADPCM codecs */
|
||||
CODEC_ID_ADPCM_IMA_QT = 0x11000,
|
||||
CODEC_ID_ADPCM_IMA_WAV,
|
||||
CODEC_ID_ADPCM_IMA_DK3,
|
||||
CODEC_ID_ADPCM_IMA_DK4,
|
||||
CODEC_ID_ADPCM_IMA_WS,
|
||||
CODEC_ID_ADPCM_IMA_SMJPEG,
|
||||
CODEC_ID_ADPCM_MS,
|
||||
CODEC_ID_ADPCM_4XM,
|
||||
CODEC_ID_ADPCM_XA,
|
||||
CODEC_ID_ADPCM_ADX,
|
||||
CODEC_ID_ADPCM_EA,
|
||||
CODEC_ID_ADPCM_G726,
|
||||
CODEC_ID_ADPCM_CT,
|
||||
CODEC_ID_ADPCM_SWF,
|
||||
CODEC_ID_ADPCM_YAMAHA,
|
||||
CODEC_ID_ADPCM_SBPRO_4,
|
||||
CODEC_ID_ADPCM_SBPRO_3,
|
||||
CODEC_ID_ADPCM_SBPRO_2,
|
||||
CODEC_ID_ADPCM_THP,
|
||||
CODEC_ID_ADPCM_IMA_AMV,
|
||||
CODEC_ID_ADPCM_EA_R1,
|
||||
CODEC_ID_ADPCM_EA_R3,
|
||||
CODEC_ID_ADPCM_EA_R2,
|
||||
CODEC_ID_ADPCM_IMA_EA_SEAD,
|
||||
CODEC_ID_ADPCM_IMA_EA_EACS,
|
||||
CODEC_ID_ADPCM_EA_XAS,
|
||||
CODEC_ID_ADPCM_EA_MAXIS_XA,
|
||||
CODEC_ID_ADPCM_IMA_ISS,
|
||||
CODEC_ID_ADPCM_G722,
|
||||
CODEC_ID_ADPCM_IMA_APC,
|
||||
CODEC_ID_VIMA = MKBETAG('V','I','M','A'),
|
||||
|
||||
/* AMR */
|
||||
CODEC_ID_AMR_NB = 0x12000,
|
||||
CODEC_ID_AMR_WB,
|
||||
|
||||
/* RealAudio codecs*/
|
||||
CODEC_ID_RA_144 = 0x13000,
|
||||
CODEC_ID_RA_288,
|
||||
|
||||
/* various DPCM codecs */
|
||||
CODEC_ID_ROQ_DPCM = 0x14000,
|
||||
CODEC_ID_INTERPLAY_DPCM,
|
||||
CODEC_ID_XAN_DPCM,
|
||||
CODEC_ID_SOL_DPCM,
|
||||
|
||||
/* audio codecs */
|
||||
CODEC_ID_MP2 = 0x15000,
|
||||
CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
|
||||
CODEC_ID_AAC,
|
||||
CODEC_ID_AC3,
|
||||
CODEC_ID_DTS,
|
||||
CODEC_ID_VORBIS,
|
||||
CODEC_ID_DVAUDIO,
|
||||
CODEC_ID_WMAV1,
|
||||
CODEC_ID_WMAV2,
|
||||
CODEC_ID_MACE3,
|
||||
CODEC_ID_MACE6,
|
||||
CODEC_ID_VMDAUDIO,
|
||||
CODEC_ID_FLAC,
|
||||
CODEC_ID_MP3ADU,
|
||||
CODEC_ID_MP3ON4,
|
||||
CODEC_ID_SHORTEN,
|
||||
CODEC_ID_ALAC,
|
||||
CODEC_ID_WESTWOOD_SND1,
|
||||
CODEC_ID_GSM, ///< as in Berlin toast format
|
||||
CODEC_ID_QDM2,
|
||||
CODEC_ID_COOK,
|
||||
CODEC_ID_TRUESPEECH,
|
||||
CODEC_ID_TTA,
|
||||
CODEC_ID_SMACKAUDIO,
|
||||
CODEC_ID_QCELP,
|
||||
CODEC_ID_WAVPACK,
|
||||
CODEC_ID_DSICINAUDIO,
|
||||
CODEC_ID_IMC,
|
||||
CODEC_ID_MUSEPACK7,
|
||||
CODEC_ID_MLP,
|
||||
CODEC_ID_GSM_MS, /* as found in WAV */
|
||||
CODEC_ID_ATRAC3,
|
||||
CODEC_ID_VOXWARE,
|
||||
CODEC_ID_APE,
|
||||
CODEC_ID_NELLYMOSER,
|
||||
CODEC_ID_MUSEPACK8,
|
||||
CODEC_ID_SPEEX,
|
||||
CODEC_ID_WMAVOICE,
|
||||
CODEC_ID_WMAPRO,
|
||||
CODEC_ID_WMALOSSLESS,
|
||||
CODEC_ID_ATRAC3P,
|
||||
CODEC_ID_EAC3,
|
||||
CODEC_ID_SIPR,
|
||||
CODEC_ID_MP1,
|
||||
CODEC_ID_TWINVQ,
|
||||
CODEC_ID_TRUEHD,
|
||||
CODEC_ID_MP4ALS,
|
||||
CODEC_ID_ATRAC1,
|
||||
CODEC_ID_BINKAUDIO_RDFT,
|
||||
CODEC_ID_BINKAUDIO_DCT,
|
||||
CODEC_ID_AAC_LATM,
|
||||
CODEC_ID_QDMC,
|
||||
CODEC_ID_CELT,
|
||||
CODEC_ID_G723_1,
|
||||
CODEC_ID_G729,
|
||||
CODEC_ID_8SVX_EXP,
|
||||
CODEC_ID_8SVX_FIB,
|
||||
CODEC_ID_BMV_AUDIO,
|
||||
CODEC_ID_RALF,
|
||||
CODEC_ID_IAC,
|
||||
CODEC_ID_ILBC,
|
||||
CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'),
|
||||
CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'),
|
||||
CODEC_ID_SONIC = MKBETAG('S','O','N','C'),
|
||||
CODEC_ID_SONIC_LS = MKBETAG('S','O','N','L'),
|
||||
CODEC_ID_PAF_AUDIO = MKBETAG('P','A','F','A'),
|
||||
CODEC_ID_OPUS = MKBETAG('O','P','U','S'),
|
||||
|
||||
/* subtitle codecs */
|
||||
CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
|
||||
CODEC_ID_DVD_SUBTITLE = 0x17000,
|
||||
CODEC_ID_DVB_SUBTITLE,
|
||||
CODEC_ID_TEXT, ///< raw UTF-8 text
|
||||
CODEC_ID_XSUB,
|
||||
CODEC_ID_SSA,
|
||||
CODEC_ID_MOV_TEXT,
|
||||
CODEC_ID_HDMV_PGS_SUBTITLE,
|
||||
CODEC_ID_DVB_TELETEXT,
|
||||
CODEC_ID_SRT,
|
||||
CODEC_ID_MICRODVD = MKBETAG('m','D','V','D'),
|
||||
CODEC_ID_EIA_608 = MKBETAG('c','6','0','8'),
|
||||
CODEC_ID_JACOSUB = MKBETAG('J','S','U','B'),
|
||||
CODEC_ID_SAMI = MKBETAG('S','A','M','I'),
|
||||
CODEC_ID_REALTEXT = MKBETAG('R','T','X','T'),
|
||||
CODEC_ID_SUBVIEWER = MKBETAG('S','u','b','V'),
|
||||
|
||||
/* other specific kind of codecs (generally used for attachments) */
|
||||
CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
|
||||
CODEC_ID_TTF = 0x18000,
|
||||
CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'),
|
||||
CODEC_ID_XBIN = MKBETAG('X','B','I','N'),
|
||||
CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'),
|
||||
CODEC_ID_OTF = MKBETAG( 0 ,'O','T','F'),
|
||||
|
||||
CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it
|
||||
|
||||
CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS
|
||||
* stream (only used by libavformat) */
|
||||
CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems
|
||||
* stream (only used by libavformat) */
|
||||
CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information.
|
||||
|
||||
#endif /* AVCODEC_OLD_CODEC_IDS_H */
|
|
@ -24,11 +24,17 @@
|
|||
#ifndef AVCODEC_VAAPI_H
|
||||
#define AVCODEC_VAAPI_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_vaapi
|
||||
* Public libavcodec VA API header.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* \defgroup VAAPI_Decoding VA API Decoding
|
||||
* \ingroup Decoder
|
||||
* @defgroup lavc_codec_hwaccel_vaapi VA API Decoding
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
|
|
@ -0,0 +1,226 @@
|
|||
/*
|
||||
* VDA HW acceleration
|
||||
*
|
||||
* copyright (c) 2011 Sebastien Zwickert
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VDA_H
|
||||
#define AVCODEC_VDA_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_vda
|
||||
* Public libavcodec VDA header.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes
|
||||
// http://openradar.appspot.com/8026390
|
||||
#undef __GNUC_STDC_INLINE__
|
||||
|
||||
#define Picture QuickdrawPicture
|
||||
#include <VideoDecodeAcceleration/VDADecoder.h>
|
||||
#undef Picture
|
||||
|
||||
#include "libavcodec/version.h"
|
||||
|
||||
#if FF_API_VDA_ASYNC
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_vda VDA
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if FF_API_VDA_ASYNC
|
||||
/**
|
||||
* This structure is used to store decoded frame information and data.
|
||||
*
|
||||
* @deprecated Use synchronous decoding mode.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* The PTS of the frame.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
int64_t pts;
|
||||
|
||||
/**
|
||||
* The CoreVideo buffer that contains the decoded data.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
CVPixelBufferRef cv_buffer;
|
||||
|
||||
/**
|
||||
* A pointer to the next frame.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
struct vda_frame *next_frame;
|
||||
} vda_frame;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This structure is used to provide the necessary configurations and data
|
||||
* to the VDA FFmpeg HWAccel implementation.
|
||||
*
|
||||
* The application must make it available as AVCodecContext.hwaccel_context.
|
||||
*/
|
||||
struct vda_context {
|
||||
/**
|
||||
* VDA decoder object.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
VDADecoder decoder;
|
||||
|
||||
/**
|
||||
* The Core Video pixel buffer that contains the current image data.
|
||||
*
|
||||
* encoding: unused
|
||||
* decoding: Set by libavcodec. Unset by user.
|
||||
*/
|
||||
CVPixelBufferRef cv_buffer;
|
||||
|
||||
/**
|
||||
* Use the hardware decoder in synchronous mode.
|
||||
*
|
||||
* encoding: unused
|
||||
* decoding: Set by user.
|
||||
*/
|
||||
int use_sync_decoding;
|
||||
|
||||
#if FF_API_VDA_ASYNC
|
||||
/**
|
||||
* VDA frames queue ordered by presentation timestamp.
|
||||
*
|
||||
* @deprecated Use synchronous decoding mode.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
vda_frame *queue;
|
||||
|
||||
/**
|
||||
* Mutex for locking queue operations.
|
||||
*
|
||||
* @deprecated Use synchronous decoding mode.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
pthread_mutex_t queue_mutex;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The frame width.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
int width;
|
||||
|
||||
/**
|
||||
* The frame height.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
int height;
|
||||
|
||||
/**
|
||||
* The frame format.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
int format;
|
||||
|
||||
/**
|
||||
* The pixel format for output image buffers.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by user.
|
||||
*/
|
||||
OSType cv_pix_fmt_type;
|
||||
|
||||
/**
|
||||
* The current bitstream buffer.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
uint8_t *priv_bitstream;
|
||||
|
||||
/**
|
||||
* The current size of the bitstream.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
int priv_bitstream_size;
|
||||
|
||||
/**
|
||||
* The reference size used for fast reallocation.
|
||||
*
|
||||
* - encoding: unused
|
||||
* - decoding: Set/Unset by libavcodec.
|
||||
*/
|
||||
int priv_allocated_size;
|
||||
};
|
||||
|
||||
/** Create the video decoder. */
|
||||
int ff_vda_create_decoder(struct vda_context *vda_ctx,
|
||||
uint8_t *extradata,
|
||||
int extradata_size);
|
||||
|
||||
/** Destroy the video decoder. */
|
||||
int ff_vda_destroy_decoder(struct vda_context *vda_ctx);
|
||||
|
||||
#if FF_API_VDA_ASYNC
|
||||
/**
|
||||
* Return the top frame of the queue.
|
||||
*
|
||||
* @deprecated Use synchronous decoding mode.
|
||||
*/
|
||||
vda_frame *ff_vda_queue_pop(struct vda_context *vda_ctx);
|
||||
|
||||
/**
|
||||
* Release the given frame.
|
||||
*
|
||||
* @deprecated Use synchronous decoding mode.
|
||||
*/
|
||||
void ff_vda_release_vda_frame(vda_frame *frame);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_VDA_H */
|
|
@ -25,7 +25,15 @@
|
|||
#define AVCODEC_VDPAU_H
|
||||
|
||||
/**
|
||||
* \defgroup Decoder VDPAU Decoder and Renderer
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_vdpau
|
||||
* Public libavcodec VDPAU header.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_vdpau VDPAU Decoder and Renderer
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
*
|
||||
* VDPAU hardware acceleration has two modules
|
||||
* - VDPAU decoding
|
||||
|
@ -39,25 +47,84 @@
|
|||
* presentation (vo_vdpau.c) module.
|
||||
*
|
||||
* @{
|
||||
* \defgroup VDPAU_Decoding VDPAU Decoding
|
||||
* \ingroup Decoder
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <vdpau/vdpau.h>
|
||||
#include <vdpau/vdpau_x11.h>
|
||||
|
||||
/** \brief The videoSurface is used for rendering. */
|
||||
union FFVdpPictureInfo {
|
||||
VdpPictureInfoH264 h264;
|
||||
VdpPictureInfoMPEG1Or2 mpeg;
|
||||
VdpPictureInfoVC1 vc1;
|
||||
VdpPictureInfoMPEG4Part2 mpeg4;
|
||||
};
|
||||
|
||||
/**
|
||||
* This structure is used to share data between the libavcodec library and
|
||||
* the client video application.
|
||||
* The user shall zero-allocate the structure and make it available as
|
||||
* AVCodecContext.hwaccel_context. Members can be set by the user once
|
||||
* during initialization or through each AVCodecContext.get_buffer()
|
||||
* function call. In any case, they must be valid prior to calling
|
||||
* decoding functions.
|
||||
*/
|
||||
typedef struct AVVDPAUContext {
|
||||
/**
|
||||
* VDPAU decoder handle
|
||||
*
|
||||
* Set by user.
|
||||
*/
|
||||
VdpDecoder decoder;
|
||||
|
||||
/**
|
||||
* VDPAU decoder render callback
|
||||
*
|
||||
* Set by the user.
|
||||
*/
|
||||
VdpDecoderRender *render;
|
||||
|
||||
/**
|
||||
* VDPAU picture information
|
||||
*
|
||||
* Set by libavcodec.
|
||||
*/
|
||||
union FFVdpPictureInfo info;
|
||||
|
||||
/**
|
||||
* Allocated size of the bitstream_buffers table.
|
||||
*
|
||||
* Set by libavcodec.
|
||||
*/
|
||||
int bitstream_buffers_allocated;
|
||||
|
||||
/**
|
||||
* Useful bitstream buffers in the bitstream buffers table.
|
||||
*
|
||||
* Set by libavcodec.
|
||||
*/
|
||||
int bitstream_buffers_used;
|
||||
|
||||
/**
|
||||
* Table of bitstream buffers.
|
||||
* The user is responsible for freeing this buffer using av_freep().
|
||||
*
|
||||
* Set by libavcodec.
|
||||
*/
|
||||
VdpBitstreamBuffer *bitstream_buffers;
|
||||
} AVVDPAUContext;
|
||||
|
||||
|
||||
/** @brief The videoSurface is used for rendering. */
|
||||
#define FF_VDPAU_STATE_USED_FOR_RENDER 1
|
||||
|
||||
/**
|
||||
* \brief The videoSurface is needed for reference/prediction.
|
||||
* @brief The videoSurface is needed for reference/prediction.
|
||||
* The codec manipulates this.
|
||||
*/
|
||||
#define FF_VDPAU_STATE_USED_FOR_REFERENCE 2
|
||||
|
||||
/**
|
||||
* \brief This structure is used as a callback between the FFmpeg
|
||||
* @brief This structure is used as a callback between the FFmpeg
|
||||
* decoder (vd_) and presentation (vo_) module.
|
||||
* This is used for defining a video frame containing surface,
|
||||
* picture parameter, bitstream information etc which are passed
|
||||
|
@ -68,20 +135,15 @@ struct vdpau_render_state {
|
|||
|
||||
int state; ///< Holds FF_VDPAU_STATE_* values.
|
||||
|
||||
/** picture parameter information for all supported codecs */
|
||||
union VdpPictureInfo {
|
||||
VdpPictureInfoH264 h264;
|
||||
VdpPictureInfoMPEG1Or2 mpeg;
|
||||
VdpPictureInfoVC1 vc1;
|
||||
VdpPictureInfoMPEG4Part2 mpeg4;
|
||||
} info;
|
||||
|
||||
/** Describe size/location of the compressed video data.
|
||||
Set to 0 when freeing bitstream_buffers. */
|
||||
int bitstream_buffers_allocated;
|
||||
int bitstream_buffers_used;
|
||||
/** The user is responsible for freeing this buffer using av_freep(). */
|
||||
VdpBitstreamBuffer *bitstream_buffers;
|
||||
|
||||
/** picture parameter information for all supported codecs */
|
||||
union FFVdpPictureInfo info;
|
||||
};
|
||||
|
||||
/* @}*/
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_VERSION_H
|
||||
#define AVCODEC_VERSION_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup libavc
|
||||
* Libavcodec version macros.
|
||||
*/
|
||||
|
||||
#include "libavutil/avutil.h"
|
||||
|
||||
#define LIBAVCODEC_VERSION_MAJOR 54
|
||||
#define LIBAVCODEC_VERSION_MINOR 92
|
||||
#define LIBAVCODEC_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
LIBAVCODEC_VERSION_MINOR, \
|
||||
LIBAVCODEC_VERSION_MICRO)
|
||||
#define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \
|
||||
LIBAVCODEC_VERSION_MINOR, \
|
||||
LIBAVCODEC_VERSION_MICRO)
|
||||
#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
|
||||
|
||||
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
|
||||
|
||||
/**
|
||||
* FF_API_* defines may be placed below to indicate public API that will be
|
||||
* dropped at a future version bump. The defines themselves are not part of
|
||||
* the public API and may change, break or disappear at any time.
|
||||
*/
|
||||
|
||||
#ifndef FF_API_REQUEST_CHANNELS
|
||||
#define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_ALLOC_CONTEXT
|
||||
#define FF_API_ALLOC_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_AVCODEC_OPEN
|
||||
#define FF_API_AVCODEC_OPEN (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_DECODE_AUDIO
|
||||
#define FF_API_OLD_DECODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_TIMECODE
|
||||
#define FF_API_OLD_TIMECODE (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
|
||||
#ifndef FF_API_OLD_ENCODE_AUDIO
|
||||
#define FF_API_OLD_ENCODE_AUDIO (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_OLD_ENCODE_VIDEO
|
||||
#define FF_API_OLD_ENCODE_VIDEO (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_MPV_GLOBAL_OPTS
|
||||
#define FF_API_MPV_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_COLOR_TABLE_ID
|
||||
#define FF_API_COLOR_TABLE_ID (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_INTER_THRESHOLD
|
||||
#define FF_API_INTER_THRESHOLD (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_SUB_ID
|
||||
#define FF_API_SUB_ID (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_DSP_MASK
|
||||
#define FF_API_DSP_MASK (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_FIND_BEST_PIX_FMT
|
||||
#define FF_API_FIND_BEST_PIX_FMT (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_CODEC_ID
|
||||
#define FF_API_CODEC_ID (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_VDA_ASYNC
|
||||
#define FF_API_VDA_ASYNC (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_AVCODEC_RESAMPLE
|
||||
#define FF_API_AVCODEC_RESAMPLE (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_LIBMPEG2
|
||||
#define FF_API_LIBMPEG2 (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_MMI
|
||||
#define FF_API_MMI (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_IDCT
|
||||
#define FF_API_IDCT (LIBAVCODEC_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_DEINTERLACE
|
||||
#define FF_API_DEINTERLACE (LIBAVCODEC_VERSION_MAJOR < 56)
|
||||
#endif
|
||||
|
||||
#endif /* AVCODEC_VERSION_H */
|
|
@ -21,15 +21,23 @@
|
|||
#ifndef AVCODEC_XVMC_H
|
||||
#define AVCODEC_XVMC_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_codec_hwaccel_xvmc
|
||||
* Public libavcodec XvMC header.
|
||||
*/
|
||||
|
||||
#include <X11/extensions/XvMC.h>
|
||||
|
||||
#include "avcodec.h"
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
#define AV_XVMC_STATE_DISPLAY_PENDING 1 /** the surface should be shown, the video driver manipulates this */
|
||||
#define AV_XVMC_STATE_PREDICTION 2 /** the surface is needed for prediction, the codec manipulates this */
|
||||
#define AV_XVMC_STATE_OSD_SOURCE 4 /** the surface is needed for subpicture rendering */
|
||||
#endif
|
||||
/**
|
||||
* @defgroup lavc_codec_hwaccel_xvmc XvMC
|
||||
* @ingroup lavc_codec_hwaccel
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AV_XVMC_ID 0x1DC711C0 /**< special value to ensure that regular pixel routines haven't corrupted the struct
|
||||
the number is 1337 speak for the letters IDCT MCo (motion compensation) */
|
||||
|
||||
|
@ -71,7 +79,7 @@ struct xvmc_pix_fmt {
|
|||
*/
|
||||
int allocated_data_blocks;
|
||||
|
||||
/** Indicates that the hardware would interpret data_blocks as IDCT
|
||||
/** Indicate that the hardware would interpret data_blocks as IDCT
|
||||
coefficients and perform IDCT on them.
|
||||
- application - set during initialization
|
||||
- libavcodec - unchanged
|
||||
|
@ -139,7 +147,7 @@ struct xvmc_pix_fmt {
|
|||
*/
|
||||
int filled_mv_blocks_num;
|
||||
|
||||
/** Number of the the next free data block; one data block consists of
|
||||
/** Number of the next free data block; one data block consists of
|
||||
64 short values in the data_blocks array.
|
||||
All blocks before this one have already been claimed by placing their
|
||||
position into the corresponding block description structure field,
|
||||
|
@ -151,22 +159,10 @@ struct xvmc_pix_fmt {
|
|||
of coded blocks it contains.
|
||||
*/
|
||||
int next_free_data_block_num;
|
||||
|
||||
/** extensions may be placed here */
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 53
|
||||
//@{
|
||||
/** State flags used to work around limitations in the MPlayer video system.
|
||||
0 - Surface is not used.
|
||||
1 - Surface is still held in application to be displayed or is
|
||||
still visible.
|
||||
2 - Surface is still held in libavcodec buffer for prediction.
|
||||
*/
|
||||
int state;
|
||||
|
||||
/** pointer to the surface where the subpicture is rendered */
|
||||
void* p_osd_target_surface_render;
|
||||
//}@
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_XVMC_H */
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVDEVICE_AVDEVICE_H
|
||||
#define AVDEVICE_AVDEVICE_H
|
||||
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavd
|
||||
* Main libavdevice API header
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lavd Special devices muxing/demuxing library
|
||||
* @{
|
||||
* Libavdevice is a complementary library to @ref libavf "libavformat". It
|
||||
* provides various "special" platform-specific muxers and demuxers, e.g. for
|
||||
* grabbing devices, audio capture and playback etc. As a consequence, the
|
||||
* (de)muxers in libavdevice are of the AVFMT_NOFILE type (they use their own
|
||||
* I/O functions). The filename passed to avformat_open_input() often does not
|
||||
* refer to an actually existing file, but has some special device-specific
|
||||
* meaning - e.g. for x11grab it is the display name.
|
||||
*
|
||||
* To use libavdevice, simply call avdevice_register_all() to register all
|
||||
* compiled muxers and demuxers. They all use standard libavformat API.
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "libavformat/avformat.h"
|
||||
|
||||
/**
|
||||
* Return the LIBAVDEVICE_VERSION_INT constant.
|
||||
*/
|
||||
unsigned avdevice_version(void);
|
||||
|
||||
/**
|
||||
* Return the libavdevice build-time configuration.
|
||||
*/
|
||||
const char *avdevice_configuration(void);
|
||||
|
||||
/**
|
||||
* Return the libavdevice license.
|
||||
*/
|
||||
const char *avdevice_license(void);
|
||||
|
||||
/**
|
||||
* Initialize libavdevice and register all the input and output devices.
|
||||
* @warning This function is not thread safe.
|
||||
*/
|
||||
void avdevice_register_all(void);
|
||||
|
||||
#endif /* AVDEVICE_AVDEVICE_H */
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVDEVICE_VERSION_H
|
||||
#define AVDEVICE_VERSION_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavd
|
||||
* Libavdevice version macros
|
||||
*/
|
||||
|
||||
#include "libavutil/avutil.h"
|
||||
|
||||
#define LIBAVDEVICE_VERSION_MAJOR 54
|
||||
#define LIBAVDEVICE_VERSION_MINOR 3
|
||||
#define LIBAVDEVICE_VERSION_MICRO 103
|
||||
|
||||
#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
|
||||
LIBAVDEVICE_VERSION_MINOR, \
|
||||
LIBAVDEVICE_VERSION_MICRO)
|
||||
#define LIBAVDEVICE_VERSION AV_VERSION(LIBAVDEVICE_VERSION_MAJOR, \
|
||||
LIBAVDEVICE_VERSION_MINOR, \
|
||||
LIBAVDEVICE_VERSION_MICRO)
|
||||
#define LIBAVDEVICE_BUILD LIBAVDEVICE_VERSION_INT
|
||||
|
||||
#define LIBAVDEVICE_IDENT "Lavd" AV_STRINGIFY(LIBAVDEVICE_VERSION)
|
||||
|
||||
/**
|
||||
* FF_API_* defines may be placed below to indicate public API that will be
|
||||
* dropped at a future version bump. The defines themselves are not part of
|
||||
* the public API and may change, break or disappear at any time.
|
||||
*/
|
||||
|
||||
#endif /* AVDEVICE_VERSION_H */
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVFILTER_ASRC_ABUFFER_H
|
||||
#define AVFILTER_ASRC_ABUFFER_H
|
||||
|
||||
#include "avfilter.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
* memory buffer source for audio
|
||||
*
|
||||
* @deprecated use buffersrc.h instead.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Queue an audio buffer to the audio buffer source.
|
||||
*
|
||||
* @param abuffersrc audio source buffer context
|
||||
* @param data pointers to the samples planes
|
||||
* @param linesize linesizes of each audio buffer plane
|
||||
* @param nb_samples number of samples per channel
|
||||
* @param sample_fmt sample format of the audio data
|
||||
* @param ch_layout channel layout of the audio data
|
||||
* @param planar flag to indicate if audio data is planar or packed
|
||||
* @param pts presentation timestamp of the audio buffer
|
||||
* @param flags unused
|
||||
*
|
||||
* @deprecated use av_buffersrc_add_ref() instead.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_asrc_buffer_add_samples(AVFilterContext *abuffersrc,
|
||||
uint8_t *data[8], int linesize[8],
|
||||
int nb_samples, int sample_rate,
|
||||
int sample_fmt, int64_t ch_layout, int planar,
|
||||
int64_t pts, int av_unused flags);
|
||||
|
||||
/**
|
||||
* Queue an audio buffer to the audio buffer source.
|
||||
*
|
||||
* This is similar to av_asrc_buffer_add_samples(), but the samples
|
||||
* are stored in a buffer with known size.
|
||||
*
|
||||
* @param abuffersrc audio source buffer context
|
||||
* @param buf pointer to the samples data, packed is assumed
|
||||
* @param size the size in bytes of the buffer, it must contain an
|
||||
* integer number of samples
|
||||
* @param sample_fmt sample format of the audio data
|
||||
* @param ch_layout channel layout of the audio data
|
||||
* @param pts presentation timestamp of the audio buffer
|
||||
* @param flags unused
|
||||
*
|
||||
* @deprecated use av_buffersrc_add_ref() instead.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_asrc_buffer_add_buffer(AVFilterContext *abuffersrc,
|
||||
uint8_t *buf, int buf_size,
|
||||
int sample_rate,
|
||||
int sample_fmt, int64_t ch_layout, int planar,
|
||||
int64_t pts, int av_unused flags);
|
||||
|
||||
/**
|
||||
* Queue an audio buffer to the audio buffer source.
|
||||
*
|
||||
* @param abuffersrc audio source buffer context
|
||||
* @param samplesref buffer ref to queue
|
||||
* @param flags unused
|
||||
*
|
||||
* @deprecated use av_buffersrc_add_ref() instead.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_asrc_buffer_add_audio_buffer_ref(AVFilterContext *abuffersrc,
|
||||
AVFilterBufferRef *samplesref,
|
||||
int av_unused flags);
|
||||
|
||||
#endif /* AVFILTER_ASRC_ABUFFER_H */
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVFILTER_AVCODEC_H
|
||||
#define AVFILTER_AVCODEC_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* libavcodec/libavfilter gluing utilities
|
||||
*
|
||||
* This should be included in an application ONLY if the installed
|
||||
* libavfilter has been compiled with libavcodec support, otherwise
|
||||
* symbols defined below will not be available.
|
||||
*/
|
||||
|
||||
#include "libavcodec/avcodec.h" // AVFrame
|
||||
#include "avfilter.h"
|
||||
|
||||
/**
|
||||
* Copy the frame properties of src to dst, without copying the actual
|
||||
* image data.
|
||||
*
|
||||
* @return 0 on success, a negative number on error.
|
||||
*/
|
||||
int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src);
|
||||
|
||||
/**
|
||||
* Copy the frame properties and data pointers of src to dst, without copying
|
||||
* the actual data.
|
||||
*
|
||||
* @return 0 on success, a negative number on error.
|
||||
*/
|
||||
int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src);
|
||||
|
||||
/**
|
||||
* Create and return a picref reference from the data and properties
|
||||
* contained in frame.
|
||||
*
|
||||
* @param perms permissions to assign to the new buffer reference
|
||||
*/
|
||||
AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame, int perms);
|
||||
|
||||
|
||||
/**
|
||||
* Create and return a picref reference from the data and properties
|
||||
* contained in frame.
|
||||
*
|
||||
* @param perms permissions to assign to the new buffer reference
|
||||
*/
|
||||
AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_frame(const AVFrame *frame,
|
||||
int perms);
|
||||
|
||||
/**
|
||||
* Create and return a buffer reference from the data and properties
|
||||
* contained in frame.
|
||||
*
|
||||
* @param perms permissions to assign to the new buffer reference
|
||||
*/
|
||||
AVFilterBufferRef *avfilter_get_buffer_ref_from_frame(enum AVMediaType type,
|
||||
const AVFrame *frame,
|
||||
int perms);
|
||||
|
||||
#ifdef FF_API_FILL_FRAME
|
||||
/**
|
||||
* Fill an AVFrame with the information stored in samplesref.
|
||||
*
|
||||
* @param frame an already allocated AVFrame
|
||||
* @param samplesref an audio buffer reference
|
||||
* @return 0 in case of success, a negative AVERROR code in case of
|
||||
* failure
|
||||
* @deprecated Use avfilter_copy_buf_props() instead.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int avfilter_fill_frame_from_audio_buffer_ref(AVFrame *frame,
|
||||
const AVFilterBufferRef *samplesref);
|
||||
|
||||
/**
|
||||
* Fill an AVFrame with the information stored in picref.
|
||||
*
|
||||
* @param frame an already allocated AVFrame
|
||||
* @param picref a video buffer reference
|
||||
* @return 0 in case of success, a negative AVERROR code in case of
|
||||
* failure
|
||||
* @deprecated Use avfilter_copy_buf_props() instead.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
|
||||
const AVFilterBufferRef *picref);
|
||||
|
||||
/**
|
||||
* Fill an AVFrame with information stored in ref.
|
||||
*
|
||||
* @param frame an already allocated AVFrame
|
||||
* @param ref a video or audio buffer reference
|
||||
* @return 0 in case of success, a negative AVERROR code in case of
|
||||
* failure
|
||||
* @deprecated Use avfilter_copy_buf_props() instead.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int avfilter_fill_frame_from_buffer_ref(AVFrame *frame,
|
||||
const AVFilterBufferRef *ref);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Add frame data to buffer_src.
|
||||
*
|
||||
* @param buffer_src pointer to a buffer source context
|
||||
* @param frame a frame, or NULL to mark EOF
|
||||
* @param flags a combination of AV_BUFFERSRC_FLAG_*
|
||||
* @return >= 0 in case of success, a negative AVERROR code
|
||||
* in case of failure
|
||||
*/
|
||||
int av_buffersrc_add_frame(AVFilterContext *buffer_src,
|
||||
const AVFrame *frame, int flags);
|
||||
|
||||
#endif /* AVFILTER_AVCODEC_H */
|
|
@ -0,0 +1,852 @@
|
|||
/*
|
||||
* filter layer
|
||||
* Copyright (c) 2007 Bobby Bingham
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVFILTER_AVFILTER_H
|
||||
#define AVFILTER_AVFILTER_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavfi
|
||||
* external API header
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lavfi Libavfilter
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "libavutil/avutil.h"
|
||||
#include "libavutil/dict.h"
|
||||
#include "libavutil/log.h"
|
||||
#include "libavutil/samplefmt.h"
|
||||
#include "libavutil/pixfmt.h"
|
||||
#include "libavutil/rational.h"
|
||||
|
||||
#include "libavfilter/version.h"
|
||||
|
||||
/**
|
||||
* Return the LIBAVFILTER_VERSION_INT constant.
|
||||
*/
|
||||
unsigned avfilter_version(void);
|
||||
|
||||
/**
|
||||
* Return the libavfilter build-time configuration.
|
||||
*/
|
||||
const char *avfilter_configuration(void);
|
||||
|
||||
/**
|
||||
* Return the libavfilter license.
|
||||
*/
|
||||
const char *avfilter_license(void);
|
||||
|
||||
/**
|
||||
* Get the class for the AVFilterContext struct.
|
||||
*/
|
||||
const AVClass *avfilter_get_class(void);
|
||||
|
||||
typedef struct AVFilterContext AVFilterContext;
|
||||
typedef struct AVFilterLink AVFilterLink;
|
||||
typedef struct AVFilterPad AVFilterPad;
|
||||
typedef struct AVFilterFormats AVFilterFormats;
|
||||
|
||||
/**
|
||||
* A reference-counted buffer data type used by the filter system. Filters
|
||||
* should not store pointers to this structure directly, but instead use the
|
||||
* AVFilterBufferRef structure below.
|
||||
*/
|
||||
typedef struct AVFilterBuffer {
|
||||
uint8_t *data[8]; ///< buffer data for each plane/channel
|
||||
|
||||
/**
|
||||
* pointers to the data planes/channels.
|
||||
*
|
||||
* For video, this should simply point to data[].
|
||||
*
|
||||
* For planar audio, each channel has a separate data pointer, and
|
||||
* linesize[0] contains the size of each channel buffer.
|
||||
* For packed audio, there is just one data pointer, and linesize[0]
|
||||
* contains the total size of the buffer for all channels.
|
||||
*
|
||||
* Note: Both data and extended_data will always be set, but for planar
|
||||
* audio with more channels that can fit in data, extended_data must be used
|
||||
* in order to access all channels.
|
||||
*/
|
||||
uint8_t **extended_data;
|
||||
int linesize[8]; ///< number of bytes per line
|
||||
|
||||
/** private data to be used by a custom free function */
|
||||
void *priv;
|
||||
/**
|
||||
* A pointer to the function to deallocate this buffer if the default
|
||||
* function is not sufficient. This could, for example, add the memory
|
||||
* back into a memory pool to be reused later without the overhead of
|
||||
* reallocating it from scratch.
|
||||
*/
|
||||
void (*free)(struct AVFilterBuffer *buf);
|
||||
|
||||
int format; ///< media format
|
||||
int w, h; ///< width and height of the allocated buffer
|
||||
unsigned refcount; ///< number of references to this buffer
|
||||
} AVFilterBuffer;
|
||||
|
||||
#define AV_PERM_READ 0x01 ///< can read from the buffer
|
||||
#define AV_PERM_WRITE 0x02 ///< can write to the buffer
|
||||
#define AV_PERM_PRESERVE 0x04 ///< nobody else can overwrite the buffer
|
||||
#define AV_PERM_REUSE 0x08 ///< can output the buffer multiple times, with the same contents each time
|
||||
#define AV_PERM_REUSE2 0x10 ///< can output the buffer multiple times, modified each time
|
||||
#define AV_PERM_NEG_LINESIZES 0x20 ///< the buffer requested can have negative linesizes
|
||||
#define AV_PERM_ALIGN 0x40 ///< the buffer must be aligned
|
||||
|
||||
#define AVFILTER_ALIGN 16 //not part of ABI
|
||||
|
||||
/**
|
||||
* Audio specific properties in a reference to an AVFilterBuffer. Since
|
||||
* AVFilterBufferRef is common to different media formats, audio specific
|
||||
* per reference properties must be separated out.
|
||||
*/
|
||||
typedef struct AVFilterBufferRefAudioProps {
|
||||
uint64_t channel_layout; ///< channel layout of audio buffer
|
||||
int nb_samples; ///< number of audio samples per channel
|
||||
int sample_rate; ///< audio buffer sample rate
|
||||
int channels; ///< number of channels (do not access directly)
|
||||
} AVFilterBufferRefAudioProps;
|
||||
|
||||
/**
|
||||
* Video specific properties in a reference to an AVFilterBuffer. Since
|
||||
* AVFilterBufferRef is common to different media formats, video specific
|
||||
* per reference properties must be separated out.
|
||||
*/
|
||||
typedef struct AVFilterBufferRefVideoProps {
|
||||
int w; ///< image width
|
||||
int h; ///< image height
|
||||
AVRational sample_aspect_ratio; ///< sample aspect ratio
|
||||
int interlaced; ///< is frame interlaced
|
||||
int top_field_first; ///< field order
|
||||
enum AVPictureType pict_type; ///< picture type of the frame
|
||||
int key_frame; ///< 1 -> keyframe, 0-> not
|
||||
int qp_table_linesize; ///< qp_table stride
|
||||
int qp_table_size; ///< qp_table size
|
||||
int8_t *qp_table; ///< array of Quantization Parameters
|
||||
} AVFilterBufferRefVideoProps;
|
||||
|
||||
/**
|
||||
* A reference to an AVFilterBuffer. Since filters can manipulate the origin of
|
||||
* a buffer to, for example, crop image without any memcpy, the buffer origin
|
||||
* and dimensions are per-reference properties. Linesize is also useful for
|
||||
* image flipping, frame to field filters, etc, and so is also per-reference.
|
||||
*
|
||||
* TODO: add anything necessary for frame reordering
|
||||
*/
|
||||
typedef struct AVFilterBufferRef {
|
||||
AVFilterBuffer *buf; ///< the buffer that this is a reference to
|
||||
uint8_t *data[8]; ///< picture/audio data for each plane
|
||||
/**
|
||||
* pointers to the data planes/channels.
|
||||
*
|
||||
* For video, this should simply point to data[].
|
||||
*
|
||||
* For planar audio, each channel has a separate data pointer, and
|
||||
* linesize[0] contains the size of each channel buffer.
|
||||
* For packed audio, there is just one data pointer, and linesize[0]
|
||||
* contains the total size of the buffer for all channels.
|
||||
*
|
||||
* Note: Both data and extended_data will always be set, but for planar
|
||||
* audio with more channels that can fit in data, extended_data must be used
|
||||
* in order to access all channels.
|
||||
*/
|
||||
uint8_t **extended_data;
|
||||
int linesize[8]; ///< number of bytes per line
|
||||
|
||||
AVFilterBufferRefVideoProps *video; ///< video buffer specific properties
|
||||
AVFilterBufferRefAudioProps *audio; ///< audio buffer specific properties
|
||||
|
||||
/**
|
||||
* presentation timestamp. The time unit may change during
|
||||
* filtering, as it is specified in the link and the filter code
|
||||
* may need to rescale the PTS accordingly.
|
||||
*/
|
||||
int64_t pts;
|
||||
int64_t pos; ///< byte position in stream, -1 if unknown
|
||||
|
||||
int format; ///< media format
|
||||
|
||||
int perms; ///< permissions, see the AV_PERM_* flags
|
||||
|
||||
enum AVMediaType type; ///< media type of buffer data
|
||||
|
||||
AVDictionary *metadata; ///< dictionary containing metadata key=value tags
|
||||
} AVFilterBufferRef;
|
||||
|
||||
/**
|
||||
* Copy properties of src to dst, without copying the actual data
|
||||
*/
|
||||
void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src);
|
||||
|
||||
/**
|
||||
* Add a new reference to a buffer.
|
||||
*
|
||||
* @param ref an existing reference to the buffer
|
||||
* @param pmask a bitmask containing the allowable permissions in the new
|
||||
* reference
|
||||
* @return a new reference to the buffer with the same properties as the
|
||||
* old, excluding any permissions denied by pmask
|
||||
*/
|
||||
AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask);
|
||||
|
||||
/**
|
||||
* Remove a reference to a buffer. If this is the last reference to the
|
||||
* buffer, the buffer itself is also automatically freed.
|
||||
*
|
||||
* @param ref reference to the buffer, may be NULL
|
||||
*
|
||||
* @note it is recommended to use avfilter_unref_bufferp() instead of this
|
||||
* function
|
||||
*/
|
||||
void avfilter_unref_buffer(AVFilterBufferRef *ref);
|
||||
|
||||
/**
|
||||
* Remove a reference to a buffer and set the pointer to NULL.
|
||||
* If this is the last reference to the buffer, the buffer itself
|
||||
* is also automatically freed.
|
||||
*
|
||||
* @param ref pointer to the buffer reference
|
||||
*/
|
||||
void avfilter_unref_bufferp(AVFilterBufferRef **ref);
|
||||
|
||||
/**
|
||||
* Get the number of channels of a buffer reference.
|
||||
*/
|
||||
int avfilter_ref_get_channels(AVFilterBufferRef *ref);
|
||||
|
||||
#if FF_API_AVFILTERPAD_PUBLIC
|
||||
/**
|
||||
* A filter pad used for either input or output.
|
||||
*
|
||||
* See doc/filter_design.txt for details on how to implement the methods.
|
||||
*
|
||||
* @warning this struct might be removed from public API.
|
||||
* users should call avfilter_pad_get_name() and avfilter_pad_get_type()
|
||||
* to access the name and type fields; there should be no need to access
|
||||
* any other fields from outside of libavfilter.
|
||||
*/
|
||||
struct AVFilterPad {
|
||||
/**
|
||||
* Pad name. The name is unique among inputs and among outputs, but an
|
||||
* input may have the same name as an output. This may be NULL if this
|
||||
* pad has no need to ever be referenced by name.
|
||||
*/
|
||||
const char *name;
|
||||
|
||||
/**
|
||||
* AVFilterPad type.
|
||||
*/
|
||||
enum AVMediaType type;
|
||||
|
||||
/**
|
||||
* Input pads:
|
||||
* Minimum required permissions on incoming buffers. Any buffer with
|
||||
* insufficient permissions will be automatically copied by the filter
|
||||
* system to a new buffer which provides the needed access permissions.
|
||||
*
|
||||
* Output pads:
|
||||
* Guaranteed permissions on outgoing buffers. Any buffer pushed on the
|
||||
* link must have at least these permissions; this fact is checked by
|
||||
* asserts. It can be used to optimize buffer allocation.
|
||||
*/
|
||||
int min_perms;
|
||||
|
||||
/**
|
||||
* Input pads:
|
||||
* Permissions which are not accepted on incoming buffers. Any buffer
|
||||
* which has any of these permissions set will be automatically copied
|
||||
* by the filter system to a new buffer which does not have those
|
||||
* permissions. This can be used to easily disallow buffers with
|
||||
* AV_PERM_REUSE.
|
||||
*
|
||||
* Output pads:
|
||||
* Permissions which are automatically removed on outgoing buffers. It
|
||||
* can be used to optimize buffer allocation.
|
||||
*/
|
||||
int rej_perms;
|
||||
|
||||
/**
|
||||
* @deprecated unused
|
||||
*/
|
||||
int (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref);
|
||||
|
||||
/**
|
||||
* Callback function to get a video buffer. If NULL, the filter system will
|
||||
* use ff_default_get_video_buffer().
|
||||
*
|
||||
* Input video pads only.
|
||||
*/
|
||||
AVFilterBufferRef *(*get_video_buffer)(AVFilterLink *link, int perms, int w, int h);
|
||||
|
||||
/**
|
||||
* Callback function to get an audio buffer. If NULL, the filter system will
|
||||
* use ff_default_get_audio_buffer().
|
||||
*
|
||||
* Input audio pads only.
|
||||
*/
|
||||
AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
|
||||
int nb_samples);
|
||||
|
||||
/**
|
||||
* @deprecated unused
|
||||
*/
|
||||
int (*end_frame)(AVFilterLink *link);
|
||||
|
||||
/**
|
||||
* @deprecated unused
|
||||
*/
|
||||
int (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
|
||||
|
||||
/**
|
||||
* Filtering callback. This is where a filter receives a frame with
|
||||
* audio/video data and should do its processing.
|
||||
*
|
||||
* Input pads only.
|
||||
*
|
||||
* @return >= 0 on success, a negative AVERROR on error. This function
|
||||
* must ensure that frame is properly unreferenced on error if it
|
||||
* hasn't been passed on to another filter.
|
||||
*/
|
||||
int (*filter_frame)(AVFilterLink *link, AVFilterBufferRef *frame);
|
||||
|
||||
/**
|
||||
* Frame poll callback. This returns the number of immediately available
|
||||
* samples. It should return a positive value if the next request_frame()
|
||||
* is guaranteed to return one frame (with no delay).
|
||||
*
|
||||
* Defaults to just calling the source poll_frame() method.
|
||||
*
|
||||
* Output pads only.
|
||||
*/
|
||||
int (*poll_frame)(AVFilterLink *link);
|
||||
|
||||
/**
|
||||
* Frame request callback. A call to this should result in at least one
|
||||
* frame being output over the given link. This should return zero on
|
||||
* success, and another value on error.
|
||||
* See ff_request_frame() for the error codes with a specific
|
||||
* meaning.
|
||||
*
|
||||
* Output pads only.
|
||||
*/
|
||||
int (*request_frame)(AVFilterLink *link);
|
||||
|
||||
/**
|
||||
* Link configuration callback.
|
||||
*
|
||||
* For output pads, this should set the following link properties:
|
||||
* video: width, height, sample_aspect_ratio, time_base
|
||||
* audio: sample_rate.
|
||||
*
|
||||
* This should NOT set properties such as format, channel_layout, etc which
|
||||
* are negotiated between filters by the filter system using the
|
||||
* query_formats() callback before this function is called.
|
||||
*
|
||||
* For input pads, this should check the properties of the link, and update
|
||||
* the filter's internal state as necessary.
|
||||
*
|
||||
* For both input and output pads, this should return zero on success,
|
||||
* and another value on error.
|
||||
*/
|
||||
int (*config_props)(AVFilterLink *link);
|
||||
|
||||
/**
|
||||
* The filter expects a fifo to be inserted on its input link,
|
||||
* typically because it has a delay.
|
||||
*
|
||||
* input pads only.
|
||||
*/
|
||||
int needs_fifo;
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the name of an AVFilterPad.
|
||||
*
|
||||
* @param pads an array of AVFilterPads
|
||||
* @param pad_idx index of the pad in the array it; is the caller's
|
||||
* responsibility to ensure the index is valid
|
||||
*
|
||||
* @return name of the pad_idx'th pad in pads
|
||||
*/
|
||||
const char *avfilter_pad_get_name(AVFilterPad *pads, int pad_idx);
|
||||
|
||||
/**
|
||||
* Get the type of an AVFilterPad.
|
||||
*
|
||||
* @param pads an array of AVFilterPads
|
||||
* @param pad_idx index of the pad in the array; it is the caller's
|
||||
* responsibility to ensure the index is valid
|
||||
*
|
||||
* @return type of the pad_idx'th pad in pads
|
||||
*/
|
||||
enum AVMediaType avfilter_pad_get_type(AVFilterPad *pads, int pad_idx);
|
||||
|
||||
/**
|
||||
* Filter definition. This defines the pads a filter contains, and all the
|
||||
* callback functions used to interact with the filter.
|
||||
*/
|
||||
typedef struct AVFilter {
|
||||
const char *name; ///< filter name
|
||||
|
||||
/**
|
||||
* A description for the filter. You should use the
|
||||
* NULL_IF_CONFIG_SMALL() macro to define it.
|
||||
*/
|
||||
const char *description;
|
||||
|
||||
const AVFilterPad *inputs; ///< NULL terminated list of inputs. NULL if none
|
||||
const AVFilterPad *outputs; ///< NULL terminated list of outputs. NULL if none
|
||||
|
||||
/*****************************************************************
|
||||
* All fields below this line are not part of the public API. They
|
||||
* may not be used outside of libavfilter and can be changed and
|
||||
* removed at will.
|
||||
* New public fields should be added right above.
|
||||
*****************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* Filter initialization function. Args contains the user-supplied
|
||||
* parameters. FIXME: maybe an AVOption-based system would be better?
|
||||
*/
|
||||
int (*init)(AVFilterContext *ctx, const char *args);
|
||||
|
||||
/**
|
||||
* Filter uninitialization function. Should deallocate any memory held
|
||||
* by the filter, release any buffer references, etc. This does not need
|
||||
* to deallocate the AVFilterContext->priv memory itself.
|
||||
*/
|
||||
void (*uninit)(AVFilterContext *ctx);
|
||||
|
||||
/**
|
||||
* Queries formats/layouts supported by the filter and its pads, and sets
|
||||
* the in_formats/in_chlayouts for links connected to its output pads,
|
||||
* and out_formats/out_chlayouts for links connected to its input pads.
|
||||
*
|
||||
* @return zero on success, a negative value corresponding to an
|
||||
* AVERROR code otherwise
|
||||
*/
|
||||
int (*query_formats)(AVFilterContext *);
|
||||
|
||||
int priv_size; ///< size of private data to allocate for the filter
|
||||
|
||||
/**
|
||||
* Make the filter instance process a command.
|
||||
*
|
||||
* @param cmd the command to process, for handling simplicity all commands must be alphanumeric only
|
||||
* @param arg the argument for the command
|
||||
* @param res a buffer with size res_size where the filter(s) can return a response. This must not change when the command is not supported.
|
||||
* @param flags if AVFILTER_CMD_FLAG_FAST is set and the command would be
|
||||
* time consuming then a filter should treat it like an unsupported command
|
||||
*
|
||||
* @returns >=0 on success otherwise an error code.
|
||||
* AVERROR(ENOSYS) on unsupported commands
|
||||
*/
|
||||
int (*process_command)(AVFilterContext *, const char *cmd, const char *arg, char *res, int res_len, int flags);
|
||||
|
||||
/**
|
||||
* Filter initialization function, alternative to the init()
|
||||
* callback. Args contains the user-supplied parameters, opaque is
|
||||
* used for providing binary data.
|
||||
*/
|
||||
int (*init_opaque)(AVFilterContext *ctx, const char *args, void *opaque);
|
||||
|
||||
const AVClass *priv_class; ///< private class, containing filter specific options
|
||||
} AVFilter;
|
||||
|
||||
/** An instance of a filter */
|
||||
struct AVFilterContext {
|
||||
const AVClass *av_class; ///< needed for av_log()
|
||||
|
||||
AVFilter *filter; ///< the AVFilter of which this is an instance
|
||||
|
||||
char *name; ///< name of this filter instance
|
||||
|
||||
AVFilterPad *input_pads; ///< array of input pads
|
||||
AVFilterLink **inputs; ///< array of pointers to input links
|
||||
#if FF_API_FOO_COUNT
|
||||
unsigned input_count; ///< @deprecated use nb_inputs
|
||||
#endif
|
||||
unsigned nb_inputs; ///< number of input pads
|
||||
|
||||
AVFilterPad *output_pads; ///< array of output pads
|
||||
AVFilterLink **outputs; ///< array of pointers to output links
|
||||
#if FF_API_FOO_COUNT
|
||||
unsigned output_count; ///< @deprecated use nb_outputs
|
||||
#endif
|
||||
unsigned nb_outputs; ///< number of output pads
|
||||
|
||||
void *priv; ///< private data for use by the filter
|
||||
|
||||
struct AVFilterCommand *command_queue;
|
||||
};
|
||||
|
||||
/**
|
||||
* A link between two filters. This contains pointers to the source and
|
||||
* destination filters between which this link exists, and the indexes of
|
||||
* the pads involved. In addition, this link also contains the parameters
|
||||
* which have been negotiated and agreed upon between the filter, such as
|
||||
* image dimensions, format, etc.
|
||||
*/
|
||||
struct AVFilterLink {
|
||||
AVFilterContext *src; ///< source filter
|
||||
AVFilterPad *srcpad; ///< output pad on the source filter
|
||||
|
||||
AVFilterContext *dst; ///< dest filter
|
||||
AVFilterPad *dstpad; ///< input pad on the dest filter
|
||||
|
||||
enum AVMediaType type; ///< filter media type
|
||||
|
||||
/* These parameters apply only to video */
|
||||
int w; ///< agreed upon image width
|
||||
int h; ///< agreed upon image height
|
||||
AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio
|
||||
/* These parameters apply only to audio */
|
||||
uint64_t channel_layout; ///< channel layout of current buffer (see libavutil/channel_layout.h)
|
||||
int sample_rate; ///< samples per second
|
||||
|
||||
int format; ///< agreed upon media format
|
||||
|
||||
/**
|
||||
* Define the time base used by the PTS of the frames/samples
|
||||
* which will pass through this link.
|
||||
* During the configuration stage, each filter is supposed to
|
||||
* change only the output timebase, while the timebase of the
|
||||
* input link is assumed to be an unchangeable property.
|
||||
*/
|
||||
AVRational time_base;
|
||||
|
||||
/*****************************************************************
|
||||
* All fields below this line are not part of the public API. They
|
||||
* may not be used outside of libavfilter and can be changed and
|
||||
* removed at will.
|
||||
* New public fields should be added right above.
|
||||
*****************************************************************
|
||||
*/
|
||||
/**
|
||||
* Lists of formats and channel layouts supported by the input and output
|
||||
* filters respectively. These lists are used for negotiating the format
|
||||
* to actually be used, which will be loaded into the format and
|
||||
* channel_layout members, above, when chosen.
|
||||
*
|
||||
*/
|
||||
AVFilterFormats *in_formats;
|
||||
AVFilterFormats *out_formats;
|
||||
|
||||
/**
|
||||
* Lists of channel layouts and sample rates used for automatic
|
||||
* negotiation.
|
||||
*/
|
||||
AVFilterFormats *in_samplerates;
|
||||
AVFilterFormats *out_samplerates;
|
||||
struct AVFilterChannelLayouts *in_channel_layouts;
|
||||
struct AVFilterChannelLayouts *out_channel_layouts;
|
||||
|
||||
/**
|
||||
* Audio only, the destination filter sets this to a non-zero value to
|
||||
* request that buffers with the given number of samples should be sent to
|
||||
* it. AVFilterPad.needs_fifo must also be set on the corresponding input
|
||||
* pad.
|
||||
* Last buffer before EOF will be padded with silence.
|
||||
*/
|
||||
int request_samples;
|
||||
|
||||
/** stage of the initialization of the link properties (dimensions, etc) */
|
||||
enum {
|
||||
AVLINK_UNINIT = 0, ///< not started
|
||||
AVLINK_STARTINIT, ///< started, but incomplete
|
||||
AVLINK_INIT ///< complete
|
||||
} init_state;
|
||||
|
||||
struct AVFilterPool *pool;
|
||||
|
||||
/**
|
||||
* Graph the filter belongs to.
|
||||
*/
|
||||
struct AVFilterGraph *graph;
|
||||
|
||||
/**
|
||||
* Current timestamp of the link, as defined by the most recent
|
||||
* frame(s), in AV_TIME_BASE units.
|
||||
*/
|
||||
int64_t current_pts;
|
||||
|
||||
/**
|
||||
* Index in the age array.
|
||||
*/
|
||||
int age_index;
|
||||
|
||||
/**
|
||||
* Frame rate of the stream on the link, or 1/0 if unknown;
|
||||
* if left to 0/0, will be automatically be copied from the first input
|
||||
* of the source filter if it exists.
|
||||
*
|
||||
* Sources should set it to the best estimation of the real frame rate.
|
||||
* Filters should update it if necessary depending on their function.
|
||||
* Sinks can use it to set a default output frame rate.
|
||||
* It is similar to the r_frame_rate field in AVStream.
|
||||
*/
|
||||
AVRational frame_rate;
|
||||
|
||||
/**
|
||||
* Buffer partially filled with samples to achieve a fixed/minimum size.
|
||||
*/
|
||||
AVFilterBufferRef *partial_buf;
|
||||
|
||||
/**
|
||||
* Size of the partial buffer to allocate.
|
||||
* Must be between min_samples and max_samples.
|
||||
*/
|
||||
int partial_buf_size;
|
||||
|
||||
/**
|
||||
* Minimum number of samples to filter at once. If filter_frame() is
|
||||
* called with fewer samples, it will accumulate them in partial_buf.
|
||||
* This field and the related ones must not be changed after filtering
|
||||
* has started.
|
||||
* If 0, all related fields are ignored.
|
||||
*/
|
||||
int min_samples;
|
||||
|
||||
/**
|
||||
* Maximum number of samples to filter at once. If filter_frame() is
|
||||
* called with more samples, it will split them.
|
||||
*/
|
||||
int max_samples;
|
||||
|
||||
/**
|
||||
* The buffer reference currently being received across the link by the
|
||||
* destination filter. This is used internally by the filter system to
|
||||
* allow automatic copying of buffers which do not have sufficient
|
||||
* permissions for the destination. This should not be accessed directly
|
||||
* by the filters.
|
||||
*/
|
||||
AVFilterBufferRef *cur_buf_copy;
|
||||
|
||||
/**
|
||||
* True if the link is closed.
|
||||
* If set, all attemps of start_frame, filter_frame or request_frame
|
||||
* will fail with AVERROR_EOF, and if necessary the reference will be
|
||||
* destroyed.
|
||||
* If request_frame returns AVERROR_EOF, this flag is set on the
|
||||
* corresponding link.
|
||||
* It can be set also be set by either the source or the destination
|
||||
* filter.
|
||||
*/
|
||||
int closed;
|
||||
|
||||
/**
|
||||
* Number of channels.
|
||||
*/
|
||||
int channels;
|
||||
};
|
||||
|
||||
/**
|
||||
* Link two filters together.
|
||||
*
|
||||
* @param src the source filter
|
||||
* @param srcpad index of the output pad on the source filter
|
||||
* @param dst the destination filter
|
||||
* @param dstpad index of the input pad on the destination filter
|
||||
* @return zero on success
|
||||
*/
|
||||
int avfilter_link(AVFilterContext *src, unsigned srcpad,
|
||||
AVFilterContext *dst, unsigned dstpad);
|
||||
|
||||
/**
|
||||
* Free the link in *link, and set its pointer to NULL.
|
||||
*/
|
||||
void avfilter_link_free(AVFilterLink **link);
|
||||
|
||||
/**
|
||||
* Get the number of channels of a link.
|
||||
*/
|
||||
int avfilter_link_get_channels(AVFilterLink *link);
|
||||
|
||||
/**
|
||||
* Set the closed field of a link.
|
||||
*/
|
||||
void avfilter_link_set_closed(AVFilterLink *link, int closed);
|
||||
|
||||
/**
|
||||
* Negotiate the media format, dimensions, etc of all inputs to a filter.
|
||||
*
|
||||
* @param filter the filter to negotiate the properties for its inputs
|
||||
* @return zero on successful negotiation
|
||||
*/
|
||||
int avfilter_config_links(AVFilterContext *filter);
|
||||
|
||||
/**
|
||||
* Create a buffer reference wrapped around an already allocated image
|
||||
* buffer.
|
||||
*
|
||||
* @param data pointers to the planes of the image to reference
|
||||
* @param linesize linesizes for the planes of the image to reference
|
||||
* @param perms the required access permissions
|
||||
* @param w the width of the image specified by the data and linesize arrays
|
||||
* @param h the height of the image specified by the data and linesize arrays
|
||||
* @param format the pixel format of the image specified by the data and linesize arrays
|
||||
*/
|
||||
AVFilterBufferRef *
|
||||
avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms,
|
||||
int w, int h, enum AVPixelFormat format);
|
||||
|
||||
/**
|
||||
* Create an audio buffer reference wrapped around an already
|
||||
* allocated samples buffer.
|
||||
*
|
||||
* See avfilter_get_audio_buffer_ref_from_arrays_channels() for a version
|
||||
* that can handle unknown channel layouts.
|
||||
*
|
||||
* @param data pointers to the samples plane buffers
|
||||
* @param linesize linesize for the samples plane buffers
|
||||
* @param perms the required access permissions
|
||||
* @param nb_samples number of samples per channel
|
||||
* @param sample_fmt the format of each sample in the buffer to allocate
|
||||
* @param channel_layout the channel layout of the buffer
|
||||
*/
|
||||
AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
|
||||
int linesize,
|
||||
int perms,
|
||||
int nb_samples,
|
||||
enum AVSampleFormat sample_fmt,
|
||||
uint64_t channel_layout);
|
||||
/**
|
||||
* Create an audio buffer reference wrapped around an already
|
||||
* allocated samples buffer.
|
||||
*
|
||||
* @param data pointers to the samples plane buffers
|
||||
* @param linesize linesize for the samples plane buffers
|
||||
* @param perms the required access permissions
|
||||
* @param nb_samples number of samples per channel
|
||||
* @param sample_fmt the format of each sample in the buffer to allocate
|
||||
* @param channels the number of channels of the buffer
|
||||
* @param channel_layout the channel layout of the buffer,
|
||||
* must be either 0 or consistent with channels
|
||||
*/
|
||||
AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays_channels(uint8_t **data,
|
||||
int linesize,
|
||||
int perms,
|
||||
int nb_samples,
|
||||
enum AVSampleFormat sample_fmt,
|
||||
int channels,
|
||||
uint64_t channel_layout);
|
||||
|
||||
|
||||
|
||||
#define AVFILTER_CMD_FLAG_ONE 1 ///< Stop once a filter understood the command (for target=all for example), fast filters are favored automatically
|
||||
#define AVFILTER_CMD_FLAG_FAST 2 ///< Only execute command when its fast (like a video out that supports contrast adjustment in hw)
|
||||
|
||||
/**
|
||||
* Make the filter instance process a command.
|
||||
* It is recommended to use avfilter_graph_send_command().
|
||||
*/
|
||||
int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags);
|
||||
|
||||
/** Initialize the filter system. Register all builtin filters. */
|
||||
void avfilter_register_all(void);
|
||||
|
||||
/** Uninitialize the filter system. Unregister all filters. */
|
||||
void avfilter_uninit(void);
|
||||
|
||||
/**
|
||||
* Register a filter. This is only needed if you plan to use
|
||||
* avfilter_get_by_name later to lookup the AVFilter structure by name. A
|
||||
* filter can still by instantiated with avfilter_open even if it is not
|
||||
* registered.
|
||||
*
|
||||
* @param filter the filter to register
|
||||
* @return 0 if the registration was successful, a negative value
|
||||
* otherwise
|
||||
*/
|
||||
int avfilter_register(AVFilter *filter);
|
||||
|
||||
/**
|
||||
* Get a filter definition matching the given name.
|
||||
*
|
||||
* @param name the filter name to find
|
||||
* @return the filter definition, if any matching one is registered.
|
||||
* NULL if none found.
|
||||
*/
|
||||
AVFilter *avfilter_get_by_name(const char *name);
|
||||
|
||||
/**
|
||||
* If filter is NULL, returns a pointer to the first registered filter pointer,
|
||||
* if filter is non-NULL, returns the next pointer after filter.
|
||||
* If the returned pointer points to NULL, the last registered filter
|
||||
* was already reached.
|
||||
*/
|
||||
AVFilter **av_filter_next(AVFilter **filter);
|
||||
|
||||
/**
|
||||
* Create a filter instance.
|
||||
*
|
||||
* @param filter_ctx put here a pointer to the created filter context
|
||||
* on success, NULL on failure
|
||||
* @param filter the filter to create an instance of
|
||||
* @param inst_name Name to give to the new instance. Can be NULL for none.
|
||||
* @return >= 0 in case of success, a negative error code otherwise
|
||||
*/
|
||||
int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name);
|
||||
|
||||
/**
|
||||
* Initialize a filter.
|
||||
*
|
||||
* @param filter the filter to initialize
|
||||
* @param args A string of parameters to use when initializing the filter.
|
||||
* The format and meaning of this string varies by filter.
|
||||
* @param opaque Any extra non-string data needed by the filter. The meaning
|
||||
* of this parameter varies by filter.
|
||||
* @return zero on success
|
||||
*/
|
||||
int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
|
||||
|
||||
/**
|
||||
* Free a filter context.
|
||||
*
|
||||
* @param filter the filter to free
|
||||
*/
|
||||
void avfilter_free(AVFilterContext *filter);
|
||||
|
||||
/**
|
||||
* Insert a filter in the middle of an existing link.
|
||||
*
|
||||
* @param link the link into which the filter should be inserted
|
||||
* @param filt the filter to be inserted
|
||||
* @param filt_srcpad_idx the input pad on the filter to connect
|
||||
* @param filt_dstpad_idx the output pad on the filter to connect
|
||||
* @return zero on success
|
||||
*/
|
||||
int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
|
||||
unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVFILTER_AVFILTER_H */
|
|
@ -0,0 +1,271 @@
|
|||
/*
|
||||
* Filter graphs
|
||||
* copyright (c) 2007 Bobby Bingham
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVFILTER_AVFILTERGRAPH_H
|
||||
#define AVFILTER_AVFILTERGRAPH_H
|
||||
|
||||
#include "avfilter.h"
|
||||
#include "libavutil/log.h"
|
||||
|
||||
typedef struct AVFilterGraph {
|
||||
const AVClass *av_class;
|
||||
unsigned filter_count;
|
||||
AVFilterContext **filters;
|
||||
|
||||
char *scale_sws_opts; ///< sws options to use for the auto-inserted scale filters
|
||||
char *resample_lavr_opts; ///< libavresample options to use for the auto-inserted resample filters
|
||||
char *aresample_swr_opts; ///< swr options to use for the auto-inserted aresample filters, Access ONLY through AVOptions
|
||||
|
||||
/**
|
||||
* Private fields
|
||||
*
|
||||
* The following fields are for internal use only.
|
||||
* Their type, offset, number and semantic can change without notice.
|
||||
*/
|
||||
|
||||
AVFilterLink **sink_links;
|
||||
int sink_links_count;
|
||||
|
||||
unsigned disable_auto_convert;
|
||||
} AVFilterGraph;
|
||||
|
||||
/**
|
||||
* Allocate a filter graph.
|
||||
*/
|
||||
AVFilterGraph *avfilter_graph_alloc(void);
|
||||
|
||||
/**
|
||||
* Get a filter instance with name name from graph.
|
||||
*
|
||||
* @return the pointer to the found filter instance or NULL if it
|
||||
* cannot be found.
|
||||
*/
|
||||
AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, char *name);
|
||||
|
||||
/**
|
||||
* Add an existing filter instance to a filter graph.
|
||||
*
|
||||
* @param graphctx the filter graph
|
||||
* @param filter the filter to be added
|
||||
*/
|
||||
int avfilter_graph_add_filter(AVFilterGraph *graphctx, AVFilterContext *filter);
|
||||
|
||||
/**
|
||||
* Create and add a filter instance into an existing graph.
|
||||
* The filter instance is created from the filter filt and inited
|
||||
* with the parameters args and opaque.
|
||||
*
|
||||
* In case of success put in *filt_ctx the pointer to the created
|
||||
* filter instance, otherwise set *filt_ctx to NULL.
|
||||
*
|
||||
* @param name the instance name to give to the created filter instance
|
||||
* @param graph_ctx the filter graph
|
||||
* @return a negative AVERROR error code in case of failure, a non
|
||||
* negative value otherwise
|
||||
*/
|
||||
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt,
|
||||
const char *name, const char *args, void *opaque,
|
||||
AVFilterGraph *graph_ctx);
|
||||
|
||||
/**
|
||||
* Enable or disable automatic format conversion inside the graph.
|
||||
*
|
||||
* Note that format conversion can still happen inside explicitly inserted
|
||||
* scale and aconvert filters.
|
||||
*
|
||||
* @param flags any of the AVFILTER_AUTO_CONVERT_* constants
|
||||
*/
|
||||
void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags);
|
||||
|
||||
enum {
|
||||
AVFILTER_AUTO_CONVERT_ALL = 0, /**< all automatic conversions enabled */
|
||||
AVFILTER_AUTO_CONVERT_NONE = -1, /**< all automatic conversions disabled */
|
||||
};
|
||||
|
||||
/**
|
||||
* Check validity and configure all the links and formats in the graph.
|
||||
*
|
||||
* @param graphctx the filter graph
|
||||
* @param log_ctx context used for logging
|
||||
* @return 0 in case of success, a negative AVERROR code otherwise
|
||||
*/
|
||||
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx);
|
||||
|
||||
/**
|
||||
* Free a graph, destroy its links, and set *graph to NULL.
|
||||
* If *graph is NULL, do nothing.
|
||||
*/
|
||||
void avfilter_graph_free(AVFilterGraph **graph);
|
||||
|
||||
/**
|
||||
* A linked-list of the inputs/outputs of the filter chain.
|
||||
*
|
||||
* This is mainly useful for avfilter_graph_parse() / avfilter_graph_parse2(),
|
||||
* where it is used to communicate open (unlinked) inputs and outputs from and
|
||||
* to the caller.
|
||||
* This struct specifies, per each not connected pad contained in the graph, the
|
||||
* filter context and the pad index required for establishing a link.
|
||||
*/
|
||||
typedef struct AVFilterInOut {
|
||||
/** unique name for this input/output in the list */
|
||||
char *name;
|
||||
|
||||
/** filter context associated to this input/output */
|
||||
AVFilterContext *filter_ctx;
|
||||
|
||||
/** index of the filt_ctx pad to use for linking */
|
||||
int pad_idx;
|
||||
|
||||
/** next input/input in the list, NULL if this is the last */
|
||||
struct AVFilterInOut *next;
|
||||
} AVFilterInOut;
|
||||
|
||||
/**
|
||||
* Allocate a single AVFilterInOut entry.
|
||||
* Must be freed with avfilter_inout_free().
|
||||
* @return allocated AVFilterInOut on success, NULL on failure.
|
||||
*/
|
||||
AVFilterInOut *avfilter_inout_alloc(void);
|
||||
|
||||
/**
|
||||
* Free the supplied list of AVFilterInOut and set *inout to NULL.
|
||||
* If *inout is NULL, do nothing.
|
||||
*/
|
||||
void avfilter_inout_free(AVFilterInOut **inout);
|
||||
|
||||
/**
|
||||
* Add a graph described by a string to a graph.
|
||||
*
|
||||
* @param graph the filter graph where to link the parsed graph context
|
||||
* @param filters string to be parsed
|
||||
* @param inputs pointer to a linked list to the inputs of the graph, may be NULL.
|
||||
* If non-NULL, *inputs is updated to contain the list of open inputs
|
||||
* after the parsing, should be freed with avfilter_inout_free().
|
||||
* @param outputs pointer to a linked list to the outputs of the graph, may be NULL.
|
||||
* If non-NULL, *outputs is updated to contain the list of open outputs
|
||||
* after the parsing, should be freed with avfilter_inout_free().
|
||||
* @return non negative on success, a negative AVERROR code on error
|
||||
*/
|
||||
int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
|
||||
AVFilterInOut **inputs, AVFilterInOut **outputs,
|
||||
void *log_ctx);
|
||||
|
||||
/**
|
||||
* Add a graph described by a string to a graph.
|
||||
*
|
||||
* @param[in] graph the filter graph where to link the parsed graph context
|
||||
* @param[in] filters string to be parsed
|
||||
* @param[out] inputs a linked list of all free (unlinked) inputs of the
|
||||
* parsed graph will be returned here. It is to be freed
|
||||
* by the caller using avfilter_inout_free().
|
||||
* @param[out] outputs a linked list of all free (unlinked) outputs of the
|
||||
* parsed graph will be returned here. It is to be freed by the
|
||||
* caller using avfilter_inout_free().
|
||||
* @return zero on success, a negative AVERROR code on error
|
||||
*
|
||||
* @note the difference between avfilter_graph_parse2() and
|
||||
* avfilter_graph_parse() is that in avfilter_graph_parse(), the caller provides
|
||||
* the lists of inputs and outputs, which therefore must be known before calling
|
||||
* the function. On the other hand, avfilter_graph_parse2() \em returns the
|
||||
* inputs and outputs that are left unlinked after parsing the graph and the
|
||||
* caller then deals with them. Another difference is that in
|
||||
* avfilter_graph_parse(), the inputs parameter describes inputs of the
|
||||
* <em>already existing</em> part of the graph; i.e. from the point of view of
|
||||
* the newly created part, they are outputs. Similarly the outputs parameter
|
||||
* describes outputs of the already existing filters, which are provided as
|
||||
* inputs to the parsed filters.
|
||||
* avfilter_graph_parse2() takes the opposite approach -- it makes no reference
|
||||
* whatsoever to already existing parts of the graph and the inputs parameter
|
||||
* will on return contain inputs of the newly parsed part of the graph.
|
||||
* Analogously the outputs parameter will contain outputs of the newly created
|
||||
* filters.
|
||||
*/
|
||||
int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters,
|
||||
AVFilterInOut **inputs,
|
||||
AVFilterInOut **outputs);
|
||||
|
||||
|
||||
/**
|
||||
* Send a command to one or more filter instances.
|
||||
*
|
||||
* @param graph the filter graph
|
||||
* @param target the filter(s) to which the command should be sent
|
||||
* "all" sends to all filters
|
||||
* otherwise it can be a filter or filter instance name
|
||||
* which will send the command to all matching filters.
|
||||
* @param cmd the command to sent, for handling simplicity all commands must be alphanumeric only
|
||||
* @param arg the argument for the command
|
||||
* @param res a buffer with size res_size where the filter(s) can return a response.
|
||||
*
|
||||
* @returns >=0 on success otherwise an error code.
|
||||
* AVERROR(ENOSYS) on unsupported commands
|
||||
*/
|
||||
int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags);
|
||||
|
||||
/**
|
||||
* Queue a command for one or more filter instances.
|
||||
*
|
||||
* @param graph the filter graph
|
||||
* @param target the filter(s) to which the command should be sent
|
||||
* "all" sends to all filters
|
||||
* otherwise it can be a filter or filter instance name
|
||||
* which will send the command to all matching filters.
|
||||
* @param cmd the command to sent, for handling simplicity all commands must be alphanummeric only
|
||||
* @param arg the argument for the command
|
||||
* @param ts time at which the command should be sent to the filter
|
||||
*
|
||||
* @note As this executes commands after this function returns, no return code
|
||||
* from the filter is provided, also AVFILTER_CMD_FLAG_ONE is not supported.
|
||||
*/
|
||||
int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, int flags, double ts);
|
||||
|
||||
|
||||
/**
|
||||
* Dump a graph into a human-readable string representation.
|
||||
*
|
||||
* @param graph the graph to dump
|
||||
* @param options formatting options; currently ignored
|
||||
* @return a string, or NULL in case of memory allocation failure;
|
||||
* the string must be freed using av_free
|
||||
*/
|
||||
char *avfilter_graph_dump(AVFilterGraph *graph, const char *options);
|
||||
|
||||
/**
|
||||
* Request a frame on the oldest sink link.
|
||||
*
|
||||
* If the request returns AVERROR_EOF, try the next.
|
||||
*
|
||||
* Note that this function is not meant to be the sole scheduling mechanism
|
||||
* of a filtergraph, only a convenience function to help drain a filtergraph
|
||||
* in a balanced way under normal circumstances.
|
||||
*
|
||||
* Also note that AVERROR_EOF does not mean that frames did not arrive on
|
||||
* some of the sinks during the process.
|
||||
* When there are multiple sink links, in case the requested link
|
||||
* returns an EOF, this may cause a filter to flush pending frames
|
||||
* which are sent to another sink link, although unrequested.
|
||||
*
|
||||
* @return the return value of ff_request_frame(),
|
||||
* or AVERROR_EOF if all links returned AVERROR_EOF
|
||||
*/
|
||||
int avfilter_graph_request_oldest(AVFilterGraph *graph);
|
||||
|
||||
#endif /* AVFILTER_AVFILTERGRAPH_H */
|
|
@ -0,0 +1,150 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVFILTER_BUFFERSINK_H
|
||||
#define AVFILTER_BUFFERSINK_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* memory buffer sink API for audio and video
|
||||
*/
|
||||
|
||||
#include "avfilter.h"
|
||||
|
||||
/**
|
||||
* Struct to use for initializing a buffersink context.
|
||||
*/
|
||||
typedef struct {
|
||||
const enum AVPixelFormat *pixel_fmts; ///< list of allowed pixel formats, terminated by AV_PIX_FMT_NONE
|
||||
} AVBufferSinkParams;
|
||||
|
||||
/**
|
||||
* Create an AVBufferSinkParams structure.
|
||||
*
|
||||
* Must be freed with av_free().
|
||||
*/
|
||||
AVBufferSinkParams *av_buffersink_params_alloc(void);
|
||||
|
||||
/**
|
||||
* Struct to use for initializing an abuffersink context.
|
||||
*/
|
||||
typedef struct {
|
||||
const enum AVSampleFormat *sample_fmts; ///< list of allowed sample formats, terminated by AV_SAMPLE_FMT_NONE
|
||||
const int64_t *channel_layouts; ///< list of allowed channel layouts, terminated by -1
|
||||
const int *channel_counts; ///< list of allowed channel counts, terminated by -1
|
||||
int all_channel_counts; ///< if not 0, accept any channel count or layout
|
||||
int *sample_rates; ///< list of allowed sample rates, terminated by -1
|
||||
} AVABufferSinkParams;
|
||||
|
||||
/**
|
||||
* Create an AVABufferSinkParams structure.
|
||||
*
|
||||
* Must be freed with av_free().
|
||||
*/
|
||||
AVABufferSinkParams *av_abuffersink_params_alloc(void);
|
||||
|
||||
/**
|
||||
* Set the frame size for an audio buffer sink.
|
||||
*
|
||||
* All calls to av_buffersink_get_buffer_ref will return a buffer with
|
||||
* exactly the specified number of samples, or AVERROR(EAGAIN) if there is
|
||||
* not enough. The last buffer at EOF will be padded with 0.
|
||||
*/
|
||||
void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size);
|
||||
|
||||
/**
|
||||
* Tell av_buffersink_get_buffer_ref() to read video/samples buffer
|
||||
* reference, but not remove it from the buffer. This is useful if you
|
||||
* need only to read a video/samples buffer, without to fetch it.
|
||||
*/
|
||||
#define AV_BUFFERSINK_FLAG_PEEK 1
|
||||
|
||||
/**
|
||||
* Tell av_buffersink_get_buffer_ref() not to request a frame from its input.
|
||||
* If a frame is already buffered, it is read (and removed from the buffer),
|
||||
* but if no frame is present, return AVERROR(EAGAIN).
|
||||
*/
|
||||
#define AV_BUFFERSINK_FLAG_NO_REQUEST 2
|
||||
|
||||
/**
|
||||
* Get an audio/video buffer data from buffer_sink and put it in bufref.
|
||||
*
|
||||
* This function works with both audio and video buffer sinks.
|
||||
*
|
||||
* @param buffer_sink pointer to a buffersink or abuffersink context
|
||||
* @param flags a combination of AV_BUFFERSINK_FLAG_* flags
|
||||
* @return >= 0 in case of success, a negative AVERROR code in case of
|
||||
* failure
|
||||
*/
|
||||
int av_buffersink_get_buffer_ref(AVFilterContext *buffer_sink,
|
||||
AVFilterBufferRef **bufref, int flags);
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of immediately available frames.
|
||||
*/
|
||||
int av_buffersink_poll_frame(AVFilterContext *ctx);
|
||||
|
||||
/**
|
||||
* Get the frame rate of the input.
|
||||
*/
|
||||
AVRational av_buffersink_get_frame_rate(AVFilterContext *ctx);
|
||||
|
||||
/**
|
||||
* @defgroup libav_api Libav API
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get a buffer with filtered data from sink and put it in buf.
|
||||
*
|
||||
* @param ctx pointer to a context of a buffersink or abuffersink AVFilter.
|
||||
* @param buf pointer to the buffer will be written here if buf is non-NULL. buf
|
||||
* must be freed by the caller using avfilter_unref_buffer().
|
||||
* Buf may also be NULL to query whether a buffer is ready to be
|
||||
* output.
|
||||
*
|
||||
* @return >= 0 in case of success, a negative AVERROR code in case of
|
||||
* failure.
|
||||
*/
|
||||
int av_buffersink_read(AVFilterContext *ctx, AVFilterBufferRef **buf);
|
||||
|
||||
/**
|
||||
* Same as av_buffersink_read, but with the ability to specify the number of
|
||||
* samples read. This function is less efficient than av_buffersink_read(),
|
||||
* because it copies the data around.
|
||||
*
|
||||
* @param ctx pointer to a context of the abuffersink AVFilter.
|
||||
* @param buf pointer to the buffer will be written here if buf is non-NULL. buf
|
||||
* must be freed by the caller using avfilter_unref_buffer(). buf
|
||||
* will contain exactly nb_samples audio samples, except at the end
|
||||
* of stream, when it can contain less than nb_samples.
|
||||
* Buf may also be NULL to query whether a buffer is ready to be
|
||||
* output.
|
||||
*
|
||||
* @warning do not mix this function with av_buffersink_read(). Use only one or
|
||||
* the other with a single sink, not both.
|
||||
*/
|
||||
int av_buffersink_read_samples(AVFilterContext *ctx, AVFilterBufferRef **buf,
|
||||
int nb_samples);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVFILTER_BUFFERSINK_H */
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVFILTER_BUFFERSRC_H
|
||||
#define AVFILTER_BUFFERSRC_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Memory buffer source API.
|
||||
*/
|
||||
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "avfilter.h"
|
||||
|
||||
enum {
|
||||
|
||||
/**
|
||||
* Do not check for format changes.
|
||||
*/
|
||||
AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT = 1,
|
||||
|
||||
/**
|
||||
* Do not copy buffer data.
|
||||
*/
|
||||
AV_BUFFERSRC_FLAG_NO_COPY = 2,
|
||||
|
||||
/**
|
||||
* Immediately push the frame to the output.
|
||||
*/
|
||||
AV_BUFFERSRC_FLAG_PUSH = 4,
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Add buffer data in picref to buffer_src.
|
||||
*
|
||||
* @param buffer_src pointer to a buffer source context
|
||||
* @param picref a buffer reference, or NULL to mark EOF
|
||||
* @param flags a combination of AV_BUFFERSRC_FLAG_*
|
||||
* @return >= 0 in case of success, a negative AVERROR code
|
||||
* in case of failure
|
||||
*/
|
||||
int av_buffersrc_add_ref(AVFilterContext *buffer_src,
|
||||
AVFilterBufferRef *picref, int flags);
|
||||
|
||||
/**
|
||||
* Get the number of failed requests.
|
||||
*
|
||||
* A failed request is when the request_frame method is called while no
|
||||
* frame is present in the buffer.
|
||||
* The number is reset when a frame is added.
|
||||
*/
|
||||
unsigned av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src);
|
||||
|
||||
#ifdef FF_API_BUFFERSRC_BUFFER
|
||||
/**
|
||||
* Add a buffer to the filtergraph s.
|
||||
*
|
||||
* @param buf buffer containing frame data to be passed down the filtergraph.
|
||||
* This function will take ownership of buf, the user must not free it.
|
||||
* A NULL buf signals EOF -- i.e. no more frames will be sent to this filter.
|
||||
* @deprecated Use av_buffersrc_add_ref(s, picref, AV_BUFFERSRC_FLAG_NO_COPY) instead.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_buffersrc_buffer(AVFilterContext *s, AVFilterBufferRef *buf);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Add a frame to the buffer source.
|
||||
*
|
||||
* @param s an instance of the buffersrc filter.
|
||||
* @param frame frame to be added.
|
||||
*
|
||||
* @warning frame data will be memcpy()ed, which may be a big performance
|
||||
* hit. Use av_buffersrc_buffer() to avoid copying the data.
|
||||
*/
|
||||
int av_buffersrc_write_frame(AVFilterContext *s, const AVFrame *frame);
|
||||
|
||||
#endif /* AVFILTER_BUFFERSRC_H */
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Version macros.
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVFILTER_VERSION_H
|
||||
#define AVFILTER_VERSION_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Libavfilter version macros
|
||||
*/
|
||||
|
||||
#include "libavutil/avutil.h"
|
||||
|
||||
#define LIBAVFILTER_VERSION_MAJOR 3
|
||||
#define LIBAVFILTER_VERSION_MINOR 42
|
||||
#define LIBAVFILTER_VERSION_MICRO 103
|
||||
|
||||
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
|
||||
LIBAVFILTER_VERSION_MINOR, \
|
||||
LIBAVFILTER_VERSION_MICRO)
|
||||
#define LIBAVFILTER_VERSION AV_VERSION(LIBAVFILTER_VERSION_MAJOR, \
|
||||
LIBAVFILTER_VERSION_MINOR, \
|
||||
LIBAVFILTER_VERSION_MICRO)
|
||||
#define LIBAVFILTER_BUILD LIBAVFILTER_VERSION_INT
|
||||
|
||||
#define LIBAVFILTER_IDENT "Lavfi" AV_STRINGIFY(LIBAVFILTER_VERSION)
|
||||
|
||||
/**
|
||||
* FF_API_* defines may be placed below to indicate public API that will be
|
||||
* dropped at a future version bump. The defines themselves are not part of
|
||||
* the public API and may change, break or disappear at any time.
|
||||
*/
|
||||
|
||||
#ifndef FF_API_AVFILTERPAD_PUBLIC
|
||||
#define FF_API_AVFILTERPAD_PUBLIC (LIBAVFILTER_VERSION_MAJOR < 4)
|
||||
#endif
|
||||
#ifndef FF_API_FOO_COUNT
|
||||
#define FF_API_FOO_COUNT (LIBAVFILTER_VERSION_MAJOR < 4)
|
||||
#endif
|
||||
#ifndef FF_API_FILL_FRAME
|
||||
#define FF_API_FILL_FRAME (LIBAVFILTER_VERSION_MAJOR < 4)
|
||||
#endif
|
||||
#ifndef FF_API_BUFFERSRC_BUFFER
|
||||
#define FF_API_BUFFERSRC_BUFFER (LIBAVFILTER_VERSION_MAJOR < 4)
|
||||
#endif
|
||||
|
||||
#endif /* AVFILTER_VERSION_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,475 @@
|
|||
/*
|
||||
* copyright (c) 2001 Fabrice Bellard
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef AVFORMAT_AVIO_H
|
||||
#define AVFORMAT_AVIO_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavf_io
|
||||
* Buffered I/O operations
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/dict.h"
|
||||
#include "libavutil/log.h"
|
||||
|
||||
#include "libavformat/version.h"
|
||||
|
||||
|
||||
#define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */
|
||||
|
||||
/**
|
||||
* Callback for checking whether to abort blocking functions.
|
||||
* AVERROR_EXIT is returned in this case by the interrupted
|
||||
* function. During blocking operations, callback is called with
|
||||
* opaque as parameter. If the callback returns 1, the
|
||||
* blocking operation will be aborted.
|
||||
*
|
||||
* No members can be added to this struct without a major bump, if
|
||||
* new elements have been added after this struct in AVFormatContext
|
||||
* or AVIOContext.
|
||||
*/
|
||||
typedef struct AVIOInterruptCB {
|
||||
int (*callback)(void*);
|
||||
void *opaque;
|
||||
} AVIOInterruptCB;
|
||||
|
||||
/**
|
||||
* Bytestream IO Context.
|
||||
* New fields can be added to the end with minor version bumps.
|
||||
* Removal, reordering and changes to existing fields require a major
|
||||
* version bump.
|
||||
* sizeof(AVIOContext) must not be used outside libav*.
|
||||
*
|
||||
* @note None of the function pointers in AVIOContext should be called
|
||||
* directly, they should only be set by the client application
|
||||
* when implementing custom I/O. Normally these are set to the
|
||||
* function pointers specified in avio_alloc_context()
|
||||
*/
|
||||
typedef struct AVIOContext {
|
||||
/**
|
||||
* A class for private options.
|
||||
*
|
||||
* If this AVIOContext is created by avio_open2(), av_class is set and
|
||||
* passes the options down to protocols.
|
||||
*
|
||||
* If this AVIOContext is manually allocated, then av_class may be set by
|
||||
* the caller.
|
||||
*
|
||||
* warning -- this field can be NULL, be sure to not pass this AVIOContext
|
||||
* to any av_opt_* functions in that case.
|
||||
*/
|
||||
const AVClass *av_class;
|
||||
unsigned char *buffer; /**< Start of the buffer. */
|
||||
int buffer_size; /**< Maximum buffer size */
|
||||
unsigned char *buf_ptr; /**< Current position in the buffer */
|
||||
unsigned char *buf_end; /**< End of the data, may be less than
|
||||
buffer+buffer_size if the read function returned
|
||||
less data than requested, e.g. for streams where
|
||||
no more data has been received yet. */
|
||||
void *opaque; /**< A private pointer, passed to the read/write/seek/...
|
||||
functions. */
|
||||
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
|
||||
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
|
||||
int64_t (*seek)(void *opaque, int64_t offset, int whence);
|
||||
int64_t pos; /**< position in the file of the current buffer */
|
||||
int must_flush; /**< true if the next seek should flush */
|
||||
int eof_reached; /**< true if eof reached */
|
||||
int write_flag; /**< true if open for writing */
|
||||
int max_packet_size;
|
||||
unsigned long checksum;
|
||||
unsigned char *checksum_ptr;
|
||||
unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
|
||||
int error; /**< contains the error code or 0 if no error happened */
|
||||
/**
|
||||
* Pause or resume playback for network streaming protocols - e.g. MMS.
|
||||
*/
|
||||
int (*read_pause)(void *opaque, int pause);
|
||||
/**
|
||||
* Seek to a given timestamp in stream with the specified stream_index.
|
||||
* Needed for some network streaming protocols which don't support seeking
|
||||
* to byte position.
|
||||
*/
|
||||
int64_t (*read_seek)(void *opaque, int stream_index,
|
||||
int64_t timestamp, int flags);
|
||||
/**
|
||||
* A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
|
||||
*/
|
||||
int seekable;
|
||||
|
||||
/**
|
||||
* max filesize, used to limit allocations
|
||||
* This field is internal to libavformat and access from outside is not allowed.
|
||||
*/
|
||||
int64_t maxsize;
|
||||
|
||||
/**
|
||||
* avio_read and avio_write should if possible be satisfied directly
|
||||
* instead of going through a buffer, and avio_seek will always
|
||||
* call the underlying seek function directly.
|
||||
*/
|
||||
int direct;
|
||||
|
||||
/**
|
||||
* Bytes read statistic
|
||||
* This field is internal to libavformat and access from outside is not allowed.
|
||||
*/
|
||||
int64_t bytes_read;
|
||||
|
||||
/**
|
||||
* seek statistic
|
||||
* This field is internal to libavformat and access from outside is not allowed.
|
||||
*/
|
||||
int seek_count;
|
||||
} AVIOContext;
|
||||
|
||||
/* unbuffered I/O */
|
||||
|
||||
/**
|
||||
* Return AVIO_FLAG_* access flags corresponding to the access permissions
|
||||
* of the resource in url, or a negative value corresponding to an
|
||||
* AVERROR code in case of failure. The returned access flags are
|
||||
* masked by the value in flags.
|
||||
*
|
||||
* @note This function is intrinsically unsafe, in the sense that the
|
||||
* checked resource may change its existence or permission status from
|
||||
* one call to another. Thus you should not trust the returned value,
|
||||
* unless you are sure that no other processes are accessing the
|
||||
* checked resource.
|
||||
*/
|
||||
int avio_check(const char *url, int flags);
|
||||
|
||||
/**
|
||||
* Allocate and initialize an AVIOContext for buffered I/O. It must be later
|
||||
* freed with av_free().
|
||||
*
|
||||
* @param buffer Memory block for input/output operations via AVIOContext.
|
||||
* The buffer must be allocated with av_malloc() and friends.
|
||||
* @param buffer_size The buffer size is very important for performance.
|
||||
* For protocols with fixed blocksize it should be set to this blocksize.
|
||||
* For others a typical size is a cache page, e.g. 4kb.
|
||||
* @param write_flag Set to 1 if the buffer should be writable, 0 otherwise.
|
||||
* @param opaque An opaque pointer to user-specific data.
|
||||
* @param read_packet A function for refilling the buffer, may be NULL.
|
||||
* @param write_packet A function for writing the buffer contents, may be NULL.
|
||||
* The function may not change the input buffers content.
|
||||
* @param seek A function for seeking to specified byte position, may be NULL.
|
||||
*
|
||||
* @return Allocated AVIOContext or NULL on failure.
|
||||
*/
|
||||
AVIOContext *avio_alloc_context(
|
||||
unsigned char *buffer,
|
||||
int buffer_size,
|
||||
int write_flag,
|
||||
void *opaque,
|
||||
int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
|
||||
int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
|
||||
int64_t (*seek)(void *opaque, int64_t offset, int whence));
|
||||
|
||||
void avio_w8(AVIOContext *s, int b);
|
||||
void avio_write(AVIOContext *s, const unsigned char *buf, int size);
|
||||
void avio_wl64(AVIOContext *s, uint64_t val);
|
||||
void avio_wb64(AVIOContext *s, uint64_t val);
|
||||
void avio_wl32(AVIOContext *s, unsigned int val);
|
||||
void avio_wb32(AVIOContext *s, unsigned int val);
|
||||
void avio_wl24(AVIOContext *s, unsigned int val);
|
||||
void avio_wb24(AVIOContext *s, unsigned int val);
|
||||
void avio_wl16(AVIOContext *s, unsigned int val);
|
||||
void avio_wb16(AVIOContext *s, unsigned int val);
|
||||
|
||||
/**
|
||||
* Write a NULL-terminated string.
|
||||
* @return number of bytes written.
|
||||
*/
|
||||
int avio_put_str(AVIOContext *s, const char *str);
|
||||
|
||||
/**
|
||||
* Convert an UTF-8 string to UTF-16LE and write it.
|
||||
* @return number of bytes written.
|
||||
*/
|
||||
int avio_put_str16le(AVIOContext *s, const char *str);
|
||||
|
||||
/**
|
||||
* Passing this as the "whence" parameter to a seek function causes it to
|
||||
* return the filesize without seeking anywhere. Supporting this is optional.
|
||||
* If it is not supported then the seek function will return <0.
|
||||
*/
|
||||
#define AVSEEK_SIZE 0x10000
|
||||
|
||||
/**
|
||||
* Oring this flag as into the "whence" parameter to a seek function causes it to
|
||||
* seek by any means (like reopening and linear reading) or other normally unreasonble
|
||||
* means that can be extreemly slow.
|
||||
* This may be ignored by the seek code.
|
||||
*/
|
||||
#define AVSEEK_FORCE 0x20000
|
||||
|
||||
/**
|
||||
* fseek() equivalent for AVIOContext.
|
||||
* @return new position or AVERROR.
|
||||
*/
|
||||
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
|
||||
|
||||
/**
|
||||
* Skip given number of bytes forward
|
||||
* @return new position or AVERROR.
|
||||
*/
|
||||
int64_t avio_skip(AVIOContext *s, int64_t offset);
|
||||
|
||||
/**
|
||||
* ftell() equivalent for AVIOContext.
|
||||
* @return position or AVERROR.
|
||||
*/
|
||||
static av_always_inline int64_t avio_tell(AVIOContext *s)
|
||||
{
|
||||
return avio_seek(s, 0, SEEK_CUR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filesize.
|
||||
* @return filesize or AVERROR
|
||||
*/
|
||||
int64_t avio_size(AVIOContext *s);
|
||||
|
||||
/**
|
||||
* feof() equivalent for AVIOContext.
|
||||
* @return non zero if and only if end of file
|
||||
*/
|
||||
int url_feof(AVIOContext *s);
|
||||
|
||||
/** @warning currently size is limited */
|
||||
int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
|
||||
|
||||
/**
|
||||
* Force flushing of buffered data to the output s.
|
||||
*
|
||||
* Force the buffered data to be immediately written to the output,
|
||||
* without to wait to fill the internal buffer.
|
||||
*/
|
||||
void avio_flush(AVIOContext *s);
|
||||
|
||||
/**
|
||||
* Read size bytes from AVIOContext into buf.
|
||||
* @return number of bytes read or AVERROR
|
||||
*/
|
||||
int avio_read(AVIOContext *s, unsigned char *buf, int size);
|
||||
|
||||
/**
|
||||
* @name Functions for reading from AVIOContext
|
||||
* @{
|
||||
*
|
||||
* @note return 0 if EOF, so you cannot use it if EOF handling is
|
||||
* necessary
|
||||
*/
|
||||
int avio_r8 (AVIOContext *s);
|
||||
unsigned int avio_rl16(AVIOContext *s);
|
||||
unsigned int avio_rl24(AVIOContext *s);
|
||||
unsigned int avio_rl32(AVIOContext *s);
|
||||
uint64_t avio_rl64(AVIOContext *s);
|
||||
unsigned int avio_rb16(AVIOContext *s);
|
||||
unsigned int avio_rb24(AVIOContext *s);
|
||||
unsigned int avio_rb32(AVIOContext *s);
|
||||
uint64_t avio_rb64(AVIOContext *s);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Read a string from pb into buf. The reading will terminate when either
|
||||
* a NULL character was encountered, maxlen bytes have been read, or nothing
|
||||
* more can be read from pb. The result is guaranteed to be NULL-terminated, it
|
||||
* will be truncated if buf is too small.
|
||||
* Note that the string is not interpreted or validated in any way, it
|
||||
* might get truncated in the middle of a sequence for multi-byte encodings.
|
||||
*
|
||||
* @return number of bytes read (is always <= maxlen).
|
||||
* If reading ends on EOF or error, the return value will be one more than
|
||||
* bytes actually read.
|
||||
*/
|
||||
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
|
||||
|
||||
/**
|
||||
* Read a UTF-16 string from pb and convert it to UTF-8.
|
||||
* The reading will terminate when either a null or invalid character was
|
||||
* encountered or maxlen bytes have been read.
|
||||
* @return number of bytes read (is always <= maxlen)
|
||||
*/
|
||||
int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
|
||||
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
|
||||
|
||||
|
||||
/**
|
||||
* @name URL open modes
|
||||
* The flags argument to avio_open must be one of the following
|
||||
* constants, optionally ORed with other flags.
|
||||
* @{
|
||||
*/
|
||||
#define AVIO_FLAG_READ 1 /**< read-only */
|
||||
#define AVIO_FLAG_WRITE 2 /**< write-only */
|
||||
#define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE) /**< read-write pseudo flag */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Use non-blocking mode.
|
||||
* If this flag is set, operations on the context will return
|
||||
* AVERROR(EAGAIN) if they can not be performed immediately.
|
||||
* If this flag is not set, operations on the context will never return
|
||||
* AVERROR(EAGAIN).
|
||||
* Note that this flag does not affect the opening/connecting of the
|
||||
* context. Connecting a protocol will always block if necessary (e.g. on
|
||||
* network protocols) but never hang (e.g. on busy devices).
|
||||
* Warning: non-blocking protocols is work-in-progress; this flag may be
|
||||
* silently ignored.
|
||||
*/
|
||||
#define AVIO_FLAG_NONBLOCK 8
|
||||
|
||||
/**
|
||||
* Use direct mode.
|
||||
* avio_read and avio_write should if possible be satisfied directly
|
||||
* instead of going through a buffer, and avio_seek will always
|
||||
* call the underlying seek function directly.
|
||||
*/
|
||||
#define AVIO_FLAG_DIRECT 0x8000
|
||||
|
||||
/**
|
||||
* Create and initialize a AVIOContext for accessing the
|
||||
* resource indicated by url.
|
||||
* @note When the resource indicated by url has been opened in
|
||||
* read+write mode, the AVIOContext can be used only for writing.
|
||||
*
|
||||
* @param s Used to return the pointer to the created AVIOContext.
|
||||
* In case of failure the pointed to value is set to NULL.
|
||||
* @param flags flags which control how the resource indicated by url
|
||||
* is to be opened
|
||||
* @return 0 in case of success, a negative value corresponding to an
|
||||
* AVERROR code in case of failure
|
||||
*/
|
||||
int avio_open(AVIOContext **s, const char *url, int flags);
|
||||
|
||||
/**
|
||||
* Create and initialize a AVIOContext for accessing the
|
||||
* resource indicated by url.
|
||||
* @note When the resource indicated by url has been opened in
|
||||
* read+write mode, the AVIOContext can be used only for writing.
|
||||
*
|
||||
* @param s Used to return the pointer to the created AVIOContext.
|
||||
* In case of failure the pointed to value is set to NULL.
|
||||
* @param flags flags which control how the resource indicated by url
|
||||
* is to be opened
|
||||
* @param int_cb an interrupt callback to be used at the protocols level
|
||||
* @param options A dictionary filled with protocol-private options. On return
|
||||
* this parameter will be destroyed and replaced with a dict containing options
|
||||
* that were not found. May be NULL.
|
||||
* @return 0 in case of success, a negative value corresponding to an
|
||||
* AVERROR code in case of failure
|
||||
*/
|
||||
int avio_open2(AVIOContext **s, const char *url, int flags,
|
||||
const AVIOInterruptCB *int_cb, AVDictionary **options);
|
||||
|
||||
/**
|
||||
* Close the resource accessed by the AVIOContext s and free it.
|
||||
* This function can only be used if s was opened by avio_open().
|
||||
*
|
||||
* The internal buffer is automatically flushed before closing the
|
||||
* resource.
|
||||
*
|
||||
* @return 0 on success, an AVERROR < 0 on error.
|
||||
* @see avio_closep
|
||||
*/
|
||||
int avio_close(AVIOContext *s);
|
||||
|
||||
/**
|
||||
* Close the resource accessed by the AVIOContext *s, free it
|
||||
* and set the pointer pointing to it to NULL.
|
||||
* This function can only be used if s was opened by avio_open().
|
||||
*
|
||||
* The internal buffer is automatically flushed before closing the
|
||||
* resource.
|
||||
*
|
||||
* @return 0 on success, an AVERROR < 0 on error.
|
||||
* @see avio_close
|
||||
*/
|
||||
int avio_closep(AVIOContext **s);
|
||||
|
||||
|
||||
/**
|
||||
* Open a write only memory stream.
|
||||
*
|
||||
* @param s new IO context
|
||||
* @return zero if no error.
|
||||
*/
|
||||
int avio_open_dyn_buf(AVIOContext **s);
|
||||
|
||||
/**
|
||||
* Return the written size and a pointer to the buffer. The buffer
|
||||
* must be freed with av_free().
|
||||
* Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer.
|
||||
*
|
||||
* @param s IO context
|
||||
* @param pbuffer pointer to a byte buffer
|
||||
* @return the length of the byte buffer
|
||||
*/
|
||||
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
|
||||
|
||||
/**
|
||||
* Iterate through names of available protocols.
|
||||
*
|
||||
* @param opaque A private pointer representing current protocol.
|
||||
* It must be a pointer to NULL on first iteration and will
|
||||
* be updated by successive calls to avio_enum_protocols.
|
||||
* @param output If set to 1, iterate over output protocols,
|
||||
* otherwise over input protocols.
|
||||
*
|
||||
* @return A static string containing the name of current protocol or NULL
|
||||
*/
|
||||
const char *avio_enum_protocols(void **opaque, int output);
|
||||
|
||||
/**
|
||||
* Pause and resume playing - only meaningful if using a network streaming
|
||||
* protocol (e.g. MMS).
|
||||
* @param pause 1 for pause, 0 for resume
|
||||
*/
|
||||
int avio_pause(AVIOContext *h, int pause);
|
||||
|
||||
/**
|
||||
* Seek to a given timestamp relative to some component stream.
|
||||
* Only meaningful if using a network streaming protocol (e.g. MMS.).
|
||||
* @param stream_index The stream index that the timestamp is relative to.
|
||||
* If stream_index is (-1) the timestamp should be in AV_TIME_BASE
|
||||
* units from the beginning of the presentation.
|
||||
* If a stream_index >= 0 is used and the protocol does not support
|
||||
* seeking based on component streams, the call will fail.
|
||||
* @param timestamp timestamp in AVStream.time_base units
|
||||
* or if there is no stream specified then in AV_TIME_BASE units.
|
||||
* @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE
|
||||
* and AVSEEK_FLAG_ANY. The protocol may silently ignore
|
||||
* AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will
|
||||
* fail if used and not supported.
|
||||
* @return >= 0 on success
|
||||
* @see AVInputFormat::read_seek
|
||||
*/
|
||||
int64_t avio_seek_time(AVIOContext *h, int stream_index,
|
||||
int64_t timestamp, int flags);
|
||||
|
||||
#endif /* AVFORMAT_AVIO_H */
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Version macros.
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVFORMAT_VERSION_H
|
||||
#define AVFORMAT_VERSION_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup libavf
|
||||
* Libavformat version macros
|
||||
*/
|
||||
|
||||
#include "libavutil/avutil.h"
|
||||
|
||||
#define LIBAVFORMAT_VERSION_MAJOR 54
|
||||
#define LIBAVFORMAT_VERSION_MINOR 63
|
||||
#define LIBAVFORMAT_VERSION_MICRO 104
|
||||
|
||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
||||
LIBAVFORMAT_VERSION_MINOR, \
|
||||
LIBAVFORMAT_VERSION_MICRO)
|
||||
#define LIBAVFORMAT_VERSION AV_VERSION(LIBAVFORMAT_VERSION_MAJOR, \
|
||||
LIBAVFORMAT_VERSION_MINOR, \
|
||||
LIBAVFORMAT_VERSION_MICRO)
|
||||
#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT
|
||||
|
||||
#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION)
|
||||
|
||||
/**
|
||||
* FF_API_* defines may be placed below to indicate public API that will be
|
||||
* dropped at a future version bump. The defines themselves are not part of
|
||||
* the public API and may change, break or disappear at any time.
|
||||
*/
|
||||
|
||||
#ifndef FF_API_OLD_AVIO
|
||||
#define FF_API_OLD_AVIO (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_PKT_DUMP
|
||||
#define FF_API_PKT_DUMP (LIBAVFORMAT_VERSION_MAJOR < 54)
|
||||
#endif
|
||||
#ifndef FF_API_ALLOC_OUTPUT_CONTEXT
|
||||
#define FF_API_ALLOC_OUTPUT_CONTEXT (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_FORMAT_PARAMETERS
|
||||
#define FF_API_FORMAT_PARAMETERS (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_NEW_STREAM
|
||||
#define FF_API_NEW_STREAM (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_SET_PTS_INFO
|
||||
#define FF_API_SET_PTS_INFO (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_CLOSE_INPUT_FILE
|
||||
#define FF_API_CLOSE_INPUT_FILE (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_APPLEHTTP_PROTO
|
||||
#define FF_API_APPLEHTTP_PROTO (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_READ_PACKET
|
||||
#define FF_API_READ_PACKET (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_INTERLEAVE_PACKET
|
||||
#define FF_API_INTERLEAVE_PACKET (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_AV_GETTIME
|
||||
#define FF_API_AV_GETTIME (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
#ifndef FF_API_R_FRAME_RATE
|
||||
#define FF_API_R_FRAME_RATE (LIBAVFORMAT_VERSION_MAJOR < 55)
|
||||
#endif
|
||||
|
||||
#endif /* AVFORMAT_VERSION_H */
|
|
@ -25,6 +25,7 @@
|
|||
#include "attributes.h"
|
||||
|
||||
/**
|
||||
* @ingroup lavu_crypto
|
||||
* Calculate the Adler32 checksum of a buffer.
|
||||
*
|
||||
* Passing the return value to a subsequent av_adler32_update() call
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* copyright (c) 2007 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AES_H
|
||||
#define AVUTIL_AES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavu_aes AES
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern const int av_aes_size;
|
||||
|
||||
struct AVAES;
|
||||
|
||||
/**
|
||||
* Allocate an AVAES context.
|
||||
*/
|
||||
struct AVAES *av_aes_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize an AVAES context.
|
||||
* @param key_bits 128, 192 or 256
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context.
|
||||
* @param count number of 16 byte blocks
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param iv initialization vector for CBC mode, if NULL then ECB will be used
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_aes_crypt(struct AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AES_H */
|
|
@ -35,87 +35,120 @@
|
|||
#ifndef av_always_inline
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
# define av_always_inline __attribute__((always_inline)) inline
|
||||
#elif defined(_MSC_VER)
|
||||
# define av_always_inline __forceinline
|
||||
#else
|
||||
# define av_always_inline inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef av_noinline
|
||||
#ifndef av_extern_inline
|
||||
#if defined(__ICL) && __ICL >= 1210 || defined(__GNUC_STDC_INLINE__)
|
||||
# define av_extern_inline extern inline
|
||||
#else
|
||||
# define av_extern_inline inline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
# define av_noinline __attribute__((noinline))
|
||||
#else
|
||||
# define av_noinline
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef av_pure
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
# define av_pure __attribute__((pure))
|
||||
#else
|
||||
# define av_pure
|
||||
#endif
|
||||
|
||||
#ifndef av_restrict
|
||||
#define av_restrict restrict
|
||||
#endif
|
||||
|
||||
#ifndef av_const
|
||||
#if AV_GCC_VERSION_AT_LEAST(2,6)
|
||||
# define av_const __attribute__((const))
|
||||
#else
|
||||
# define av_const
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef av_cold
|
||||
#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3)
|
||||
#if AV_GCC_VERSION_AT_LEAST(4,3)
|
||||
# define av_cold __attribute__((cold))
|
||||
#else
|
||||
# define av_cold
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef av_flatten
|
||||
#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,1)
|
||||
#if AV_GCC_VERSION_AT_LEAST(4,1)
|
||||
# define av_flatten __attribute__((flatten))
|
||||
#else
|
||||
# define av_flatten
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef attribute_deprecated
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
# define attribute_deprecated __attribute__((deprecated))
|
||||
#else
|
||||
# define attribute_deprecated
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Disable warnings about deprecated features
|
||||
* This is useful for sections of code kept for backward compatibility and
|
||||
* scheduled for removal.
|
||||
*/
|
||||
#ifndef AV_NOWARN_DEPRECATED
|
||||
#if AV_GCC_VERSION_AT_LEAST(4,6)
|
||||
# define AV_NOWARN_DEPRECATED(code) \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \
|
||||
code \
|
||||
_Pragma("GCC diagnostic pop")
|
||||
#else
|
||||
# define AV_NOWARN_DEPRECATED(code) code
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef av_unused
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# define av_unused __attribute__((unused))
|
||||
#else
|
||||
# define av_unused
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Mark a variable as used and prevent the compiler from optimizing it
|
||||
* away. This is useful for variables accessed only from inline
|
||||
* assembler without the compiler being aware.
|
||||
*/
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
# define av_used __attribute__((used))
|
||||
#else
|
||||
# define av_used
|
||||
#endif
|
||||
|
||||
#ifndef av_alias
|
||||
#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(3,3)
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,3)
|
||||
# define av_alias __attribute__((may_alias))
|
||||
#else
|
||||
# define av_alias
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef av_uninit
|
||||
#if defined(__GNUC__) && !defined(__ICC)
|
||||
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
|
||||
# define av_uninit(x) x=x
|
||||
#else
|
||||
# define av_uninit(x) x
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define av_builtin_constant_p __builtin_constant_p
|
||||
# define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
|
||||
#else
|
||||
# define av_builtin_constant_p(x) 0
|
||||
# define av_printf_format(fmtpos, attrpos)
|
||||
#endif
|
||||
|
||||
#if AV_GCC_VERSION_AT_LEAST(2,5)
|
||||
# define av_noreturn __attribute__((noreturn))
|
||||
#else
|
||||
# define av_noreturn
|
||||
#endif
|
||||
|
||||
#endif /* AVUTIL_ATTRIBUTES_H */
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Audio FIFO
|
||||
* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Audio FIFO Buffer
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AUDIO_FIFO_H
|
||||
#define AVUTIL_AUDIO_FIFO_H
|
||||
|
||||
#include "avutil.h"
|
||||
#include "fifo.h"
|
||||
#include "samplefmt.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_audio
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Context for an Audio FIFO Buffer.
|
||||
*
|
||||
* - Operates at the sample level rather than the byte level.
|
||||
* - Supports multiple channels with either planar or packed sample format.
|
||||
* - Automatic reallocation when writing to a full buffer.
|
||||
*/
|
||||
typedef struct AVAudioFifo AVAudioFifo;
|
||||
|
||||
/**
|
||||
* Free an AVAudioFifo.
|
||||
*
|
||||
* @param af AVAudioFifo to free
|
||||
*/
|
||||
void av_audio_fifo_free(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* Allocate an AVAudioFifo.
|
||||
*
|
||||
* @param sample_fmt sample format
|
||||
* @param channels number of channels
|
||||
* @param nb_samples initial allocation size, in samples
|
||||
* @return newly allocated AVAudioFifo, or NULL on error
|
||||
*/
|
||||
AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels,
|
||||
int nb_samples);
|
||||
|
||||
/**
|
||||
* Reallocate an AVAudioFifo.
|
||||
*
|
||||
* @param af AVAudioFifo to reallocate
|
||||
* @param nb_samples new allocation size, in samples
|
||||
* @return 0 if OK, or negative AVERROR code on failure
|
||||
*/
|
||||
int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples);
|
||||
|
||||
/**
|
||||
* Write data to an AVAudioFifo.
|
||||
*
|
||||
* The AVAudioFifo will be reallocated automatically if the available space
|
||||
* is less than nb_samples.
|
||||
*
|
||||
* @see enum AVSampleFormat
|
||||
* The documentation for AVSampleFormat describes the data layout.
|
||||
*
|
||||
* @param af AVAudioFifo to write to
|
||||
* @param data audio data plane pointers
|
||||
* @param nb_samples number of samples to write
|
||||
* @return number of samples actually written, or negative AVERROR
|
||||
* code on failure.
|
||||
*/
|
||||
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples);
|
||||
|
||||
/**
|
||||
* Read data from an AVAudioFifo.
|
||||
*
|
||||
* @see enum AVSampleFormat
|
||||
* The documentation for AVSampleFormat describes the data layout.
|
||||
*
|
||||
* @param af AVAudioFifo to read from
|
||||
* @param data audio data plane pointers
|
||||
* @param nb_samples number of samples to read
|
||||
* @return number of samples actually read, or negative AVERROR code
|
||||
* on failure.
|
||||
*/
|
||||
int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples);
|
||||
|
||||
/**
|
||||
* Drain data from an AVAudioFifo.
|
||||
*
|
||||
* Removes the data without reading it.
|
||||
*
|
||||
* @param af AVAudioFifo to drain
|
||||
* @param nb_samples number of samples to drain
|
||||
* @return 0 if OK, or negative AVERROR code on failure
|
||||
*/
|
||||
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples);
|
||||
|
||||
/**
|
||||
* Reset the AVAudioFifo buffer.
|
||||
*
|
||||
* This empties all data in the buffer.
|
||||
*
|
||||
* @param af AVAudioFifo to reset
|
||||
*/
|
||||
void av_audio_fifo_reset(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* Get the current number of samples in the AVAudioFifo available for reading.
|
||||
*
|
||||
* @param af the AVAudioFifo to query
|
||||
* @return number of samples available for reading
|
||||
*/
|
||||
int av_audio_fifo_size(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* Get the current number of samples in the AVAudioFifo available for writing.
|
||||
*
|
||||
* @param af the AVAudioFifo to query
|
||||
* @return number of samples available for writing
|
||||
*/
|
||||
int av_audio_fifo_space(AVAudioFifo *af);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AUDIO_FIFO_H */
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
#include "version.h"
|
||||
|
||||
#if FF_API_AUDIOCONVERT
|
||||
#include "channel_layout.h"
|
||||
#endif
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* copyright (c) 2010 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* simple assert() macros that are a bit more flexible than ISO C assert().
|
||||
* @author Michael Niedermayer <michaelni@gmx.at>
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_AVASSERT_H
|
||||
#define AVUTIL_AVASSERT_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "avutil.h"
|
||||
#include "log.h"
|
||||
|
||||
/**
|
||||
* assert() equivalent, that is always enabled.
|
||||
*/
|
||||
#define av_assert0(cond) do { \
|
||||
if (!(cond)) { \
|
||||
av_log(NULL, AV_LOG_PANIC, "Assertion %s failed at %s:%d\n", \
|
||||
AV_STRINGIFY(cond), __FILE__, __LINE__); \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
* assert() equivalent, that does not lie in speed critical code.
|
||||
* These asserts() thus can be enabled without fearing speedloss.
|
||||
*/
|
||||
#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 0
|
||||
#define av_assert1(cond) av_assert0(cond)
|
||||
#else
|
||||
#define av_assert1(cond) ((void)0)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* assert() equivalent, that does lie in speed critical code.
|
||||
*/
|
||||
#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1
|
||||
#define av_assert2(cond) av_assert0(cond)
|
||||
#else
|
||||
#define av_assert2(cond) ((void)0)
|
||||
#endif
|
||||
|
||||
#endif /* AVUTIL_AVASSERT_H */
|
|
@ -3,4 +3,5 @@
|
|||
#define AVUTIL_AVCONFIG_H
|
||||
#define AV_HAVE_BIGENDIAN 0
|
||||
#define AV_HAVE_FAST_UNALIGNED 1
|
||||
#define AV_HAVE_INCOMPATIBLE_FORK_ABI 0
|
||||
#endif /* AVUTIL_AVCONFIG_H */
|
||||
|
|
|
@ -22,6 +22,12 @@
|
|||
#define AVUTIL_AVSTRING_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include "attributes.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_string
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return non-zero if pfx is a prefix of str. If it is, *ptr is set to
|
||||
|
@ -60,6 +66,21 @@ int av_stristart(const char *str, const char *pfx, const char **ptr);
|
|||
*/
|
||||
char *av_stristr(const char *haystack, const char *needle);
|
||||
|
||||
/**
|
||||
* Locate the first occurrence of the string needle in the string haystack
|
||||
* where not more than hay_length characters are searched. A zero-length
|
||||
* string needle is considered to match at the start of haystack.
|
||||
*
|
||||
* This function is a length-limited version of the standard strstr().
|
||||
*
|
||||
* @param haystack string to search in
|
||||
* @param needle string to search for
|
||||
* @param hay_length length of string to search in
|
||||
* @return pointer to the located match within haystack
|
||||
* or a null pointer if no match
|
||||
*/
|
||||
char *av_strnstr(const char *haystack, const char *needle, size_t hay_length);
|
||||
|
||||
/**
|
||||
* Copy the string src to dst, but no more than size - 1 bytes, and
|
||||
* null-terminate dst.
|
||||
|
@ -71,7 +92,7 @@ char *av_stristr(const char *haystack, const char *needle);
|
|||
* @param size size of destination buffer
|
||||
* @return the length of src
|
||||
*
|
||||
* WARNING: since the return value is the length of src, src absolutely
|
||||
* @warning since the return value is the length of src, src absolutely
|
||||
* _must_ be a properly 0-terminated string, otherwise this will read beyond
|
||||
* the end of the buffer and possibly crash.
|
||||
*/
|
||||
|
@ -89,9 +110,9 @@ size_t av_strlcpy(char *dst, const char *src, size_t size);
|
|||
* @param size size of destination buffer
|
||||
* @return the total length of src and dst
|
||||
*
|
||||
* WARNING: since the return value use the length of src and dst, these absolutely
|
||||
* _must_ be a properly 0-terminated strings, otherwise this will read beyond
|
||||
* the end of the buffer and possibly crash.
|
||||
* @warning since the return value use the length of src and dst, these
|
||||
* absolutely _must_ be a properly 0-terminated strings, otherwise this
|
||||
* will read beyond the end of the buffer and possibly crash.
|
||||
*/
|
||||
size_t av_strlcat(char *dst, const char *src, size_t size);
|
||||
|
||||
|
@ -107,11 +128,188 @@ size_t av_strlcat(char *dst, const char *src, size_t size);
|
|||
* @return the length of the string that would have been generated
|
||||
* if enough space had been available
|
||||
*/
|
||||
size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...);
|
||||
size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_format(3, 4);
|
||||
|
||||
/**
|
||||
* Print arguments following specified format into a large enough auto
|
||||
* allocated buffer. It is similar to GNU asprintf().
|
||||
* @param fmt printf-compatible format string, specifying how the
|
||||
* following parameters are used.
|
||||
* @return the allocated string
|
||||
* @note You have to free the string yourself with av_free().
|
||||
*/
|
||||
char *av_asprintf(const char *fmt, ...) av_printf_format(1, 2);
|
||||
|
||||
/**
|
||||
* Convert a number to a av_malloced string.
|
||||
*/
|
||||
char *av_d2str(double d);
|
||||
|
||||
/**
|
||||
* Unescape the given string until a non escaped terminating char,
|
||||
* and return the token corresponding to the unescaped string.
|
||||
*
|
||||
* The normal \ and ' escaping is supported. Leading and trailing
|
||||
* whitespaces are removed, unless they are escaped with '\' or are
|
||||
* enclosed between ''.
|
||||
*
|
||||
* @param buf the buffer to parse, buf will be updated to point to the
|
||||
* terminating char
|
||||
* @param term a 0-terminated list of terminating chars
|
||||
* @return the malloced unescaped string, which must be av_freed by
|
||||
* the user, NULL in case of allocation failure
|
||||
*/
|
||||
char *av_get_token(const char **buf, const char *term);
|
||||
|
||||
/**
|
||||
* Split the string into several tokens which can be accessed by
|
||||
* successive calls to av_strtok().
|
||||
*
|
||||
* A token is defined as a sequence of characters not belonging to the
|
||||
* set specified in delim.
|
||||
*
|
||||
* On the first call to av_strtok(), s should point to the string to
|
||||
* parse, and the value of saveptr is ignored. In subsequent calls, s
|
||||
* should be NULL, and saveptr should be unchanged since the previous
|
||||
* call.
|
||||
*
|
||||
* This function is similar to strtok_r() defined in POSIX.1.
|
||||
*
|
||||
* @param s the string to parse, may be NULL
|
||||
* @param delim 0-terminated list of token delimiters, must be non-NULL
|
||||
* @param saveptr user-provided pointer which points to stored
|
||||
* information necessary for av_strtok() to continue scanning the same
|
||||
* string. saveptr is updated to point to the next character after the
|
||||
* first delimiter found, or to NULL if the string was terminated
|
||||
* @return the found token, or NULL when no token is found
|
||||
*/
|
||||
char *av_strtok(char *s, const char *delim, char **saveptr);
|
||||
|
||||
/**
|
||||
* Locale-independent conversion of ASCII isdigit.
|
||||
*/
|
||||
static inline int av_isdigit(int c)
|
||||
{
|
||||
return c >= '0' && c <= '9';
|
||||
}
|
||||
|
||||
/**
|
||||
* Locale-independent conversion of ASCII isgraph.
|
||||
*/
|
||||
static inline int av_isgraph(int c)
|
||||
{
|
||||
return c > 32 && c < 127;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locale-independent conversion of ASCII isspace.
|
||||
*/
|
||||
static inline int av_isspace(int c)
|
||||
{
|
||||
return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v';
|
||||
}
|
||||
|
||||
/**
|
||||
* Locale-independent conversion of ASCII characters to uppercase.
|
||||
*/
|
||||
static inline int av_toupper(int c)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
c ^= 0x20;
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locale-independent conversion of ASCII characters to lowercase.
|
||||
*/
|
||||
static inline int av_tolower(int c)
|
||||
{
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
c ^= 0x20;
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locale-independent conversion of ASCII isxdigit.
|
||||
*/
|
||||
static inline int av_isxdigit(int c)
|
||||
{
|
||||
c = av_tolower(c);
|
||||
return av_isdigit(c) || (c >= 'a' && c <= 'z');
|
||||
}
|
||||
|
||||
/**
|
||||
* Locale-independent case-insensitive compare.
|
||||
* @note This means only ASCII-range characters are case-insensitive
|
||||
*/
|
||||
int av_strcasecmp(const char *a, const char *b);
|
||||
|
||||
/**
|
||||
* Locale-independent case-insensitive compare.
|
||||
* @note This means only ASCII-range characters are case-insensitive
|
||||
*/
|
||||
int av_strncasecmp(const char *a, const char *b, size_t n);
|
||||
|
||||
|
||||
/**
|
||||
* Thread safe basename.
|
||||
* @param path the path, on DOS both \ and / are considered separators.
|
||||
* @return pointer to the basename substring.
|
||||
*/
|
||||
const char *av_basename(const char *path);
|
||||
|
||||
/**
|
||||
* Thread safe dirname.
|
||||
* @param path the path, on DOS both \ and / are considered separators.
|
||||
* @return the path with the separator replaced by the string terminator or ".".
|
||||
* @note the function may change the input string.
|
||||
*/
|
||||
const char *av_dirname(char *path);
|
||||
|
||||
enum AVEscapeMode {
|
||||
AV_ESCAPE_MODE_AUTO, ///< Use auto-selected escaping mode.
|
||||
AV_ESCAPE_MODE_BACKSLASH, ///< Use backslash escaping.
|
||||
AV_ESCAPE_MODE_QUOTE, ///< Use single-quote escaping.
|
||||
};
|
||||
|
||||
/**
|
||||
* Consider spaces special and escape them even in the middle of the
|
||||
* string.
|
||||
*
|
||||
* This is equivalent to adding the whitespace characters to the special
|
||||
* characters lists, except it is guaranteed to use the exact same list
|
||||
* of whitespace characters as the rest of libavutil.
|
||||
*/
|
||||
#define AV_ESCAPE_FLAG_WHITESPACE 0x01
|
||||
|
||||
/**
|
||||
* Escape only specified special characters.
|
||||
* Without this flag, escape also any characters that may be considered
|
||||
* special by av_get_token(), such as the single quote.
|
||||
*/
|
||||
#define AV_ESCAPE_FLAG_STRICT 0x02
|
||||
|
||||
/**
|
||||
* Escape string in src, and put the escaped string in an allocated
|
||||
* string in *dst, which must be freed with av_free().
|
||||
*
|
||||
* @param dst pointer where an allocated string is put
|
||||
* @param src string to escape, must be non-NULL
|
||||
* @param special_chars string containing the special characters which
|
||||
* need to be escaped, can be NULL
|
||||
* @param mode escape mode to employ, see AV_ESCAPE_MODE_* macros.
|
||||
* Any unknown value for mode will be considered equivalent to
|
||||
* AV_ESCAPE_MODE_BACKSLASH, but this behaviour can change without
|
||||
* notice.
|
||||
* @param flags flags which control how to escape, see AV_ESCAPE_FLAG_ macros
|
||||
* @return the length of the allocated string, or a negative error code in case of error
|
||||
* @see av_bprint_escape()
|
||||
*/
|
||||
int av_escape(char **dst, const char *src, const char *special_chars,
|
||||
enum AVEscapeMode mode, int flags);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AVSTRING_H */
|
||||
|
|
|
@ -26,32 +26,93 @@
|
|||
* external API header
|
||||
*/
|
||||
|
||||
/**
|
||||
* @mainpage
|
||||
*
|
||||
* @section ffmpeg_intro Introduction
|
||||
*
|
||||
* This document describes the usage of the different libraries
|
||||
* provided by FFmpeg.
|
||||
*
|
||||
* @li @ref libavc "libavcodec" encoding/decoding library
|
||||
* @li @ref lavfi "libavfilter" graph based frame editing library
|
||||
* @li @ref libavf "libavformat" I/O and muxing/demuxing library
|
||||
* @li @ref lavd "libavdevice" special devices muxing/demuxing library
|
||||
* @li @ref lavu "libavutil" common utility library
|
||||
* @li @ref lswr "libswresample" audio resampling, format conversion and mixing
|
||||
* @li @ref lpp "libpostproc" post processing library
|
||||
* @li @ref lsws "libswscale" color conversion and scaling library
|
||||
*/
|
||||
|
||||
#define AV_STRINGIFY(s) AV_TOSTRING(s)
|
||||
#define AV_TOSTRING(s) #s
|
||||
/**
|
||||
* @defgroup lavu Common utility functions
|
||||
*
|
||||
* @brief
|
||||
* libavutil contains the code shared across all the other FFmpeg
|
||||
* libraries
|
||||
*
|
||||
* @note In order to use the functions provided by avutil you must include
|
||||
* the specific header.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavu_crypto Crypto and Hashing
|
||||
*
|
||||
* @{
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_math Maths
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_string String Manipulation
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_mem Memory Management
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_data Data Structures
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_audio Audio related
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_error Error Codes
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavu_misc Other
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavu_internal Internal
|
||||
*
|
||||
* Not exported functions, for internal usage only
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#define AV_GLUE(a, b) a ## b
|
||||
#define AV_JOIN(a, b) AV_GLUE(a, b)
|
||||
|
||||
#define AV_PRAGMA(s) _Pragma(#s)
|
||||
|
||||
#define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c)
|
||||
#define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c
|
||||
#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
|
||||
|
||||
#define LIBAVUTIL_VERSION_MAJOR 50
|
||||
#define LIBAVUTIL_VERSION_MINOR 23
|
||||
#define LIBAVUTIL_VERSION_MICRO 0
|
||||
|
||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||
LIBAVUTIL_VERSION_MINOR, \
|
||||
LIBAVUTIL_VERSION_MICRO)
|
||||
#define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \
|
||||
LIBAVUTIL_VERSION_MINOR, \
|
||||
LIBAVUTIL_VERSION_MICRO)
|
||||
#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
|
||||
|
||||
#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
|
||||
/**
|
||||
* @addtogroup lavu_ver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return the LIBAVUTIL_VERSION_INT constant.
|
||||
|
@ -68,22 +129,132 @@ const char *avutil_configuration(void);
|
|||
*/
|
||||
const char *avutil_license(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_media Media Type
|
||||
* @brief Media Type
|
||||
*/
|
||||
|
||||
enum AVMediaType {
|
||||
AVMEDIA_TYPE_UNKNOWN = -1,
|
||||
AVMEDIA_TYPE_UNKNOWN = -1, ///< Usually treated as AVMEDIA_TYPE_DATA
|
||||
AVMEDIA_TYPE_VIDEO,
|
||||
AVMEDIA_TYPE_AUDIO,
|
||||
AVMEDIA_TYPE_DATA,
|
||||
AVMEDIA_TYPE_DATA, ///< Opaque data information usually continuous
|
||||
AVMEDIA_TYPE_SUBTITLE,
|
||||
AVMEDIA_TYPE_ATTACHMENT,
|
||||
AVMEDIA_TYPE_ATTACHMENT, ///< Opaque data information usually sparse
|
||||
AVMEDIA_TYPE_NB
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a string describing the media_type enum, NULL if media_type
|
||||
* is unknown.
|
||||
*/
|
||||
const char *av_get_media_type_string(enum AVMediaType media_type);
|
||||
|
||||
/**
|
||||
* @defgroup lavu_const Constants
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavu_enc Encoding specific
|
||||
*
|
||||
* @note those definition should move to avcodec
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define FF_LAMBDA_SHIFT 7
|
||||
#define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT)
|
||||
#define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda
|
||||
#define FF_LAMBDA_MAX (256*128-1)
|
||||
|
||||
#define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @defgroup lavu_time Timestamp specific
|
||||
*
|
||||
* FFmpeg internal timebase and timestamp definitions
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Undefined timestamp value
|
||||
*
|
||||
* Usually reported by demuxer that work on containers that do not provide
|
||||
* either pts or dts.
|
||||
*/
|
||||
|
||||
#define AV_NOPTS_VALUE ((int64_t)UINT64_C(0x8000000000000000))
|
||||
|
||||
/**
|
||||
* Internal time base represented as integer
|
||||
*/
|
||||
|
||||
#define AV_TIME_BASE 1000000
|
||||
|
||||
/**
|
||||
* Internal time base represented as fractional value
|
||||
*/
|
||||
|
||||
#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
* @defgroup lavu_picture Image related
|
||||
*
|
||||
* AVPicture types, pixel formats and basic image planes manipulation.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
enum AVPictureType {
|
||||
AV_PICTURE_TYPE_NONE = 0, ///< Undefined
|
||||
AV_PICTURE_TYPE_I, ///< Intra
|
||||
AV_PICTURE_TYPE_P, ///< Predicted
|
||||
AV_PICTURE_TYPE_B, ///< Bi-dir predicted
|
||||
AV_PICTURE_TYPE_S, ///< S(GMC)-VOP MPEG4
|
||||
AV_PICTURE_TYPE_SI, ///< Switching Intra
|
||||
AV_PICTURE_TYPE_SP, ///< Switching Predicted
|
||||
AV_PICTURE_TYPE_BI, ///< BI type
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a single letter to describe the given picture type
|
||||
* pict_type.
|
||||
*
|
||||
* @param[in] pict_type the picture type @return a single character
|
||||
* representing the picture type, '?' if pict_type is unknown
|
||||
*/
|
||||
char av_get_picture_type_char(enum AVPictureType pict_type);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "error.h"
|
||||
#include "version.h"
|
||||
#include "mathematics.h"
|
||||
#include "rational.h"
|
||||
#include "intfloat_readwrite.h"
|
||||
#include "log.h"
|
||||
#include "pixfmt.h"
|
||||
|
||||
/**
|
||||
* Return x default pointer in case p is NULL.
|
||||
*/
|
||||
static inline void *av_x_if_null(const void *p, const void *x)
|
||||
{
|
||||
return (void *)(intptr_t)(p ? p : x);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_AVUTIL_H */
|
||||
|
|
|
@ -23,6 +23,13 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavu_base64 Base64
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Decode a base64-encoded string.
|
||||
*
|
||||
|
@ -39,16 +46,22 @@ int av_base64_decode(uint8_t *out, const char *in, int out_size);
|
|||
* Encode data to base64 and null-terminate.
|
||||
*
|
||||
* @param out buffer for encoded data
|
||||
* @param out_size size in bytes of the output buffer, must be at
|
||||
* least AV_BASE64_SIZE(in_size)
|
||||
* @param in_size size in bytes of the 'in' buffer
|
||||
* @return 'out' or NULL in case of error
|
||||
* @param out_size size in bytes of the out buffer (including the
|
||||
* null terminator), must be at least AV_BASE64_SIZE(in_size)
|
||||
* @param in input buffer containing the data to encode
|
||||
* @param in_size size in bytes of the in buffer
|
||||
* @return out or NULL in case of error
|
||||
*/
|
||||
char *av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size);
|
||||
|
||||
/**
|
||||
* Calculate the output size needed to base64-encode x bytes.
|
||||
* Calculate the output size needed to base64-encode x bytes to a
|
||||
* null-terminated string.
|
||||
*/
|
||||
#define AV_BASE64_SIZE(x) (((x)+2) / 3 * 4 + 1)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_BASE64_H */
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Blowfish algorithm
|
||||
* Copyright (c) 2012 Samuel Pitoiset
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_BLOWFISH_H
|
||||
#define AVUTIL_BLOWFISH_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavu_blowfish Blowfish
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AV_BF_ROUNDS 16
|
||||
|
||||
typedef struct AVBlowfish {
|
||||
uint32_t p[AV_BF_ROUNDS + 2];
|
||||
uint32_t s[4][256];
|
||||
} AVBlowfish;
|
||||
|
||||
/**
|
||||
* Initialize an AVBlowfish context.
|
||||
*
|
||||
* @param ctx an AVBlowfish context
|
||||
* @param key a key
|
||||
* @param key_len length of the key
|
||||
*/
|
||||
void av_blowfish_init(struct AVBlowfish *ctx, const uint8_t *key, int key_len);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context.
|
||||
*
|
||||
* @param ctx an AVBlowfish context
|
||||
* @param xl left four bytes halves of input to be encrypted
|
||||
* @param xr right four bytes halves of input to be encrypted
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_blowfish_crypt_ecb(struct AVBlowfish *ctx, uint32_t *xl, uint32_t *xr,
|
||||
int decrypt);
|
||||
|
||||
/**
|
||||
* Encrypt or decrypt a buffer using a previously initialized context.
|
||||
*
|
||||
* @param ctx an AVBlowfish context
|
||||
* @param dst destination array, can be equal to src
|
||||
* @param src source array, can be equal to dst
|
||||
* @param count number of 8 byte blocks
|
||||
* @param iv initialization vector for CBC mode, if NULL ECB will be used
|
||||
* @param decrypt 0 for encryption, 1 for decryption
|
||||
*/
|
||||
void av_blowfish_crypt(struct AVBlowfish *ctx, uint8_t *dst, const uint8_t *src,
|
||||
int count, uint8_t *iv, int decrypt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_BLOWFISH_H */
|
|
@ -0,0 +1,200 @@
|
|||
/*
|
||||
* Copyright (c) 2012 Nicolas George
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_BPRINT_H
|
||||
#define AVUTIL_BPRINT_H
|
||||
|
||||
#include "attributes.h"
|
||||
#include "avstring.h"
|
||||
|
||||
/**
|
||||
* Define a structure with extra padding to a fixed size
|
||||
* This helps ensuring binary compatibility with future versions.
|
||||
*/
|
||||
#define FF_PAD_STRUCTURE(size, ...) \
|
||||
__VA_ARGS__ \
|
||||
char reserved_padding[size - sizeof(struct { __VA_ARGS__ })];
|
||||
|
||||
/**
|
||||
* Buffer to print data progressively
|
||||
*
|
||||
* The string buffer grows as necessary and is always 0-terminated.
|
||||
* The content of the string is never accessed, and thus is
|
||||
* encoding-agnostic and can even hold binary data.
|
||||
*
|
||||
* Small buffers are kept in the structure itself, and thus require no
|
||||
* memory allocation at all (unless the contents of the buffer is needed
|
||||
* after the structure goes out of scope). This is almost as lightweight as
|
||||
* declaring a local "char buf[512]".
|
||||
*
|
||||
* The length of the string can go beyond the allocated size: the buffer is
|
||||
* then truncated, but the functions still keep account of the actual total
|
||||
* length.
|
||||
*
|
||||
* In other words, buf->len can be greater than buf->size and records the
|
||||
* total length of what would have been to the buffer if there had been
|
||||
* enough memory.
|
||||
*
|
||||
* Append operations do not need to be tested for failure: if a memory
|
||||
* allocation fails, data stop being appended to the buffer, but the length
|
||||
* is still updated. This situation can be tested with
|
||||
* av_bprint_is_complete().
|
||||
*
|
||||
* The size_max field determines several possible behaviours:
|
||||
*
|
||||
* size_max = -1 (= UINT_MAX) or any large value will let the buffer be
|
||||
* reallocated as necessary, with an amortized linear cost.
|
||||
*
|
||||
* size_max = 0 prevents writing anything to the buffer: only the total
|
||||
* length is computed. The write operations can then possibly be repeated in
|
||||
* a buffer with exactly the necessary size
|
||||
* (using size_init = size_max = len + 1).
|
||||
*
|
||||
* size_max = 1 is automatically replaced by the exact size available in the
|
||||
* structure itself, thus ensuring no dynamic memory allocation. The
|
||||
* internal buffer is large enough to hold a reasonable paragraph of text,
|
||||
* such as the current paragraph.
|
||||
*/
|
||||
typedef struct AVBPrint {
|
||||
FF_PAD_STRUCTURE(1024,
|
||||
char *str; /** string so far */
|
||||
unsigned len; /** length so far */
|
||||
unsigned size; /** allocated memory */
|
||||
unsigned size_max; /** maximum allocated memory */
|
||||
char reserved_internal_buffer[1];
|
||||
)
|
||||
} AVBPrint;
|
||||
|
||||
/**
|
||||
* Convenience macros for special values for av_bprint_init() size_max
|
||||
* parameter.
|
||||
*/
|
||||
#define AV_BPRINT_SIZE_UNLIMITED ((unsigned)-1)
|
||||
#define AV_BPRINT_SIZE_AUTOMATIC 1
|
||||
#define AV_BPRINT_SIZE_COUNT_ONLY 0
|
||||
|
||||
/**
|
||||
* Init a print buffer.
|
||||
*
|
||||
* @param buf buffer to init
|
||||
* @param size_init initial size (including the final 0)
|
||||
* @param size_max maximum size;
|
||||
* 0 means do not write anything, just count the length;
|
||||
* 1 is replaced by the maximum value for automatic storage;
|
||||
* any large value means that the internal buffer will be
|
||||
* reallocated as needed up to that limit; -1 is converted to
|
||||
* UINT_MAX, the largest limit possible.
|
||||
* Check also AV_BPRINT_SIZE_* macros.
|
||||
*/
|
||||
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max);
|
||||
|
||||
/**
|
||||
* Init a print buffer using a pre-existing buffer.
|
||||
*
|
||||
* The buffer will not be reallocated.
|
||||
*
|
||||
* @param buf buffer structure to init
|
||||
* @param buffer byte buffer to use for the string data
|
||||
* @param size size of buffer
|
||||
*/
|
||||
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size);
|
||||
|
||||
/**
|
||||
* Append a formatted string to a print buffer.
|
||||
*/
|
||||
void av_bprintf(AVBPrint *buf, const char *fmt, ...) av_printf_format(2, 3);
|
||||
|
||||
/**
|
||||
* Append char c n times to a print buffer.
|
||||
*/
|
||||
void av_bprint_chars(AVBPrint *buf, char c, unsigned n);
|
||||
|
||||
struct tm;
|
||||
/**
|
||||
* Append a formatted date and time to a print buffer.
|
||||
*
|
||||
* param buf bprint buffer to use
|
||||
* param fmt date and time format string, see strftime()
|
||||
* param tm broken-down time structure to translate
|
||||
*
|
||||
* @note due to poor design of the standard strftime function, it may
|
||||
* produce poor results if the format string expands to a very long text and
|
||||
* the bprint buffer is near the limit stated by the size_max option.
|
||||
*/
|
||||
void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm);
|
||||
|
||||
/**
|
||||
* Allocate bytes in the buffer for external use.
|
||||
*
|
||||
* @param[in] buf buffer structure
|
||||
* @param[in] size required size
|
||||
* @param[out] mem pointer to the memory area
|
||||
* @param[out] actual_size size of the memory area after allocation;
|
||||
* can be larger or smaller than size
|
||||
*/
|
||||
void av_bprint_get_buffer(AVBPrint *buf, unsigned size,
|
||||
unsigned char **mem, unsigned *actual_size);
|
||||
|
||||
/**
|
||||
* Reset the string to "" but keep internal allocated data.
|
||||
*/
|
||||
void av_bprint_clear(AVBPrint *buf);
|
||||
|
||||
/**
|
||||
* Test if the print buffer is complete (not truncated).
|
||||
*
|
||||
* It may have been truncated due to a memory allocation failure
|
||||
* or the size_max limit (compare size and size_max if necessary).
|
||||
*/
|
||||
static inline int av_bprint_is_complete(AVBPrint *buf)
|
||||
{
|
||||
return buf->len < buf->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalize a print buffer.
|
||||
*
|
||||
* The print buffer can no longer be used afterwards,
|
||||
* but the len and size fields are still valid.
|
||||
*
|
||||
* @arg[out] ret_str if not NULL, used to return a permanent copy of the
|
||||
* buffer contents, or NULL if memory allocation fails;
|
||||
* if NULL, the buffer is discarded and freed
|
||||
* @return 0 for success or error code (probably AVERROR(ENOMEM))
|
||||
*/
|
||||
int av_bprint_finalize(AVBPrint *buf, char **ret_str);
|
||||
|
||||
/**
|
||||
* Escape the content in src and append it to dstbuf.
|
||||
*
|
||||
* @param dstbuf already inited destination bprint buffer
|
||||
* @param src string containing the text to escape
|
||||
* @param special_chars string containing the special characters which
|
||||
* need to be escaped, can be NULL
|
||||
* @param mode escape mode to employ, see AV_ESCAPE_MODE_* macros.
|
||||
* Any unknown value for mode will be considered equivalent to
|
||||
* AV_ESCAPE_MODE_BACKSLASH, but this behaviour can change without
|
||||
* notice.
|
||||
* @param flags flags which control how to escape, see AV_ESCAPE_FLAG_* macros
|
||||
*/
|
||||
void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars,
|
||||
enum AVEscapeMode mode, int flags);
|
||||
|
||||
#endif /* AVUTIL_BPRINT_H */
|
|
@ -65,29 +65,14 @@ static av_always_inline av_const uint16_t av_bswap16(uint16_t x)
|
|||
#ifndef av_bswap32
|
||||
static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
|
||||
{
|
||||
x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF);
|
||||
x= (x>>16) | (x<<16);
|
||||
return x;
|
||||
return AV_BSWAP32C(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef av_bswap64
|
||||
static inline uint64_t av_const av_bswap64(uint64_t x)
|
||||
{
|
||||
#if 0
|
||||
x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL);
|
||||
x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL);
|
||||
return (x>>32) | (x<<32);
|
||||
#else
|
||||
union {
|
||||
uint64_t ll;
|
||||
uint32_t l[2];
|
||||
} w, r;
|
||||
w.ll = x;
|
||||
r.l[0] = av_bswap32 (w.l[1]);
|
||||
r.l[1] = av_bswap32 (w.l[0]);
|
||||
return r.ll;
|
||||
#endif
|
||||
return (uint64_t)av_bswap32(x) << 32 | av_bswap32(x >> 32);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -0,0 +1,216 @@
|
|||
/*
|
||||
* Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
|
||||
* Copyright (c) 2008 Peter Ross
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_CHANNEL_LAYOUT_H
|
||||
#define AVUTIL_CHANNEL_LAYOUT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @file
|
||||
* audio channel layout utility functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_audio
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup channel_masks Audio channel masks
|
||||
*
|
||||
* A channel layout is a 64-bits integer with a bit set for every channel.
|
||||
* The number of bits set must be equal to the number of channels.
|
||||
* The value 0 means that the channel layout is not known.
|
||||
* @note this data structure is not powerful enough to handle channels
|
||||
* combinations that have the same channel multiple times, such as
|
||||
* dual-mono.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
#define AV_CH_FRONT_LEFT 0x00000001
|
||||
#define AV_CH_FRONT_RIGHT 0x00000002
|
||||
#define AV_CH_FRONT_CENTER 0x00000004
|
||||
#define AV_CH_LOW_FREQUENCY 0x00000008
|
||||
#define AV_CH_BACK_LEFT 0x00000010
|
||||
#define AV_CH_BACK_RIGHT 0x00000020
|
||||
#define AV_CH_FRONT_LEFT_OF_CENTER 0x00000040
|
||||
#define AV_CH_FRONT_RIGHT_OF_CENTER 0x00000080
|
||||
#define AV_CH_BACK_CENTER 0x00000100
|
||||
#define AV_CH_SIDE_LEFT 0x00000200
|
||||
#define AV_CH_SIDE_RIGHT 0x00000400
|
||||
#define AV_CH_TOP_CENTER 0x00000800
|
||||
#define AV_CH_TOP_FRONT_LEFT 0x00001000
|
||||
#define AV_CH_TOP_FRONT_CENTER 0x00002000
|
||||
#define AV_CH_TOP_FRONT_RIGHT 0x00004000
|
||||
#define AV_CH_TOP_BACK_LEFT 0x00008000
|
||||
#define AV_CH_TOP_BACK_CENTER 0x00010000
|
||||
#define AV_CH_TOP_BACK_RIGHT 0x00020000
|
||||
#define AV_CH_STEREO_LEFT 0x20000000 ///< Stereo downmix.
|
||||
#define AV_CH_STEREO_RIGHT 0x40000000 ///< See AV_CH_STEREO_LEFT.
|
||||
#define AV_CH_WIDE_LEFT 0x0000000080000000ULL
|
||||
#define AV_CH_WIDE_RIGHT 0x0000000100000000ULL
|
||||
#define AV_CH_SURROUND_DIRECT_LEFT 0x0000000200000000ULL
|
||||
#define AV_CH_SURROUND_DIRECT_RIGHT 0x0000000400000000ULL
|
||||
#define AV_CH_LOW_FREQUENCY_2 0x0000000800000000ULL
|
||||
|
||||
/** Channel mask value used for AVCodecContext.request_channel_layout
|
||||
to indicate that the user requests the channel order of the decoder output
|
||||
to be the native codec channel order. */
|
||||
#define AV_CH_LAYOUT_NATIVE 0x8000000000000000ULL
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @defgroup channel_mask_c Audio channel convenience macros
|
||||
* @{
|
||||
* */
|
||||
#define AV_CH_LAYOUT_MONO (AV_CH_FRONT_CENTER)
|
||||
#define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT)
|
||||
#define AV_CH_LAYOUT_2POINT1 (AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_2_1 (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_SURROUND (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER)
|
||||
#define AV_CH_LAYOUT_3POINT1 (AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_4POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_4POINT1 (AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_2_2 (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
|
||||
#define AV_CH_LAYOUT_QUAD (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_5POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT)
|
||||
#define AV_CH_LAYOUT_5POINT1 (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_5POINT0_BACK (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_5POINT1_BACK (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_6POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_6POINT0_FRONT (AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
#define AV_CH_LAYOUT_HEXAGONAL (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_6POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_6POINT1_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER)
|
||||
#define AV_CH_LAYOUT_6POINT1_FRONT (AV_CH_LAYOUT_6POINT0_FRONT|AV_CH_LOW_FREQUENCY)
|
||||
#define AV_CH_LAYOUT_7POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_7POINT0_FRONT (AV_CH_LAYOUT_5POINT0|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
#define AV_CH_LAYOUT_7POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
#define AV_CH_LAYOUT_7POINT1_WIDE_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
#define AV_CH_LAYOUT_OCTAGONAL (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT)
|
||||
#define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT)
|
||||
|
||||
enum AVMatrixEncoding {
|
||||
AV_MATRIX_ENCODING_NONE,
|
||||
AV_MATRIX_ENCODING_DOLBY,
|
||||
AV_MATRIX_ENCODING_DPLII,
|
||||
AV_MATRIX_ENCODING_NB
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return a channel layout id that matches name, or 0 if no match is found.
|
||||
*
|
||||
* name can be one or several of the following notations,
|
||||
* separated by '+' or '|':
|
||||
* - the name of an usual channel layout (mono, stereo, 4.0, quad, 5.0,
|
||||
* 5.0(side), 5.1, 5.1(side), 7.1, 7.1(wide), downmix);
|
||||
* - the name of a single channel (FL, FR, FC, LFE, BL, BR, FLC, FRC, BC,
|
||||
* SL, SR, TC, TFL, TFC, TFR, TBL, TBC, TBR, DL, DR);
|
||||
* - a number of channels, in decimal, optionally followed by 'c', yielding
|
||||
* the default channel layout for that number of channels (@see
|
||||
* av_get_default_channel_layout);
|
||||
* - a channel layout mask, in hexadecimal starting with "0x" (see the
|
||||
* AV_CH_* macros).
|
||||
*
|
||||
* Example: "stereo+FC" = "2+FC" = "2c+1c" = "0x7"
|
||||
*/
|
||||
uint64_t av_get_channel_layout(const char *name);
|
||||
|
||||
/**
|
||||
* Return a description of a channel layout.
|
||||
* If nb_channels is <= 0, it is guessed from the channel_layout.
|
||||
*
|
||||
* @param buf put here the string containing the channel layout
|
||||
* @param buf_size size in bytes of the buffer
|
||||
*/
|
||||
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout);
|
||||
|
||||
struct AVBPrint;
|
||||
/**
|
||||
* Append a description of a channel layout to a bprint buffer.
|
||||
*/
|
||||
void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout);
|
||||
|
||||
/**
|
||||
* Return the number of channels in the channel layout.
|
||||
*/
|
||||
int av_get_channel_layout_nb_channels(uint64_t channel_layout);
|
||||
|
||||
/**
|
||||
* Return default channel layout for a given number of channels.
|
||||
*/
|
||||
int64_t av_get_default_channel_layout(int nb_channels);
|
||||
|
||||
/**
|
||||
* Get the index of a channel in channel_layout.
|
||||
*
|
||||
* @param channel a channel layout describing exactly one channel which must be
|
||||
* present in channel_layout.
|
||||
*
|
||||
* @return index of channel in channel_layout on success, a negative AVERROR
|
||||
* on error.
|
||||
*/
|
||||
int av_get_channel_layout_channel_index(uint64_t channel_layout,
|
||||
uint64_t channel);
|
||||
|
||||
/**
|
||||
* Get the channel with the given index in channel_layout.
|
||||
*/
|
||||
uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index);
|
||||
|
||||
/**
|
||||
* Get the name of a given channel.
|
||||
*
|
||||
* @return channel name on success, NULL on error.
|
||||
*/
|
||||
const char *av_get_channel_name(uint64_t channel);
|
||||
|
||||
/**
|
||||
* Get the description of a given channel.
|
||||
*
|
||||
* @param channel a channel layout with a single channel
|
||||
* @return channel description on success, NULL on error
|
||||
*/
|
||||
const char *av_get_channel_description(uint64_t channel);
|
||||
|
||||
/**
|
||||
* Get the value and name of a standard channel layout.
|
||||
*
|
||||
* @param[in] index index in an internal list, starting at 0
|
||||
* @param[out] layout channel layout mask
|
||||
* @param[out] name name of the layout
|
||||
* @return 0 if the layout exists,
|
||||
* <0 if index is beyond the limits
|
||||
*/
|
||||
int av_get_standard_channel_layout(unsigned index, uint64_t *layout,
|
||||
const char **name);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_CHANNEL_LAYOUT_H */
|
|
@ -26,7 +26,6 @@
|
|||
#ifndef AVUTIL_COMMON_H
|
||||
#define AVUTIL_COMMON_H
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
|
@ -34,12 +33,23 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
#include "libavutil/avconfig.h"
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
# define AV_NE(be, le) (be)
|
||||
#else
|
||||
# define AV_NE(be, le) (le)
|
||||
#endif
|
||||
|
||||
//rounded division & shift
|
||||
#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
|
||||
/* assume b>0 */
|
||||
#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
|
||||
#define FFUDIV(a,b) (((a)>0 ?(a):(a)-(b)+1) / (b))
|
||||
#define FFUMOD(a,b) ((a)-(b)*FFUDIV(a,b))
|
||||
#define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
|
||||
#define FFSIGN(a) ((a) > 0 ? 1 : -1)
|
||||
|
||||
|
@ -53,37 +63,13 @@
|
|||
#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
|
||||
|
||||
/* misc math functions */
|
||||
extern const uint8_t ff_log2_tab[256];
|
||||
|
||||
extern const uint8_t av_reverse[256];
|
||||
|
||||
static inline av_const int av_log2_c(unsigned int v)
|
||||
{
|
||||
int n = 0;
|
||||
if (v & 0xffff0000) {
|
||||
v >>= 16;
|
||||
n += 16;
|
||||
}
|
||||
if (v & 0xff00) {
|
||||
v >>= 8;
|
||||
n += 8;
|
||||
}
|
||||
n += ff_log2_tab[v];
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static inline av_const int av_log2_16bit_c(unsigned int v)
|
||||
{
|
||||
int n = 0;
|
||||
if (v & 0xff00) {
|
||||
v >>= 8;
|
||||
n += 8;
|
||||
}
|
||||
n += ff_log2_tab[v];
|
||||
|
||||
return n;
|
||||
}
|
||||
/**
|
||||
* Reverse the order of the bits of an 8-bits unsigned integer.
|
||||
*/
|
||||
#if FF_API_AV_REVERSE
|
||||
extern attribute_deprecated const uint8_t av_reverse[256];
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
# include "config.h"
|
||||
|
@ -93,6 +79,14 @@ static inline av_const int av_log2_16bit_c(unsigned int v)
|
|||
/* Pull in unguarded fallback defines at the end of this file. */
|
||||
#include "common.h"
|
||||
|
||||
#ifndef av_log2
|
||||
av_const int av_log2(unsigned v);
|
||||
#endif
|
||||
|
||||
#ifndef av_log2_16bit
|
||||
av_const int av_log2_16bit(unsigned v);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the amin-amax range.
|
||||
* @param a value to clip
|
||||
|
@ -100,8 +94,28 @@ static inline av_const int av_log2_16bit_c(unsigned int v)
|
|||
* @param amax maximum value of the clip range
|
||||
* @return clipped value
|
||||
*/
|
||||
static inline av_const int av_clip_c(int a, int amin, int amax)
|
||||
static av_always_inline av_const int av_clip_c(int a, int amin, int amax)
|
||||
{
|
||||
#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
|
||||
if (amin > amax) abort();
|
||||
#endif
|
||||
if (a < amin) return amin;
|
||||
else if (a > amax) return amax;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed 64bit integer value into the amin-amax range.
|
||||
* @param a value to clip
|
||||
* @param amin minimum value of the clip range
|
||||
* @param amax maximum value of the clip range
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, int64_t amax)
|
||||
{
|
||||
#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
|
||||
if (amin > amax) abort();
|
||||
#endif
|
||||
if (a < amin) return amin;
|
||||
else if (a > amax) return amax;
|
||||
else return a;
|
||||
|
@ -112,7 +126,7 @@ static inline av_const int av_clip_c(int a, int amin, int amax)
|
|||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static inline av_const uint8_t av_clip_uint8_c(int a)
|
||||
static av_always_inline av_const uint8_t av_clip_uint8_c(int a)
|
||||
{
|
||||
if (a&(~0xFF)) return (-a)>>31;
|
||||
else return a;
|
||||
|
@ -123,7 +137,7 @@ static inline av_const uint8_t av_clip_uint8_c(int a)
|
|||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static inline av_const int8_t av_clip_int8_c(int a)
|
||||
static av_always_inline av_const int8_t av_clip_int8_c(int a)
|
||||
{
|
||||
if ((a+0x80) & ~0xFF) return (a>>31) ^ 0x7F;
|
||||
else return a;
|
||||
|
@ -134,7 +148,7 @@ static inline av_const int8_t av_clip_int8_c(int a)
|
|||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static inline av_const uint16_t av_clip_uint16_c(int a)
|
||||
static av_always_inline av_const uint16_t av_clip_uint16_c(int a)
|
||||
{
|
||||
if (a&(~0xFFFF)) return (-a)>>31;
|
||||
else return a;
|
||||
|
@ -145,7 +159,7 @@ static inline av_const uint16_t av_clip_uint16_c(int a)
|
|||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static inline av_const int16_t av_clip_int16_c(int a)
|
||||
static av_always_inline av_const int16_t av_clip_int16_c(int a)
|
||||
{
|
||||
if ((a+0x8000) & ~0xFFFF) return (a>>31) ^ 0x7FFF;
|
||||
else return a;
|
||||
|
@ -156,12 +170,48 @@ static inline av_const int16_t av_clip_int16_c(int a)
|
|||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static inline av_const int32_t av_clipl_int32_c(int64_t a)
|
||||
static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a)
|
||||
{
|
||||
if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (a>>63) ^ 0x7FFFFFFF;
|
||||
else return (int32_t)a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer to an unsigned power of two range.
|
||||
* @param a value to clip
|
||||
* @param p bit position to clip at
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
|
||||
{
|
||||
if (a & ~((1<<p) - 1)) return -a >> 31 & ((1<<p) - 1);
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add two signed 32-bit values with saturation.
|
||||
*
|
||||
* @param a one value
|
||||
* @param b another value
|
||||
* @return sum with signed saturation
|
||||
*/
|
||||
static av_always_inline int av_sat_add32_c(int a, int b)
|
||||
{
|
||||
return av_clipl_int32((int64_t)a + b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a doubled value to another value with saturation at both stages.
|
||||
*
|
||||
* @param a first value
|
||||
* @param b value doubled and added to a
|
||||
* @return sum with signed saturation
|
||||
*/
|
||||
static av_always_inline int av_sat_dadd32_c(int a, int b)
|
||||
{
|
||||
return av_sat_add32(a, av_sat_add32(b, b));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a float value into the amin-amax range.
|
||||
* @param a value to clip
|
||||
|
@ -169,8 +219,11 @@ static inline av_const int32_t av_clipl_int32_c(int64_t a)
|
|||
* @param amax maximum value of the clip range
|
||||
* @return clipped value
|
||||
*/
|
||||
static inline av_const float av_clipf_c(float a, float amin, float amax)
|
||||
static av_always_inline av_const float av_clipf_c(float a, float amin, float amax)
|
||||
{
|
||||
#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
|
||||
if (amin > amax) abort();
|
||||
#endif
|
||||
if (a < amin) return amin;
|
||||
else if (a > amax) return amax;
|
||||
else return a;
|
||||
|
@ -180,13 +233,37 @@ static inline av_const float av_clipf_c(float a, float amin, float amax)
|
|||
* @param x value used to compute ceil(log2(x))
|
||||
* @return computed ceiling of log2(x)
|
||||
*/
|
||||
static inline av_const int av_ceil_log2_c(int x)
|
||||
static av_always_inline av_const int av_ceil_log2_c(int x)
|
||||
{
|
||||
return av_log2((x - 1) << 1);
|
||||
}
|
||||
|
||||
#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
|
||||
#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24))
|
||||
/**
|
||||
* Count number of bits set to one in x
|
||||
* @param x value to count bits of
|
||||
* @return the number of bits set to one in x
|
||||
*/
|
||||
static av_always_inline av_const int av_popcount_c(uint32_t x)
|
||||
{
|
||||
x -= (x >> 1) & 0x55555555;
|
||||
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
|
||||
x = (x + (x >> 4)) & 0x0F0F0F0F;
|
||||
x += x >> 8;
|
||||
return (x + (x >> 16)) & 0x3F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Count number of bits set to one in x
|
||||
* @param x value to count bits of
|
||||
* @return the number of bits set to one in x
|
||||
*/
|
||||
static av_always_inline av_const int av_popcount64_c(uint64_t x)
|
||||
{
|
||||
return av_popcount((uint32_t)x) + av_popcount(x >> 32);
|
||||
}
|
||||
|
||||
#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24))
|
||||
#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24))
|
||||
|
||||
/**
|
||||
* Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
|
||||
|
@ -202,16 +279,17 @@ static inline av_const int av_ceil_log2_c(int x)
|
|||
#define GET_UTF8(val, GET_BYTE, ERROR)\
|
||||
val= GET_BYTE;\
|
||||
{\
|
||||
int ones= 7 - av_log2(val ^ 255);\
|
||||
if(ones==1)\
|
||||
uint32_t top = (val & 128) >> 1;\
|
||||
if ((val & 0xc0) == 0x80)\
|
||||
ERROR\
|
||||
val&= 127>>ones;\
|
||||
while(--ones > 0){\
|
||||
while (val & top) {\
|
||||
int tmp= GET_BYTE - 128;\
|
||||
if(tmp>>6)\
|
||||
ERROR\
|
||||
val= (val<<6) + tmp;\
|
||||
top <<= 5;\
|
||||
}\
|
||||
val &= (top << 1) - 1;\
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -235,16 +313,16 @@ static inline av_const int av_ceil_log2_c(int x)
|
|||
}\
|
||||
}\
|
||||
|
||||
/*!
|
||||
* \def PUT_UTF8(val, tmp, PUT_BYTE)
|
||||
/**
|
||||
* @def PUT_UTF8(val, tmp, PUT_BYTE)
|
||||
* Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
|
||||
* \param val is an input-only argument and should be of type uint32_t. It holds
|
||||
* @param val is an input-only argument and should be of type uint32_t. It holds
|
||||
* a UCS-4 encoded Unicode character that is to be converted to UTF-8. If
|
||||
* val is given as a function it is executed only once.
|
||||
* \param tmp is a temporary variable and should be of type uint8_t. It
|
||||
* @param tmp is a temporary variable and should be of type uint8_t. It
|
||||
* represents an intermediate value during conversion that is to be
|
||||
* output by PUT_BYTE.
|
||||
* \param PUT_BYTE writes the converted UTF-8 bytes to any proper destination.
|
||||
* @param PUT_BYTE writes the converted UTF-8 bytes to any proper destination.
|
||||
* It could be a function or a statement, and uses tmp as the input byte.
|
||||
* For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be
|
||||
* executed up to 4 times for values in the valid UTF-8 range and up to
|
||||
|
@ -271,16 +349,16 @@ static inline av_const int av_ceil_log2_c(int x)
|
|||
}\
|
||||
}
|
||||
|
||||
/*!
|
||||
* \def PUT_UTF16(val, tmp, PUT_16BIT)
|
||||
/**
|
||||
* @def PUT_UTF16(val, tmp, PUT_16BIT)
|
||||
* Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes).
|
||||
* \param val is an input-only argument and should be of type uint32_t. It holds
|
||||
* @param val is an input-only argument and should be of type uint32_t. It holds
|
||||
* a UCS-4 encoded Unicode character that is to be converted to UTF-16. If
|
||||
* val is given as a function it is executed only once.
|
||||
* \param tmp is a temporary variable and should be of type uint16_t. It
|
||||
* @param tmp is a temporary variable and should be of type uint16_t. It
|
||||
* represents an intermediate value during conversion that is to be
|
||||
* output by PUT_16BIT.
|
||||
* \param PUT_16BIT writes the converted UTF-16 data to any proper destination
|
||||
* @param PUT_16BIT writes the converted UTF-16 data to any proper destination
|
||||
* in desired endianness. It could be a function or a statement, and uses tmp
|
||||
* as the input byte. For example, PUT_BYTE could be "*output++ = tmp;"
|
||||
* PUT_BYTE will be executed 1 or 2 times depending on input character.
|
||||
|
@ -314,18 +392,15 @@ static inline av_const int av_ceil_log2_c(int x)
|
|||
* to ensure they are immediately available in intmath.h.
|
||||
*/
|
||||
|
||||
#ifndef av_log2
|
||||
# define av_log2 av_log2_c
|
||||
#endif
|
||||
#ifndef av_log2_16bit
|
||||
# define av_log2_16bit av_log2_16bit_c
|
||||
#endif
|
||||
#ifndef av_ceil_log2
|
||||
# define av_ceil_log2 av_ceil_log2_c
|
||||
#endif
|
||||
#ifndef av_clip
|
||||
# define av_clip av_clip_c
|
||||
#endif
|
||||
#ifndef av_clip64
|
||||
# define av_clip64 av_clip64_c
|
||||
#endif
|
||||
#ifndef av_clip_uint8
|
||||
# define av_clip_uint8 av_clip_uint8_c
|
||||
#endif
|
||||
|
@ -341,6 +416,21 @@ static inline av_const int av_ceil_log2_c(int x)
|
|||
#ifndef av_clipl_int32
|
||||
# define av_clipl_int32 av_clipl_int32_c
|
||||
#endif
|
||||
#ifndef av_clip_uintp2
|
||||
# define av_clip_uintp2 av_clip_uintp2_c
|
||||
#endif
|
||||
#ifndef av_sat_add32
|
||||
# define av_sat_add32 av_sat_add32_c
|
||||
#endif
|
||||
#ifndef av_sat_dadd32
|
||||
# define av_sat_dadd32 av_sat_dadd32_c
|
||||
#endif
|
||||
#ifndef av_clipf
|
||||
# define av_clipf av_clipf_c
|
||||
#endif
|
||||
#ifndef av_popcount
|
||||
# define av_popcount av_popcount_c
|
||||
#endif
|
||||
#ifndef av_popcount64
|
||||
# define av_popcount64 av_popcount64_c
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2001, 2002 Fabrice Bellard
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_CPU_H
|
||||
#define AVUTIL_CPU_H
|
||||
|
||||
#include "attributes.h"
|
||||
|
||||
#define AV_CPU_FLAG_FORCE 0x80000000 /* force usage of selected flags (OR) */
|
||||
|
||||
/* lower 16 bits - CPU features */
|
||||
#define AV_CPU_FLAG_MMX 0x0001 ///< standard MMX
|
||||
#define AV_CPU_FLAG_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext
|
||||
#define AV_CPU_FLAG_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext
|
||||
#define AV_CPU_FLAG_3DNOW 0x0004 ///< AMD 3DNOW
|
||||
#define AV_CPU_FLAG_SSE 0x0008 ///< SSE functions
|
||||
#define AV_CPU_FLAG_SSE2 0x0010 ///< PIV SSE2 functions
|
||||
#define AV_CPU_FLAG_SSE2SLOW 0x40000000 ///< SSE2 supported, but usually not faster
|
||||
#define AV_CPU_FLAG_3DNOWEXT 0x0020 ///< AMD 3DNowExt
|
||||
#define AV_CPU_FLAG_SSE3 0x0040 ///< Prescott SSE3 functions
|
||||
#define AV_CPU_FLAG_SSE3SLOW 0x20000000 ///< SSE3 supported, but usually not faster
|
||||
#define AV_CPU_FLAG_SSSE3 0x0080 ///< Conroe SSSE3 functions
|
||||
#define AV_CPU_FLAG_ATOM 0x10000000 ///< Atom processor, some SSSE3 instructions are slower
|
||||
#define AV_CPU_FLAG_SSE4 0x0100 ///< Penryn SSE4.1 functions
|
||||
#define AV_CPU_FLAG_SSE42 0x0200 ///< Nehalem SSE4.2 functions
|
||||
#define AV_CPU_FLAG_AVX 0x4000 ///< AVX functions: requires OS support even if YMM registers aren't used
|
||||
#define AV_CPU_FLAG_XOP 0x0400 ///< Bulldozer XOP functions
|
||||
#define AV_CPU_FLAG_FMA4 0x0800 ///< Bulldozer FMA4 functions
|
||||
// #if LIBAVUTIL_VERSION_MAJOR <52
|
||||
#define AV_CPU_FLAG_CMOV 0x1001000 ///< supports cmov instruction
|
||||
// #else
|
||||
// #define AV_CPU_FLAG_CMOV 0x1000 ///< supports cmov instruction
|
||||
// #endif
|
||||
|
||||
#define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard
|
||||
|
||||
#define AV_CPU_FLAG_ARMV5TE (1 << 0)
|
||||
#define AV_CPU_FLAG_ARMV6 (1 << 1)
|
||||
#define AV_CPU_FLAG_ARMV6T2 (1 << 2)
|
||||
#define AV_CPU_FLAG_VFP (1 << 3)
|
||||
#define AV_CPU_FLAG_VFPV3 (1 << 4)
|
||||
#define AV_CPU_FLAG_NEON (1 << 5)
|
||||
|
||||
/**
|
||||
* Return the flags which specify extensions supported by the CPU.
|
||||
* The returned value is affected by av_force_cpu_flags() if that was used
|
||||
* before. So av_get_cpu_flags() can easily be used in a application to
|
||||
* detect the enabled cpu flags.
|
||||
*/
|
||||
int av_get_cpu_flags(void);
|
||||
|
||||
/**
|
||||
* Disables cpu detection and forces the specified flags.
|
||||
* -1 is a special case that disables forcing of specific flags.
|
||||
*/
|
||||
void av_force_cpu_flags(int flags);
|
||||
|
||||
/**
|
||||
* Set a mask on flags returned by av_get_cpu_flags().
|
||||
* This function is mainly useful for testing.
|
||||
* Please use av_force_cpu_flags() and av_get_cpu_flags() instead which are more flexible
|
||||
*
|
||||
* @warning this function is not thread safe.
|
||||
*/
|
||||
attribute_deprecated void av_set_cpu_flags_mask(int mask);
|
||||
|
||||
/**
|
||||
* Parse CPU flags from a string.
|
||||
*
|
||||
* The returned flags contain the specified flags as well as related unspecified flags.
|
||||
*
|
||||
* This function exists only for compatibility with libav.
|
||||
* Please use av_parse_cpu_caps() when possible.
|
||||
* @return a combination of AV_CPU_* flags, negative on error.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_parse_cpu_flags(const char *s);
|
||||
|
||||
/**
|
||||
* Parse CPU caps from a string and update the given AV_CPU_* flags based on that.
|
||||
*
|
||||
* @return negative on error.
|
||||
*/
|
||||
int av_parse_cpu_caps(unsigned *flags, const char *s);
|
||||
|
||||
/* The following CPU-specific functions shall not be called directly. */
|
||||
int ff_get_cpu_flags_arm(void);
|
||||
int ff_get_cpu_flags_ppc(void);
|
||||
int ff_get_cpu_flags_x86(void);
|
||||
|
||||
#endif /* AVUTIL_CPU_H */
|
|
@ -36,9 +36,39 @@ typedef enum {
|
|||
AV_CRC_MAX, /*< Not part of public API! Do not use outside libavutil. */
|
||||
}AVCRCId;
|
||||
|
||||
/**
|
||||
* Initialize a CRC table.
|
||||
* @param ctx must be an array of size sizeof(AVCRC)*257 or sizeof(AVCRC)*1024
|
||||
* @param le If 1, the lowest bit represents the coefficient for the highest
|
||||
* exponent of the corresponding polynomial (both for poly and
|
||||
* actual CRC).
|
||||
* If 0, you must swap the CRC parameter and the result of av_crc
|
||||
* if you need the standard representation (can be simplified in
|
||||
* most cases to e.g. bswap16):
|
||||
* av_bswap32(crc << (32-bits))
|
||||
* @param bits number of bits for the CRC
|
||||
* @param poly generator polynomial without the x**bits coefficient, in the
|
||||
* representation as specified by le
|
||||
* @param ctx_size size of ctx in bytes
|
||||
* @return <0 on failure
|
||||
*/
|
||||
int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size);
|
||||
|
||||
/**
|
||||
* Get an initialized standard CRC table.
|
||||
* @param crc_id ID of a standard CRC
|
||||
* @return a pointer to the CRC table or NULL on failure
|
||||
*/
|
||||
const AVCRC *av_crc_get_table(AVCRCId crc_id);
|
||||
uint32_t av_crc(const AVCRC *ctx, uint32_t start_crc, const uint8_t *buffer, size_t length) av_pure;
|
||||
|
||||
/**
|
||||
* Calculate the CRC of a block.
|
||||
* @param crc CRC of previous blocks if any or initial value for CRC
|
||||
* @return CRC updated with the data from the given block
|
||||
*
|
||||
* @see av_crc_init() "le" parameter
|
||||
*/
|
||||
uint32_t av_crc(const AVCRC *ctx, uint32_t crc,
|
||||
const uint8_t *buffer, size_t length) av_pure;
|
||||
|
||||
#endif /* AVUTIL_CRC_H */
|
||||
|
||||
|
|
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Public dictionary API.
|
||||
* @deprecated
|
||||
* AVDictionary is provided for compatibility with libav. It is both in
|
||||
* implementation as well as API inefficient. It does not scale and is
|
||||
* extremely slow with large dictionaries.
|
||||
* It is recommended that new code uses our tree container from tree.c/h
|
||||
* where applicable, which uses AVL trees to achieve O(log n) performance.
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_DICT_H
|
||||
#define AVUTIL_DICT_H
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_dict AVDictionary
|
||||
* @ingroup lavu_data
|
||||
*
|
||||
* @brief Simple key:value store
|
||||
*
|
||||
* @{
|
||||
* Dictionaries are used for storing key:value pairs. To create
|
||||
* an AVDictionary, simply pass an address of a NULL pointer to
|
||||
* av_dict_set(). NULL can be used as an empty dictionary wherever
|
||||
* a pointer to an AVDictionary is required.
|
||||
* Use av_dict_get() to retrieve an entry or iterate over all
|
||||
* entries and finally av_dict_free() to free the dictionary
|
||||
* and all its contents.
|
||||
*
|
||||
* @code
|
||||
* AVDictionary *d = NULL; // "create" an empty dictionary
|
||||
* av_dict_set(&d, "foo", "bar", 0); // add an entry
|
||||
*
|
||||
* char *k = av_strdup("key"); // if your strings are already allocated,
|
||||
* char *v = av_strdup("value"); // you can avoid copying them like this
|
||||
* av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
|
||||
*
|
||||
* AVDictionaryEntry *t = NULL;
|
||||
* while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) {
|
||||
* <....> // iterate over all entries in d
|
||||
* }
|
||||
*
|
||||
* av_dict_free(&d);
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
|
||||
#define AV_DICT_MATCH_CASE 1
|
||||
#define AV_DICT_IGNORE_SUFFIX 2
|
||||
#define AV_DICT_DONT_STRDUP_KEY 4 /**< Take ownership of a key that's been
|
||||
allocated with av_malloc() and children. */
|
||||
#define AV_DICT_DONT_STRDUP_VAL 8 /**< Take ownership of a value that's been
|
||||
allocated with av_malloc() and chilren. */
|
||||
#define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries.
|
||||
#define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no
|
||||
delimiter is added, the strings are simply concatenated. */
|
||||
|
||||
typedef struct AVDictionaryEntry {
|
||||
char *key;
|
||||
char *value;
|
||||
} AVDictionaryEntry;
|
||||
|
||||
typedef struct AVDictionary AVDictionary;
|
||||
|
||||
/**
|
||||
* Get a dictionary entry with matching key.
|
||||
*
|
||||
* @param prev Set to the previous matching element to find the next.
|
||||
* If set to NULL the first matching element is returned.
|
||||
* @param flags Allows case as well as suffix-insensitive comparisons.
|
||||
* @return Found entry or NULL, changing key or value leads to undefined behavior.
|
||||
*/
|
||||
AVDictionaryEntry *
|
||||
av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags);
|
||||
|
||||
/**
|
||||
* Get number of entries in dictionary.
|
||||
*
|
||||
* @param m dictionary
|
||||
* @return number of entries in dictionary
|
||||
*/
|
||||
int av_dict_count(const AVDictionary *m);
|
||||
|
||||
/**
|
||||
* Set the given entry in *pm, overwriting an existing entry.
|
||||
*
|
||||
* @param pm pointer to a pointer to a dictionary struct. If *pm is NULL
|
||||
* a dictionary struct is allocated and put in *pm.
|
||||
* @param key entry key to add to *pm (will be av_strduped depending on flags)
|
||||
* @param value entry value to add to *pm (will be av_strduped depending on flags).
|
||||
* Passing a NULL value will cause an existing entry to be deleted.
|
||||
* @return >= 0 on success otherwise an error code <0
|
||||
*/
|
||||
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags);
|
||||
|
||||
/**
|
||||
* Parse the key/value pairs list and add to a dictionary.
|
||||
*
|
||||
* @param key_val_sep a 0-terminated list of characters used to separate
|
||||
* key from value
|
||||
* @param pairs_sep a 0-terminated list of characters used to separate
|
||||
* two pairs from each other
|
||||
* @param flags flags to use when adding to dictionary.
|
||||
* AV_DICT_DONT_STRDUP_KEY and AV_DICT_DONT_STRDUP_VAL
|
||||
* are ignored since the key/value tokens will always
|
||||
* be duplicated.
|
||||
* @return 0 on success, negative AVERROR code on failure
|
||||
*/
|
||||
int av_dict_parse_string(AVDictionary **pm, const char *str,
|
||||
const char *key_val_sep, const char *pairs_sep,
|
||||
int flags);
|
||||
|
||||
/**
|
||||
* Copy entries from one AVDictionary struct into another.
|
||||
* @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL,
|
||||
* this function will allocate a struct for you and put it in *dst
|
||||
* @param src pointer to source AVDictionary struct
|
||||
* @param flags flags to use when setting entries in *dst
|
||||
* @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
|
||||
*/
|
||||
void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags);
|
||||
|
||||
/**
|
||||
* Free all the memory allocated for an AVDictionary struct
|
||||
* and all keys and values.
|
||||
*/
|
||||
void av_dict_free(AVDictionary **m);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_DICT_H */
|
|
@ -25,7 +25,14 @@
|
|||
#define AVUTIL_ERROR_H
|
||||
|
||||
#include <errno.h>
|
||||
#include "avutil.h"
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_error
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/* error handling */
|
||||
#if EDOM > 0
|
||||
|
@ -37,25 +44,34 @@
|
|||
#define AVUNERROR(e) (e)
|
||||
#endif
|
||||
|
||||
#if LIBAVUTIL_VERSION_MAJOR < 51
|
||||
#define AVERROR_INVALIDDATA AVERROR(EINVAL) ///< Invalid data found when processing input
|
||||
#define AVERROR_IO AVERROR(EIO) ///< I/O error
|
||||
#define AVERROR_NOENT AVERROR(ENOENT) ///< No such file or directory
|
||||
#define AVERROR_NOFMT AVERROR(EILSEQ) ///< Unknown format
|
||||
#define AVERROR_NOMEM AVERROR(ENOMEM) ///< Not enough memory
|
||||
#define AVERROR_NOTSUPP AVERROR(ENOSYS) ///< Operation not supported
|
||||
#define AVERROR_NUMEXPECTED AVERROR(EDOM) ///< Number syntax expected in filename
|
||||
#define AVERROR_UNKNOWN AVERROR(EINVAL) ///< Unknown error
|
||||
#endif
|
||||
#define FFERRTAG(a, b, c, d) (-(int)MKTAG(a, b, c, d))
|
||||
|
||||
#define AVERROR_EOF AVERROR(EPIPE) ///< End of file
|
||||
#define AVERROR_BSF_NOT_FOUND FFERRTAG(0xF8,'B','S','F') ///< Bitstream filter not found
|
||||
#define AVERROR_BUG FFERRTAG( 'B','U','G','!') ///< Internal bug, also see AVERROR_BUG2
|
||||
#define AVERROR_BUFFER_TOO_SMALL FFERRTAG( 'B','U','F','S') ///< Buffer too small
|
||||
#define AVERROR_DECODER_NOT_FOUND FFERRTAG(0xF8,'D','E','C') ///< Decoder not found
|
||||
#define AVERROR_DEMUXER_NOT_FOUND FFERRTAG(0xF8,'D','E','M') ///< Demuxer not found
|
||||
#define AVERROR_ENCODER_NOT_FOUND FFERRTAG(0xF8,'E','N','C') ///< Encoder not found
|
||||
#define AVERROR_EOF FFERRTAG( 'E','O','F',' ') ///< End of file
|
||||
#define AVERROR_EXIT FFERRTAG( 'E','X','I','T') ///< Immediate exit was requested; the called function should not be restarted
|
||||
#define AVERROR_EXTERNAL FFERRTAG( 'E','X','T',' ') ///< Generic error in an external library
|
||||
#define AVERROR_FILTER_NOT_FOUND FFERRTAG(0xF8,'F','I','L') ///< Filter not found
|
||||
#define AVERROR_INVALIDDATA FFERRTAG( 'I','N','D','A') ///< Invalid data found when processing input
|
||||
#define AVERROR_MUXER_NOT_FOUND FFERRTAG(0xF8,'M','U','X') ///< Muxer not found
|
||||
#define AVERROR_OPTION_NOT_FOUND FFERRTAG(0xF8,'O','P','T') ///< Option not found
|
||||
#define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') ///< Not yet implemented in FFmpeg, patches welcome
|
||||
#define AVERROR_PROTOCOL_NOT_FOUND FFERRTAG(0xF8,'P','R','O') ///< Protocol not found
|
||||
|
||||
#define AVERROR_PATCHWELCOME (-MKTAG('P','A','W','E')) ///< Not yet implemented in FFmpeg, patches welcome
|
||||
#define AVERROR_STREAM_NOT_FOUND FFERRTAG(0xF8,'S','T','R') ///< Stream not found
|
||||
/**
|
||||
* This is semantically identical to AVERROR_BUG
|
||||
* it has been introduced in Libav after our AVERROR_BUG and with a modified value.
|
||||
*/
|
||||
#define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ')
|
||||
#define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') ///< Unknown error, typically from an external library
|
||||
#define AVERROR_EXPERIMENTAL (-0x2bb2afa8) ///< Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
|
||||
|
||||
#if LIBAVUTIL_VERSION_MAJOR > 50
|
||||
#define AVERROR_INVALIDDATA (-MKTAG('I','N','D','A')) ///< Invalid data found when processing input
|
||||
#define AVERROR_NUMEXPECTED (-MKTAG('N','U','E','X')) ///< Number syntax expected in filename
|
||||
#endif
|
||||
#define AV_ERROR_MAX_STRING_SIZE 64
|
||||
|
||||
/**
|
||||
* Put a description of the AVERROR code errnum in errbuf.
|
||||
|
@ -71,4 +87,31 @@
|
|||
*/
|
||||
int av_strerror(int errnum, char *errbuf, size_t errbuf_size);
|
||||
|
||||
/**
|
||||
* Fill the provided buffer with a string containing an error string
|
||||
* corresponding to the AVERROR code errnum.
|
||||
*
|
||||
* @param errbuf a buffer
|
||||
* @param errbuf_size size in bytes of errbuf
|
||||
* @param errnum error code to describe
|
||||
* @return the buffer in input, filled with the error description
|
||||
* @see av_strerror()
|
||||
*/
|
||||
static inline char *av_make_error_string(char *errbuf, size_t errbuf_size, int errnum)
|
||||
{
|
||||
av_strerror(errnum, errbuf, errbuf_size);
|
||||
return errbuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience macro, the return value should be used only directly in
|
||||
* function arguments but never stand-alone.
|
||||
*/
|
||||
#define av_err2str(errnum) \
|
||||
av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0}, AV_ERROR_MAX_STRING_SIZE, errnum)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_ERROR_H */
|
||||
|
|
|
@ -26,11 +26,13 @@
|
|||
#ifndef AVUTIL_EVAL_H
|
||||
#define AVUTIL_EVAL_H
|
||||
|
||||
#include "avutil.h"
|
||||
|
||||
typedef struct AVExpr AVExpr;
|
||||
|
||||
/**
|
||||
* Parse and evaluate an expression.
|
||||
* Note, this is significantly slower than av_eval_expr().
|
||||
* Note, this is significantly slower than av_expr_eval().
|
||||
*
|
||||
* @param res a pointer to a double where is put the result value of
|
||||
* the expression, or NAN in case of error
|
||||
|
@ -46,7 +48,7 @@ typedef struct AVExpr AVExpr;
|
|||
* @return 0 in case of success, a negative value corresponding to an
|
||||
* AVERROR code otherwise
|
||||
*/
|
||||
int av_parse_and_eval_expr(double *res, const char *s,
|
||||
int av_expr_parse_and_eval(double *res, const char *s,
|
||||
const char * const *const_names, const double *const_values,
|
||||
const char * const *func1_names, double (* const *funcs1)(void *, double),
|
||||
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
|
||||
|
@ -56,8 +58,8 @@ int av_parse_and_eval_expr(double *res, const char *s,
|
|||
* Parse an expression.
|
||||
*
|
||||
* @param expr a pointer where is put an AVExpr containing the parsed
|
||||
* value in case of successfull parsing, or NULL otherwise.
|
||||
* The pointed to AVExpr must be freed with av_free_expr() by the user
|
||||
* value in case of successful parsing, or NULL otherwise.
|
||||
* The pointed to AVExpr must be freed with av_expr_free() by the user
|
||||
* when it is not needed anymore.
|
||||
* @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
|
||||
* @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
|
||||
|
@ -69,7 +71,7 @@ int av_parse_and_eval_expr(double *res, const char *s,
|
|||
* @return 0 in case of success, a negative value corresponding to an
|
||||
* AVERROR code otherwise
|
||||
*/
|
||||
int av_parse_expr(AVExpr **expr, const char *s,
|
||||
int av_expr_parse(AVExpr **expr, const char *s,
|
||||
const char * const *const_names,
|
||||
const char * const *func1_names, double (* const *funcs1)(void *, double),
|
||||
const char * const *func2_names, double (* const *funcs2)(void *, double, double),
|
||||
|
@ -78,16 +80,16 @@ int av_parse_expr(AVExpr **expr, const char *s,
|
|||
/**
|
||||
* Evaluate a previously parsed expression.
|
||||
*
|
||||
* @param const_values a zero terminated array of values for the identifiers from av_parse_expr() const_names
|
||||
* @param const_values a zero terminated array of values for the identifiers from av_expr_parse() const_names
|
||||
* @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
|
||||
* @return the value of the expression
|
||||
*/
|
||||
double av_eval_expr(AVExpr *e, const double *const_values, void *opaque);
|
||||
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque);
|
||||
|
||||
/**
|
||||
* Free a parsed expression previously created with av_parse_expr().
|
||||
* Free a parsed expression previously created with av_expr_parse().
|
||||
*/
|
||||
void av_free_expr(AVExpr *e);
|
||||
void av_expr_free(AVExpr *e);
|
||||
|
||||
/**
|
||||
* Parse the string in numstr and return its value as a double. If
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#define AVUTIL_FIFO_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "avutil.h"
|
||||
#include "attributes.h"
|
||||
|
||||
typedef struct AVFifoBuffer {
|
||||
uint8_t *buffer;
|
||||
|
@ -41,20 +43,20 @@ AVFifoBuffer *av_fifo_alloc(unsigned int size);
|
|||
|
||||
/**
|
||||
* Free an AVFifoBuffer.
|
||||
* @param *f AVFifoBuffer to free
|
||||
* @param f AVFifoBuffer to free
|
||||
*/
|
||||
void av_fifo_free(AVFifoBuffer *f);
|
||||
|
||||
/**
|
||||
* Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
|
||||
* @param *f AVFifoBuffer to reset
|
||||
* @param f AVFifoBuffer to reset
|
||||
*/
|
||||
void av_fifo_reset(AVFifoBuffer *f);
|
||||
|
||||
/**
|
||||
* Return the amount of data in bytes in the AVFifoBuffer, that is the
|
||||
* amount of data you can read from it.
|
||||
* @param *f AVFifoBuffer to read from
|
||||
* @param f AVFifoBuffer to read from
|
||||
* @return size
|
||||
*/
|
||||
int av_fifo_size(AVFifoBuffer *f);
|
||||
|
@ -62,27 +64,27 @@ int av_fifo_size(AVFifoBuffer *f);
|
|||
/**
|
||||
* Return the amount of space in bytes in the AVFifoBuffer, that is the
|
||||
* amount of data you can write into it.
|
||||
* @param *f AVFifoBuffer to write into
|
||||
* @param f AVFifoBuffer to write into
|
||||
* @return size
|
||||
*/
|
||||
int av_fifo_space(AVFifoBuffer *f);
|
||||
|
||||
/**
|
||||
* Feed data from an AVFifoBuffer to a user-supplied callback.
|
||||
* @param *f AVFifoBuffer to read from
|
||||
* @param f AVFifoBuffer to read from
|
||||
* @param buf_size number of bytes to read
|
||||
* @param *func generic read function
|
||||
* @param *dest data destination
|
||||
* @param func generic read function
|
||||
* @param dest data destination
|
||||
*/
|
||||
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
|
||||
|
||||
/**
|
||||
* Feed data from a user-supplied callback to an AVFifoBuffer.
|
||||
* @param *f AVFifoBuffer to write to
|
||||
* @param *src data source; non-const since it may be used as a
|
||||
* @param f AVFifoBuffer to write to
|
||||
* @param src data source; non-const since it may be used as a
|
||||
* modifiable context by the function defined in func
|
||||
* @param size number of bytes to write
|
||||
* @param *func generic write function; the first parameter is src,
|
||||
* @param func generic write function; the first parameter is src,
|
||||
* the second is dest_buf, the third is dest_buf_size.
|
||||
* func must return the number of bytes written to dest_buf, or <= 0 to
|
||||
* indicate no more data available to write.
|
||||
|
@ -93,24 +95,50 @@ int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void
|
|||
|
||||
/**
|
||||
* Resize an AVFifoBuffer.
|
||||
* @param *f AVFifoBuffer to resize
|
||||
* In case of reallocation failure, the old FIFO is kept unchanged.
|
||||
*
|
||||
* @param f AVFifoBuffer to resize
|
||||
* @param size new AVFifoBuffer size in bytes
|
||||
* @return <0 for failure, >=0 otherwise
|
||||
*/
|
||||
int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size);
|
||||
|
||||
/**
|
||||
* Enlarge an AVFifoBuffer.
|
||||
* In case of reallocation failure, the old FIFO is kept unchanged.
|
||||
* The new fifo size may be larger than the requested size.
|
||||
*
|
||||
* @param f AVFifoBuffer to resize
|
||||
* @param additional_space the amount of space in bytes to allocate in addition to av_fifo_size()
|
||||
* @return <0 for failure, >=0 otherwise
|
||||
*/
|
||||
int av_fifo_grow(AVFifoBuffer *f, unsigned int additional_space);
|
||||
|
||||
/**
|
||||
* Read and discard the specified amount of data from an AVFifoBuffer.
|
||||
* @param *f AVFifoBuffer to read from
|
||||
* @param f AVFifoBuffer to read from
|
||||
* @param size amount of data to read in bytes
|
||||
*/
|
||||
void av_fifo_drain(AVFifoBuffer *f, int size);
|
||||
|
||||
static inline uint8_t av_fifo_peek(AVFifoBuffer *f, int offs)
|
||||
/**
|
||||
* Return a pointer to the data stored in a FIFO buffer at a certain offset.
|
||||
* The FIFO buffer is not modified.
|
||||
*
|
||||
* @param f AVFifoBuffer to peek at, f must be non-NULL
|
||||
* @param offs an offset in bytes, its absolute value must be less
|
||||
* than the used buffer size or the returned pointer will
|
||||
* point outside to the buffer data.
|
||||
* The used buffer size can be checked with av_fifo_size().
|
||||
*/
|
||||
static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs)
|
||||
{
|
||||
uint8_t *ptr = f->rptr + offs;
|
||||
if (ptr >= f->end)
|
||||
ptr -= f->end - f->buffer;
|
||||
return *ptr;
|
||||
ptr = f->buffer + (ptr - f->end);
|
||||
else if (ptr < f->buffer)
|
||||
ptr = f->end - (f->buffer - ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#endif /* AVUTIL_FIFO_H */
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_FILE_H
|
||||
#define AVUTIL_FILE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avutil.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Misc file utilities.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Read the file with name filename, and put its content in a newly
|
||||
* allocated buffer or map it with mmap() when available.
|
||||
* In case of success set *bufptr to the read or mmapped buffer, and
|
||||
* *size to the size in bytes of the buffer in *bufptr.
|
||||
* The returned buffer must be released with av_file_unmap().
|
||||
*
|
||||
* @param log_offset loglevel offset used for logging
|
||||
* @param log_ctx context used for logging
|
||||
* @return a non negative number in case of success, a negative value
|
||||
* corresponding to an AVERROR error code in case of failure
|
||||
*/
|
||||
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
|
||||
int log_offset, void *log_ctx);
|
||||
|
||||
/**
|
||||
* Unmap or free the buffer bufptr created by av_file_map().
|
||||
*
|
||||
* @param size size in bytes of bufptr, must be the same as returned
|
||||
* by av_file_map()
|
||||
*/
|
||||
void av_file_unmap(uint8_t *bufptr, size_t size);
|
||||
|
||||
/**
|
||||
* Wrapper to work around the lack of mkstemp() on mingw.
|
||||
* Also, tries to create file in /tmp first, if possible.
|
||||
* *prefix can be a character constant; *filename will be allocated internally.
|
||||
* @return file descriptor of opened file (or -1 on error)
|
||||
* and opened file name in **filename.
|
||||
* @note On very old libcs it is necessary to set a secure umask before
|
||||
* calling this, av_tempfile() cant call umask itself as it is used in
|
||||
* libraries and could interfere with the calling application.
|
||||
*/
|
||||
int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx);
|
||||
|
||||
#endif /* AVUTIL_FILE_H */
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* Copyright (C) 2012 Martin Storsjo
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_HMAC_H
|
||||
#define AVUTIL_HMAC_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @defgroup lavu_hmac HMAC
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
enum AVHMACType {
|
||||
AV_HMAC_MD5,
|
||||
AV_HMAC_SHA1,
|
||||
};
|
||||
|
||||
typedef struct AVHMAC AVHMAC;
|
||||
|
||||
/**
|
||||
* Allocate an AVHMAC context.
|
||||
* @param type The hash function used for the HMAC.
|
||||
*/
|
||||
AVHMAC *av_hmac_alloc(enum AVHMACType type);
|
||||
|
||||
/**
|
||||
* Free an AVHMAC context.
|
||||
* @param ctx The context to free, may be NULL
|
||||
*/
|
||||
void av_hmac_free(AVHMAC *ctx);
|
||||
|
||||
/**
|
||||
* Initialize an AVHMAC context with an authentication key.
|
||||
* @param ctx The HMAC context
|
||||
* @param key The authentication key
|
||||
* @param keylen The length of the key, in bytes
|
||||
*/
|
||||
void av_hmac_init(AVHMAC *ctx, const uint8_t *key, unsigned int keylen);
|
||||
|
||||
/**
|
||||
* Hash data with the HMAC.
|
||||
* @param ctx The HMAC context
|
||||
* @param data The data to hash
|
||||
* @param len The length of the data, in bytes
|
||||
*/
|
||||
void av_hmac_update(AVHMAC *ctx, const uint8_t *data, unsigned int len);
|
||||
|
||||
/**
|
||||
* Finish hashing and output the HMAC digest.
|
||||
* @param ctx The HMAC context
|
||||
* @param out The output buffer to write the digest into
|
||||
* @param outlen The length of the out buffer, in bytes
|
||||
* @return The number of bytes written to out, or a negative error code.
|
||||
*/
|
||||
int av_hmac_final(AVHMAC *ctx, uint8_t *out, unsigned int outlen);
|
||||
|
||||
/**
|
||||
* Hash an array of data with a key.
|
||||
* @param ctx The HMAC context
|
||||
* @param data The data to hash
|
||||
* @param len The length of the data, in bytes
|
||||
* @param key The authentication key
|
||||
* @param keylen The length of the key, in bytes
|
||||
* @param out The output buffer to write the digest into
|
||||
* @param outlen The length of the out buffer, in bytes
|
||||
* @return The number of bytes written to out, or a negative error code.
|
||||
*/
|
||||
int av_hmac_calc(AVHMAC *ctx, const uint8_t *data, unsigned int len,
|
||||
const uint8_t *key, unsigned int keylen,
|
||||
uint8_t *out, unsigned int outlen);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_HMAC_H */
|
|
@ -0,0 +1,200 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_IMGUTILS_H
|
||||
#define AVUTIL_IMGUTILS_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* misc image utilities
|
||||
*
|
||||
* @addtogroup lavu_picture
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "avutil.h"
|
||||
#include "pixdesc.h"
|
||||
|
||||
/**
|
||||
* Compute the max pixel step for each plane of an image with a
|
||||
* format described by pixdesc.
|
||||
*
|
||||
* The pixel step is the distance in bytes between the first byte of
|
||||
* the group of bytes which describe a pixel component and the first
|
||||
* byte of the successive group in the same plane for the same
|
||||
* component.
|
||||
*
|
||||
* @param max_pixsteps an array which is filled with the max pixel step
|
||||
* for each plane. Since a plane may contain different pixel
|
||||
* components, the computed max_pixsteps[plane] is relative to the
|
||||
* component in the plane with the max pixel step.
|
||||
* @param max_pixstep_comps an array which is filled with the component
|
||||
* for each plane which has the max pixel step. May be NULL.
|
||||
*/
|
||||
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
|
||||
const AVPixFmtDescriptor *pixdesc);
|
||||
|
||||
/**
|
||||
* Compute the size of an image line with format pix_fmt and width
|
||||
* width for the plane plane.
|
||||
*
|
||||
* @return the computed size in bytes
|
||||
*/
|
||||
int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane);
|
||||
|
||||
/**
|
||||
* Fill plane linesizes for an image with pixel format pix_fmt and
|
||||
* width width.
|
||||
*
|
||||
* @param linesizes array to be filled with the linesize for each plane
|
||||
* @return >= 0 in case of success, a negative error code otherwise
|
||||
*/
|
||||
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width);
|
||||
|
||||
/**
|
||||
* Fill plane data pointers for an image with pixel format pix_fmt and
|
||||
* height height.
|
||||
*
|
||||
* @param data pointers array to be filled with the pointer for each image plane
|
||||
* @param ptr the pointer to a buffer which will contain the image
|
||||
* @param linesizes the array containing the linesize for each
|
||||
* plane, should be filled by av_image_fill_linesizes()
|
||||
* @return the size in bytes required for the image buffer, a negative
|
||||
* error code in case of failure
|
||||
*/
|
||||
int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height,
|
||||
uint8_t *ptr, const int linesizes[4]);
|
||||
|
||||
/**
|
||||
* Allocate an image with size w and h and pixel format pix_fmt, and
|
||||
* fill pointers and linesizes accordingly.
|
||||
* The allocated image buffer has to be freed by using
|
||||
* av_freep(&pointers[0]).
|
||||
*
|
||||
* @param align the value to use for buffer size alignment
|
||||
* @return the size in bytes required for the image buffer, a negative
|
||||
* error code in case of failure
|
||||
*/
|
||||
int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
|
||||
int w, int h, enum AVPixelFormat pix_fmt, int align);
|
||||
|
||||
/**
|
||||
* Copy image plane from src to dst.
|
||||
* That is, copy "height" number of lines of "bytewidth" bytes each.
|
||||
* The first byte of each successive line is separated by *_linesize
|
||||
* bytes.
|
||||
*
|
||||
* bytewidth must be contained by both absolute values of dst_linesize
|
||||
* and src_linesize, otherwise the function behavior is undefined.
|
||||
*
|
||||
* @param dst_linesize linesize for the image plane in dst
|
||||
* @param src_linesize linesize for the image plane in src
|
||||
*/
|
||||
void av_image_copy_plane(uint8_t *dst, int dst_linesize,
|
||||
const uint8_t *src, int src_linesize,
|
||||
int bytewidth, int height);
|
||||
|
||||
/**
|
||||
* Copy image in src_data to dst_data.
|
||||
*
|
||||
* @param dst_linesizes linesizes for the image in dst_data
|
||||
* @param src_linesizes linesizes for the image in src_data
|
||||
*/
|
||||
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
|
||||
const uint8_t *src_data[4], const int src_linesizes[4],
|
||||
enum AVPixelFormat pix_fmt, int width, int height);
|
||||
|
||||
/**
|
||||
* Setup the data pointers and linesizes based on the specified image
|
||||
* parameters and the provided array.
|
||||
*
|
||||
* The fields of the given image are filled in by using the src
|
||||
* address which points to the image data buffer. Depending on the
|
||||
* specified pixel format, one or multiple image data pointers and
|
||||
* line sizes will be set. If a planar format is specified, several
|
||||
* pointers will be set pointing to the different picture planes and
|
||||
* the line sizes of the different planes will be stored in the
|
||||
* lines_sizes array. Call with src == NULL to get the required
|
||||
* size for the src buffer.
|
||||
*
|
||||
* To allocate the buffer and fill in the dst_data and dst_linesize in
|
||||
* one call, use av_image_alloc().
|
||||
*
|
||||
* @param dst_data data pointers to be filled in
|
||||
* @param dst_linesizes linesizes for the image in dst_data to be filled in
|
||||
* @param src buffer which will contain or contains the actual image data, can be NULL
|
||||
* @param pix_fmt the pixel format of the image
|
||||
* @param width the width of the image in pixels
|
||||
* @param height the height of the image in pixels
|
||||
* @param align the value used in src for linesize alignment
|
||||
* @return the size in bytes required for src, a negative error code
|
||||
* in case of failure
|
||||
*/
|
||||
int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4],
|
||||
const uint8_t *src,
|
||||
enum AVPixelFormat pix_fmt, int width, int height, int align);
|
||||
|
||||
/**
|
||||
* Return the size in bytes of the amount of data required to store an
|
||||
* image with the given parameters.
|
||||
*
|
||||
* @param[in] align the assumed linesize alignment
|
||||
*/
|
||||
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align);
|
||||
|
||||
/**
|
||||
* Copy image data from an image into a buffer.
|
||||
*
|
||||
* av_image_get_buffer_size() can be used to compute the required size
|
||||
* for the buffer to fill.
|
||||
*
|
||||
* @param dst a buffer into which picture data will be copied
|
||||
* @param dst_size the size in bytes of dst
|
||||
* @param src_data pointers containing the source image data
|
||||
* @param src_linesizes linesizes for the image in src_data
|
||||
* @param pix_fmt the pixel format of the source image
|
||||
* @param width the width of the source image in pixels
|
||||
* @param height the height of the source image in pixels
|
||||
* @param align the assumed linesize alignment for dst
|
||||
* @return the number of bytes written to dst, or a negative value
|
||||
* (error code) on error
|
||||
*/
|
||||
int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
|
||||
const uint8_t * const src_data[4], const int src_linesize[4],
|
||||
enum AVPixelFormat pix_fmt, int width, int height, int align);
|
||||
|
||||
/**
|
||||
* Check if the given dimension of an image is valid, meaning that all
|
||||
* bytes of the image can be addressed with a signed int.
|
||||
*
|
||||
* @param w the width of the picture
|
||||
* @param h the height of the picture
|
||||
* @param log_offset the offset to sum to the log level for logging with log_ctx
|
||||
* @param log_ctx the parent logging context, it may be NULL
|
||||
* @return >= 0 if valid, a negative error code otherwise
|
||||
*/
|
||||
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
|
||||
|
||||
int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#endif /* AVUTIL_IMGUTILS_H */
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Mans Rullgard
|
||||
*
|
||||
* This file is part of Libav.
|
||||
*
|
||||
* Libav is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* Libav is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with Libav; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_INTFLOAT_H
|
||||
#define AVUTIL_INTFLOAT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "attributes.h"
|
||||
|
||||
union av_intfloat32 {
|
||||
uint32_t i;
|
||||
float f;
|
||||
};
|
||||
|
||||
union av_intfloat64 {
|
||||
uint64_t i;
|
||||
double f;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reinterpret a 32-bit integer as a float.
|
||||
*/
|
||||
static av_always_inline float av_int2float(uint32_t i)
|
||||
{
|
||||
union av_intfloat32 v;
|
||||
v.i = i;
|
||||
return v.f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reinterpret a float as a 32-bit integer.
|
||||
*/
|
||||
static av_always_inline uint32_t av_float2int(float f)
|
||||
{
|
||||
union av_intfloat32 v;
|
||||
v.f = f;
|
||||
return v.i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reinterpret a 64-bit integer as a double.
|
||||
*/
|
||||
static av_always_inline double av_int2double(uint64_t i)
|
||||
{
|
||||
union av_intfloat64 v;
|
||||
v.i = i;
|
||||
return v.f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reinterpret a double as a 64-bit integer.
|
||||
*/
|
||||
static av_always_inline uint64_t av_double2int(double f)
|
||||
{
|
||||
union av_intfloat64 v;
|
||||
v.f = f;
|
||||
return v.i;
|
||||
}
|
||||
|
||||
#endif /* AVUTIL_INTFLOAT_H */
|
|
@ -30,11 +30,11 @@ typedef struct AVExtFloat {
|
|||
uint8_t mantissa[8];
|
||||
} AVExtFloat;
|
||||
|
||||
double av_int2dbl(int64_t v) av_const;
|
||||
float av_int2flt(int32_t v) av_const;
|
||||
double av_ext2dbl(const AVExtFloat ext) av_const;
|
||||
int64_t av_dbl2int(double d) av_const;
|
||||
int32_t av_flt2int(float d) av_const;
|
||||
AVExtFloat av_dbl2ext(double d) av_const;
|
||||
attribute_deprecated double av_int2dbl(int64_t v) av_const;
|
||||
attribute_deprecated float av_int2flt(int32_t v) av_const;
|
||||
attribute_deprecated double av_ext2dbl(const AVExtFloat ext) av_const;
|
||||
attribute_deprecated int64_t av_dbl2int(double d) av_const;
|
||||
attribute_deprecated int32_t av_flt2int(float d) av_const;
|
||||
attribute_deprecated AVExtFloat av_dbl2ext(double d) av_const;
|
||||
|
||||
#endif /* AVUTIL_INTFLOAT_READWRITE_H */
|
||||
|
|
|
@ -47,7 +47,7 @@ typedef union {
|
|||
|
||||
/*
|
||||
* Arch-specific headers can provide any combination of
|
||||
* AV_[RW][BLN](16|24|32|64) and AV_(COPY|SWAP|ZERO)(64|128) macros.
|
||||
* AV_[RW][BLN](16|24|32|48|64) and AV_(COPY|SWAP|ZERO)(64|128) macros.
|
||||
* Preprocessor symbols must be defined, even if these are implemented
|
||||
* as inline functions.
|
||||
*/
|
||||
|
@ -114,6 +114,18 @@ typedef union {
|
|||
# define AV_WN32(p, v) AV_WB32(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN48) && !defined(AV_RB48)
|
||||
# define AV_RB48(p) AV_RN48(p)
|
||||
# elif !defined(AV_RN48) && defined(AV_RB48)
|
||||
# define AV_RN48(p) AV_RB48(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN48) && !defined(AV_WB48)
|
||||
# define AV_WB48(p, v) AV_WN48(p, v)
|
||||
# elif !defined(AV_WN48) && defined(AV_WB48)
|
||||
# define AV_WN48(p, v) AV_WB48(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN64) && !defined(AV_RB64)
|
||||
# define AV_RB64(p) AV_RN64(p)
|
||||
# elif !defined(AV_RN64) && defined(AV_RB64)
|
||||
|
@ -164,6 +176,18 @@ typedef union {
|
|||
# define AV_WN32(p, v) AV_WL32(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN48) && !defined(AV_RL48)
|
||||
# define AV_RL48(p) AV_RN48(p)
|
||||
# elif !defined(AV_RN48) && defined(AV_RL48)
|
||||
# define AV_RN48(p) AV_RL48(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN48) && !defined(AV_WL48)
|
||||
# define AV_WL48(p, v) AV_WN48(p, v)
|
||||
# elif !defined(AV_WN48) && defined(AV_WL48)
|
||||
# define AV_WN48(p, v) AV_WL48(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN64) && !defined(AV_RL64)
|
||||
# define AV_RL64(p) AV_RN64(p)
|
||||
# elif !defined(AV_RN64) && defined(AV_RL64)
|
||||
|
@ -210,7 +234,8 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
|
|||
((const uint8_t*)(x))[1])
|
||||
#endif
|
||||
#ifndef AV_WB16
|
||||
# define AV_WB16(p, d) do { \
|
||||
# define AV_WB16(p, darg) do { \
|
||||
unsigned d = (darg); \
|
||||
((uint8_t*)(p))[1] = (d); \
|
||||
((uint8_t*)(p))[0] = (d)>>8; \
|
||||
} while(0)
|
||||
|
@ -222,21 +247,23 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
|
|||
((const uint8_t*)(x))[0])
|
||||
#endif
|
||||
#ifndef AV_WL16
|
||||
# define AV_WL16(p, d) do { \
|
||||
# define AV_WL16(p, darg) do { \
|
||||
unsigned d = (darg); \
|
||||
((uint8_t*)(p))[0] = (d); \
|
||||
((uint8_t*)(p))[1] = (d)>>8; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RB32
|
||||
# define AV_RB32(x) \
|
||||
((((const uint8_t*)(x))[0] << 24) | \
|
||||
(((const uint8_t*)(x))[1] << 16) | \
|
||||
(((const uint8_t*)(x))[2] << 8) | \
|
||||
((const uint8_t*)(x))[3])
|
||||
# define AV_RB32(x) \
|
||||
(((uint32_t)((const uint8_t*)(x))[0] << 24) | \
|
||||
(((const uint8_t*)(x))[1] << 16) | \
|
||||
(((const uint8_t*)(x))[2] << 8) | \
|
||||
((const uint8_t*)(x))[3])
|
||||
#endif
|
||||
#ifndef AV_WB32
|
||||
# define AV_WB32(p, d) do { \
|
||||
# define AV_WB32(p, darg) do { \
|
||||
unsigned d = (darg); \
|
||||
((uint8_t*)(p))[3] = (d); \
|
||||
((uint8_t*)(p))[2] = (d)>>8; \
|
||||
((uint8_t*)(p))[1] = (d)>>16; \
|
||||
|
@ -245,14 +272,15 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
|
|||
#endif
|
||||
|
||||
#ifndef AV_RL32
|
||||
# define AV_RL32(x) \
|
||||
((((const uint8_t*)(x))[3] << 24) | \
|
||||
(((const uint8_t*)(x))[2] << 16) | \
|
||||
(((const uint8_t*)(x))[1] << 8) | \
|
||||
((const uint8_t*)(x))[0])
|
||||
# define AV_RL32(x) \
|
||||
(((uint32_t)((const uint8_t*)(x))[3] << 24) | \
|
||||
(((const uint8_t*)(x))[2] << 16) | \
|
||||
(((const uint8_t*)(x))[1] << 8) | \
|
||||
((const uint8_t*)(x))[0])
|
||||
#endif
|
||||
#ifndef AV_WL32
|
||||
# define AV_WL32(p, d) do { \
|
||||
# define AV_WL32(p, darg) do { \
|
||||
unsigned d = (darg); \
|
||||
((uint8_t*)(p))[0] = (d); \
|
||||
((uint8_t*)(p))[1] = (d)>>8; \
|
||||
((uint8_t*)(p))[2] = (d)>>16; \
|
||||
|
@ -272,7 +300,8 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
|
|||
(uint64_t)((const uint8_t*)(x))[7])
|
||||
#endif
|
||||
#ifndef AV_WB64
|
||||
# define AV_WB64(p, d) do { \
|
||||
# define AV_WB64(p, darg) do { \
|
||||
uint64_t d = (darg); \
|
||||
((uint8_t*)(p))[7] = (d); \
|
||||
((uint8_t*)(p))[6] = (d)>>8; \
|
||||
((uint8_t*)(p))[5] = (d)>>16; \
|
||||
|
@ -296,7 +325,8 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
|
|||
(uint64_t)((const uint8_t*)(x))[0])
|
||||
#endif
|
||||
#ifndef AV_WL64
|
||||
# define AV_WL64(p, d) do { \
|
||||
# define AV_WL64(p, darg) do { \
|
||||
uint64_t d = (darg); \
|
||||
((uint8_t*)(p))[0] = (d); \
|
||||
((uint8_t*)(p))[1] = (d)>>8; \
|
||||
((uint8_t*)(p))[2] = (d)>>16; \
|
||||
|
@ -430,6 +460,48 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
|
|||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RB48
|
||||
# define AV_RB48(x) \
|
||||
(((uint64_t)((const uint8_t*)(x))[0] << 40) | \
|
||||
((uint64_t)((const uint8_t*)(x))[1] << 32) | \
|
||||
((uint64_t)((const uint8_t*)(x))[2] << 24) | \
|
||||
((uint64_t)((const uint8_t*)(x))[3] << 16) | \
|
||||
((uint64_t)((const uint8_t*)(x))[4] << 8) | \
|
||||
(uint64_t)((const uint8_t*)(x))[5])
|
||||
#endif
|
||||
#ifndef AV_WB48
|
||||
# define AV_WB48(p, darg) do { \
|
||||
uint64_t d = (darg); \
|
||||
((uint8_t*)(p))[5] = (d); \
|
||||
((uint8_t*)(p))[4] = (d)>>8; \
|
||||
((uint8_t*)(p))[3] = (d)>>16; \
|
||||
((uint8_t*)(p))[2] = (d)>>24; \
|
||||
((uint8_t*)(p))[1] = (d)>>32; \
|
||||
((uint8_t*)(p))[0] = (d)>>40; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#ifndef AV_RL48
|
||||
# define AV_RL48(x) \
|
||||
(((uint64_t)((const uint8_t*)(x))[5] << 40) | \
|
||||
((uint64_t)((const uint8_t*)(x))[4] << 32) | \
|
||||
((uint64_t)((const uint8_t*)(x))[3] << 24) | \
|
||||
((uint64_t)((const uint8_t*)(x))[2] << 16) | \
|
||||
((uint64_t)((const uint8_t*)(x))[1] << 8) | \
|
||||
(uint64_t)((const uint8_t*)(x))[0])
|
||||
#endif
|
||||
#ifndef AV_WL48
|
||||
# define AV_WL48(p, darg) do { \
|
||||
uint64_t d = (darg); \
|
||||
((uint8_t*)(p))[0] = (d); \
|
||||
((uint8_t*)(p))[1] = (d)>>8; \
|
||||
((uint8_t*)(p))[2] = (d)>>16; \
|
||||
((uint8_t*)(p))[3] = (d)>>24; \
|
||||
((uint8_t*)(p))[4] = (d)>>32; \
|
||||
((uint8_t*)(p))[5] = (d)>>40; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The AV_[RW]NA macros access naturally aligned data
|
||||
* in a type-safe way.
|
||||
|
@ -462,6 +534,33 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
|
|||
# define AV_WN64A(p, v) AV_WNA(64, p, v)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The AV_COPYxxU macros are suitable for copying data to/from unaligned
|
||||
* memory locations.
|
||||
*/
|
||||
|
||||
#define AV_COPYU(n, d, s) AV_WN##n(d, AV_RN##n(s));
|
||||
|
||||
#ifndef AV_COPY16U
|
||||
# define AV_COPY16U(d, s) AV_COPYU(16, d, s)
|
||||
#endif
|
||||
|
||||
#ifndef AV_COPY32U
|
||||
# define AV_COPY32U(d, s) AV_COPYU(32, d, s)
|
||||
#endif
|
||||
|
||||
#ifndef AV_COPY64U
|
||||
# define AV_COPY64U(d, s) AV_COPYU(64, d, s)
|
||||
#endif
|
||||
|
||||
#ifndef AV_COPY128U
|
||||
# define AV_COPY128U(d, s) \
|
||||
do { \
|
||||
AV_COPY64U(d, s); \
|
||||
AV_COPY64U((char *)(d) + 8, (const char *)(s) + 8); \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
/* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be
|
||||
* naturally aligned. They may be implemented using MMX,
|
||||
* so emms_c() must be called before using any float code
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef AVUTIL_LFG_H
|
||||
#define AVUTIL_LFG_H
|
||||
|
||||
typedef struct {
|
||||
typedef struct AVLFG {
|
||||
unsigned int state[64];
|
||||
int index;
|
||||
} AVLFG;
|
||||
|
@ -55,7 +55,7 @@ static inline unsigned int av_mlfg_get(AVLFG *c){
|
|||
* Get the next two numbers generated by a Box-Muller Gaussian
|
||||
* generator using the random numbers issued by lfg.
|
||||
*
|
||||
* @param out[2] array where the two generated numbers are placed
|
||||
* @param out array where the two generated numbers are placed
|
||||
*/
|
||||
void av_bmg_get(AVLFG *lfg, double out[2]);
|
||||
|
||||
|
|
|
@ -23,13 +23,31 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
#include "avutil.h"
|
||||
#include "attributes.h"
|
||||
|
||||
typedef enum {
|
||||
AV_CLASS_CATEGORY_NA = 0,
|
||||
AV_CLASS_CATEGORY_INPUT,
|
||||
AV_CLASS_CATEGORY_OUTPUT,
|
||||
AV_CLASS_CATEGORY_MUXER,
|
||||
AV_CLASS_CATEGORY_DEMUXER,
|
||||
AV_CLASS_CATEGORY_ENCODER,
|
||||
AV_CLASS_CATEGORY_DECODER,
|
||||
AV_CLASS_CATEGORY_FILTER,
|
||||
AV_CLASS_CATEGORY_BITSTREAM_FILTER,
|
||||
AV_CLASS_CATEGORY_SWSCALER,
|
||||
AV_CLASS_CATEGORY_SWRESAMPLER,
|
||||
AV_CLASS_CATEGORY_NB, ///< not part of ABI/API
|
||||
}AVClassCategory;
|
||||
|
||||
struct AVOptionRanges;
|
||||
|
||||
/**
|
||||
* Describe the class of an AVClass context structure. That is an
|
||||
* arbitrary struct of which the first field is a pointer to an
|
||||
* AVClass struct (e.g. AVCodecContext, AVFormatContext etc.).
|
||||
*/
|
||||
typedef struct {
|
||||
typedef struct AVClass {
|
||||
/**
|
||||
* The name of the class; usually it is the same name as the
|
||||
* context structure type to which the AVClass is associated.
|
||||
|
@ -64,12 +82,47 @@ typedef struct {
|
|||
int log_level_offset_offset;
|
||||
|
||||
/**
|
||||
* Offset in the structure where a pointer to the parent context for loging is stored.
|
||||
* for example a decoder that uses eval.c could pass its AVCodecContext to eval as such
|
||||
* parent context. And a av_log() implementation could then display the parent context
|
||||
* can be NULL of course
|
||||
* Offset in the structure where a pointer to the parent context for
|
||||
* logging is stored. For example a decoder could pass its AVCodecContext
|
||||
* to eval as such a parent context, which an av_log() implementation
|
||||
* could then leverage to display the parent context.
|
||||
* The offset can be NULL.
|
||||
*/
|
||||
int parent_log_context_offset;
|
||||
|
||||
/**
|
||||
* Return next AVOptions-enabled child or NULL
|
||||
*/
|
||||
void* (*child_next)(void *obj, void *prev);
|
||||
|
||||
/**
|
||||
* Return an AVClass corresponding to the next potential
|
||||
* AVOptions-enabled child.
|
||||
*
|
||||
* The difference between child_next and this is that
|
||||
* child_next iterates over _already existing_ objects, while
|
||||
* child_class_next iterates over _all possible_ children.
|
||||
*/
|
||||
const struct AVClass* (*child_class_next)(const struct AVClass *prev);
|
||||
|
||||
/**
|
||||
* Category used for visualization (like color)
|
||||
* This is only set if the category is equal for all objects using this class.
|
||||
* available since version (51 << 16 | 56 << 8 | 100)
|
||||
*/
|
||||
AVClassCategory category;
|
||||
|
||||
/**
|
||||
* Callback to return the category.
|
||||
* available since version (51 << 16 | 59 << 8 | 100)
|
||||
*/
|
||||
AVClassCategory (*get_category)(void* ctx);
|
||||
|
||||
/**
|
||||
* Callback to return the supported/allowed ranges.
|
||||
* available since version (52.12)
|
||||
*/
|
||||
int (*query_ranges)(struct AVOptionRanges **, void *obj, const char *key, int flags);
|
||||
} AVClass;
|
||||
|
||||
/* av_log API */
|
||||
|
@ -108,6 +161,8 @@ typedef struct {
|
|||
*/
|
||||
#define AV_LOG_DEBUG 48
|
||||
|
||||
#define AV_LOG_MAX_OFFSET (AV_LOG_DEBUG - AV_LOG_QUIET)
|
||||
|
||||
/**
|
||||
* Send the specified message to the log if the level is less than or equal
|
||||
* to the current av_log_level. By default, all logging messages are sent to
|
||||
|
@ -122,11 +177,7 @@ typedef struct {
|
|||
* subsequent arguments are converted to output.
|
||||
* @see av_vlog
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
void av_log(void *avcl, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
#else
|
||||
void av_log(void *avcl, int level, const char *fmt, ...);
|
||||
#endif
|
||||
void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4);
|
||||
|
||||
void av_vlog(void *avcl, int level, const char *fmt, va_list);
|
||||
int av_log_get_level(void);
|
||||
|
@ -134,5 +185,38 @@ void av_log_set_level(int);
|
|||
void av_log_set_callback(void (*)(void*, int, const char*, va_list));
|
||||
void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl);
|
||||
const char* av_default_item_name(void* ctx);
|
||||
AVClassCategory av_default_get_category(void *ptr);
|
||||
|
||||
/**
|
||||
* Format a line of log the same way as the default callback.
|
||||
* @param line buffer to receive the formated line
|
||||
* @param line_size size of the buffer
|
||||
* @param print_prefix used to store whether the prefix must be printed;
|
||||
* must point to a persistent integer initially set to 1
|
||||
*/
|
||||
void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
|
||||
char *line, int line_size, int *print_prefix);
|
||||
|
||||
/**
|
||||
* av_dlog macros
|
||||
* Useful to print debug messages that shouldn't get compiled in normally.
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
# define av_dlog(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__)
|
||||
#else
|
||||
# define av_dlog(pctx, ...) do { if (0) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Skip repeated messages, this requires the user app to use av_log() instead of
|
||||
* (f)printf as the 2 would otherwise interfere and lead to
|
||||
* "Last message repeated x times" messages below (f)printf messages with some
|
||||
* bad luck.
|
||||
* Also to receive the last, "last repeated" line if any, the user app must
|
||||
* call av_log(NULL, AV_LOG_QUIET, "%s", ""); at the end
|
||||
*/
|
||||
#define AV_LOG_SKIP_REPEATED 1
|
||||
void av_log_set_flags(int arg);
|
||||
|
||||
#endif /* AVUTIL_LOG_H */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
|
||||
* copyright (c) 2005-2012 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
|
@ -25,6 +25,7 @@
|
|||
#include <math.h>
|
||||
#include "attributes.h"
|
||||
#include "rational.h"
|
||||
#include "intfloat.h"
|
||||
|
||||
#ifndef M_E
|
||||
#define M_E 2.7182818284590452354 /* e */
|
||||
|
@ -51,18 +52,25 @@
|
|||
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
|
||||
#endif
|
||||
#ifndef NAN
|
||||
#define NAN (0.0/0.0)
|
||||
#define NAN av_int2float(0x7fc00000)
|
||||
#endif
|
||||
#ifndef INFINITY
|
||||
#define INFINITY (1.0/0.0)
|
||||
#define INFINITY av_int2float(0x7f800000)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_math
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
enum AVRounding {
|
||||
AV_ROUND_ZERO = 0, ///< Round toward zero.
|
||||
AV_ROUND_INF = 1, ///< Round away from zero.
|
||||
AV_ROUND_DOWN = 2, ///< Round toward -infinity.
|
||||
AV_ROUND_UP = 3, ///< Round toward +infinity.
|
||||
AV_ROUND_NEAR_INF = 5, ///< Round to nearest and halfway cases away from zero.
|
||||
AV_ROUND_PASS_MINMAX = 8192, ///< Flag to pass INT64_MIN/MAX through instead of rescaling, this avoids special cases for AV_NOPTS_VALUE
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -81,6 +89,9 @@ int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const;
|
|||
/**
|
||||
* Rescale a 64-bit integer with specified rounding.
|
||||
* A simple a*b/c isn't possible as it can overflow.
|
||||
*
|
||||
* @return rescaled value a, or if AV_ROUND_PASS_MINMAX is set and a is
|
||||
* INT64_MIN or INT64_MAX then a is passed through unchanged.
|
||||
*/
|
||||
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const;
|
||||
|
||||
|
@ -89,6 +100,15 @@ int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_cons
|
|||
*/
|
||||
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const;
|
||||
|
||||
/**
|
||||
* Rescale a 64-bit integer by 2 rational numbers with specified rounding.
|
||||
*
|
||||
* @return rescaled value a, or if AV_ROUND_PASS_MINMAX is set and a is
|
||||
* INT64_MIN or INT64_MAX then a is passed through unchanged.
|
||||
*/
|
||||
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq,
|
||||
enum AVRounding) av_const;
|
||||
|
||||
/**
|
||||
* Compare 2 timestamps each in its own timebases.
|
||||
* The result of the function is undefined if one of the timestamps
|
||||
|
@ -109,4 +129,19 @@ int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b);
|
|||
*/
|
||||
int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod);
|
||||
|
||||
/**
|
||||
* Rescale a timestamp while preserving known durations.
|
||||
*
|
||||
* @param in_ts Input timestamp
|
||||
* @param in_tb Input timesbase
|
||||
* @param fs_tb Duration and *last timebase
|
||||
* @param duration duration till the next call
|
||||
* @param out_tb Output timesbase
|
||||
*/
|
||||
int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int duration, int64_t *last, AVRational out_tb);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_MATHEMATICS_H */
|
||||
|
|
|
@ -23,14 +23,27 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavu_md5 MD5
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern const int av_md5_size;
|
||||
|
||||
struct AVMD5;
|
||||
|
||||
struct AVMD5 *av_md5_alloc(void);
|
||||
void av_md5_init(struct AVMD5 *ctx);
|
||||
void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len);
|
||||
void av_md5_final(struct AVMD5 *ctx, uint8_t *dst);
|
||||
void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len);
|
||||
|
||||
#endif /* AVUTIL_MD5_H */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_MD5_H */
|
||||
|
|
|
@ -26,10 +26,20 @@
|
|||
#ifndef AVUTIL_MEM_H
|
||||
#define AVUTIL_MEM_H
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "error.h"
|
||||
#include "avutil.h"
|
||||
|
||||
#if defined(__ICC) && _ICC < 1200 || defined(__SUNPRO_C)
|
||||
/**
|
||||
* @addtogroup lavu_mem
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C)
|
||||
#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
|
||||
#define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v
|
||||
#elif defined(__TI_COMPILER_VERSION__)
|
||||
|
@ -41,7 +51,7 @@
|
|||
static const t __attribute__((aligned(n))) v
|
||||
#elif defined(__GNUC__)
|
||||
#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
|
||||
#define DECLARE_ASM_CONST(n,t,v) static const t attribute_used __attribute__ ((aligned (n))) v
|
||||
#define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v
|
||||
#elif defined(_MSC_VER)
|
||||
#define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
|
||||
#define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
|
||||
|
@ -56,10 +66,10 @@
|
|||
#define av_malloc_attrib
|
||||
#endif
|
||||
|
||||
#if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3)
|
||||
#define av_alloc_size(n) __attribute__((alloc_size(n)))
|
||||
#if AV_GCC_VERSION_AT_LEAST(4,3)
|
||||
#define av_alloc_size(...) __attribute__((alloc_size(__VA_ARGS__)))
|
||||
#else
|
||||
#define av_alloc_size(n)
|
||||
#define av_alloc_size(...)
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -70,21 +80,47 @@
|
|||
* be allocated.
|
||||
* @see av_mallocz()
|
||||
*/
|
||||
void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1);
|
||||
void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1);
|
||||
|
||||
/**
|
||||
* Helper function to allocate a block of size * nmemb bytes with
|
||||
* using av_malloc()
|
||||
* @param nmemb Number of elements
|
||||
* @param size Size of the single element
|
||||
* @return Pointer to the allocated block, NULL if the block cannot
|
||||
* be allocated.
|
||||
* @see av_malloc()
|
||||
*/
|
||||
av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t size)
|
||||
{
|
||||
if (size <= 0 || nmemb >= INT_MAX / size)
|
||||
return NULL;
|
||||
return av_malloc(nmemb * size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate or reallocate a block of memory.
|
||||
* If ptr is NULL and size > 0, allocate a new block. If
|
||||
* size is zero, free the memory block pointed to by ptr.
|
||||
* @param size Size in bytes for the memory block to be allocated or
|
||||
* reallocated.
|
||||
* @param ptr Pointer to a memory block already allocated with
|
||||
* av_malloc(z)() or av_realloc() or NULL.
|
||||
* @param size Size in bytes for the memory block to be allocated or
|
||||
* reallocated.
|
||||
* @return Pointer to a newly reallocated block or NULL if the block
|
||||
* cannot be reallocated or the function is used to free the memory block.
|
||||
* @see av_fast_realloc()
|
||||
*/
|
||||
void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2);
|
||||
void *av_realloc(void *ptr, size_t size) av_alloc_size(2);
|
||||
|
||||
/**
|
||||
* Allocate or reallocate a block of memory.
|
||||
* This function does the same thing as av_realloc, except:
|
||||
* - It takes two arguments and checks the result of the multiplication for
|
||||
* integer overflow.
|
||||
* - It frees the input block in case of failure, thus avoiding the memory
|
||||
* leak with the classic "buf = realloc(buf); if (!buf) return -1;".
|
||||
*/
|
||||
void *av_realloc_f(void *ptr, size_t nelem, size_t elsize);
|
||||
|
||||
/**
|
||||
* Free a memory block which has been allocated with av_malloc(z)() or
|
||||
|
@ -104,7 +140,36 @@ void av_free(void *ptr);
|
|||
* @return Pointer to the allocated block, NULL if it cannot be allocated.
|
||||
* @see av_malloc()
|
||||
*/
|
||||
void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1);
|
||||
void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1);
|
||||
|
||||
/**
|
||||
* Allocate a block of nmemb * size bytes with alignment suitable for all
|
||||
* memory accesses (including vectors if available on the CPU) and
|
||||
* zero all the bytes of the block.
|
||||
* The allocation will fail if nmemb * size is greater than or equal
|
||||
* to INT_MAX.
|
||||
* @param nmemb
|
||||
* @param size
|
||||
* @return Pointer to the allocated block, NULL if it cannot be allocated.
|
||||
*/
|
||||
void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib;
|
||||
|
||||
/**
|
||||
* Helper function to allocate a block of size * nmemb bytes with
|
||||
* using av_mallocz()
|
||||
* @param nmemb Number of elements
|
||||
* @param size Size of the single element
|
||||
* @return Pointer to the allocated block, NULL if the block cannot
|
||||
* be allocated.
|
||||
* @see av_mallocz()
|
||||
* @see av_malloc_array()
|
||||
*/
|
||||
av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t size)
|
||||
{
|
||||
if (size <= 0 || nmemb >= INT_MAX / size)
|
||||
return NULL;
|
||||
return av_mallocz(nmemb * size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate the string s.
|
||||
|
@ -123,4 +188,48 @@ char *av_strdup(const char *s) av_malloc_attrib;
|
|||
*/
|
||||
void av_freep(void *ptr);
|
||||
|
||||
/**
|
||||
* Add an element to a dynamic array.
|
||||
*
|
||||
* @param tab_ptr Pointer to the array.
|
||||
* @param nb_ptr Pointer to the number of elements in the array.
|
||||
* @param elem Element to be added.
|
||||
*/
|
||||
void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem);
|
||||
|
||||
/**
|
||||
* Multiply two size_t values checking for overflow.
|
||||
* @return 0 if success, AVERROR(EINVAL) if overflow.
|
||||
*/
|
||||
static inline int av_size_mult(size_t a, size_t b, size_t *r)
|
||||
{
|
||||
size_t t = a * b;
|
||||
/* Hack inspired from glibc: only try the division if nelem and elsize
|
||||
* are both greater than sqrt(SIZE_MAX). */
|
||||
if ((a | b) >= ((size_t)1 << (sizeof(size_t) * 4)) && a && t / a != b)
|
||||
return AVERROR(EINVAL);
|
||||
*r = t;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum size that may me allocated in one block.
|
||||
*/
|
||||
void av_max_alloc(size_t max);
|
||||
|
||||
/**
|
||||
* @brief deliberately overlapping memcpy implementation
|
||||
* @param dst destination buffer
|
||||
* @param back how many bytes back we start (the initial size of the overlapping window), must be > 0
|
||||
* @param cnt number of bytes to copy, must be >= 0
|
||||
*
|
||||
* cnt > back is valid, this will copy the bytes we just copied,
|
||||
* thus creating a repeating pattern with a period length of back.
|
||||
*/
|
||||
void av_memcpy_backptr(uint8_t *dst, int back, int cnt);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_MEM_H */
|
||||
|
|
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* copyright (c) 2006-2012 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_OLD_PIX_FMTS_H
|
||||
#define AVUTIL_OLD_PIX_FMTS_H
|
||||
|
||||
/*
|
||||
* This header exists to prevent new pixel formats from being accidentally added
|
||||
* to the deprecated list.
|
||||
* Do not include it directly. It will be removed on next major bump
|
||||
*
|
||||
* Do not add new items to this list. Use the AVPixelFormat enum instead.
|
||||
*/
|
||||
PIX_FMT_NONE = AV_PIX_FMT_NONE,
|
||||
PIX_FMT_YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
|
||||
PIX_FMT_YUYV422, ///< packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
|
||||
PIX_FMT_RGB24, ///< packed RGB 8:8:8, 24bpp, RGBRGB...
|
||||
PIX_FMT_BGR24, ///< packed RGB 8:8:8, 24bpp, BGRBGR...
|
||||
PIX_FMT_YUV422P, ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
|
||||
PIX_FMT_YUV444P, ///< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
|
||||
PIX_FMT_YUV410P, ///< planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
|
||||
PIX_FMT_YUV411P, ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
|
||||
PIX_FMT_GRAY8, ///< Y , 8bpp
|
||||
PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb
|
||||
PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb
|
||||
PIX_FMT_PAL8, ///< 8 bit with PIX_FMT_RGB32 palette
|
||||
PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range
|
||||
PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range
|
||||
PIX_FMT_YUVJ444P, ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range
|
||||
PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing
|
||||
PIX_FMT_XVMC_MPEG2_IDCT,
|
||||
PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
|
||||
PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
|
||||
PIX_FMT_BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
|
||||
PIX_FMT_BGR4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
|
||||
PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
|
||||
PIX_FMT_RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
|
||||
PIX_FMT_RGB4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
|
||||
PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
|
||||
PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)
|
||||
PIX_FMT_NV21, ///< as above, but U and V bytes are swapped
|
||||
|
||||
PIX_FMT_ARGB, ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
|
||||
PIX_FMT_RGBA, ///< packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
|
||||
PIX_FMT_ABGR, ///< packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
|
||||
PIX_FMT_BGRA, ///< packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
|
||||
|
||||
PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endian
|
||||
PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endian
|
||||
PIX_FMT_YUV440P, ///< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
|
||||
PIX_FMT_YUVJ440P, ///< planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range
|
||||
PIX_FMT_YUVA420P, ///< planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
|
||||
PIX_FMT_VDPAU_H264,///< H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
PIX_FMT_VDPAU_MPEG1,///< MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
PIX_FMT_VDPAU_MPEG2,///< MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
PIX_FMT_VDPAU_WMV3,///< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
PIX_FMT_VDPAU_VC1, ///< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian
|
||||
PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian
|
||||
|
||||
PIX_FMT_RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
|
||||
PIX_FMT_RGB565LE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
|
||||
PIX_FMT_RGB555BE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0
|
||||
PIX_FMT_RGB555LE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0
|
||||
|
||||
PIX_FMT_BGR565BE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
|
||||
PIX_FMT_BGR565LE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
|
||||
PIX_FMT_BGR555BE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1
|
||||
PIX_FMT_BGR555LE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1
|
||||
|
||||
PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers
|
||||
PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers
|
||||
PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
|
||||
PIX_FMT_YUV420P16LE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
|
||||
PIX_FMT_YUV420P16BE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
|
||||
PIX_FMT_YUV422P16LE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
|
||||
PIX_FMT_YUV422P16BE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
|
||||
PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
|
||||
PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
|
||||
PIX_FMT_VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer
|
||||
|
||||
PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0
|
||||
PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0
|
||||
PIX_FMT_BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1
|
||||
PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1
|
||||
PIX_FMT_GRAY8A, ///< 8bit gray, 8bit alpha
|
||||
PIX_FMT_BGR48BE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian
|
||||
PIX_FMT_BGR48LE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian
|
||||
|
||||
//the following 10 formats have the disadvantage of needing 1 format for each bit depth, thus
|
||||
//If you want to support multiple bit depths, then using PIX_FMT_YUV420P16* with the bpp stored separately
|
||||
//is better
|
||||
PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
|
||||
PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
|
||||
PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
|
||||
PIX_FMT_YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
|
||||
PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
|
||||
PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
|
||||
PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
|
||||
PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
|
||||
PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
|
||||
PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
|
||||
PIX_FMT_YUV422P9BE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
|
||||
PIX_FMT_YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
|
||||
PIX_FMT_VDA_VLD, ///< hardware decoding through VDA
|
||||
|
||||
#ifdef AV_PIX_FMT_ABI_GIT_MASTER
|
||||
PIX_FMT_RGBA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
|
||||
PIX_FMT_RGBA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
|
||||
PIX_FMT_BGRA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
|
||||
PIX_FMT_BGRA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
|
||||
#endif
|
||||
PIX_FMT_GBRP, ///< planar GBR 4:4:4 24bpp
|
||||
PIX_FMT_GBRP9BE, ///< planar GBR 4:4:4 27bpp, big endian
|
||||
PIX_FMT_GBRP9LE, ///< planar GBR 4:4:4 27bpp, little endian
|
||||
PIX_FMT_GBRP10BE, ///< planar GBR 4:4:4 30bpp, big endian
|
||||
PIX_FMT_GBRP10LE, ///< planar GBR 4:4:4 30bpp, little endian
|
||||
PIX_FMT_GBRP16BE, ///< planar GBR 4:4:4 48bpp, big endian
|
||||
PIX_FMT_GBRP16LE, ///< planar GBR 4:4:4 48bpp, little endian
|
||||
|
||||
#ifndef AV_PIX_FMT_ABI_GIT_MASTER
|
||||
PIX_FMT_RGBA64BE=0x123, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
|
||||
PIX_FMT_RGBA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
|
||||
PIX_FMT_BGRA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
|
||||
PIX_FMT_BGRA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
|
||||
#endif
|
||||
PIX_FMT_0RGB=0x123+4, ///< packed RGB 8:8:8, 32bpp, 0RGB0RGB...
|
||||
PIX_FMT_RGB0, ///< packed RGB 8:8:8, 32bpp, RGB0RGB0...
|
||||
PIX_FMT_0BGR, ///< packed BGR 8:8:8, 32bpp, 0BGR0BGR...
|
||||
PIX_FMT_BGR0, ///< packed BGR 8:8:8, 32bpp, BGR0BGR0...
|
||||
PIX_FMT_YUVA444P, ///< planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
|
||||
PIX_FMT_YUVA422P, ///< planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
|
||||
|
||||
PIX_FMT_YUV420P12BE, ///< planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
|
||||
PIX_FMT_YUV420P12LE, ///< planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
|
||||
PIX_FMT_YUV420P14BE, ///< planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
|
||||
PIX_FMT_YUV420P14LE, ///< planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
|
||||
PIX_FMT_YUV422P12BE, ///< planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
|
||||
PIX_FMT_YUV422P12LE, ///< planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
|
||||
PIX_FMT_YUV422P14BE, ///< planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
|
||||
PIX_FMT_YUV422P14LE, ///< planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
|
||||
PIX_FMT_YUV444P12BE, ///< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
|
||||
PIX_FMT_YUV444P12LE, ///< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
|
||||
PIX_FMT_YUV444P14BE, ///< planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
|
||||
PIX_FMT_YUV444P14LE, ///< planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
|
||||
PIX_FMT_GBRP12BE, ///< planar GBR 4:4:4 36bpp, big endian
|
||||
PIX_FMT_GBRP12LE, ///< planar GBR 4:4:4 36bpp, little endian
|
||||
PIX_FMT_GBRP14BE, ///< planar GBR 4:4:4 42bpp, big endian
|
||||
PIX_FMT_GBRP14LE, ///< planar GBR 4:4:4 42bpp, little endian
|
||||
|
||||
PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
|
||||
#endif /* AVUTIL_OLD_PIX_FMTS_H */
|
|
@ -0,0 +1,733 @@
|
|||
/*
|
||||
* AVOptions
|
||||
* copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_OPT_H
|
||||
#define AVUTIL_OPT_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* AVOptions
|
||||
*/
|
||||
|
||||
#include "rational.h"
|
||||
#include "avutil.h"
|
||||
#include "dict.h"
|
||||
#include "log.h"
|
||||
#include "pixfmt.h"
|
||||
#include "samplefmt.h"
|
||||
|
||||
/**
|
||||
* @defgroup avoptions AVOptions
|
||||
* @ingroup lavu_data
|
||||
* @{
|
||||
* AVOptions provide a generic system to declare options on arbitrary structs
|
||||
* ("objects"). An option can have a help text, a type and a range of possible
|
||||
* values. Options may then be enumerated, read and written to.
|
||||
*
|
||||
* @section avoptions_implement Implementing AVOptions
|
||||
* This section describes how to add AVOptions capabilities to a struct.
|
||||
*
|
||||
* All AVOptions-related information is stored in an AVClass. Therefore
|
||||
* the first member of the struct should be a pointer to an AVClass describing it.
|
||||
* The option field of the AVClass must be set to a NULL-terminated static array
|
||||
* of AVOptions. Each AVOption must have a non-empty name, a type, a default
|
||||
* value and for number-type AVOptions also a range of allowed values. It must
|
||||
* also declare an offset in bytes from the start of the struct, where the field
|
||||
* associated with this AVOption is located. Other fields in the AVOption struct
|
||||
* should also be set when applicable, but are not required.
|
||||
*
|
||||
* The following example illustrates an AVOptions-enabled struct:
|
||||
* @code
|
||||
* typedef struct test_struct {
|
||||
* AVClass *class;
|
||||
* int int_opt;
|
||||
* char *str_opt;
|
||||
* uint8_t *bin_opt;
|
||||
* int bin_len;
|
||||
* } test_struct;
|
||||
*
|
||||
* static const AVOption options[] = {
|
||||
* { "test_int", "This is a test option of int type.", offsetof(test_struct, int_opt),
|
||||
* AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX },
|
||||
* { "test_str", "This is a test option of string type.", offsetof(test_struct, str_opt),
|
||||
* AV_OPT_TYPE_STRING },
|
||||
* { "test_bin", "This is a test option of binary type.", offsetof(test_struct, bin_opt),
|
||||
* AV_OPT_TYPE_BINARY },
|
||||
* { NULL },
|
||||
* };
|
||||
*
|
||||
* static const AVClass test_class = {
|
||||
* .class_name = "test class",
|
||||
* .item_name = av_default_item_name,
|
||||
* .option = options,
|
||||
* .version = LIBAVUTIL_VERSION_INT,
|
||||
* };
|
||||
* @endcode
|
||||
*
|
||||
* Next, when allocating your struct, you must ensure that the AVClass pointer
|
||||
* is set to the correct value. Then, av_opt_set_defaults() can be called to
|
||||
* initialize defaults. After that the struct is ready to be used with the
|
||||
* AVOptions API.
|
||||
*
|
||||
* When cleaning up, you may use the av_opt_free() function to automatically
|
||||
* free all the allocated string and binary options.
|
||||
*
|
||||
* Continuing with the above example:
|
||||
*
|
||||
* @code
|
||||
* test_struct *alloc_test_struct(void)
|
||||
* {
|
||||
* test_struct *ret = av_malloc(sizeof(*ret));
|
||||
* ret->class = &test_class;
|
||||
* av_opt_set_defaults(ret);
|
||||
* return ret;
|
||||
* }
|
||||
* void free_test_struct(test_struct **foo)
|
||||
* {
|
||||
* av_opt_free(*foo);
|
||||
* av_freep(foo);
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
* @subsection avoptions_implement_nesting Nesting
|
||||
* It may happen that an AVOptions-enabled struct contains another
|
||||
* AVOptions-enabled struct as a member (e.g. AVCodecContext in
|
||||
* libavcodec exports generic options, while its priv_data field exports
|
||||
* codec-specific options). In such a case, it is possible to set up the
|
||||
* parent struct to export a child's options. To do that, simply
|
||||
* implement AVClass.child_next() and AVClass.child_class_next() in the
|
||||
* parent struct's AVClass.
|
||||
* Assuming that the test_struct from above now also contains a
|
||||
* child_struct field:
|
||||
*
|
||||
* @code
|
||||
* typedef struct child_struct {
|
||||
* AVClass *class;
|
||||
* int flags_opt;
|
||||
* } child_struct;
|
||||
* static const AVOption child_opts[] = {
|
||||
* { "test_flags", "This is a test option of flags type.",
|
||||
* offsetof(child_struct, flags_opt), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX },
|
||||
* { NULL },
|
||||
* };
|
||||
* static const AVClass child_class = {
|
||||
* .class_name = "child class",
|
||||
* .item_name = av_default_item_name,
|
||||
* .option = child_opts,
|
||||
* .version = LIBAVUTIL_VERSION_INT,
|
||||
* };
|
||||
*
|
||||
* void *child_next(void *obj, void *prev)
|
||||
* {
|
||||
* test_struct *t = obj;
|
||||
* if (!prev && t->child_struct)
|
||||
* return t->child_struct;
|
||||
* return NULL
|
||||
* }
|
||||
* const AVClass child_class_next(const AVClass *prev)
|
||||
* {
|
||||
* return prev ? NULL : &child_class;
|
||||
* }
|
||||
* @endcode
|
||||
* Putting child_next() and child_class_next() as defined above into
|
||||
* test_class will now make child_struct's options accessible through
|
||||
* test_struct (again, proper setup as described above needs to be done on
|
||||
* child_struct right after it is created).
|
||||
*
|
||||
* From the above example it might not be clear why both child_next()
|
||||
* and child_class_next() are needed. The distinction is that child_next()
|
||||
* iterates over actually existing objects, while child_class_next()
|
||||
* iterates over all possible child classes. E.g. if an AVCodecContext
|
||||
* was initialized to use a codec which has private options, then its
|
||||
* child_next() will return AVCodecContext.priv_data and finish
|
||||
* iterating. OTOH child_class_next() on AVCodecContext.av_class will
|
||||
* iterate over all available codecs with private options.
|
||||
*
|
||||
* @subsection avoptions_implement_named_constants Named constants
|
||||
* It is possible to create named constants for options. Simply set the unit
|
||||
* field of the option the constants should apply to to a string and
|
||||
* create the constants themselves as options of type AV_OPT_TYPE_CONST
|
||||
* with their unit field set to the same string.
|
||||
* Their default_val field should contain the value of the named
|
||||
* constant.
|
||||
* For example, to add some named constants for the test_flags option
|
||||
* above, put the following into the child_opts array:
|
||||
* @code
|
||||
* { "test_flags", "This is a test option of flags type.",
|
||||
* offsetof(child_struct, flags_opt), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX, "test_unit" },
|
||||
* { "flag1", "This is a flag with value 16", 0, AV_OPT_TYPE_CONST, { .i64 = 16 }, 0, 0, "test_unit" },
|
||||
* @endcode
|
||||
*
|
||||
* @section avoptions_use Using AVOptions
|
||||
* This section deals with accessing options in an AVOptions-enabled struct.
|
||||
* Such structs in FFmpeg are e.g. AVCodecContext in libavcodec or
|
||||
* AVFormatContext in libavformat.
|
||||
*
|
||||
* @subsection avoptions_use_examine Examining AVOptions
|
||||
* The basic functions for examining options are av_opt_next(), which iterates
|
||||
* over all options defined for one object, and av_opt_find(), which searches
|
||||
* for an option with the given name.
|
||||
*
|
||||
* The situation is more complicated with nesting. An AVOptions-enabled struct
|
||||
* may have AVOptions-enabled children. Passing the AV_OPT_SEARCH_CHILDREN flag
|
||||
* to av_opt_find() will make the function search children recursively.
|
||||
*
|
||||
* For enumerating there are basically two cases. The first is when you want to
|
||||
* get all options that may potentially exist on the struct and its children
|
||||
* (e.g. when constructing documentation). In that case you should call
|
||||
* av_opt_child_class_next() recursively on the parent struct's AVClass. The
|
||||
* second case is when you have an already initialized struct with all its
|
||||
* children and you want to get all options that can be actually written or read
|
||||
* from it. In that case you should call av_opt_child_next() recursively (and
|
||||
* av_opt_next() on each result).
|
||||
*
|
||||
* @subsection avoptions_use_get_set Reading and writing AVOptions
|
||||
* When setting options, you often have a string read directly from the
|
||||
* user. In such a case, simply passing it to av_opt_set() is enough. For
|
||||
* non-string type options, av_opt_set() will parse the string according to the
|
||||
* option type.
|
||||
*
|
||||
* Similarly av_opt_get() will read any option type and convert it to a string
|
||||
* which will be returned. Do not forget that the string is allocated, so you
|
||||
* have to free it with av_free().
|
||||
*
|
||||
* In some cases it may be more convenient to put all options into an
|
||||
* AVDictionary and call av_opt_set_dict() on it. A specific case of this
|
||||
* are the format/codec open functions in lavf/lavc which take a dictionary
|
||||
* filled with option as a parameter. This allows to set some options
|
||||
* that cannot be set otherwise, since e.g. the input file format is not known
|
||||
* before the file is actually opened.
|
||||
*/
|
||||
|
||||
enum AVOptionType{
|
||||
AV_OPT_TYPE_FLAGS,
|
||||
AV_OPT_TYPE_INT,
|
||||
AV_OPT_TYPE_INT64,
|
||||
AV_OPT_TYPE_DOUBLE,
|
||||
AV_OPT_TYPE_FLOAT,
|
||||
AV_OPT_TYPE_STRING,
|
||||
AV_OPT_TYPE_RATIONAL,
|
||||
AV_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length
|
||||
AV_OPT_TYPE_CONST = 128,
|
||||
AV_OPT_TYPE_IMAGE_SIZE = MKBETAG('S','I','Z','E'), ///< offset must point to two consecutive integers
|
||||
AV_OPT_TYPE_PIXEL_FMT = MKBETAG('P','F','M','T'),
|
||||
AV_OPT_TYPE_SAMPLE_FMT = MKBETAG('S','F','M','T'),
|
||||
#if FF_API_OLD_AVOPTIONS
|
||||
FF_OPT_TYPE_FLAGS = 0,
|
||||
FF_OPT_TYPE_INT,
|
||||
FF_OPT_TYPE_INT64,
|
||||
FF_OPT_TYPE_DOUBLE,
|
||||
FF_OPT_TYPE_FLOAT,
|
||||
FF_OPT_TYPE_STRING,
|
||||
FF_OPT_TYPE_RATIONAL,
|
||||
FF_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length
|
||||
FF_OPT_TYPE_CONST=128,
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* AVOption
|
||||
*/
|
||||
typedef struct AVOption {
|
||||
const char *name;
|
||||
|
||||
/**
|
||||
* short English help text
|
||||
* @todo What about other languages?
|
||||
*/
|
||||
const char *help;
|
||||
|
||||
/**
|
||||
* The offset relative to the context structure where the option
|
||||
* value is stored. It should be 0 for named constants.
|
||||
*/
|
||||
int offset;
|
||||
enum AVOptionType type;
|
||||
|
||||
/**
|
||||
* the default value for scalar options
|
||||
*/
|
||||
union {
|
||||
int64_t i64;
|
||||
double dbl;
|
||||
const char *str;
|
||||
/* TODO those are unused now */
|
||||
AVRational q;
|
||||
} default_val;
|
||||
double min; ///< minimum valid value for the option
|
||||
double max; ///< maximum valid value for the option
|
||||
|
||||
int flags;
|
||||
#define AV_OPT_FLAG_ENCODING_PARAM 1 ///< a generic parameter which can be set by the user for muxing or encoding
|
||||
#define AV_OPT_FLAG_DECODING_PARAM 2 ///< a generic parameter which can be set by the user for demuxing or decoding
|
||||
#define AV_OPT_FLAG_METADATA 4 ///< some data extracted or inserted into the file like title, comment, ...
|
||||
#define AV_OPT_FLAG_AUDIO_PARAM 8
|
||||
#define AV_OPT_FLAG_VIDEO_PARAM 16
|
||||
#define AV_OPT_FLAG_SUBTITLE_PARAM 32
|
||||
#define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which can be set by the user for filtering
|
||||
//FIXME think about enc-audio, ... style flags
|
||||
|
||||
/**
|
||||
* The logical unit to which the option belongs. Non-constant
|
||||
* options and corresponding named constants share the same
|
||||
* unit. May be NULL.
|
||||
*/
|
||||
const char *unit;
|
||||
} AVOption;
|
||||
|
||||
/**
|
||||
* A single allowed range of values, or a single allowed value.
|
||||
*/
|
||||
typedef struct AVOptionRange {
|
||||
const char *str;
|
||||
double value_min, value_max; ///< For string ranges this represents the min/max length, for dimensions this represents the min/max pixel count
|
||||
double component_min, component_max; ///< For string this represents the unicode range for chars, 0-127 limits to ASCII
|
||||
int is_range; ///< if set to 1 the struct encodes a range, if set to 0 a single value
|
||||
} AVOptionRange;
|
||||
|
||||
/**
|
||||
* List of AVOptionRange structs
|
||||
*/
|
||||
typedef struct AVOptionRanges {
|
||||
AVOptionRange **range;
|
||||
int nb_ranges;
|
||||
} AVOptionRanges;
|
||||
|
||||
|
||||
#if FF_API_FIND_OPT
|
||||
/**
|
||||
* Look for an option in obj. Look only for the options which
|
||||
* have the flags set as specified in mask and flags (that is,
|
||||
* for which it is the case that opt->flags & mask == flags).
|
||||
*
|
||||
* @param[in] obj a pointer to a struct whose first element is a
|
||||
* pointer to an AVClass
|
||||
* @param[in] name the name of the option to look for
|
||||
* @param[in] unit the unit of the option to look for, or any if NULL
|
||||
* @return a pointer to the option found, or NULL if no option
|
||||
* has been found
|
||||
*
|
||||
* @deprecated use av_opt_find.
|
||||
*/
|
||||
attribute_deprecated
|
||||
const AVOption *av_find_opt(void *obj, const char *name, const char *unit, int mask, int flags);
|
||||
#endif
|
||||
|
||||
#if FF_API_OLD_AVOPTIONS
|
||||
/**
|
||||
* Set the field of obj with the given name to value.
|
||||
*
|
||||
* @param[in] obj A struct whose first element is a pointer to an
|
||||
* AVClass.
|
||||
* @param[in] name the name of the field to set
|
||||
* @param[in] val The value to set. If the field is not of a string
|
||||
* type, then the given string is parsed.
|
||||
* SI postfixes and some named scalars are supported.
|
||||
* If the field is of a numeric type, it has to be a numeric or named
|
||||
* scalar. Behavior with more than one scalar and +- infix operators
|
||||
* is undefined.
|
||||
* If the field is of a flags type, it has to be a sequence of numeric
|
||||
* scalars or named flags separated by '+' or '-'. Prefixing a flag
|
||||
* with '+' causes it to be set without affecting the other flags;
|
||||
* similarly, '-' unsets a flag.
|
||||
* @param[out] o_out if non-NULL put here a pointer to the AVOption
|
||||
* found
|
||||
* @param alloc this parameter is currently ignored
|
||||
* @return 0 if the value has been set, or an AVERROR code in case of
|
||||
* error:
|
||||
* AVERROR_OPTION_NOT_FOUND if no matching option exists
|
||||
* AVERROR(ERANGE) if the value is out of range
|
||||
* AVERROR(EINVAL) if the value is not valid
|
||||
* @deprecated use av_opt_set()
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out);
|
||||
|
||||
attribute_deprecated const AVOption *av_set_double(void *obj, const char *name, double n);
|
||||
attribute_deprecated const AVOption *av_set_q(void *obj, const char *name, AVRational n);
|
||||
attribute_deprecated const AVOption *av_set_int(void *obj, const char *name, int64_t n);
|
||||
|
||||
double av_get_double(void *obj, const char *name, const AVOption **o_out);
|
||||
AVRational av_get_q(void *obj, const char *name, const AVOption **o_out);
|
||||
int64_t av_get_int(void *obj, const char *name, const AVOption **o_out);
|
||||
attribute_deprecated const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len);
|
||||
attribute_deprecated const AVOption *av_next_option(void *obj, const AVOption *last);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Show the obj options.
|
||||
*
|
||||
* @param req_flags requested flags for the options to show. Show only the
|
||||
* options for which it is opt->flags & req_flags.
|
||||
* @param rej_flags rejected flags for the options to show. Show only the
|
||||
* options for which it is !(opt->flags & req_flags).
|
||||
* @param av_log_obj log context to use for showing the options
|
||||
*/
|
||||
int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags);
|
||||
|
||||
/**
|
||||
* Set the values of all AVOption fields to their default values.
|
||||
*
|
||||
* @param s an AVOption-enabled struct (its first member must be a pointer to AVClass)
|
||||
*/
|
||||
void av_opt_set_defaults(void *s);
|
||||
|
||||
#if FF_API_OLD_AVOPTIONS
|
||||
attribute_deprecated
|
||||
void av_opt_set_defaults2(void *s, int mask, int flags);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Parse the key/value pairs list in opts. For each key/value pair
|
||||
* found, stores the value in the field in ctx that is named like the
|
||||
* key. ctx must be an AVClass context, storing is done using
|
||||
* AVOptions.
|
||||
*
|
||||
* @param opts options string to parse, may be NULL
|
||||
* @param key_val_sep a 0-terminated list of characters used to
|
||||
* separate key from value
|
||||
* @param pairs_sep a 0-terminated list of characters used to separate
|
||||
* two pairs from each other
|
||||
* @return the number of successfully set key/value pairs, or a negative
|
||||
* value corresponding to an AVERROR code in case of error:
|
||||
* AVERROR(EINVAL) if opts cannot be parsed,
|
||||
* the error code issued by av_set_string3() if a key/value pair
|
||||
* cannot be set
|
||||
*/
|
||||
int av_set_options_string(void *ctx, const char *opts,
|
||||
const char *key_val_sep, const char *pairs_sep);
|
||||
|
||||
/**
|
||||
* Parse the key-value pairs list in opts. For each key=value pair found,
|
||||
* set the value of the corresponding option in ctx.
|
||||
*
|
||||
* @param ctx the AVClass object to set options on
|
||||
* @param opts the options string, key-value pairs separated by a
|
||||
* delimiter
|
||||
* @param shorthand a NULL-terminated array of options names for shorthand
|
||||
* notation: if the first field in opts has no key part,
|
||||
* the key is taken from the first element of shorthand;
|
||||
* then again for the second, etc., until either opts is
|
||||
* finished, shorthand is finished or a named option is
|
||||
* found; after that, all options must be named
|
||||
* @param key_val_sep a 0-terminated list of characters used to separate
|
||||
* key from value, for example '='
|
||||
* @param pairs_sep a 0-terminated list of characters used to separate
|
||||
* two pairs from each other, for example ':' or ','
|
||||
* @return the number of successfully set key=value pairs, or a negative
|
||||
* value corresponding to an AVERROR code in case of error:
|
||||
* AVERROR(EINVAL) if opts cannot be parsed,
|
||||
* the error code issued by av_set_string3() if a key/value pair
|
||||
* cannot be set
|
||||
*
|
||||
* Options names must use only the following characters: a-z A-Z 0-9 - . / _
|
||||
* Separators must use characters distinct from option names and from each
|
||||
* other.
|
||||
*/
|
||||
int av_opt_set_from_string(void *ctx, const char *opts,
|
||||
const char *const *shorthand,
|
||||
const char *key_val_sep, const char *pairs_sep);
|
||||
/**
|
||||
* Free all string and binary options in obj.
|
||||
*/
|
||||
void av_opt_free(void *obj);
|
||||
|
||||
/**
|
||||
* Check whether a particular flag is set in a flags field.
|
||||
*
|
||||
* @param field_name the name of the flag field option
|
||||
* @param flag_name the name of the flag to check
|
||||
* @return non-zero if the flag is set, zero if the flag isn't set,
|
||||
* isn't of the right type, or the flags field doesn't exist.
|
||||
*/
|
||||
int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name);
|
||||
|
||||
/**
|
||||
* Set all the options from a given dictionary on an object.
|
||||
*
|
||||
* @param obj a struct whose first element is a pointer to AVClass
|
||||
* @param options options to process. This dictionary will be freed and replaced
|
||||
* by a new one containing all options not found in obj.
|
||||
* Of course this new dictionary needs to be freed by caller
|
||||
* with av_dict_free().
|
||||
*
|
||||
* @return 0 on success, a negative AVERROR if some option was found in obj,
|
||||
* but could not be set.
|
||||
*
|
||||
* @see av_dict_copy()
|
||||
*/
|
||||
int av_opt_set_dict(void *obj, struct AVDictionary **options);
|
||||
|
||||
/**
|
||||
* Extract a key-value pair from the beginning of a string.
|
||||
*
|
||||
* @param ropts pointer to the options string, will be updated to
|
||||
* point to the rest of the string (one of the pairs_sep
|
||||
* or the final NUL)
|
||||
* @param key_val_sep a 0-terminated list of characters used to separate
|
||||
* key from value, for example '='
|
||||
* @param pairs_sep a 0-terminated list of characters used to separate
|
||||
* two pairs from each other, for example ':' or ','
|
||||
* @param flags flags; see the AV_OPT_FLAG_* values below
|
||||
* @param rkey parsed key; must be freed using av_free()
|
||||
* @param rval parsed value; must be freed using av_free()
|
||||
*
|
||||
* @return >=0 for success, or a negative value corresponding to an
|
||||
* AVERROR code in case of error; in particular:
|
||||
* AVERROR(EINVAL) if no key is present
|
||||
*
|
||||
*/
|
||||
int av_opt_get_key_value(const char **ropts,
|
||||
const char *key_val_sep, const char *pairs_sep,
|
||||
unsigned flags,
|
||||
char **rkey, char **rval);
|
||||
|
||||
enum {
|
||||
|
||||
/**
|
||||
* Accept to parse a value without a key; the key will then be returned
|
||||
* as NULL.
|
||||
*/
|
||||
AV_OPT_FLAG_IMPLICIT_KEY = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* @defgroup opt_eval_funcs Evaluating option strings
|
||||
* @{
|
||||
* This group of functions can be used to evaluate option strings
|
||||
* and get numbers out of them. They do the same thing as av_opt_set(),
|
||||
* except the result is written into the caller-supplied pointer.
|
||||
*
|
||||
* @param obj a struct whose first element is a pointer to AVClass.
|
||||
* @param o an option for which the string is to be evaluated.
|
||||
* @param val string to be evaluated.
|
||||
* @param *_out value of the string will be written here.
|
||||
*
|
||||
* @return 0 on success, a negative number on failure.
|
||||
*/
|
||||
int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out);
|
||||
int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out);
|
||||
int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out);
|
||||
int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out);
|
||||
int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out);
|
||||
int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#define AV_OPT_SEARCH_CHILDREN 0x0001 /**< Search in possible children of the
|
||||
given object first. */
|
||||
/**
|
||||
* The obj passed to av_opt_find() is fake -- only a double pointer to AVClass
|
||||
* instead of a required pointer to a struct containing AVClass. This is
|
||||
* useful for searching for options without needing to allocate the corresponding
|
||||
* object.
|
||||
*/
|
||||
#define AV_OPT_SEARCH_FAKE_OBJ 0x0002
|
||||
|
||||
/**
|
||||
* Look for an option in an object. Consider only options which
|
||||
* have all the specified flags set.
|
||||
*
|
||||
* @param[in] obj A pointer to a struct whose first element is a
|
||||
* pointer to an AVClass.
|
||||
* Alternatively a double pointer to an AVClass, if
|
||||
* AV_OPT_SEARCH_FAKE_OBJ search flag is set.
|
||||
* @param[in] name The name of the option to look for.
|
||||
* @param[in] unit When searching for named constants, name of the unit
|
||||
* it belongs to.
|
||||
* @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG).
|
||||
* @param search_flags A combination of AV_OPT_SEARCH_*.
|
||||
*
|
||||
* @return A pointer to the option found, or NULL if no option
|
||||
* was found.
|
||||
*
|
||||
* @note Options found with AV_OPT_SEARCH_CHILDREN flag may not be settable
|
||||
* directly with av_set_string3(). Use special calls which take an options
|
||||
* AVDictionary (e.g. avformat_open_input()) to set options found with this
|
||||
* flag.
|
||||
*/
|
||||
const AVOption *av_opt_find(void *obj, const char *name, const char *unit,
|
||||
int opt_flags, int search_flags);
|
||||
|
||||
/**
|
||||
* Look for an option in an object. Consider only options which
|
||||
* have all the specified flags set.
|
||||
*
|
||||
* @param[in] obj A pointer to a struct whose first element is a
|
||||
* pointer to an AVClass.
|
||||
* Alternatively a double pointer to an AVClass, if
|
||||
* AV_OPT_SEARCH_FAKE_OBJ search flag is set.
|
||||
* @param[in] name The name of the option to look for.
|
||||
* @param[in] unit When searching for named constants, name of the unit
|
||||
* it belongs to.
|
||||
* @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG).
|
||||
* @param search_flags A combination of AV_OPT_SEARCH_*.
|
||||
* @param[out] target_obj if non-NULL, an object to which the option belongs will be
|
||||
* written here. It may be different from obj if AV_OPT_SEARCH_CHILDREN is present
|
||||
* in search_flags. This parameter is ignored if search_flags contain
|
||||
* AV_OPT_SEARCH_FAKE_OBJ.
|
||||
*
|
||||
* @return A pointer to the option found, or NULL if no option
|
||||
* was found.
|
||||
*/
|
||||
const AVOption *av_opt_find2(void *obj, const char *name, const char *unit,
|
||||
int opt_flags, int search_flags, void **target_obj);
|
||||
|
||||
/**
|
||||
* Iterate over all AVOptions belonging to obj.
|
||||
*
|
||||
* @param obj an AVOptions-enabled struct or a double pointer to an
|
||||
* AVClass describing it.
|
||||
* @param prev result of the previous call to av_opt_next() on this object
|
||||
* or NULL
|
||||
* @return next AVOption or NULL
|
||||
*/
|
||||
const AVOption *av_opt_next(void *obj, const AVOption *prev);
|
||||
|
||||
/**
|
||||
* Iterate over AVOptions-enabled children of obj.
|
||||
*
|
||||
* @param prev result of a previous call to this function or NULL
|
||||
* @return next AVOptions-enabled child or NULL
|
||||
*/
|
||||
void *av_opt_child_next(void *obj, void *prev);
|
||||
|
||||
/**
|
||||
* Iterate over potential AVOptions-enabled children of parent.
|
||||
*
|
||||
* @param prev result of a previous call to this function or NULL
|
||||
* @return AVClass corresponding to next potential child or NULL
|
||||
*/
|
||||
const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev);
|
||||
|
||||
/**
|
||||
* @defgroup opt_set_funcs Option setting functions
|
||||
* @{
|
||||
* Those functions set the field of obj with the given name to value.
|
||||
*
|
||||
* @param[in] obj A struct whose first element is a pointer to an AVClass.
|
||||
* @param[in] name the name of the field to set
|
||||
* @param[in] val The value to set. In case of av_opt_set() if the field is not
|
||||
* of a string type, then the given string is parsed.
|
||||
* SI postfixes and some named scalars are supported.
|
||||
* If the field is of a numeric type, it has to be a numeric or named
|
||||
* scalar. Behavior with more than one scalar and +- infix operators
|
||||
* is undefined.
|
||||
* If the field is of a flags type, it has to be a sequence of numeric
|
||||
* scalars or named flags separated by '+' or '-'. Prefixing a flag
|
||||
* with '+' causes it to be set without affecting the other flags;
|
||||
* similarly, '-' unsets a flag.
|
||||
* @param search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN
|
||||
* is passed here, then the option may be set on a child of obj.
|
||||
*
|
||||
* @return 0 if the value has been set, or an AVERROR code in case of
|
||||
* error:
|
||||
* AVERROR_OPTION_NOT_FOUND if no matching option exists
|
||||
* AVERROR(ERANGE) if the value is out of range
|
||||
* AVERROR(EINVAL) if the value is not valid
|
||||
*/
|
||||
int av_opt_set (void *obj, const char *name, const char *val, int search_flags);
|
||||
int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags);
|
||||
int av_opt_set_double(void *obj, const char *name, double val, int search_flags);
|
||||
int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags);
|
||||
int av_opt_set_bin (void *obj, const char *name, const uint8_t *val, int size, int search_flags);
|
||||
int av_opt_set_image_size(void *obj, const char *name, int w, int h, int search_flags);
|
||||
int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat fmt, int search_flags);
|
||||
int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup opt_get_funcs Option getting functions
|
||||
* @{
|
||||
* Those functions get a value of the option with the given name from an object.
|
||||
*
|
||||
* @param[in] obj a struct whose first element is a pointer to an AVClass.
|
||||
* @param[in] name name of the option to get.
|
||||
* @param[in] search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN
|
||||
* is passed here, then the option may be found in a child of obj.
|
||||
* @param[out] out_val value of the option will be written here
|
||||
* @return 0 on success, a negative error code otherwise
|
||||
*/
|
||||
/**
|
||||
* @note the returned string will av_malloc()ed and must be av_free()ed by the caller
|
||||
*/
|
||||
int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
|
||||
int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val);
|
||||
int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val);
|
||||
int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val);
|
||||
int av_opt_get_image_size(void *obj, const char *name, int search_flags, int *w_out, int *h_out);
|
||||
int av_opt_get_pixel_fmt (void *obj, const char *name, int search_flags, enum AVPixelFormat *out_fmt);
|
||||
int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/**
|
||||
* Gets a pointer to the requested field in a struct.
|
||||
* This function allows accessing a struct even when its fields are moved or
|
||||
* renamed since the application making the access has been compiled,
|
||||
*
|
||||
* @returns a pointer to the field, it can be cast to the correct type and read
|
||||
* or written to.
|
||||
*/
|
||||
void *av_opt_ptr(const AVClass *avclass, void *obj, const char *name);
|
||||
|
||||
/**
|
||||
* Free an AVOptionRanges struct and set it to NULL.
|
||||
*/
|
||||
void av_opt_freep_ranges(AVOptionRanges **ranges);
|
||||
|
||||
/**
|
||||
* Get a list of allowed ranges for the given option.
|
||||
*
|
||||
* The returned list may depend on other fields in obj like for example profile.
|
||||
*
|
||||
* @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
|
||||
* AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
|
||||
*
|
||||
* The result must be freed with av_opt_freep_ranges.
|
||||
*
|
||||
* @return >= 0 on success, a negative errro code otherwise
|
||||
*/
|
||||
int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags);
|
||||
|
||||
/**
|
||||
* Get a default list of allowed ranges for the given option.
|
||||
*
|
||||
* This list is constructed without using the AVClass.query_ranges() callback
|
||||
* and can be used as fallback from within the callback.
|
||||
*
|
||||
* @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
|
||||
* AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
|
||||
*
|
||||
* The result must be freed with av_opt_free_ranges.
|
||||
*
|
||||
* @return >= 0 on success, a negative errro code otherwise
|
||||
*/
|
||||
int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_OPT_H */
|
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_PARSEUTILS_H
|
||||
#define AVUTIL_PARSEUTILS_H
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "rational.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
* misc parsing utilities
|
||||
*/
|
||||
|
||||
/**
|
||||
* Parse str and store the parsed ratio in q.
|
||||
*
|
||||
* Note that a ratio with infinite (1/0) or negative value is
|
||||
* considered valid, so you should check on the returned value if you
|
||||
* want to exclude those values.
|
||||
*
|
||||
* The undefined value can be expressed using the "0:0" string.
|
||||
*
|
||||
* @param[in,out] q pointer to the AVRational which will contain the ratio
|
||||
* @param[in] str the string to parse: it has to be a string in the format
|
||||
* num:den, a float number or an expression
|
||||
* @param[in] max the maximum allowed numerator and denominator
|
||||
* @param[in] log_offset log level offset which is applied to the log
|
||||
* level of log_ctx
|
||||
* @param[in] log_ctx parent logging context
|
||||
* @return >= 0 on success, a negative error code otherwise
|
||||
*/
|
||||
int av_parse_ratio(AVRational *q, const char *str, int max,
|
||||
int log_offset, void *log_ctx);
|
||||
|
||||
#define av_parse_ratio_quiet(rate, str, max) \
|
||||
av_parse_ratio(rate, str, max, AV_LOG_MAX_OFFSET, NULL)
|
||||
|
||||
/**
|
||||
* Parse str and put in width_ptr and height_ptr the detected values.
|
||||
*
|
||||
* @param[in,out] width_ptr pointer to the variable which will contain the detected
|
||||
* width value
|
||||
* @param[in,out] height_ptr pointer to the variable which will contain the detected
|
||||
* height value
|
||||
* @param[in] str the string to parse: it has to be a string in the format
|
||||
* width x height or a valid video size abbreviation.
|
||||
* @return >= 0 on success, a negative error code otherwise
|
||||
*/
|
||||
int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str);
|
||||
|
||||
/**
|
||||
* Parse str and store the detected values in *rate.
|
||||
*
|
||||
* @param[in,out] rate pointer to the AVRational which will contain the detected
|
||||
* frame rate
|
||||
* @param[in] str the string to parse: it has to be a string in the format
|
||||
* rate_num / rate_den, a float number or a valid video rate abbreviation
|
||||
* @return >= 0 on success, a negative error code otherwise
|
||||
*/
|
||||
int av_parse_video_rate(AVRational *rate, const char *str);
|
||||
|
||||
/**
|
||||
* Put the RGBA values that correspond to color_string in rgba_color.
|
||||
*
|
||||
* @param color_string a string specifying a color. It can be the name of
|
||||
* a color (case insensitive match) or a [0x|#]RRGGBB[AA] sequence,
|
||||
* possibly followed by "@" and a string representing the alpha
|
||||
* component.
|
||||
* The alpha component may be a string composed by "0x" followed by an
|
||||
* hexadecimal number or a decimal number between 0.0 and 1.0, which
|
||||
* represents the opacity value (0x00/0.0 means completely transparent,
|
||||
* 0xff/1.0 completely opaque).
|
||||
* If the alpha component is not specified then 0xff is assumed.
|
||||
* The string "random" will result in a random color.
|
||||
* @param slen length of the initial part of color_string containing the
|
||||
* color. It can be set to -1 if color_string is a null terminated string
|
||||
* containing nothing else than the color.
|
||||
* @return >= 0 in case of success, a negative value in case of
|
||||
* failure (for example if color_string cannot be parsed).
|
||||
*/
|
||||
int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen,
|
||||
void *log_ctx);
|
||||
|
||||
/**
|
||||
* Parse timestr and return in *time a corresponding number of
|
||||
* microseconds.
|
||||
*
|
||||
* @param timeval puts here the number of microseconds corresponding
|
||||
* to the string in timestr. If the string represents a duration, it
|
||||
* is the number of microseconds contained in the time interval. If
|
||||
* the string is a date, is the number of microseconds since 1st of
|
||||
* January, 1970 up to the time of the parsed date. If timestr cannot
|
||||
* be successfully parsed, set *time to INT64_MIN.
|
||||
|
||||
* @param timestr a string representing a date or a duration.
|
||||
* - If a date the syntax is:
|
||||
* @code
|
||||
* [{YYYY-MM-DD|YYYYMMDD}[T|t| ]]{{HH:MM:SS[.m...]]]}|{HHMMSS[.m...]]]}}[Z]
|
||||
* now
|
||||
* @endcode
|
||||
* If the value is "now" it takes the current time.
|
||||
* Time is local time unless Z is appended, in which case it is
|
||||
* interpreted as UTC.
|
||||
* If the year-month-day part is not specified it takes the current
|
||||
* year-month-day.
|
||||
* - If a duration the syntax is:
|
||||
* @code
|
||||
* [-][HH:]MM:SS[.m...]
|
||||
* [-]S+[.m...]
|
||||
* @endcode
|
||||
* @param duration flag which tells how to interpret timestr, if not
|
||||
* zero timestr is interpreted as a duration, otherwise as a date
|
||||
* @return 0 in case of success, a negative value corresponding to an
|
||||
* AVERROR code otherwise
|
||||
*/
|
||||
int av_parse_time(int64_t *timeval, const char *timestr, int duration);
|
||||
|
||||
/**
|
||||
* Parse the input string p according to the format string fmt and
|
||||
* store its results in the structure dt.
|
||||
* This implementation supports only a subset of the formats supported
|
||||
* by the standard strptime().
|
||||
*
|
||||
* In particular it actually supports the parameters:
|
||||
* - %H: the hour as a decimal number, using a 24-hour clock, in the
|
||||
* range '00' through '23'
|
||||
* - %J: hours as a decimal number, in the range '0' through INT_MAX
|
||||
* - %M: the minute as a decimal number, using a 24-hour clock, in the
|
||||
* range '00' through '59'
|
||||
* - %S: the second as a decimal number, using a 24-hour clock, in the
|
||||
* range '00' through '59'
|
||||
* - %Y: the year as a decimal number, using the Gregorian calendar
|
||||
* - %m: the month as a decimal number, in the range '1' through '12'
|
||||
* - %d: the day of the month as a decimal number, in the range '1'
|
||||
* through '31'
|
||||
* - %%: a literal '%'
|
||||
*
|
||||
* @return a pointer to the first character not processed in this
|
||||
* function call, or NULL in case the function fails to match all of
|
||||
* the fmt string and therefore an error occurred
|
||||
*/
|
||||
char *av_small_strptime(const char *p, const char *fmt, struct tm *dt);
|
||||
|
||||
/**
|
||||
* Attempt to find a specific tag in a URL.
|
||||
*
|
||||
* syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
|
||||
* Return 1 if found.
|
||||
*/
|
||||
int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
|
||||
|
||||
/**
|
||||
* Convert the decomposed UTC time in tm to a time_t value.
|
||||
*/
|
||||
time_t av_timegm(struct tm *tm);
|
||||
|
||||
#endif /* AVUTIL_PARSEUTILS_H */
|
|
@ -23,6 +23,7 @@
|
|||
#define AVUTIL_PIXDESC_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "pixfmt.h"
|
||||
|
||||
typedef struct AVComponentDescriptor{
|
||||
uint16_t plane :2; ///< which of the 4 planes contains the component
|
||||
|
@ -75,9 +76,12 @@ typedef struct AVPixFmtDescriptor{
|
|||
uint8_t flags;
|
||||
|
||||
/**
|
||||
* Parameters that describe how pixels are packed. If the format
|
||||
* has chroma components, they must be stored in comp[1] and
|
||||
* comp[2].
|
||||
* Parameters that describe how pixels are packed.
|
||||
* If the format has 2 or 4 components, then alpha is last.
|
||||
* If the format has 1 or 2 components, then luma is 0.
|
||||
* If the format has 3 or 4 components,
|
||||
* if the RGB flag is set then 0 is red, 1 is green and 2 is blue;
|
||||
* otherwise 0 is luma, 1 is chroma-U and 2 is chroma-V.
|
||||
*/
|
||||
AVComponentDescriptor comp[4];
|
||||
}AVPixFmtDescriptor;
|
||||
|
@ -86,11 +90,24 @@ typedef struct AVPixFmtDescriptor{
|
|||
#define PIX_FMT_PAL 2 ///< Pixel format has a palette in data[1], values are indexes in this palette.
|
||||
#define PIX_FMT_BITSTREAM 4 ///< All values of a component are bit-wise packed end to end.
|
||||
#define PIX_FMT_HWACCEL 8 ///< Pixel format is an HW accelerated format.
|
||||
#define PIX_FMT_PLANAR 16 ///< At least one pixel component is not in the first data plane
|
||||
#define PIX_FMT_RGB 32 ///< The pixel format contains RGB-like data (as opposed to YUV/grayscale)
|
||||
/**
|
||||
* The pixel format is "pseudo-paletted". This means that FFmpeg treats it as
|
||||
* paletted internally, but the palette is generated by the decoder and is not
|
||||
* stored in the file.
|
||||
*/
|
||||
#define PIX_FMT_PSEUDOPAL 64
|
||||
|
||||
#define PIX_FMT_ALPHA 128 ///< The pixel format has an alpha channel
|
||||
|
||||
|
||||
#if FF_API_PIX_FMT_DESC
|
||||
/**
|
||||
* The array of all the pixel format descriptors.
|
||||
*/
|
||||
extern const AVPixFmtDescriptor av_pix_fmt_descriptors[];
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Read a line from an image, and write the values of the
|
||||
|
@ -137,9 +154,29 @@ void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesi
|
|||
* For example in a little-endian system, first looks for "gray16",
|
||||
* then for "gray16le".
|
||||
*
|
||||
* Finally if no pixel format has been found, returns PIX_FMT_NONE.
|
||||
* Finally if no pixel format has been found, returns AV_PIX_FMT_NONE.
|
||||
*/
|
||||
enum PixelFormat av_get_pix_fmt(const char *name);
|
||||
enum AVPixelFormat av_get_pix_fmt(const char *name);
|
||||
|
||||
/**
|
||||
* Return the short name for a pixel format, NULL in case pix_fmt is
|
||||
* unknown.
|
||||
*
|
||||
* @see av_get_pix_fmt(), av_get_pix_fmt_string()
|
||||
*/
|
||||
const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt);
|
||||
|
||||
/**
|
||||
* Print in buf the string corresponding to the pixel format with
|
||||
* number pix_fmt, or an header if pix_fmt is negative.
|
||||
*
|
||||
* @param buf the buffer where to write the string
|
||||
* @param buf_size the size of buf
|
||||
* @param pix_fmt the number of the pixel format to print the
|
||||
* corresponding info string, or a negative value to print the
|
||||
* corresponding header.
|
||||
*/
|
||||
char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt);
|
||||
|
||||
/**
|
||||
* Return the number of bits per pixel used by the pixel format
|
||||
|
@ -151,4 +188,50 @@ enum PixelFormat av_get_pix_fmt(const char *name);
|
|||
*/
|
||||
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
|
||||
|
||||
/**
|
||||
* Return the number of bits per pixel for the pixel format
|
||||
* described by pixdesc, including any padding or unused bits.
|
||||
*/
|
||||
int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
|
||||
|
||||
/**
|
||||
* @return a pixel format descriptor for provided pixel format or NULL if
|
||||
* this pixel format is unknown.
|
||||
*/
|
||||
const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt);
|
||||
|
||||
/**
|
||||
* Iterate over all pixel format descriptors known to libavutil.
|
||||
*
|
||||
* @param prev previous descriptor. NULL to get the first descriptor.
|
||||
*
|
||||
* @return next descriptor or NULL after the last descriptor
|
||||
*/
|
||||
const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev);
|
||||
|
||||
/**
|
||||
* @return an AVPixelFormat id described by desc, or AV_PIX_FMT_NONE if desc
|
||||
* is not a valid pointer to a pixel format descriptor.
|
||||
*/
|
||||
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc);
|
||||
|
||||
/**
|
||||
* Utility function to access log2_chroma_w log2_chroma_h from
|
||||
* the pixel format AVPixFmtDescriptor.
|
||||
*
|
||||
* See avcodec_get_chroma_sub_sample() for a function that asserts a
|
||||
* valid pixel format instead of returning an error code.
|
||||
* Its recommanded that you use avcodec_get_chroma_sub_sample unless
|
||||
* you do check the return code!
|
||||
*
|
||||
* @param[in] pix_fmt the pixel format
|
||||
* @param[out] h_shift store log2_chroma_h
|
||||
* @param[out] v_shift store log2_chroma_w
|
||||
*
|
||||
* @return 0 on success, AVERROR(ENOSYS) on invalid or unknown pixel format
|
||||
*/
|
||||
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,
|
||||
int *h_shift, int *v_shift);
|
||||
|
||||
|
||||
#endif /* AVUTIL_PIXDESC_H */
|
||||
|
|
|
@ -25,21 +25,25 @@
|
|||
* @file
|
||||
* pixel format definitions
|
||||
*
|
||||
* @warning This file has to be considered an internal but installed
|
||||
* header, so it should not be directly included in your projects.
|
||||
*/
|
||||
|
||||
#include "libavutil/avconfig.h"
|
||||
#include "libavutil/version.h"
|
||||
|
||||
#define AVPALETTE_SIZE 1024
|
||||
#define AVPALETTE_COUNT 256
|
||||
|
||||
/**
|
||||
* Pixel format. Notes:
|
||||
* Pixel format.
|
||||
*
|
||||
* @note
|
||||
* PIX_FMT_RGB32 is handled in an endian-specific manner. An RGBA
|
||||
* color is put together as:
|
||||
* (A << 24) | (R << 16) | (G << 8) | B
|
||||
* This is stored as BGRA on little-endian CPU architectures and ARGB on
|
||||
* big-endian CPUs.
|
||||
*
|
||||
* @par
|
||||
* When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized
|
||||
* image data is stored in AVFrame.data[0]. The palette is transported in
|
||||
* AVFrame.data[1], is 1024 bytes long (256 4-byte entries) and is
|
||||
|
@ -49,115 +53,305 @@
|
|||
* This is important as many custom PAL8 video codecs that were designed
|
||||
* to run on the IBM VGA graphics adapter use 6-bit palette components.
|
||||
*
|
||||
* @par
|
||||
* For all the 8bit per pixel formats, an RGB32 palette is in data[1] like
|
||||
* for pal8. This palette is filled in automatically by the function
|
||||
* allocating the picture.
|
||||
*
|
||||
* Note, make sure that all newly added big endian formats have pix_fmt&1==1
|
||||
* and that all newly added little endian formats have pix_fmt&1==0
|
||||
* this allows simpler detection of big vs little endian.
|
||||
* @note
|
||||
* Make sure that all newly added big-endian formats have pix_fmt & 1 == 1
|
||||
* and that all newly added little-endian formats have pix_fmt & 1 == 0.
|
||||
* This allows simpler detection of big vs little-endian.
|
||||
*/
|
||||
enum PixelFormat {
|
||||
PIX_FMT_NONE= -1,
|
||||
PIX_FMT_YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
|
||||
PIX_FMT_YUYV422, ///< packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
|
||||
PIX_FMT_RGB24, ///< packed RGB 8:8:8, 24bpp, RGBRGB...
|
||||
PIX_FMT_BGR24, ///< packed RGB 8:8:8, 24bpp, BGRBGR...
|
||||
PIX_FMT_YUV422P, ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
|
||||
PIX_FMT_YUV444P, ///< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
|
||||
PIX_FMT_YUV410P, ///< planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
|
||||
PIX_FMT_YUV411P, ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
|
||||
PIX_FMT_GRAY8, ///< Y , 8bpp
|
||||
PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb
|
||||
PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb
|
||||
PIX_FMT_PAL8, ///< 8 bit with PIX_FMT_RGB32 palette
|
||||
PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range
|
||||
PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range
|
||||
PIX_FMT_YUVJ444P, ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range
|
||||
PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing
|
||||
PIX_FMT_XVMC_MPEG2_IDCT,
|
||||
PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
|
||||
PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
|
||||
PIX_FMT_BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
|
||||
PIX_FMT_BGR4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
|
||||
PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
|
||||
PIX_FMT_RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
|
||||
PIX_FMT_RGB4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
|
||||
PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
|
||||
PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)
|
||||
PIX_FMT_NV21, ///< as above, but U and V bytes are swapped
|
||||
enum AVPixelFormat {
|
||||
AV_PIX_FMT_NONE = -1,
|
||||
AV_PIX_FMT_YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
|
||||
AV_PIX_FMT_YUYV422, ///< packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
|
||||
AV_PIX_FMT_RGB24, ///< packed RGB 8:8:8, 24bpp, RGBRGB...
|
||||
AV_PIX_FMT_BGR24, ///< packed RGB 8:8:8, 24bpp, BGRBGR...
|
||||
AV_PIX_FMT_YUV422P, ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
|
||||
AV_PIX_FMT_YUV444P, ///< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
|
||||
AV_PIX_FMT_YUV410P, ///< planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
|
||||
AV_PIX_FMT_YUV411P, ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
|
||||
AV_PIX_FMT_GRAY8, ///< Y , 8bpp
|
||||
AV_PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb
|
||||
AV_PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb
|
||||
AV_PIX_FMT_PAL8, ///< 8 bit with PIX_FMT_RGB32 palette
|
||||
AV_PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range
|
||||
AV_PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range
|
||||
AV_PIX_FMT_YUVJ444P, ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range
|
||||
AV_PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing
|
||||
AV_PIX_FMT_XVMC_MPEG2_IDCT,
|
||||
AV_PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
|
||||
AV_PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
|
||||
AV_PIX_FMT_BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
|
||||
AV_PIX_FMT_BGR4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
|
||||
AV_PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
|
||||
AV_PIX_FMT_RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
|
||||
AV_PIX_FMT_RGB4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
|
||||
AV_PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
|
||||
AV_PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)
|
||||
AV_PIX_FMT_NV21, ///< as above, but U and V bytes are swapped
|
||||
|
||||
PIX_FMT_ARGB, ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
|
||||
PIX_FMT_RGBA, ///< packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
|
||||
PIX_FMT_ABGR, ///< packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
|
||||
PIX_FMT_BGRA, ///< packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
|
||||
AV_PIX_FMT_ARGB, ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
|
||||
AV_PIX_FMT_RGBA, ///< packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
|
||||
AV_PIX_FMT_ABGR, ///< packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
|
||||
AV_PIX_FMT_BGRA, ///< packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
|
||||
|
||||
PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endian
|
||||
PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endian
|
||||
PIX_FMT_YUV440P, ///< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
|
||||
PIX_FMT_YUVJ440P, ///< planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range
|
||||
PIX_FMT_YUVA420P, ///< planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
|
||||
PIX_FMT_VDPAU_H264,///< H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
PIX_FMT_VDPAU_MPEG1,///< MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
PIX_FMT_VDPAU_MPEG2,///< MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
PIX_FMT_VDPAU_WMV3,///< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
PIX_FMT_VDPAU_VC1, ///< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian
|
||||
PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian
|
||||
AV_PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endian
|
||||
AV_PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endian
|
||||
AV_PIX_FMT_YUV440P, ///< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
|
||||
AV_PIX_FMT_YUVJ440P, ///< planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range
|
||||
AV_PIX_FMT_YUVA420P, ///< planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
|
||||
AV_PIX_FMT_VDPAU_H264,///< H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
AV_PIX_FMT_VDPAU_MPEG1,///< MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
AV_PIX_FMT_VDPAU_MPEG2,///< MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
AV_PIX_FMT_VDPAU_WMV3,///< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
AV_PIX_FMT_VDPAU_VC1, ///< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
AV_PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian
|
||||
AV_PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian
|
||||
|
||||
PIX_FMT_RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
|
||||
PIX_FMT_RGB565LE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
|
||||
PIX_FMT_RGB555BE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0
|
||||
PIX_FMT_RGB555LE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0
|
||||
AV_PIX_FMT_RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
|
||||
AV_PIX_FMT_RGB565LE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
|
||||
AV_PIX_FMT_RGB555BE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0
|
||||
AV_PIX_FMT_RGB555LE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0
|
||||
|
||||
PIX_FMT_BGR565BE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
|
||||
PIX_FMT_BGR565LE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
|
||||
PIX_FMT_BGR555BE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1
|
||||
PIX_FMT_BGR555LE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1
|
||||
AV_PIX_FMT_BGR565BE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
|
||||
AV_PIX_FMT_BGR565LE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
|
||||
AV_PIX_FMT_BGR555BE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1
|
||||
AV_PIX_FMT_BGR555LE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1
|
||||
|
||||
PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers
|
||||
PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers
|
||||
PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
AV_PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers
|
||||
AV_PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers
|
||||
AV_PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
|
||||
PIX_FMT_YUV420P16LE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
|
||||
PIX_FMT_YUV420P16BE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
|
||||
PIX_FMT_YUV422P16LE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
|
||||
PIX_FMT_YUV422P16BE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
|
||||
PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
|
||||
PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
|
||||
PIX_FMT_VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer
|
||||
AV_PIX_FMT_YUV420P16LE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV420P16BE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV422P16LE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV422P16BE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
|
||||
AV_PIX_FMT_VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
|
||||
AV_PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer
|
||||
|
||||
PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0
|
||||
PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0
|
||||
PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1
|
||||
PIX_FMT_BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1
|
||||
PIX_FMT_Y400A, ///< 8bit gray, 8bit alpha
|
||||
PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
|
||||
AV_PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0
|
||||
AV_PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0
|
||||
AV_PIX_FMT_BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1
|
||||
AV_PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1
|
||||
AV_PIX_FMT_GRAY8A, ///< 8bit gray, 8bit alpha
|
||||
AV_PIX_FMT_BGR48BE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian
|
||||
AV_PIX_FMT_BGR48LE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian
|
||||
|
||||
//the following 10 formats have the disadvantage of needing 1 format for each bit depth, thus
|
||||
//If you want to support multiple bit depths, then using AV_PIX_FMT_YUV420P16* with the bpp stored separately
|
||||
//is better
|
||||
AV_PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV422P9BE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
|
||||
AV_PIX_FMT_VDA_VLD, ///< hardware decoding through VDA
|
||||
|
||||
#ifdef AV_PIX_FMT_ABI_GIT_MASTER
|
||||
AV_PIX_FMT_RGBA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
|
||||
AV_PIX_FMT_RGBA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
|
||||
AV_PIX_FMT_BGRA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
|
||||
AV_PIX_FMT_BGRA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
|
||||
#endif
|
||||
AV_PIX_FMT_GBRP, ///< planar GBR 4:4:4 24bpp
|
||||
AV_PIX_FMT_GBRP9BE, ///< planar GBR 4:4:4 27bpp, big-endian
|
||||
AV_PIX_FMT_GBRP9LE, ///< planar GBR 4:4:4 27bpp, little-endian
|
||||
AV_PIX_FMT_GBRP10BE, ///< planar GBR 4:4:4 30bpp, big-endian
|
||||
AV_PIX_FMT_GBRP10LE, ///< planar GBR 4:4:4 30bpp, little-endian
|
||||
AV_PIX_FMT_GBRP16BE, ///< planar GBR 4:4:4 48bpp, big-endian
|
||||
AV_PIX_FMT_GBRP16LE, ///< planar GBR 4:4:4 48bpp, little-endian
|
||||
|
||||
/**
|
||||
* duplicated pixel formats for compatibility with libav.
|
||||
* FFmpeg supports these formats since May 8 2012 and Jan 28 2012 (commits f9ca1ac7 and 143a5c55)
|
||||
* Libav added them Oct 12 2012 with incompatible values (commit 6d5600e85)
|
||||
*/
|
||||
AV_PIX_FMT_YUVA422P_LIBAV, ///< planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
|
||||
AV_PIX_FMT_YUVA444P_LIBAV, ///< planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
|
||||
|
||||
AV_PIX_FMT_YUVA420P9BE, ///< planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
|
||||
AV_PIX_FMT_YUVA420P9LE, ///< planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian
|
||||
AV_PIX_FMT_YUVA422P9BE, ///< planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
|
||||
AV_PIX_FMT_YUVA422P9LE, ///< planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
|
||||
AV_PIX_FMT_YUVA444P9BE, ///< planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
|
||||
AV_PIX_FMT_YUVA444P9LE, ///< planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
|
||||
AV_PIX_FMT_YUVA420P10BE, ///< planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
|
||||
AV_PIX_FMT_YUVA420P10LE, ///< planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
|
||||
AV_PIX_FMT_YUVA422P10BE, ///< planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
|
||||
AV_PIX_FMT_YUVA422P10LE, ///< planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
|
||||
AV_PIX_FMT_YUVA444P10BE, ///< planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
|
||||
AV_PIX_FMT_YUVA444P10LE, ///< planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
|
||||
AV_PIX_FMT_YUVA420P16BE, ///< planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
|
||||
AV_PIX_FMT_YUVA420P16LE, ///< planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
|
||||
AV_PIX_FMT_YUVA422P16BE, ///< planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
|
||||
AV_PIX_FMT_YUVA422P16LE, ///< planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
|
||||
AV_PIX_FMT_YUVA444P16BE, ///< planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
|
||||
AV_PIX_FMT_YUVA444P16LE, ///< planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
|
||||
|
||||
AV_PIX_FMT_VDPAU, ///< HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface
|
||||
|
||||
#ifndef AV_PIX_FMT_ABI_GIT_MASTER
|
||||
AV_PIX_FMT_RGBA64BE=0x123, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
|
||||
AV_PIX_FMT_RGBA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
|
||||
AV_PIX_FMT_BGRA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
|
||||
AV_PIX_FMT_BGRA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
|
||||
#endif
|
||||
AV_PIX_FMT_0RGB=0x123+4, ///< packed RGB 8:8:8, 32bpp, 0RGB0RGB...
|
||||
AV_PIX_FMT_RGB0, ///< packed RGB 8:8:8, 32bpp, RGB0RGB0...
|
||||
AV_PIX_FMT_0BGR, ///< packed BGR 8:8:8, 32bpp, 0BGR0BGR...
|
||||
AV_PIX_FMT_BGR0, ///< packed BGR 8:8:8, 32bpp, BGR0BGR0...
|
||||
AV_PIX_FMT_YUVA444P, ///< planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
|
||||
AV_PIX_FMT_YUVA422P, ///< planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
|
||||
|
||||
AV_PIX_FMT_YUV420P12BE, ///< planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV420P12LE, ///< planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV420P14BE, ///< planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV420P14LE, ///< planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV422P12BE, ///< planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV422P12LE, ///< planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV422P14BE, ///< planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV422P14LE, ///< planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV444P12BE, ///< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV444P12LE, ///< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV444P14BE, ///< planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV444P14LE, ///< planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
|
||||
AV_PIX_FMT_GBRP12BE, ///< planar GBR 4:4:4 36bpp, big-endian
|
||||
AV_PIX_FMT_GBRP12LE, ///< planar GBR 4:4:4 36bpp, little-endian
|
||||
AV_PIX_FMT_GBRP14BE, ///< planar GBR 4:4:4 42bpp, big-endian
|
||||
AV_PIX_FMT_GBRP14LE, ///< planar GBR 4:4:4 42bpp, little-endian
|
||||
AV_PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
|
||||
|
||||
#if FF_API_PIX_FMT
|
||||
#include "old_pix_fmts.h"
|
||||
#endif
|
||||
};
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
# define PIX_FMT_NE(be, le) PIX_FMT_##be
|
||||
#else
|
||||
# define PIX_FMT_NE(be, le) PIX_FMT_##le
|
||||
#if AV_HAVE_INCOMPATIBLE_FORK_ABI
|
||||
#define AV_PIX_FMT_YUVA422P AV_PIX_FMT_YUVA422P_LIBAV
|
||||
#define AV_PIX_FMT_YUVA444P AV_PIX_FMT_YUVA444P_LIBAV
|
||||
#endif
|
||||
|
||||
#define PIX_FMT_RGB32 PIX_FMT_NE(ARGB, BGRA)
|
||||
#define PIX_FMT_RGB32_1 PIX_FMT_NE(RGBA, ABGR)
|
||||
#define PIX_FMT_BGR32 PIX_FMT_NE(ABGR, RGBA)
|
||||
#define PIX_FMT_BGR32_1 PIX_FMT_NE(BGRA, ARGB)
|
||||
|
||||
#define PIX_FMT_GRAY16 PIX_FMT_NE(GRAY16BE, GRAY16LE)
|
||||
#define PIX_FMT_RGB48 PIX_FMT_NE(RGB48BE, RGB48LE)
|
||||
#define PIX_FMT_RGB565 PIX_FMT_NE(RGB565BE, RGB565LE)
|
||||
#define PIX_FMT_RGB555 PIX_FMT_NE(RGB555BE, RGB555LE)
|
||||
#define PIX_FMT_RGB444 PIX_FMT_NE(RGB444BE, RGB444LE)
|
||||
#define PIX_FMT_BGR565 PIX_FMT_NE(BGR565BE, BGR565LE)
|
||||
#define PIX_FMT_BGR555 PIX_FMT_NE(BGR555BE, BGR555LE)
|
||||
#define PIX_FMT_BGR444 PIX_FMT_NE(BGR444BE, BGR444LE)
|
||||
#define AV_PIX_FMT_Y400A AV_PIX_FMT_GRAY8A
|
||||
#define AV_PIX_FMT_GBR24P AV_PIX_FMT_GBRP
|
||||
|
||||
#define PIX_FMT_YUV420P16 PIX_FMT_NE(YUV420P16BE, YUV420P16LE)
|
||||
#define PIX_FMT_YUV422P16 PIX_FMT_NE(YUV422P16BE, YUV422P16LE)
|
||||
#define PIX_FMT_YUV444P16 PIX_FMT_NE(YUV444P16BE, YUV444P16LE)
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
# define AV_PIX_FMT_NE(be, le) AV_PIX_FMT_##be
|
||||
#else
|
||||
# define AV_PIX_FMT_NE(be, le) AV_PIX_FMT_##le
|
||||
#endif
|
||||
|
||||
#define AV_PIX_FMT_RGB32 AV_PIX_FMT_NE(ARGB, BGRA)
|
||||
#define AV_PIX_FMT_RGB32_1 AV_PIX_FMT_NE(RGBA, ABGR)
|
||||
#define AV_PIX_FMT_BGR32 AV_PIX_FMT_NE(ABGR, RGBA)
|
||||
#define AV_PIX_FMT_BGR32_1 AV_PIX_FMT_NE(BGRA, ARGB)
|
||||
#define AV_PIX_FMT_0RGB32 AV_PIX_FMT_NE(0RGB, BGR0)
|
||||
#define AV_PIX_FMT_0BGR32 AV_PIX_FMT_NE(0BGR, RGB0)
|
||||
|
||||
#define AV_PIX_FMT_GRAY16 AV_PIX_FMT_NE(GRAY16BE, GRAY16LE)
|
||||
#define AV_PIX_FMT_RGB48 AV_PIX_FMT_NE(RGB48BE, RGB48LE)
|
||||
#define AV_PIX_FMT_RGB565 AV_PIX_FMT_NE(RGB565BE, RGB565LE)
|
||||
#define AV_PIX_FMT_RGB555 AV_PIX_FMT_NE(RGB555BE, RGB555LE)
|
||||
#define AV_PIX_FMT_RGB444 AV_PIX_FMT_NE(RGB444BE, RGB444LE)
|
||||
#define AV_PIX_FMT_BGR48 AV_PIX_FMT_NE(BGR48BE, BGR48LE)
|
||||
#define AV_PIX_FMT_BGR565 AV_PIX_FMT_NE(BGR565BE, BGR565LE)
|
||||
#define AV_PIX_FMT_BGR555 AV_PIX_FMT_NE(BGR555BE, BGR555LE)
|
||||
#define AV_PIX_FMT_BGR444 AV_PIX_FMT_NE(BGR444BE, BGR444LE)
|
||||
|
||||
#define AV_PIX_FMT_YUV420P9 AV_PIX_FMT_NE(YUV420P9BE , YUV420P9LE)
|
||||
#define AV_PIX_FMT_YUV422P9 AV_PIX_FMT_NE(YUV422P9BE , YUV422P9LE)
|
||||
#define AV_PIX_FMT_YUV444P9 AV_PIX_FMT_NE(YUV444P9BE , YUV444P9LE)
|
||||
#define AV_PIX_FMT_YUV420P10 AV_PIX_FMT_NE(YUV420P10BE, YUV420P10LE)
|
||||
#define AV_PIX_FMT_YUV422P10 AV_PIX_FMT_NE(YUV422P10BE, YUV422P10LE)
|
||||
#define AV_PIX_FMT_YUV444P10 AV_PIX_FMT_NE(YUV444P10BE, YUV444P10LE)
|
||||
#define AV_PIX_FMT_YUV420P12 AV_PIX_FMT_NE(YUV420P12BE, YUV420P12LE)
|
||||
#define AV_PIX_FMT_YUV422P12 AV_PIX_FMT_NE(YUV422P12BE, YUV422P12LE)
|
||||
#define AV_PIX_FMT_YUV444P12 AV_PIX_FMT_NE(YUV444P12BE, YUV444P12LE)
|
||||
#define AV_PIX_FMT_YUV420P14 AV_PIX_FMT_NE(YUV420P14BE, YUV420P14LE)
|
||||
#define AV_PIX_FMT_YUV422P14 AV_PIX_FMT_NE(YUV422P14BE, YUV422P14LE)
|
||||
#define AV_PIX_FMT_YUV444P14 AV_PIX_FMT_NE(YUV444P14BE, YUV444P14LE)
|
||||
#define AV_PIX_FMT_YUV420P16 AV_PIX_FMT_NE(YUV420P16BE, YUV420P16LE)
|
||||
#define AV_PIX_FMT_YUV422P16 AV_PIX_FMT_NE(YUV422P16BE, YUV422P16LE)
|
||||
#define AV_PIX_FMT_YUV444P16 AV_PIX_FMT_NE(YUV444P16BE, YUV444P16LE)
|
||||
|
||||
#define AV_PIX_FMT_RGBA64 AV_PIX_FMT_NE(RGBA64BE, RGBA64LE)
|
||||
#define AV_PIX_FMT_BGRA64 AV_PIX_FMT_NE(BGRA64BE, BGRA64LE)
|
||||
#define AV_PIX_FMT_GBRP9 AV_PIX_FMT_NE(GBRP9BE , GBRP9LE)
|
||||
#define AV_PIX_FMT_GBRP10 AV_PIX_FMT_NE(GBRP10BE, GBRP10LE)
|
||||
#define AV_PIX_FMT_GBRP12 AV_PIX_FMT_NE(GBRP12BE, GBRP12LE)
|
||||
#define AV_PIX_FMT_GBRP14 AV_PIX_FMT_NE(GBRP14BE, GBRP14LE)
|
||||
#define AV_PIX_FMT_GBRP16 AV_PIX_FMT_NE(GBRP16BE, GBRP16LE)
|
||||
|
||||
#define AV_PIX_FMT_YUVA420P9 AV_PIX_FMT_NE(YUVA420P9BE , YUVA420P9LE)
|
||||
#define AV_PIX_FMT_YUVA422P9 AV_PIX_FMT_NE(YUVA422P9BE , YUVA422P9LE)
|
||||
#define AV_PIX_FMT_YUVA444P9 AV_PIX_FMT_NE(YUVA444P9BE , YUVA444P9LE)
|
||||
#define AV_PIX_FMT_YUVA420P10 AV_PIX_FMT_NE(YUVA420P10BE, YUVA420P10LE)
|
||||
#define AV_PIX_FMT_YUVA422P10 AV_PIX_FMT_NE(YUVA422P10BE, YUVA422P10LE)
|
||||
#define AV_PIX_FMT_YUVA444P10 AV_PIX_FMT_NE(YUVA444P10BE, YUVA444P10LE)
|
||||
#define AV_PIX_FMT_YUVA420P16 AV_PIX_FMT_NE(YUVA420P16BE, YUVA420P16LE)
|
||||
#define AV_PIX_FMT_YUVA422P16 AV_PIX_FMT_NE(YUVA422P16BE, YUVA422P16LE)
|
||||
#define AV_PIX_FMT_YUVA444P16 AV_PIX_FMT_NE(YUVA444P16BE, YUVA444P16LE)
|
||||
|
||||
#if FF_API_PIX_FMT
|
||||
#define PixelFormat AVPixelFormat
|
||||
|
||||
#define PIX_FMT_Y400A AV_PIX_FMT_Y400A
|
||||
#define PIX_FMT_GBR24P AV_PIX_FMT_GBR24P
|
||||
|
||||
#define PIX_FMT_NE(be, le) AV_PIX_FMT_NE(be, le)
|
||||
|
||||
#define PIX_FMT_RGB32 AV_PIX_FMT_RGB32
|
||||
#define PIX_FMT_RGB32_1 AV_PIX_FMT_RGB32_1
|
||||
#define PIX_FMT_BGR32 AV_PIX_FMT_BGR32
|
||||
#define PIX_FMT_BGR32_1 AV_PIX_FMT_BGR32_1
|
||||
#define PIX_FMT_0RGB32 AV_PIX_FMT_0RGB32
|
||||
#define PIX_FMT_0BGR32 AV_PIX_FMT_0BGR32
|
||||
|
||||
#define PIX_FMT_GRAY16 AV_PIX_FMT_GRAY16
|
||||
#define PIX_FMT_RGB48 AV_PIX_FMT_RGB48
|
||||
#define PIX_FMT_RGB565 AV_PIX_FMT_RGB565
|
||||
#define PIX_FMT_RGB555 AV_PIX_FMT_RGB555
|
||||
#define PIX_FMT_RGB444 AV_PIX_FMT_RGB444
|
||||
#define PIX_FMT_BGR48 AV_PIX_FMT_BGR48
|
||||
#define PIX_FMT_BGR565 AV_PIX_FMT_BGR565
|
||||
#define PIX_FMT_BGR555 AV_PIX_FMT_BGR555
|
||||
#define PIX_FMT_BGR444 AV_PIX_FMT_BGR444
|
||||
|
||||
#define PIX_FMT_YUV420P9 AV_PIX_FMT_YUV420P9
|
||||
#define PIX_FMT_YUV422P9 AV_PIX_FMT_YUV422P9
|
||||
#define PIX_FMT_YUV444P9 AV_PIX_FMT_YUV444P9
|
||||
#define PIX_FMT_YUV420P10 AV_PIX_FMT_YUV420P10
|
||||
#define PIX_FMT_YUV422P10 AV_PIX_FMT_YUV422P10
|
||||
#define PIX_FMT_YUV444P10 AV_PIX_FMT_YUV444P10
|
||||
#define PIX_FMT_YUV420P12 AV_PIX_FMT_YUV420P12
|
||||
#define PIX_FMT_YUV422P12 AV_PIX_FMT_YUV422P12
|
||||
#define PIX_FMT_YUV444P12 AV_PIX_FMT_YUV444P12
|
||||
#define PIX_FMT_YUV420P14 AV_PIX_FMT_YUV420P14
|
||||
#define PIX_FMT_YUV422P14 AV_PIX_FMT_YUV422P14
|
||||
#define PIX_FMT_YUV444P14 AV_PIX_FMT_YUV444P14
|
||||
#define PIX_FMT_YUV420P16 AV_PIX_FMT_YUV420P16
|
||||
#define PIX_FMT_YUV422P16 AV_PIX_FMT_YUV422P16
|
||||
#define PIX_FMT_YUV444P16 AV_PIX_FMT_YUV444P16
|
||||
|
||||
#define PIX_FMT_RGBA64 AV_PIX_FMT_RGBA64
|
||||
#define PIX_FMT_BGRA64 AV_PIX_FMT_BGRA64
|
||||
#define PIX_FMT_GBRP9 AV_PIX_FMT_GBRP9
|
||||
#define PIX_FMT_GBRP10 AV_PIX_FMT_GBRP10
|
||||
#define PIX_FMT_GBRP12 AV_PIX_FMT_GBRP12
|
||||
#define PIX_FMT_GBRP14 AV_PIX_FMT_GBRP14
|
||||
#define PIX_FMT_GBRP16 AV_PIX_FMT_GBRP16
|
||||
#endif
|
||||
|
||||
#endif /* AVUTIL_PIXFMT_H */
|
||||
|
|
|
@ -22,10 +22,22 @@
|
|||
#define AVUTIL_RANDOM_SEED_H
|
||||
|
||||
#include <stdint.h>
|
||||
/**
|
||||
* @addtogroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get a seed to use in conjunction with random functions.
|
||||
* This function tries to provide a good seed at a best effort bases.
|
||||
* Its possible to call this function multiple times if more bits are needed.
|
||||
* It can be quite slow, which is why it should only be used as seed for a faster
|
||||
* PRNG. The quality of the seed depends on the platform.
|
||||
*/
|
||||
uint32_t av_get_random_seed(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_RANDOM_SEED_H */
|
||||
|
|
|
@ -29,8 +29,14 @@
|
|||
#define AVUTIL_RATIONAL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include "attributes.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_math
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* rational number numerator/denominator
|
||||
*/
|
||||
|
@ -43,13 +49,16 @@ typedef struct AVRational{
|
|||
* Compare two rationals.
|
||||
* @param a first rational
|
||||
* @param b second rational
|
||||
* @return 0 if a==b, 1 if a>b and -1 if a<b
|
||||
* @return 0 if a==b, 1 if a>b, -1 if a<b, and INT_MIN if one of the
|
||||
* values is of the form 0/0
|
||||
*/
|
||||
static inline int av_cmp_q(AVRational a, AVRational b){
|
||||
const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den;
|
||||
|
||||
if(tmp) return (tmp>>63)|1;
|
||||
else return 0;
|
||||
if(tmp) return ((tmp ^ a.den ^ b.den)>>63)|1;
|
||||
else if(b.den && a.den) return 0;
|
||||
else if(a.num && b.num) return (a.num>>31) - (b.num>>31);
|
||||
else return INT_MIN;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,8 +114,21 @@ AVRational av_add_q(AVRational b, AVRational c) av_const;
|
|||
*/
|
||||
AVRational av_sub_q(AVRational b, AVRational c) av_const;
|
||||
|
||||
/**
|
||||
* Invert a rational.
|
||||
* @param q value
|
||||
* @return 1 / q
|
||||
*/
|
||||
static av_always_inline AVRational av_inv_q(AVRational q)
|
||||
{
|
||||
AVRational r = { q.den, q.num };
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a double precision floating point number to a rational.
|
||||
* inf is expressed as {1,0} or {-1,0} depending on the sign.
|
||||
*
|
||||
* @param d double to convert
|
||||
* @param max the maximum allowed numerator and denominator
|
||||
* @return (AVRational) d
|
||||
|
@ -126,4 +148,8 @@ int av_nearer_q(AVRational q, AVRational q1, AVRational q2);
|
|||
*/
|
||||
int av_find_nearest_q_idx(AVRational q, const AVRational* q_list);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_RATIONAL_H */
|
||||
|
|
|
@ -0,0 +1,243 @@
|
|||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_SAMPLEFMT_H
|
||||
#define AVUTIL_SAMPLEFMT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avutil.h"
|
||||
#include "attributes.h"
|
||||
|
||||
/**
|
||||
* Audio Sample Formats
|
||||
*
|
||||
* @par
|
||||
* The data described by the sample format is always in native-endian order.
|
||||
* Sample values can be expressed by native C types, hence the lack of a signed
|
||||
* 24-bit sample format even though it is a common raw audio data format.
|
||||
*
|
||||
* @par
|
||||
* The floating-point formats are based on full volume being in the range
|
||||
* [-1.0, 1.0]. Any values outside this range are beyond full volume level.
|
||||
*
|
||||
* @par
|
||||
* The data layout as used in av_samples_fill_arrays() and elsewhere in FFmpeg
|
||||
* (such as AVFrame in libavcodec) is as follows:
|
||||
*
|
||||
* For planar sample formats, each audio channel is in a separate data plane,
|
||||
* and linesize is the buffer size, in bytes, for a single plane. All data
|
||||
* planes must be the same size. For packed sample formats, only the first data
|
||||
* plane is used, and samples for each channel are interleaved. In this case,
|
||||
* linesize is the buffer size, in bytes, for the 1 plane.
|
||||
*/
|
||||
enum AVSampleFormat {
|
||||
AV_SAMPLE_FMT_NONE = -1,
|
||||
AV_SAMPLE_FMT_U8, ///< unsigned 8 bits
|
||||
AV_SAMPLE_FMT_S16, ///< signed 16 bits
|
||||
AV_SAMPLE_FMT_S32, ///< signed 32 bits
|
||||
AV_SAMPLE_FMT_FLT, ///< float
|
||||
AV_SAMPLE_FMT_DBL, ///< double
|
||||
|
||||
AV_SAMPLE_FMT_U8P, ///< unsigned 8 bits, planar
|
||||
AV_SAMPLE_FMT_S16P, ///< signed 16 bits, planar
|
||||
AV_SAMPLE_FMT_S32P, ///< signed 32 bits, planar
|
||||
AV_SAMPLE_FMT_FLTP, ///< float, planar
|
||||
AV_SAMPLE_FMT_DBLP, ///< double, planar
|
||||
|
||||
AV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if linking dynamically
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the name of sample_fmt, or NULL if sample_fmt is not
|
||||
* recognized.
|
||||
*/
|
||||
const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt);
|
||||
|
||||
/**
|
||||
* Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE
|
||||
* on error.
|
||||
*/
|
||||
enum AVSampleFormat av_get_sample_fmt(const char *name);
|
||||
|
||||
/**
|
||||
* Return the planar<->packed alternative form of the given sample format, or
|
||||
* AV_SAMPLE_FMT_NONE on error. If the passed sample_fmt is already in the
|
||||
* requested planar/packed format, the format returned is the same as the
|
||||
* input.
|
||||
*/
|
||||
enum AVSampleFormat av_get_alt_sample_fmt(enum AVSampleFormat sample_fmt, int planar);
|
||||
|
||||
/**
|
||||
* Get the packed alternative form of the given sample format.
|
||||
*
|
||||
* If the passed sample_fmt is already in packed format, the format returned is
|
||||
* the same as the input.
|
||||
*
|
||||
* @return the packed alternative form of the given sample format or
|
||||
AV_SAMPLE_FMT_NONE on error.
|
||||
*/
|
||||
enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt);
|
||||
|
||||
/**
|
||||
* Get the planar alternative form of the given sample format.
|
||||
*
|
||||
* If the passed sample_fmt is already in planar format, the format returned is
|
||||
* the same as the input.
|
||||
*
|
||||
* @return the planar alternative form of the given sample format or
|
||||
AV_SAMPLE_FMT_NONE on error.
|
||||
*/
|
||||
enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt);
|
||||
|
||||
/**
|
||||
* Generate a string corresponding to the sample format with
|
||||
* sample_fmt, or a header if sample_fmt is negative.
|
||||
*
|
||||
* @param buf the buffer where to write the string
|
||||
* @param buf_size the size of buf
|
||||
* @param sample_fmt the number of the sample format to print the
|
||||
* corresponding info string, or a negative value to print the
|
||||
* corresponding header.
|
||||
* @return the pointer to the filled buffer or NULL if sample_fmt is
|
||||
* unknown or in case of other errors
|
||||
*/
|
||||
char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt);
|
||||
|
||||
#if FF_API_GET_BITS_PER_SAMPLE_FMT
|
||||
/**
|
||||
* @deprecated Use av_get_bytes_per_sample() instead.
|
||||
*/
|
||||
attribute_deprecated
|
||||
int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return number of bytes per sample.
|
||||
*
|
||||
* @param sample_fmt the sample format
|
||||
* @return number of bytes per sample or zero if unknown for the given
|
||||
* sample format
|
||||
*/
|
||||
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt);
|
||||
|
||||
/**
|
||||
* Check if the sample format is planar.
|
||||
*
|
||||
* @param sample_fmt the sample format to inspect
|
||||
* @return 1 if the sample format is planar, 0 if it is interleaved
|
||||
*/
|
||||
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt);
|
||||
|
||||
/**
|
||||
* Get the required buffer size for the given audio parameters.
|
||||
*
|
||||
* @param[out] linesize calculated linesize, may be NULL
|
||||
* @param nb_channels the number of channels
|
||||
* @param nb_samples the number of samples in a single channel
|
||||
* @param sample_fmt the sample format
|
||||
* @param align buffer size alignment (0 = default, 1 = no alignment)
|
||||
* @return required buffer size, or negative error code on failure
|
||||
*/
|
||||
int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
|
||||
enum AVSampleFormat sample_fmt, int align);
|
||||
|
||||
/**
|
||||
* Fill plane data pointers and linesize for samples with sample
|
||||
* format sample_fmt.
|
||||
*
|
||||
* The audio_data array is filled with the pointers to the samples data planes:
|
||||
* for planar, set the start point of each channel's data within the buffer,
|
||||
* for packed, set the start point of the entire buffer only.
|
||||
*
|
||||
* The value pointed to by linesize is set to the aligned size of each
|
||||
* channel's data buffer for planar layout, or to the aligned size of the
|
||||
* buffer for all channels for packed layout.
|
||||
*
|
||||
* The buffer in buf must be big enough to contain all the samples
|
||||
* (use av_samples_get_buffer_size() to compute its minimum size),
|
||||
* otherwise the audio_data pointers will point to invalid data.
|
||||
*
|
||||
* @see enum AVSampleFormat
|
||||
* The documentation for AVSampleFormat describes the data layout.
|
||||
*
|
||||
* @param[out] audio_data array to be filled with the pointer for each channel
|
||||
* @param[out] linesize calculated linesize, may be NULL
|
||||
* @param buf the pointer to a buffer containing the samples
|
||||
* @param nb_channels the number of channels
|
||||
* @param nb_samples the number of samples in a single channel
|
||||
* @param sample_fmt the sample format
|
||||
* @param align buffer size alignment (0 = default, 1 = no alignment)
|
||||
* @return >=0 on success or a negative error code on failure
|
||||
* @todo return minimum size in bytes required for the buffer in case
|
||||
* of success at the next bump
|
||||
*/
|
||||
int av_samples_fill_arrays(uint8_t **audio_data, int *linesize,
|
||||
const uint8_t *buf,
|
||||
int nb_channels, int nb_samples,
|
||||
enum AVSampleFormat sample_fmt, int align);
|
||||
|
||||
/**
|
||||
* Allocate a samples buffer for nb_samples samples, and fill data pointers and
|
||||
* linesize accordingly.
|
||||
* The allocated samples buffer can be freed by using av_freep(&audio_data[0])
|
||||
* Allocated data will be initialized to silence.
|
||||
*
|
||||
* @see enum AVSampleFormat
|
||||
* The documentation for AVSampleFormat describes the data layout.
|
||||
*
|
||||
* @param[out] audio_data array to be filled with the pointer for each channel
|
||||
* @param[out] linesize aligned size for audio buffer(s), may be NULL
|
||||
* @param nb_channels number of audio channels
|
||||
* @param nb_samples number of samples per channel
|
||||
* @param align buffer size alignment (0 = default, 1 = no alignment)
|
||||
* @return >=0 on success or a negative error code on failure
|
||||
* @todo return the size of the allocated buffer in case of success at the next bump
|
||||
* @see av_samples_fill_arrays()
|
||||
*/
|
||||
int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels,
|
||||
int nb_samples, enum AVSampleFormat sample_fmt, int align);
|
||||
|
||||
/**
|
||||
* Copy samples from src to dst.
|
||||
*
|
||||
* @param dst destination array of pointers to data planes
|
||||
* @param src source array of pointers to data planes
|
||||
* @param dst_offset offset in samples at which the data will be written to dst
|
||||
* @param src_offset offset in samples at which the data will be read from src
|
||||
* @param nb_samples number of samples to be copied
|
||||
* @param nb_channels number of audio channels
|
||||
* @param sample_fmt audio sample format
|
||||
*/
|
||||
int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset,
|
||||
int src_offset, int nb_samples, int nb_channels,
|
||||
enum AVSampleFormat sample_fmt);
|
||||
|
||||
/**
|
||||
* Fill an audio buffer with silence.
|
||||
*
|
||||
* @param audio_data array of pointers to data planes
|
||||
* @param offset offset in samples at which to start filling
|
||||
* @param nb_samples number of samples to fill
|
||||
* @param nb_channels number of audio channels
|
||||
* @param sample_fmt audio sample format
|
||||
*/
|
||||
int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples,
|
||||
int nb_channels, enum AVSampleFormat sample_fmt);
|
||||
|
||||
#endif /* AVUTIL_SAMPLEFMT_H */
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright (C) 2007 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_SHA_H
|
||||
#define AVUTIL_SHA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
* @defgroup lavu_sha SHA
|
||||
* @ingroup lavu_crypto
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern const int av_sha_size;
|
||||
|
||||
struct AVSHA;
|
||||
|
||||
/**
|
||||
* Allocate an AVSHA context.
|
||||
*/
|
||||
struct AVSHA *av_sha_alloc(void);
|
||||
|
||||
/**
|
||||
* Initialize SHA-1 or SHA-2 hashing.
|
||||
*
|
||||
* @param context pointer to the function context (of size av_sha_size)
|
||||
* @param bits number of bits in digest (SHA-1 - 160 bits, SHA-2 224 or 256 bits)
|
||||
* @return zero if initialization succeeded, -1 otherwise
|
||||
*/
|
||||
int av_sha_init(struct AVSHA* context, int bits);
|
||||
|
||||
/**
|
||||
* Update hash value.
|
||||
*
|
||||
* @param context hash function context
|
||||
* @param data input data to update hash with
|
||||
* @param len input data length
|
||||
*/
|
||||
void av_sha_update(struct AVSHA* context, const uint8_t* data, unsigned int len);
|
||||
|
||||
/**
|
||||
* Finish hashing and output digest value.
|
||||
*
|
||||
* @param context hash function context
|
||||
* @param digest buffer where output digest value is stored
|
||||
*/
|
||||
void av_sha_final(struct AVSHA* context, uint8_t *digest);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_SHA_H */
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2000-2003 Fabrice Bellard
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_TIME_H
|
||||
#define AVUTIL_TIME_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* Get the current time in microseconds.
|
||||
*/
|
||||
int64_t av_gettime(void);
|
||||
|
||||
/**
|
||||
* Sleep for a period of time. Although the duration is expressed in
|
||||
* microseconds, the actual delay may be rounded to the precision of the
|
||||
* system timer.
|
||||
*
|
||||
* @param usec Number of microseconds to sleep.
|
||||
* @return zero on success or (negative) error code.
|
||||
*/
|
||||
int av_usleep(unsigned usec);
|
||||
|
||||
#endif /* AVUTIL_TIME_H */
|
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
* Copyright (c) 2006 Smartjog S.A.S, Baptiste Coudurier <baptiste.coudurier@gmail.com>
|
||||
* Copyright (c) 2011-2012 Smartjog S.A.S, Clément Bœsch <clement.boesch@smartjog.com>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Timecode helpers header
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_TIMECODE_H
|
||||
#define AVUTIL_TIMECODE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "rational.h"
|
||||
|
||||
#define AV_TIMECODE_STR_SIZE 16
|
||||
|
||||
enum AVTimecodeFlag {
|
||||
AV_TIMECODE_FLAG_DROPFRAME = 1<<0, ///< timecode is drop frame
|
||||
AV_TIMECODE_FLAG_24HOURSMAX = 1<<1, ///< timecode wraps after 24 hours
|
||||
AV_TIMECODE_FLAG_ALLOWNEGATIVE = 1<<2, ///< negative time values are allowed
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int start; ///< timecode frame start (first base frame number)
|
||||
uint32_t flags; ///< flags such as drop frame, +24 hours support, ...
|
||||
AVRational rate; ///< frame rate in rational form
|
||||
unsigned fps; ///< frame per second; must be consistent with the rate field
|
||||
} AVTimecode;
|
||||
|
||||
/**
|
||||
* Adjust frame number for NTSC drop frame time code.
|
||||
*
|
||||
* @param framenum frame number to adjust
|
||||
* @param fps frame per second, 30 or 60
|
||||
* @return adjusted frame number
|
||||
* @warning adjustment is only valid in NTSC 29.97 and 59.94
|
||||
*/
|
||||
int av_timecode_adjust_ntsc_framenum2(int framenum, int fps);
|
||||
|
||||
/**
|
||||
* Convert frame number to SMPTE 12M binary representation.
|
||||
*
|
||||
* @param tc timecode data correctly initialized
|
||||
* @param framenum frame number
|
||||
* @return the SMPTE binary representation
|
||||
*
|
||||
* @note Frame number adjustment is automatically done in case of drop timecode,
|
||||
* you do NOT have to call av_timecode_adjust_ntsc_framenum2().
|
||||
* @note The frame number is relative to tc->start.
|
||||
* @note Color frame (CF), binary group flags (BGF) and biphase mark polarity
|
||||
* correction (PC) bits are set to zero.
|
||||
*/
|
||||
uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum);
|
||||
|
||||
/**
|
||||
* Load timecode string in buf.
|
||||
*
|
||||
* @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
|
||||
* @param tc timecode data correctly initialized
|
||||
* @param framenum frame number
|
||||
* @return the buf parameter
|
||||
*
|
||||
* @note Timecode representation can be a negative timecode and have more than
|
||||
* 24 hours, but will only be honored if the flags are correctly set.
|
||||
* @note The frame number is relative to tc->start.
|
||||
*/
|
||||
char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum);
|
||||
|
||||
/**
|
||||
* Get the timecode string from the SMPTE timecode format.
|
||||
*
|
||||
* @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
|
||||
* @param tcsmpte the 32-bit SMPTE timecode
|
||||
* @param prevent_df prevent the use of a drop flag when it is known the DF bit
|
||||
* is arbitrary
|
||||
* @return the buf parameter
|
||||
*/
|
||||
char *av_timecode_make_smpte_tc_string(char *buf, uint32_t tcsmpte, int prevent_df);
|
||||
|
||||
/**
|
||||
* Get the timecode string from the 25-bit timecode format (MPEG GOP format).
|
||||
*
|
||||
* @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
|
||||
* @param tc25bit the 25-bits timecode
|
||||
* @return the buf parameter
|
||||
*/
|
||||
char *av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit);
|
||||
|
||||
/**
|
||||
* Init a timecode struct with the passed parameters.
|
||||
*
|
||||
* @param log_ctx a pointer to an arbitrary struct of which the first field
|
||||
* is a pointer to an AVClass struct (used for av_log)
|
||||
* @param tc pointer to an allocated AVTimecode
|
||||
* @param rate frame rate in rational form
|
||||
* @param flags miscellaneous flags such as drop frame, +24 hours, ...
|
||||
* (see AVTimecodeFlag)
|
||||
* @param frame_start the first frame number
|
||||
* @return 0 on success, AVERROR otherwise
|
||||
*/
|
||||
int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx);
|
||||
|
||||
/**
|
||||
* Parse timecode representation (hh:mm:ss[:;.]ff).
|
||||
*
|
||||
* @param log_ctx a pointer to an arbitrary struct of which the first field is a
|
||||
* pointer to an AVClass struct (used for av_log).
|
||||
* @param tc pointer to an allocated AVTimecode
|
||||
* @param rate frame rate in rational form
|
||||
* @param str timecode string which will determine the frame start
|
||||
* @return 0 on success, AVERROR otherwise
|
||||
*/
|
||||
int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx);
|
||||
|
||||
/**
|
||||
* Check if the timecode feature is available for the given frame rate
|
||||
*
|
||||
* @return 0 if supported, <0 otherwise
|
||||
*/
|
||||
int av_timecode_check_frame_rate(AVRational rate);
|
||||
|
||||
#endif /* AVUTIL_TIMECODE_H */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue