mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-25 00:04:49 +02:00
Remove atomics stuff, a lot more
This commit is contained in:
@@ -386,7 +386,6 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\ext\at3_standalone\at3_decoders.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\atomic.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\atrac.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\atrac3data.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\atrac3plus.h" />
|
||||
@@ -396,7 +395,6 @@
|
||||
<ClInclude Include="..\ext\at3_standalone\avfft.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\avstring.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\avutil.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\bprint.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\bswap.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\buffer.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\buffer_internal.h" />
|
||||
@@ -424,8 +422,6 @@
|
||||
<ClInclude Include="..\ext\at3_standalone\mem.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\opt.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\options_table.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\pixdesc.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\pixfmt.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\rational.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\samplefmt.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\sinewin.h" />
|
||||
@@ -630,7 +626,6 @@
|
||||
<ClInclude Include="x64Emitter.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\ext\at3_standalone\atomic.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\atrac.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\atrac3.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\atrac3plus.c" />
|
||||
@@ -641,16 +636,13 @@
|
||||
<ClCompile Include="..\ext\at3_standalone\avstring.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\av_buffer.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\bitstream.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\bprint.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\channel_layout.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\codec_desc.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\dict.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\fft_template.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\float_dsp.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\frame.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\intmath.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\mathematics.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\mathops.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\mdct_template.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\mem.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\opt.c" />
|
||||
|
||||
@@ -590,9 +590,6 @@
|
||||
<ClInclude Include="..\ext\at3_standalone\samplefmt.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\pixfmt.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\buffer.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
@@ -620,9 +617,6 @@
|
||||
<ClInclude Include="..\ext\at3_standalone\util_internal.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\pixdesc.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\mem.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
@@ -644,15 +638,9 @@
|
||||
<ClInclude Include="..\ext\at3_standalone\buffer_internal.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\atomic.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\intmath.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\bprint.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\avstring.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
@@ -1137,9 +1125,6 @@
|
||||
<ClCompile Include="..\ext\at3_standalone\avfft.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\at3_standalone\mathops.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="compat.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
@@ -1167,9 +1152,6 @@
|
||||
<ClCompile Include="..\ext\at3_standalone\dict.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\at3_standalone\atomic.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\at3_standalone\utils.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
@@ -1191,12 +1173,6 @@
|
||||
<ClCompile Include="..\ext\at3_standalone\avstring.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\at3_standalone\bprint.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\at3_standalone\codec_desc.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\at3_standalone\fft_template.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Ronald S. Bultje <rsbultje@gmail.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
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "atomic.h"
|
||||
|
||||
#if !HAVE_ATOMICS_NATIVE
|
||||
|
||||
#if HAVE_PTHREADS
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
static pthread_mutex_t atomic_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
int avpriv_atomic_int_get(volatile int *ptr)
|
||||
{
|
||||
int res;
|
||||
|
||||
pthread_mutex_lock(&atomic_lock);
|
||||
res = *ptr;
|
||||
pthread_mutex_unlock(&atomic_lock);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void avpriv_atomic_int_set(volatile int *ptr, int val)
|
||||
{
|
||||
pthread_mutex_lock(&atomic_lock);
|
||||
*ptr = val;
|
||||
pthread_mutex_unlock(&atomic_lock);
|
||||
}
|
||||
|
||||
int avpriv_atomic_int_add_and_fetch(volatile int *ptr, int inc)
|
||||
{
|
||||
int res;
|
||||
|
||||
pthread_mutex_lock(&atomic_lock);
|
||||
*ptr += inc;
|
||||
res = *ptr;
|
||||
pthread_mutex_unlock(&atomic_lock);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void *avpriv_atomic_ptr_cas(void * volatile *ptr, void *oldval, void *newval)
|
||||
{
|
||||
void *ret;
|
||||
pthread_mutex_lock(&atomic_lock);
|
||||
ret = *ptr;
|
||||
if (ret == oldval)
|
||||
*ptr = newval;
|
||||
pthread_mutex_unlock(&atomic_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#elif !HAVE_THREADS
|
||||
|
||||
int avpriv_atomic_int_get(volatile int *ptr)
|
||||
{
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
void avpriv_atomic_int_set(volatile int *ptr, int val)
|
||||
{
|
||||
*ptr = val;
|
||||
}
|
||||
|
||||
int avpriv_atomic_int_add_and_fetch(volatile int *ptr, int inc)
|
||||
{
|
||||
*ptr += inc;
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
void *avpriv_atomic_ptr_cas(void * volatile *ptr, void *oldval, void *newval)
|
||||
{
|
||||
if (*ptr == oldval) {
|
||||
*ptr = newval;
|
||||
return oldval;
|
||||
}
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
#else /* HAVE_THREADS */
|
||||
|
||||
/* This should never trigger, unless a new threading implementation
|
||||
* without correct atomics dependencies in configure or a corresponding
|
||||
* atomics implementation is added. */
|
||||
#error "Threading is enabled, but there is no implementation of atomic operations available"
|
||||
|
||||
#endif /* HAVE_PTHREADS */
|
||||
|
||||
#endif /* !HAVE_ATOMICS_NATIVE */
|
||||
|
||||
#ifdef TEST
|
||||
#include "avassert.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
volatile int val = 1;
|
||||
int res;
|
||||
|
||||
res = avpriv_atomic_int_add_and_fetch(&val, 1);
|
||||
av_assert0(res == 2);
|
||||
avpriv_atomic_int_set(&val, 3);
|
||||
res = avpriv_atomic_int_get(&val);
|
||||
av_assert0(res == 3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012 Ronald S. Bultje <rsbultje@gmail.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
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_ATOMIC_H
|
||||
#define AVUTIL_ATOMIC_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_ATOMICS_NATIVE
|
||||
|
||||
#if HAVE_ATOMICS_GCC
|
||||
#include "atomic_gcc.h"
|
||||
#elif HAVE_ATOMICS_WIN32
|
||||
#include "atomic_win32.h"
|
||||
#elif HAVE_ATOMICS_SUNCC
|
||||
#include "atomic_suncc.h"
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Load the current value stored in an atomic integer.
|
||||
*
|
||||
* @param ptr atomic integer
|
||||
* @return the current value of the atomic integer
|
||||
* @note This acts as a memory barrier.
|
||||
*/
|
||||
int avpriv_atomic_int_get(volatile int *ptr);
|
||||
|
||||
/**
|
||||
* Store a new value in an atomic integer.
|
||||
*
|
||||
* @param ptr atomic integer
|
||||
* @param val the value to store in the atomic integer
|
||||
* @note This acts as a memory barrier.
|
||||
*/
|
||||
void avpriv_atomic_int_set(volatile int *ptr, int val);
|
||||
|
||||
/**
|
||||
* Add a value to an atomic integer.
|
||||
*
|
||||
* @param ptr atomic integer
|
||||
* @param inc the value to add to the atomic integer (may be negative)
|
||||
* @return the new value of the atomic integer.
|
||||
* @note This does NOT act as a memory barrier. This is primarily
|
||||
* intended for reference counting.
|
||||
*/
|
||||
int avpriv_atomic_int_add_and_fetch(volatile int *ptr, int inc);
|
||||
|
||||
/**
|
||||
* Atomic pointer compare and swap.
|
||||
*
|
||||
* @param ptr pointer to the pointer to operate on
|
||||
* @param oldval do the swap if the current value of *ptr equals to oldval
|
||||
* @param newval value to replace *ptr with
|
||||
* @return the value of *ptr before comparison
|
||||
*/
|
||||
void *avpriv_atomic_ptr_cas(void * volatile *ptr, void *oldval, void *newval);
|
||||
|
||||
#endif /* HAVE_ATOMICS_NATIVE */
|
||||
|
||||
#endif /* AVUTIL_ATOMIC_H */
|
||||
@@ -98,7 +98,7 @@ AVBufferRef *av_buffer_ref(AVBufferRef *buf)
|
||||
|
||||
*ret = *buf;
|
||||
|
||||
avpriv_atomic_int_add_and_fetch(&buf->buffer->refcount, 1);
|
||||
buf->buffer->refcount++;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -115,10 +115,9 @@ static void buffer_replace(AVBufferRef **dst, AVBufferRef **src)
|
||||
} else
|
||||
av_freep(dst);
|
||||
|
||||
if (!avpriv_atomic_int_add_and_fetch(&b->refcount, -1)) {
|
||||
b->free(b->opaque, b->data);
|
||||
av_freep(&b);
|
||||
}
|
||||
b->refcount--;
|
||||
b->free(b->opaque, b->data);
|
||||
av_freep(&b);
|
||||
}
|
||||
|
||||
void av_buffer_unref(AVBufferRef **buf)
|
||||
@@ -134,7 +133,7 @@ int av_buffer_is_writable(const AVBufferRef *buf)
|
||||
if (buf->buffer->flags & AV_BUFFER_FLAG_READONLY)
|
||||
return 0;
|
||||
|
||||
return avpriv_atomic_int_get(&buf->buffer->refcount) == 1;
|
||||
return buf->buffer->refcount == 1;
|
||||
}
|
||||
|
||||
void *av_buffer_get_opaque(const AVBufferRef *buf)
|
||||
@@ -223,7 +222,7 @@ AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size))
|
||||
pool->size = size;
|
||||
pool->alloc = alloc ? alloc : av_buffer_alloc;
|
||||
|
||||
avpriv_atomic_int_set(&pool->refcount, 1);
|
||||
pool->refcount = 1;
|
||||
|
||||
return pool;
|
||||
}
|
||||
@@ -253,61 +252,21 @@ void av_buffer_pool_uninit(AVBufferPool **ppool)
|
||||
pool = *ppool;
|
||||
*ppool = NULL;
|
||||
|
||||
if (!avpriv_atomic_int_add_and_fetch(&pool->refcount, -1))
|
||||
pool->refcount--;
|
||||
if (!pool->refcount)
|
||||
buffer_pool_free(pool);
|
||||
}
|
||||
|
||||
#if USE_ATOMICS
|
||||
/* remove the whole buffer list from the pool and return it */
|
||||
static BufferPoolEntry *get_pool(AVBufferPool *pool)
|
||||
{
|
||||
BufferPoolEntry *cur = *(void * volatile *)&pool->pool, *last = NULL;
|
||||
|
||||
while (cur != last) {
|
||||
last = cur;
|
||||
cur = avpriv_atomic_ptr_cas((void * volatile *)&pool->pool, last, NULL);
|
||||
if (!cur)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return cur;
|
||||
}
|
||||
|
||||
static void add_to_pool(BufferPoolEntry *buf)
|
||||
{
|
||||
AVBufferPool *pool;
|
||||
BufferPoolEntry *cur, *end = buf;
|
||||
|
||||
if (!buf)
|
||||
return;
|
||||
pool = buf->pool;
|
||||
|
||||
while (end->next)
|
||||
end = end->next;
|
||||
|
||||
while (avpriv_atomic_ptr_cas((void * volatile *)&pool->pool, NULL, buf)) {
|
||||
/* pool is not empty, retrieve it and append it to our list */
|
||||
cur = get_pool(pool);
|
||||
end->next = cur;
|
||||
while (end->next)
|
||||
end = end->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void pool_release_buffer(void *opaque, uint8_t *data)
|
||||
{
|
||||
BufferPoolEntry *buf = opaque;
|
||||
AVBufferPool *pool = buf->pool;
|
||||
|
||||
#if USE_ATOMICS
|
||||
add_to_pool(buf);
|
||||
#else
|
||||
buf->next = pool->pool;
|
||||
pool->pool = buf;
|
||||
#endif
|
||||
|
||||
if (!avpriv_atomic_int_add_and_fetch(&pool->refcount, -1))
|
||||
pool->refcount--;
|
||||
if (!pool->refcount)
|
||||
buffer_pool_free(pool);
|
||||
}
|
||||
|
||||
@@ -336,11 +295,6 @@ static AVBufferRef *pool_alloc_buffer(AVBufferPool *pool)
|
||||
ret->buffer->opaque = buf;
|
||||
ret->buffer->free = pool_release_buffer;
|
||||
|
||||
#if USE_ATOMICS
|
||||
avpriv_atomic_int_add_and_fetch(&pool->refcount, 1);
|
||||
avpriv_atomic_int_add_and_fetch(&pool->nb_allocated, 1);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -349,29 +303,6 @@ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool)
|
||||
AVBufferRef *ret;
|
||||
BufferPoolEntry *buf;
|
||||
|
||||
#if USE_ATOMICS
|
||||
/* check whether the pool is empty */
|
||||
buf = get_pool(pool);
|
||||
if (!buf && pool->refcount <= pool->nb_allocated) {
|
||||
av_log(NULL, AV_LOG_DEBUG, "Pool race dectected, spining to avoid overallocation and eventual OOM\n");
|
||||
while (!buf && avpriv_atomic_int_get(&pool->refcount) <= avpriv_atomic_int_get(&pool->nb_allocated))
|
||||
buf = get_pool(pool);
|
||||
}
|
||||
|
||||
if (!buf)
|
||||
return pool_alloc_buffer(pool);
|
||||
|
||||
/* keep the first entry, return the rest of the list to the pool */
|
||||
add_to_pool(buf->next);
|
||||
buf->next = NULL;
|
||||
|
||||
ret = av_buffer_create(buf->data, pool->size, pool_release_buffer,
|
||||
buf, 0);
|
||||
if (!ret) {
|
||||
add_to_pool(buf);
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
buf = pool->pool;
|
||||
if (buf) {
|
||||
ret = av_buffer_create(buf->data, pool->size, pool_release_buffer,
|
||||
@@ -383,10 +314,9 @@ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool)
|
||||
} else {
|
||||
ret = pool_alloc_buffer(pool);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ret)
|
||||
avpriv_atomic_int_add_and_fetch(&pool->refcount, 1);
|
||||
if (ret)
|
||||
pool->refcount++;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,36 +21,6 @@
|
||||
#include "fft.h"
|
||||
#include "mem.h"
|
||||
|
||||
/* FFT */
|
||||
|
||||
FFTContext *av_fft_init(int nbits, int inverse)
|
||||
{
|
||||
FFTContext *s = av_mallocz(sizeof(*s));
|
||||
|
||||
if (s && ff_fft_init(s, nbits, inverse))
|
||||
av_freep(&s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void av_fft_permute(FFTContext *s, FFTComplex *z)
|
||||
{
|
||||
s->fft_permute(s, z);
|
||||
}
|
||||
|
||||
void av_fft_calc(FFTContext *s, FFTComplex *z)
|
||||
{
|
||||
s->fft_calc(s, z);
|
||||
}
|
||||
|
||||
av_cold void av_fft_end(FFTContext *s)
|
||||
{
|
||||
if (s) {
|
||||
ff_fft_end(s);
|
||||
av_free(s);
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_MDCT
|
||||
|
||||
FFTContext *av_mdct_init(int nbits, int inverse, double scale)
|
||||
|
||||
@@ -43,8 +43,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
pkt->flags = 0;
|
||||
pkt->stream_index = 0;
|
||||
pkt->buf = NULL;
|
||||
pkt->side_data = NULL;
|
||||
pkt->side_data_elems = 0;
|
||||
}
|
||||
|
||||
AVPacket *av_packet_alloc(void)
|
||||
@@ -97,42 +95,6 @@ int av_new_packet(AVPacket *pkt, int size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void av_shrink_packet(AVPacket *pkt, int size)
|
||||
{
|
||||
if (pkt->size <= size)
|
||||
return;
|
||||
pkt->size = size;
|
||||
memset(pkt->data + size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
}
|
||||
|
||||
int av_grow_packet(AVPacket *pkt, int grow_by)
|
||||
{
|
||||
int new_size;
|
||||
av_assert0((unsigned)pkt->size <= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!pkt->size)
|
||||
return av_new_packet(pkt, grow_by);
|
||||
if ((unsigned)grow_by >
|
||||
INT_MAX - (pkt->size + AV_INPUT_BUFFER_PADDING_SIZE))
|
||||
return -1;
|
||||
|
||||
new_size = pkt->size + grow_by + AV_INPUT_BUFFER_PADDING_SIZE;
|
||||
if (pkt->buf) {
|
||||
int ret = av_buffer_realloc(&pkt->buf, new_size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else {
|
||||
pkt->buf = av_buffer_alloc(new_size);
|
||||
if (!pkt->buf)
|
||||
return AVERROR(ENOMEM);
|
||||
memcpy(pkt->buf->data, pkt->data, FFMIN(pkt->size, pkt->size + grow_by));
|
||||
}
|
||||
pkt->data = pkt->buf->data;
|
||||
pkt->size += grow_by;
|
||||
memset(pkt->data + pkt->size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size)
|
||||
{
|
||||
if (size >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
|
||||
@@ -182,7 +144,6 @@ do { \
|
||||
static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
|
||||
{
|
||||
pkt->data = NULL;
|
||||
pkt->side_data = NULL;
|
||||
if (pkt->buf) {
|
||||
AVBufferRef *ref = av_buffer_ref(src->buf);
|
||||
if (!ref)
|
||||
@@ -192,11 +153,6 @@ static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
|
||||
} else {
|
||||
DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF);
|
||||
}
|
||||
if (pkt->side_data_elems && dup)
|
||||
pkt->side_data = src->side_data;
|
||||
if (pkt->side_data_elems && !dup) {
|
||||
return av_copy_packet_side_data(pkt, src);
|
||||
}
|
||||
return 0;
|
||||
|
||||
failed_alloc:
|
||||
@@ -204,30 +160,6 @@ failed_alloc:
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src)
|
||||
{
|
||||
if (src->side_data_elems) {
|
||||
int i;
|
||||
DUP_DATA(pkt->side_data, src->side_data,
|
||||
src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC);
|
||||
if (src != pkt) {
|
||||
memset(pkt->side_data, 0,
|
||||
src->side_data_elems * sizeof(*src->side_data));
|
||||
}
|
||||
for (i = 0; i < src->side_data_elems; i++) {
|
||||
DUP_DATA(pkt->side_data[i].data, src->side_data[i].data,
|
||||
src->side_data[i].size, 1, ALLOC_MALLOC);
|
||||
pkt->side_data[i].size = src->side_data[i].size;
|
||||
pkt->side_data[i].type = src->side_data[i].type;
|
||||
}
|
||||
}
|
||||
pkt->side_data_elems = src->side_data_elems;
|
||||
return 0;
|
||||
|
||||
failed_alloc:
|
||||
av_packet_unref(pkt);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
@@ -248,15 +180,6 @@ int av_copy_packet(AVPacket *dst, const AVPacket *src)
|
||||
return copy_packet_data(dst, src, 0);
|
||||
}
|
||||
|
||||
void av_packet_free_side_data(AVPacket *pkt)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < pkt->side_data_elems; i++)
|
||||
av_freep(&pkt->side_data[i].data);
|
||||
av_freep(&pkt->side_data);
|
||||
pkt->side_data_elems = 0;
|
||||
}
|
||||
|
||||
#if FF_API_AVPACKET_OLD_API
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
void av_free_packet(AVPacket *pkt)
|
||||
@@ -266,175 +189,13 @@ void av_free_packet(AVPacket *pkt)
|
||||
av_buffer_unref(&pkt->buf);
|
||||
pkt->data = NULL;
|
||||
pkt->size = 0;
|
||||
|
||||
av_packet_free_side_data(pkt);
|
||||
}
|
||||
}
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
|
||||
uint8_t *data, size_t size)
|
||||
{
|
||||
int elems = pkt->side_data_elems;
|
||||
|
||||
if ((unsigned)elems + 1 > INT_MAX / sizeof(*pkt->side_data))
|
||||
return AVERROR(ERANGE);
|
||||
|
||||
pkt->side_data = av_realloc(pkt->side_data,
|
||||
(elems + 1) * sizeof(*pkt->side_data));
|
||||
if (!pkt->side_data)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
pkt->side_data[elems].data = data;
|
||||
pkt->side_data[elems].size = size;
|
||||
pkt->side_data[elems].type = type;
|
||||
pkt->side_data_elems++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
|
||||
int size)
|
||||
{
|
||||
int ret;
|
||||
uint8_t *data;
|
||||
|
||||
if ((unsigned)size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
|
||||
return NULL;
|
||||
data = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!data)
|
||||
return NULL;
|
||||
|
||||
ret = av_packet_add_side_data(pkt, type, data, size);
|
||||
if (ret < 0) {
|
||||
av_freep(&data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
uint8_t *av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
|
||||
int *size)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < pkt->side_data_elems; i++) {
|
||||
if (pkt->side_data[i].type == type) {
|
||||
if (size)
|
||||
*size = pkt->side_data[i].size;
|
||||
return pkt->side_data[i].data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *av_packet_side_data_name(enum AVPacketSideDataType type)
|
||||
{
|
||||
switch(type) {
|
||||
case AV_PKT_DATA_PALETTE: return "Palette";
|
||||
case AV_PKT_DATA_NEW_EXTRADATA: return "New Extradata";
|
||||
case AV_PKT_DATA_PARAM_CHANGE: return "Param Change";
|
||||
case AV_PKT_DATA_H263_MB_INFO: return "H263 MB Info";
|
||||
case AV_PKT_DATA_REPLAYGAIN: return "Replay Gain";
|
||||
case AV_PKT_DATA_DISPLAYMATRIX: return "Display Matrix";
|
||||
case AV_PKT_DATA_STEREO3D: return "Stereo 3D";
|
||||
case AV_PKT_DATA_AUDIO_SERVICE_TYPE: return "Audio Service Type";
|
||||
case AV_PKT_DATA_SKIP_SAMPLES: return "Skip Samples";
|
||||
case AV_PKT_DATA_JP_DUALMONO: return "JP Dual Mono";
|
||||
case AV_PKT_DATA_STRINGS_METADATA: return "Strings Metadata";
|
||||
case AV_PKT_DATA_SUBTITLE_POSITION: return "Subtitle Position";
|
||||
case AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL: return "Matroska BlockAdditional";
|
||||
case AV_PKT_DATA_WEBVTT_IDENTIFIER: return "WebVTT ID";
|
||||
case AV_PKT_DATA_WEBVTT_SETTINGS: return "WebVTT Settings";
|
||||
case AV_PKT_DATA_METADATA_UPDATE: return "Metadata Update";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define FF_MERGE_MARKER 0x8c4d9d108e25e9feULL
|
||||
|
||||
int av_packet_merge_side_data(AVPacket *pkt){
|
||||
if(pkt->side_data_elems){
|
||||
AVBufferRef *buf;
|
||||
int i;
|
||||
uint8_t *p;
|
||||
uint64_t size= pkt->size + 8LL + AV_INPUT_BUFFER_PADDING_SIZE;
|
||||
AVPacket old= *pkt;
|
||||
for (i=0; i<old.side_data_elems; i++) {
|
||||
size += old.side_data[i].size + 5LL;
|
||||
}
|
||||
if (size > INT_MAX)
|
||||
return AVERROR(EINVAL);
|
||||
buf = av_buffer_alloc(size);
|
||||
if (!buf)
|
||||
return AVERROR(ENOMEM);
|
||||
pkt->buf = buf;
|
||||
pkt->data = p = buf->data;
|
||||
pkt->size = size - AV_INPUT_BUFFER_PADDING_SIZE;
|
||||
bytestream_put_buffer(&p, old.data, old.size);
|
||||
for (i=old.side_data_elems-1; i>=0; i--) {
|
||||
bytestream_put_buffer(&p, old.side_data[i].data, old.side_data[i].size);
|
||||
bytestream_put_be32(&p, old.side_data[i].size);
|
||||
*p++ = old.side_data[i].type | ((i==old.side_data_elems-1)*128);
|
||||
}
|
||||
bytestream_put_be64(&p, FF_MERGE_MARKER);
|
||||
av_assert0(p-pkt->data == pkt->size);
|
||||
memset(p, 0, AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
av_packet_unref(&old);
|
||||
pkt->side_data_elems = 0;
|
||||
pkt->side_data = NULL;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int av_packet_split_side_data(AVPacket *pkt){
|
||||
if (!pkt->side_data_elems && pkt->size >12 && AV_RB64(pkt->data + pkt->size - 8) == FF_MERGE_MARKER){
|
||||
int i;
|
||||
unsigned int size;
|
||||
uint8_t *p;
|
||||
|
||||
p = pkt->data + pkt->size - 8 - 5;
|
||||
for (i=1; ; i++){
|
||||
size = AV_RB32(p);
|
||||
if (size>INT_MAX - 5 || p - pkt->data < size)
|
||||
return 0;
|
||||
if (p[4]&128)
|
||||
break;
|
||||
if (p - pkt->data < size + 5)
|
||||
return 0;
|
||||
p-= size+5;
|
||||
}
|
||||
|
||||
pkt->side_data = av_malloc_array(i, sizeof(*pkt->side_data));
|
||||
if (!pkt->side_data)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
p= pkt->data + pkt->size - 8 - 5;
|
||||
for (i=0; ; i++){
|
||||
size= AV_RB32(p);
|
||||
av_assert0(size<=INT_MAX - 5 && p - pkt->data >= size);
|
||||
pkt->side_data[i].data = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
pkt->side_data[i].size = size;
|
||||
pkt->side_data[i].type = p[4]&127;
|
||||
if (!pkt->side_data[i].data)
|
||||
return AVERROR(ENOMEM);
|
||||
memcpy(pkt->side_data[i].data, p-size, size);
|
||||
pkt->size -= size + 5;
|
||||
if(p[4]&128)
|
||||
break;
|
||||
p-= size+5;
|
||||
}
|
||||
pkt->size -= 8;
|
||||
pkt->side_data_elems = i+1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size)
|
||||
{
|
||||
AVDictionaryEntry *t = NULL;
|
||||
@@ -495,22 +256,6 @@ int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **di
|
||||
return ret;
|
||||
}
|
||||
|
||||
int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
|
||||
int size)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < pkt->side_data_elems; i++) {
|
||||
if (pkt->side_data[i].type == type) {
|
||||
if (size > pkt->side_data[i].size)
|
||||
return AVERROR(ENOMEM);
|
||||
pkt->side_data[i].size = size;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return AVERROR(ENOENT);
|
||||
}
|
||||
|
||||
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
|
||||
{
|
||||
int i;
|
||||
@@ -527,25 +272,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
||||
dst->flags = src->flags;
|
||||
dst->stream_index = src->stream_index;
|
||||
|
||||
for (i = 0; i < src->side_data_elems; i++) {
|
||||
enum AVPacketSideDataType type = src->side_data[i].type;
|
||||
int size = src->side_data[i].size;
|
||||
uint8_t *src_data = src->side_data[i].data;
|
||||
uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
|
||||
|
||||
if (!dst_data) {
|
||||
av_packet_free_side_data(dst);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
memcpy(dst_data, src_data, size);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void av_packet_unref(AVPacket *pkt)
|
||||
{
|
||||
av_packet_free_side_data(pkt);
|
||||
av_buffer_unref(&pkt->buf);
|
||||
av_init_packet(pkt);
|
||||
pkt->data = NULL;
|
||||
@@ -577,7 +308,6 @@ int av_packet_ref(AVPacket *dst, const AVPacket *src)
|
||||
dst->data = dst->buf->data;
|
||||
return 0;
|
||||
fail:
|
||||
av_packet_free_side_data(dst);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -615,28 +345,3 @@ FF_DISABLE_DEPRECATION_WARNINGS
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
}
|
||||
|
||||
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
|
||||
{
|
||||
uint8_t *side_data;
|
||||
int side_data_size;
|
||||
int i;
|
||||
|
||||
side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, &side_data_size);
|
||||
if (!side_data) {
|
||||
side_data_size = 4+4+8*error_count;
|
||||
side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_STATS,
|
||||
side_data_size);
|
||||
}
|
||||
|
||||
if (!side_data || side_data_size < 4+4+8*error_count)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
AV_WL32(side_data , quality );
|
||||
side_data[4] = pict_type;
|
||||
side_data[5] = error_count;
|
||||
for (i = 0; i<error_count; i++)
|
||||
AV_WL64(side_data+8 + 8*i , error[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "common.h"
|
||||
#include "mem.h"
|
||||
#include "avstring.h"
|
||||
#include "bprint.h"
|
||||
|
||||
int av_strstart(const char *str, const char *pfx, const char **ptr)
|
||||
{
|
||||
@@ -299,23 +298,6 @@ char *av_append_path_component(const char *path, const char *component)
|
||||
return fullpath;
|
||||
}
|
||||
|
||||
int av_escape(char **dst, const char *src, const char *special_chars,
|
||||
enum AVEscapeMode mode, int flags)
|
||||
{
|
||||
AVBPrint dstbuf;
|
||||
|
||||
av_bprint_init(&dstbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
|
||||
av_bprint_escape(&dstbuf, src, special_chars, mode, flags);
|
||||
|
||||
if (!av_bprint_is_complete(&dstbuf)) {
|
||||
av_bprint_finalize(&dstbuf, NULL);
|
||||
return AVERROR(ENOMEM);
|
||||
} else {
|
||||
av_bprint_finalize(&dstbuf, dst);
|
||||
return dstbuf.len;
|
||||
}
|
||||
}
|
||||
|
||||
int av_match_name(const char *name, const char *names)
|
||||
{
|
||||
const char *p;
|
||||
@@ -434,67 +416,3 @@ int av_match_list(const char *name, const char *list, char separator)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i;
|
||||
char *fullpath;
|
||||
static const char * const strings[] = {
|
||||
"''",
|
||||
"",
|
||||
":",
|
||||
"\\",
|
||||
"'",
|
||||
" '' :",
|
||||
" '' '' :",
|
||||
"foo '' :",
|
||||
"'foo'",
|
||||
"foo ",
|
||||
" ' foo ' ",
|
||||
"foo\\",
|
||||
"foo': blah:blah",
|
||||
"foo\\: blah:blah",
|
||||
"foo\'",
|
||||
"'foo : ' :blahblah",
|
||||
"\\ :blah",
|
||||
" foo",
|
||||
" foo ",
|
||||
" foo \\ ",
|
||||
"foo ':blah",
|
||||
" foo bar : blahblah",
|
||||
"\\f\\o\\o",
|
||||
"'foo : \\ \\ ' : blahblah",
|
||||
"'\\fo\\o:': blahblah",
|
||||
"\\'fo\\o\\:': foo ' :blahblah"
|
||||
};
|
||||
|
||||
printf("Testing av_get_token()\n");
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(strings); i++) {
|
||||
const char *p = strings[i];
|
||||
char *q;
|
||||
printf("|%s|", p);
|
||||
q = av_get_token(&p, ":");
|
||||
printf(" -> |%s|", q);
|
||||
printf(" + |%s|\n", p);
|
||||
av_free(q);
|
||||
}
|
||||
|
||||
printf("Testing av_append_path_component()\n");
|
||||
#define TEST_APPEND_PATH_COMPONENT(path, component, expected) \
|
||||
fullpath = av_append_path_component((path), (component)); \
|
||||
printf("%s = %s\n", fullpath ? fullpath : "(null)", expected); \
|
||||
av_free(fullpath);
|
||||
TEST_APPEND_PATH_COMPONENT(NULL, NULL, "(null)")
|
||||
TEST_APPEND_PATH_COMPONENT("path", NULL, "path");
|
||||
TEST_APPEND_PATH_COMPONENT(NULL, "comp", "comp");
|
||||
TEST_APPEND_PATH_COMPONENT("path", "comp", "path/comp");
|
||||
TEST_APPEND_PATH_COMPONENT("path/", "comp", "path/comp");
|
||||
TEST_APPEND_PATH_COMPONENT("path", "/comp", "path/comp");
|
||||
TEST_APPEND_PATH_COMPONENT("path/", "/comp", "path/comp");
|
||||
TEST_APPEND_PATH_COMPONENT("path/path2/", "/comp/comp2", "path/path2/comp/comp2");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
||||
|
||||
@@ -251,36 +251,6 @@ const char *av_get_media_type_string(enum AVMediaType media_type);
|
||||
|
||||
#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);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@@ -292,7 +262,6 @@ char av_get_picture_type_char(enum AVPictureType pict_type);
|
||||
#include "macros.h"
|
||||
#include "mathematics.h"
|
||||
#include "log.h"
|
||||
#include "pixfmt.h"
|
||||
|
||||
/**
|
||||
* Return x default pointer in case p is NULL.
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
* bitstream api.
|
||||
*/
|
||||
|
||||
#include "atomic.h"
|
||||
#include "qsort.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
|
||||
@@ -1,379 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "avstring.h"
|
||||
#include "bprint.h"
|
||||
#include "common.h"
|
||||
#include "error.h"
|
||||
#include "mem.h"
|
||||
|
||||
#define av_bprint_room(buf) ((buf)->size - FFMIN((buf)->len, (buf)->size))
|
||||
#define av_bprint_is_allocated(buf) ((buf)->str != (buf)->reserved_internal_buffer)
|
||||
|
||||
static int av_bprint_alloc(AVBPrint *buf, unsigned room)
|
||||
{
|
||||
char *old_str, *new_str;
|
||||
unsigned min_size, new_size;
|
||||
|
||||
if (buf->size == buf->size_max)
|
||||
return AVERROR(EIO);
|
||||
if (!av_bprint_is_complete(buf))
|
||||
return AVERROR_INVALIDDATA; /* it is already truncated anyway */
|
||||
min_size = buf->len + 1 + FFMIN(UINT_MAX - buf->len - 1, room);
|
||||
new_size = buf->size > buf->size_max / 2 ? buf->size_max : buf->size * 2;
|
||||
if (new_size < min_size)
|
||||
new_size = FFMIN(buf->size_max, min_size);
|
||||
old_str = av_bprint_is_allocated(buf) ? buf->str : NULL;
|
||||
new_str = av_realloc(old_str, new_size);
|
||||
if (!new_str)
|
||||
return AVERROR(ENOMEM);
|
||||
if (!old_str)
|
||||
memcpy(new_str, buf->str, buf->len + 1);
|
||||
buf->str = new_str;
|
||||
buf->size = new_size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void av_bprint_grow(AVBPrint *buf, unsigned extra_len)
|
||||
{
|
||||
/* arbitrary margin to avoid small overflows */
|
||||
extra_len = FFMIN(extra_len, UINT_MAX - 5 - buf->len);
|
||||
buf->len += extra_len;
|
||||
if (buf->size)
|
||||
buf->str[FFMIN(buf->len, buf->size - 1)] = 0;
|
||||
}
|
||||
|
||||
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
|
||||
{
|
||||
unsigned size_auto = (char *)buf + sizeof(*buf) -
|
||||
buf->reserved_internal_buffer;
|
||||
|
||||
if (size_max == 1)
|
||||
size_max = size_auto;
|
||||
buf->str = buf->reserved_internal_buffer;
|
||||
buf->len = 0;
|
||||
buf->size = FFMIN(size_auto, size_max);
|
||||
buf->size_max = size_max;
|
||||
*buf->str = 0;
|
||||
if (size_init > buf->size)
|
||||
av_bprint_alloc(buf, size_init - 1);
|
||||
}
|
||||
|
||||
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
|
||||
{
|
||||
buf->str = buffer;
|
||||
buf->len = 0;
|
||||
buf->size = size;
|
||||
buf->size_max = size;
|
||||
*buf->str = 0;
|
||||
}
|
||||
|
||||
void av_bprintf(AVBPrint *buf, const char *fmt, ...)
|
||||
{
|
||||
unsigned room;
|
||||
char *dst;
|
||||
va_list vl;
|
||||
int extra_len;
|
||||
|
||||
while (1) {
|
||||
room = av_bprint_room(buf);
|
||||
dst = room ? buf->str + buf->len : NULL;
|
||||
va_start(vl, fmt);
|
||||
extra_len = vsnprintf(dst, room, fmt, vl);
|
||||
va_end(vl);
|
||||
if (extra_len <= 0)
|
||||
return;
|
||||
if (extra_len < room)
|
||||
break;
|
||||
if (av_bprint_alloc(buf, extra_len))
|
||||
break;
|
||||
}
|
||||
av_bprint_grow(buf, extra_len);
|
||||
}
|
||||
|
||||
void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg)
|
||||
{
|
||||
unsigned room;
|
||||
char *dst;
|
||||
int extra_len;
|
||||
va_list vl;
|
||||
|
||||
while (1) {
|
||||
room = av_bprint_room(buf);
|
||||
dst = room ? buf->str + buf->len : NULL;
|
||||
va_copy(vl, vl_arg);
|
||||
extra_len = vsnprintf(dst, room, fmt, vl);
|
||||
va_end(vl);
|
||||
if (extra_len <= 0)
|
||||
return;
|
||||
if (extra_len < room)
|
||||
break;
|
||||
if (av_bprint_alloc(buf, extra_len))
|
||||
break;
|
||||
}
|
||||
av_bprint_grow(buf, extra_len);
|
||||
}
|
||||
|
||||
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
|
||||
{
|
||||
unsigned room, real_n;
|
||||
|
||||
while (1) {
|
||||
room = av_bprint_room(buf);
|
||||
if (n < room)
|
||||
break;
|
||||
if (av_bprint_alloc(buf, n))
|
||||
break;
|
||||
}
|
||||
if (room) {
|
||||
real_n = FFMIN(n, room - 1);
|
||||
memset(buf->str + buf->len, c, real_n);
|
||||
}
|
||||
av_bprint_grow(buf, n);
|
||||
}
|
||||
|
||||
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
|
||||
{
|
||||
unsigned room, real_n;
|
||||
|
||||
while (1) {
|
||||
room = av_bprint_room(buf);
|
||||
if (size < room)
|
||||
break;
|
||||
if (av_bprint_alloc(buf, size))
|
||||
break;
|
||||
}
|
||||
if (room) {
|
||||
real_n = FFMIN(size, room - 1);
|
||||
memcpy(buf->str + buf->len, data, real_n);
|
||||
}
|
||||
av_bprint_grow(buf, size);
|
||||
}
|
||||
|
||||
void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm)
|
||||
{
|
||||
unsigned room;
|
||||
size_t l;
|
||||
|
||||
if (!*fmt)
|
||||
return;
|
||||
while (1) {
|
||||
room = av_bprint_room(buf);
|
||||
if (room && (l = strftime(buf->str + buf->len, room, fmt, tm)))
|
||||
break;
|
||||
/* strftime does not tell us how much room it would need: let us
|
||||
retry with twice as much until the buffer is large enough */
|
||||
room = !room ? strlen(fmt) + 1 :
|
||||
room <= INT_MAX / 2 ? room * 2 : INT_MAX;
|
||||
if (av_bprint_alloc(buf, room)) {
|
||||
/* impossible to grow, try to manage something useful anyway */
|
||||
room = av_bprint_room(buf);
|
||||
if (room < 1024) {
|
||||
/* if strftime fails because the buffer has (almost) reached
|
||||
its maximum size, let us try in a local buffer; 1k should
|
||||
be enough to format any real date+time string */
|
||||
char buf2[1024];
|
||||
if ((l = strftime(buf2, sizeof(buf2), fmt, tm))) {
|
||||
av_bprintf(buf, "%s", buf2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (room) {
|
||||
/* if anything else failed and the buffer is not already
|
||||
truncated, let us add a stock string and force truncation */
|
||||
static const char txt[] = "[truncated strftime output]";
|
||||
memset(buf->str + buf->len, '!', room);
|
||||
memcpy(buf->str + buf->len, txt, FFMIN(sizeof(txt) - 1, room));
|
||||
av_bprint_grow(buf, room); /* force truncation */
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
av_bprint_grow(buf, l);
|
||||
}
|
||||
|
||||
void av_bprint_get_buffer(AVBPrint *buf, unsigned size,
|
||||
unsigned char **mem, unsigned *actual_size)
|
||||
{
|
||||
if (size > av_bprint_room(buf))
|
||||
av_bprint_alloc(buf, size);
|
||||
*actual_size = av_bprint_room(buf);
|
||||
*mem = *actual_size ? buf->str + buf->len : NULL;
|
||||
}
|
||||
|
||||
void av_bprint_clear(AVBPrint *buf)
|
||||
{
|
||||
if (buf->len) {
|
||||
*buf->str = 0;
|
||||
buf->len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
|
||||
{
|
||||
unsigned real_size = FFMIN(buf->len + 1, buf->size);
|
||||
char *str;
|
||||
int ret = 0;
|
||||
|
||||
if (ret_str) {
|
||||
if (av_bprint_is_allocated(buf)) {
|
||||
str = av_realloc(buf->str, real_size);
|
||||
if (!str)
|
||||
str = buf->str;
|
||||
buf->str = NULL;
|
||||
} else {
|
||||
str = av_malloc(real_size);
|
||||
if (str)
|
||||
memcpy(str, buf->str, real_size);
|
||||
else
|
||||
ret = AVERROR(ENOMEM);
|
||||
}
|
||||
*ret_str = str;
|
||||
} else {
|
||||
if (av_bprint_is_allocated(buf))
|
||||
av_freep(&buf->str);
|
||||
}
|
||||
buf->size = real_size;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define WHITESPACES " \n\t"
|
||||
|
||||
void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars,
|
||||
enum AVEscapeMode mode, int flags)
|
||||
{
|
||||
const char *src0 = src;
|
||||
|
||||
if (mode == AV_ESCAPE_MODE_AUTO)
|
||||
mode = AV_ESCAPE_MODE_BACKSLASH; /* TODO: implement a heuristic */
|
||||
|
||||
switch (mode) {
|
||||
case AV_ESCAPE_MODE_QUOTE:
|
||||
/* enclose the string between '' */
|
||||
av_bprint_chars(dstbuf, '\'', 1);
|
||||
for (; *src; src++) {
|
||||
if (*src == '\'')
|
||||
av_bprintf(dstbuf, "'\\''");
|
||||
else
|
||||
av_bprint_chars(dstbuf, *src, 1);
|
||||
}
|
||||
av_bprint_chars(dstbuf, '\'', 1);
|
||||
break;
|
||||
|
||||
/* case AV_ESCAPE_MODE_BACKSLASH or unknown mode */
|
||||
default:
|
||||
/* \-escape characters */
|
||||
for (; *src; src++) {
|
||||
int is_first_last = src == src0 || !*(src+1);
|
||||
int is_ws = !!strchr(WHITESPACES, *src);
|
||||
int is_strictly_special = special_chars && strchr(special_chars, *src);
|
||||
int is_special =
|
||||
is_strictly_special || strchr("'\\", *src) ||
|
||||
(is_ws && (flags & AV_ESCAPE_FLAG_WHITESPACE));
|
||||
|
||||
if (is_strictly_special ||
|
||||
(!(flags & AV_ESCAPE_FLAG_STRICT) &&
|
||||
(is_special || (is_ws && is_first_last))))
|
||||
av_bprint_chars(dstbuf, '\\', 1);
|
||||
av_bprint_chars(dstbuf, *src, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#undef printf
|
||||
|
||||
static void bprint_pascal(AVBPrint *b, unsigned size)
|
||||
{
|
||||
unsigned i, j;
|
||||
unsigned p[42];
|
||||
|
||||
av_assert0(size < FF_ARRAY_ELEMS(p));
|
||||
|
||||
p[0] = 1;
|
||||
av_bprintf(b, "%8d\n", 1);
|
||||
for (i = 1; i <= size; i++) {
|
||||
p[i] = 1;
|
||||
for (j = i - 1; j > 0; j--)
|
||||
p[j] = p[j] + p[j - 1];
|
||||
for (j = 0; j <= i; j++)
|
||||
av_bprintf(b, "%8d", p[j]);
|
||||
av_bprintf(b, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
AVBPrint b;
|
||||
char buf[256];
|
||||
struct tm testtime = { .tm_year = 100, .tm_mon = 11, .tm_mday = 20 };
|
||||
|
||||
av_bprint_init(&b, 0, -1);
|
||||
bprint_pascal(&b, 5);
|
||||
printf("Short text in unlimited buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
|
||||
printf("%s\n", b.str);
|
||||
av_bprint_finalize(&b, NULL);
|
||||
|
||||
av_bprint_init(&b, 0, -1);
|
||||
bprint_pascal(&b, 25);
|
||||
printf("Long text in unlimited buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
|
||||
av_bprint_finalize(&b, NULL);
|
||||
|
||||
av_bprint_init(&b, 0, 2048);
|
||||
bprint_pascal(&b, 25);
|
||||
printf("Long text in limited buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
|
||||
av_bprint_finalize(&b, NULL);
|
||||
|
||||
av_bprint_init(&b, 0, 1);
|
||||
bprint_pascal(&b, 5);
|
||||
printf("Short text in automatic buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
|
||||
|
||||
av_bprint_init(&b, 0, 1);
|
||||
bprint_pascal(&b, 25);
|
||||
printf("Long text in automatic buffer: %u/%u\n", (unsigned)strlen(b.str)/8*8, b.len);
|
||||
/* Note that the size of the automatic buffer is arch-dependent. */
|
||||
|
||||
av_bprint_init(&b, 0, 0);
|
||||
bprint_pascal(&b, 25);
|
||||
printf("Long text count only buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
|
||||
|
||||
av_bprint_init_for_buffer(&b, buf, sizeof(buf));
|
||||
bprint_pascal(&b, 25);
|
||||
printf("Long text count only buffer: %u/%u\n", (unsigned)strlen(buf), b.len);
|
||||
|
||||
av_bprint_init(&b, 0, -1);
|
||||
av_bprint_strftime(&b, "%Y-%m-%d", &testtime);
|
||||
printf("strftime full: %u/%u \"%s\"\n", (unsigned)strlen(buf), b.len, b.str);
|
||||
av_bprint_finalize(&b, NULL);
|
||||
|
||||
av_bprint_init(&b, 0, 8);
|
||||
av_bprint_strftime(&b, "%Y-%m-%d", &testtime);
|
||||
printf("strftime truncated: %u/%u \"%s\"\n", (unsigned)strlen(buf), b.len, b.str);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,219 +0,0 @@
|
||||
/*
|
||||
* 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 <stdarg.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(name, size, ...) \
|
||||
struct ff_pad_helper_##name { __VA_ARGS__ }; \
|
||||
typedef struct name { \
|
||||
__VA_ARGS__ \
|
||||
char reserved_padding[size - sizeof(struct ff_pad_helper_##name)]; \
|
||||
} name;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
FF_PAD_STRUCTURE(AVBPrint, 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];
|
||||
)
|
||||
|
||||
/**
|
||||
* 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 a formatted string to a print buffer.
|
||||
*/
|
||||
void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg);
|
||||
|
||||
/**
|
||||
* Append char c n times to a print buffer.
|
||||
*/
|
||||
void av_bprint_chars(AVBPrint *buf, char c, unsigned n);
|
||||
|
||||
/**
|
||||
* Append data to a print buffer.
|
||||
*
|
||||
* param buf bprint buffer to use
|
||||
* param data pointer to data
|
||||
* param size size of data
|
||||
*/
|
||||
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size);
|
||||
|
||||
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(const 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 */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,4 +25,7 @@
|
||||
#define CONFIG_MDCT 1
|
||||
#define CONFIG_FFT 1
|
||||
|
||||
#pragma warning(disable:4305)
|
||||
#pragma warning(disable:4244)
|
||||
|
||||
int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc);
|
||||
|
||||
@@ -221,117 +221,3 @@ int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
static void print_dict(const AVDictionary *m)
|
||||
{
|
||||
AVDictionaryEntry *t = NULL;
|
||||
while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX)))
|
||||
printf("%s %s ", t->key, t->value);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void test_separators(const AVDictionary *m, const char pair, const char val)
|
||||
{
|
||||
AVDictionary *dict = NULL;
|
||||
char pairs[] = {pair , '\0'};
|
||||
char vals[] = {val, '\0'};
|
||||
|
||||
char *buffer = NULL;
|
||||
av_dict_copy(&dict, m, 0);
|
||||
print_dict(dict);
|
||||
av_dict_get_string(dict, &buffer, val, pair);
|
||||
printf("%s\n", buffer);
|
||||
av_dict_free(&dict);
|
||||
av_dict_parse_string(&dict, buffer, vals, pairs, 0);
|
||||
av_freep(&buffer);
|
||||
print_dict(dict);
|
||||
av_dict_free(&dict);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
AVDictionary *dict = NULL;
|
||||
AVDictionaryEntry *e;
|
||||
char *buffer = NULL;
|
||||
|
||||
printf("Testing av_dict_get_string() and av_dict_parse_string()\n");
|
||||
av_dict_get_string(dict, &buffer, '=', ',');
|
||||
printf("%s\n", buffer);
|
||||
av_freep(&buffer);
|
||||
av_dict_set(&dict, "aaa", "aaa", 0);
|
||||
av_dict_set(&dict, "b,b", "bbb", 0);
|
||||
av_dict_set(&dict, "c=c", "ccc", 0);
|
||||
av_dict_set(&dict, "ddd", "d,d", 0);
|
||||
av_dict_set(&dict, "eee", "e=e", 0);
|
||||
av_dict_set(&dict, "f,f", "f=f", 0);
|
||||
av_dict_set(&dict, "g=g", "g,g", 0);
|
||||
test_separators(dict, ',', '=');
|
||||
av_dict_free(&dict);
|
||||
av_dict_set(&dict, "aaa", "aaa", 0);
|
||||
av_dict_set(&dict, "bbb", "bbb", 0);
|
||||
av_dict_set(&dict, "ccc", "ccc", 0);
|
||||
av_dict_set(&dict, "\\,=\'\"", "\\,=\'\"", 0);
|
||||
test_separators(dict, '"', '=');
|
||||
test_separators(dict, '\'', '=');
|
||||
test_separators(dict, ',', '"');
|
||||
test_separators(dict, ',', '\'');
|
||||
test_separators(dict, '\'', '"');
|
||||
test_separators(dict, '"', '\'');
|
||||
av_dict_free(&dict);
|
||||
|
||||
printf("\nTesting av_dict_set()\n");
|
||||
av_dict_set(&dict, "a", "a", 0);
|
||||
av_dict_set(&dict, "b", av_strdup("b"), AV_DICT_DONT_STRDUP_VAL);
|
||||
av_dict_set(&dict, av_strdup("c"), "c", AV_DICT_DONT_STRDUP_KEY);
|
||||
av_dict_set(&dict, av_strdup("d"), av_strdup("d"), AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
|
||||
av_dict_set(&dict, "e", "e", AV_DICT_DONT_OVERWRITE);
|
||||
av_dict_set(&dict, "e", "f", AV_DICT_DONT_OVERWRITE);
|
||||
av_dict_set(&dict, "f", "f", 0);
|
||||
av_dict_set(&dict, "f", NULL, 0);
|
||||
av_dict_set(&dict, "ff", "f", 0);
|
||||
av_dict_set(&dict, "ff", "f", AV_DICT_APPEND);
|
||||
e = NULL;
|
||||
while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX)))
|
||||
printf("%s %s\n", e->key, e->value);
|
||||
av_dict_free(&dict);
|
||||
|
||||
av_dict_set(&dict, NULL, "a", 0);
|
||||
av_dict_set(&dict, NULL, "b", 0);
|
||||
av_dict_get(dict, NULL, NULL, 0);
|
||||
e = NULL;
|
||||
while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX)))
|
||||
printf("'%s' '%s'\n", e->key, e->value);
|
||||
av_dict_free(&dict);
|
||||
|
||||
|
||||
//valgrind sensible test
|
||||
printf("\nTesting av_dict_set_int()\n");
|
||||
av_dict_set_int(&dict, "1", 1, AV_DICT_DONT_STRDUP_VAL);
|
||||
av_dict_set_int(&dict, av_strdup("2"), 2, AV_DICT_DONT_STRDUP_KEY);
|
||||
av_dict_set_int(&dict, av_strdup("3"), 3, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
|
||||
av_dict_set_int(&dict, "4", 4, 0);
|
||||
av_dict_set_int(&dict, "5", 5, AV_DICT_DONT_OVERWRITE);
|
||||
av_dict_set_int(&dict, "5", 6, AV_DICT_DONT_OVERWRITE);
|
||||
av_dict_set_int(&dict, "12", 1, 0);
|
||||
av_dict_set_int(&dict, "12", 2, AV_DICT_APPEND);
|
||||
e = NULL;
|
||||
while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX)))
|
||||
printf("%s %s\n", e->key, e->value);
|
||||
av_dict_free(&dict);
|
||||
|
||||
//valgrind sensible test
|
||||
printf("\nTesting av_dict_set() with existing AVDictionaryEntry.key as key\n");
|
||||
av_dict_set(&dict, "key", "old", 0);
|
||||
e = av_dict_get(dict, "key", NULL, 0);
|
||||
av_dict_set(&dict, e->key, "new val OK", 0);
|
||||
e = av_dict_get(dict, "key", NULL, 0);
|
||||
printf("%s\n", e->value);
|
||||
av_dict_set(&dict, e->key, e->value, 0);
|
||||
e = av_dict_get(dict, "key", NULL, 0);
|
||||
printf("%s\n", e->value);
|
||||
av_dict_free(&dict);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -146,321 +146,3 @@ av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact)
|
||||
*/
|
||||
return fdsp;
|
||||
}
|
||||
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h> /* for getopt */
|
||||
#endif
|
||||
#if !HAVE_GETOPT
|
||||
#include "compat/getopt.c"
|
||||
#endif
|
||||
|
||||
#include "common.h"
|
||||
#include "cpu.h"
|
||||
#include "internal.h"
|
||||
#include "lfg.h"
|
||||
#include "log.h"
|
||||
#include "random_seed.h"
|
||||
|
||||
#define LEN 240
|
||||
|
||||
static void fill_float_array(AVLFG *lfg, float *a, int len)
|
||||
{
|
||||
int i;
|
||||
double bmg[2], stddev = 10.0, mean = 0.0;
|
||||
|
||||
for (i = 0; i < len; i += 2) {
|
||||
av_bmg_get(lfg, bmg);
|
||||
a[i] = bmg[0] * stddev + mean;
|
||||
a[i + 1] = bmg[1] * stddev + mean;
|
||||
}
|
||||
}
|
||||
static int compare_floats(const float *a, const float *b, int len,
|
||||
float max_diff)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < len; i++) {
|
||||
if (fabsf(a[i] - b[i]) > max_diff) {
|
||||
av_log(NULL, AV_LOG_ERROR, "%d: %- .12f - %- .12f = % .12g\n",
|
||||
i, a[i], b[i], a[i] - b[i]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fill_double_array(AVLFG *lfg, double *a, int len)
|
||||
{
|
||||
int i;
|
||||
double bmg[2], stddev = 10.0, mean = 0.0;
|
||||
|
||||
for (i = 0; i < len; i += 2) {
|
||||
av_bmg_get(lfg, bmg);
|
||||
a[i] = bmg[0] * stddev + mean;
|
||||
a[i + 1] = bmg[1] * stddev + mean;
|
||||
}
|
||||
}
|
||||
|
||||
static int compare_doubles(const double *a, const double *b, int len,
|
||||
double max_diff)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (fabs(a[i] - b[i]) > max_diff) {
|
||||
av_log(NULL, AV_LOG_ERROR, "%d: %- .12f - %- .12f = % .12g\n",
|
||||
i, a[i], b[i], a[i] - b[i]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_vector_fmul(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
||||
const float *v1, const float *v2)
|
||||
{
|
||||
LOCAL_ALIGNED(32, float, cdst, [LEN]);
|
||||
LOCAL_ALIGNED(32, float, odst, [LEN]);
|
||||
int ret;
|
||||
|
||||
cdsp->vector_fmul(cdst, v1, v2, LEN);
|
||||
fdsp->vector_fmul(odst, v1, v2, LEN);
|
||||
|
||||
if (ret = compare_floats(cdst, odst, LEN, FLT_EPSILON))
|
||||
av_log(NULL, AV_LOG_ERROR, "vector_fmul failed\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define ARBITRARY_FMAC_SCALAR_CONST 0.005
|
||||
static int test_vector_fmac_scalar(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
||||
const float *v1, const float *src0, float scale)
|
||||
{
|
||||
LOCAL_ALIGNED(32, float, cdst, [LEN]);
|
||||
LOCAL_ALIGNED(32, float, odst, [LEN]);
|
||||
int ret;
|
||||
|
||||
memcpy(cdst, v1, LEN * sizeof(*v1));
|
||||
memcpy(odst, v1, LEN * sizeof(*v1));
|
||||
|
||||
cdsp->vector_fmac_scalar(cdst, src0, scale, LEN);
|
||||
fdsp->vector_fmac_scalar(odst, src0, scale, LEN);
|
||||
|
||||
if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMAC_SCALAR_CONST))
|
||||
av_log(NULL, AV_LOG_ERROR, "vector_fmac_scalar failed\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_vector_fmul_scalar(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
||||
const float *v1, float scale)
|
||||
{
|
||||
LOCAL_ALIGNED(32, float, cdst, [LEN]);
|
||||
LOCAL_ALIGNED(32, float, odst, [LEN]);
|
||||
int ret;
|
||||
|
||||
cdsp->vector_fmul_scalar(cdst, v1, scale, LEN);
|
||||
fdsp->vector_fmul_scalar(odst, v1, scale, LEN);
|
||||
|
||||
if (ret = compare_floats(cdst, odst, LEN, FLT_EPSILON))
|
||||
av_log(NULL, AV_LOG_ERROR, "vector_fmul_scalar failed\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_vector_dmul_scalar(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
||||
const double *v1, double scale)
|
||||
{
|
||||
LOCAL_ALIGNED(32, double, cdst, [LEN]);
|
||||
LOCAL_ALIGNED(32, double, odst, [LEN]);
|
||||
int ret;
|
||||
|
||||
cdsp->vector_dmul_scalar(cdst, v1, scale, LEN);
|
||||
fdsp->vector_dmul_scalar(odst, v1, scale, LEN);
|
||||
|
||||
if (ret = compare_doubles(cdst, odst, LEN, DBL_EPSILON))
|
||||
av_log(NULL, AV_LOG_ERROR, "vector_dmul_scalar failed\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define ARBITRARY_FMUL_WINDOW_CONST 0.008
|
||||
static int test_vector_fmul_window(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
||||
const float *v1, const float *v2, const float *v3)
|
||||
{
|
||||
LOCAL_ALIGNED(32, float, cdst, [LEN]);
|
||||
LOCAL_ALIGNED(32, float, odst, [LEN]);
|
||||
int ret;
|
||||
|
||||
cdsp->vector_fmul_window(cdst, v1, v2, v3, LEN / 2);
|
||||
fdsp->vector_fmul_window(odst, v1, v2, v3, LEN / 2);
|
||||
|
||||
if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMUL_WINDOW_CONST))
|
||||
av_log(NULL, AV_LOG_ERROR, "vector_fmul_window failed\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define ARBITRARY_FMUL_ADD_CONST 0.005
|
||||
static int test_vector_fmul_add(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
||||
const float *v1, const float *v2, const float *v3)
|
||||
{
|
||||
LOCAL_ALIGNED(32, float, cdst, [LEN]);
|
||||
LOCAL_ALIGNED(32, float, odst, [LEN]);
|
||||
int ret;
|
||||
|
||||
cdsp->vector_fmul_add(cdst, v1, v2, v3, LEN);
|
||||
fdsp->vector_fmul_add(odst, v1, v2, v3, LEN);
|
||||
|
||||
if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMUL_ADD_CONST))
|
||||
av_log(NULL, AV_LOG_ERROR, "vector_fmul_add failed\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_vector_fmul_reverse(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
||||
const float *v1, const float *v2)
|
||||
{
|
||||
LOCAL_ALIGNED(32, float, cdst, [LEN]);
|
||||
LOCAL_ALIGNED(32, float, odst, [LEN]);
|
||||
int ret;
|
||||
|
||||
cdsp->vector_fmul_reverse(cdst, v1, v2, LEN);
|
||||
fdsp->vector_fmul_reverse(odst, v1, v2, LEN);
|
||||
|
||||
if (ret = compare_floats(cdst, odst, LEN, FLT_EPSILON))
|
||||
av_log(NULL, AV_LOG_ERROR, "vector_fmul_reverse failed\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_butterflies_float(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
||||
const float *v1, const float *v2)
|
||||
{
|
||||
LOCAL_ALIGNED(32, float, cv1, [LEN]);
|
||||
LOCAL_ALIGNED(32, float, cv2, [LEN]);
|
||||
LOCAL_ALIGNED(32, float, ov1, [LEN]);
|
||||
LOCAL_ALIGNED(32, float, ov2, [LEN]);
|
||||
int ret;
|
||||
|
||||
memcpy(cv1, v1, LEN * sizeof(*v1));
|
||||
memcpy(cv2, v2, LEN * sizeof(*v2));
|
||||
memcpy(ov1, v1, LEN * sizeof(*v1));
|
||||
memcpy(ov2, v2, LEN * sizeof(*v2));
|
||||
|
||||
cdsp->butterflies_float(cv1, cv2, LEN);
|
||||
fdsp->butterflies_float(ov1, ov2, LEN);
|
||||
|
||||
if ((ret = compare_floats(cv1, ov1, LEN, FLT_EPSILON)) ||
|
||||
(ret = compare_floats(cv2, ov2, LEN, FLT_EPSILON)))
|
||||
av_log(NULL, AV_LOG_ERROR, "butterflies_float failed\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define ARBITRARY_SCALARPRODUCT_CONST 0.2
|
||||
static int test_scalarproduct_float(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp,
|
||||
const float *v1, const float *v2)
|
||||
{
|
||||
float cprod, oprod;
|
||||
int ret;
|
||||
|
||||
cprod = cdsp->scalarproduct_float(v1, v2, LEN);
|
||||
oprod = fdsp->scalarproduct_float(v1, v2, LEN);
|
||||
|
||||
if (ret = compare_floats(&cprod, &oprod, 1, ARBITRARY_SCALARPRODUCT_CONST))
|
||||
av_log(NULL, AV_LOG_ERROR, "scalarproduct_float failed\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret = 0, seeded = 0;
|
||||
uint32_t seed;
|
||||
AVFloatDSPContext *fdsp, *cdsp;
|
||||
AVLFG lfg;
|
||||
|
||||
LOCAL_ALIGNED(32, float, src0, [LEN]);
|
||||
LOCAL_ALIGNED(32, float, src1, [LEN]);
|
||||
LOCAL_ALIGNED(32, float, src2, [LEN]);
|
||||
LOCAL_ALIGNED(32, double, dbl_src0, [LEN]);
|
||||
LOCAL_ALIGNED(32, double, dbl_src1, [LEN]);
|
||||
|
||||
for (;;) {
|
||||
int arg = getopt(argc, argv, "s:c:");
|
||||
if (arg == -1)
|
||||
break;
|
||||
switch (arg) {
|
||||
case 's':
|
||||
seed = strtoul(optarg, NULL, 10);
|
||||
seeded = 1;
|
||||
break;
|
||||
case 'c':
|
||||
{
|
||||
int cpuflags = av_get_cpu_flags();
|
||||
|
||||
if (av_parse_cpu_caps(&cpuflags, optarg) < 0)
|
||||
return 1;
|
||||
|
||||
av_force_cpu_flags(cpuflags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!seeded)
|
||||
seed = av_get_random_seed();
|
||||
|
||||
av_log(NULL, AV_LOG_INFO, "float_dsp-test: %s %u\n", seeded ? "seed" : "random seed", seed);
|
||||
|
||||
fdsp = avpriv_float_dsp_alloc(1);
|
||||
av_force_cpu_flags(0);
|
||||
cdsp = avpriv_float_dsp_alloc(1);
|
||||
|
||||
if (!fdsp || !cdsp) {
|
||||
ret = 1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
av_lfg_init(&lfg, seed);
|
||||
|
||||
fill_float_array(&lfg, src0, LEN);
|
||||
fill_float_array(&lfg, src1, LEN);
|
||||
fill_float_array(&lfg, src2, LEN);
|
||||
|
||||
fill_double_array(&lfg, dbl_src0, LEN);
|
||||
fill_double_array(&lfg, dbl_src1, LEN);
|
||||
|
||||
if (test_vector_fmul(fdsp, cdsp, src0, src1))
|
||||
ret -= 1 << 0;
|
||||
if (test_vector_fmac_scalar(fdsp, cdsp, src2, src0, src1[0]))
|
||||
ret -= 1 << 1;
|
||||
if (test_vector_fmul_scalar(fdsp, cdsp, src0, src1[0]))
|
||||
ret -= 1 << 2;
|
||||
if (test_vector_fmul_window(fdsp, cdsp, src0, src1, src2))
|
||||
ret -= 1 << 3;
|
||||
if (test_vector_fmul_add(fdsp, cdsp, src0, src1, src2))
|
||||
ret -= 1 << 4;
|
||||
if (test_vector_fmul_reverse(fdsp, cdsp, src0, src1))
|
||||
ret -= 1 << 5;
|
||||
if (test_butterflies_float(fdsp, cdsp, src0, src1))
|
||||
ret -= 1 << 6;
|
||||
if (test_scalarproduct_float(fdsp, cdsp, src0, src1))
|
||||
ret -= 1 << 7;
|
||||
if (test_vector_dmul_scalar(fdsp, cdsp, dbl_src0, dbl_src1[0]))
|
||||
ret -= 1 << 8;
|
||||
|
||||
end:
|
||||
av_freep(&fdsp);
|
||||
av_freep(&cdsp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* TEST */
|
||||
|
||||
@@ -18,13 +18,10 @@
|
||||
*/
|
||||
|
||||
#include "channel_layout.h"
|
||||
// #include "avassert.h"
|
||||
#include "buffer.h"
|
||||
#include "common.h"
|
||||
#include "dict.h"
|
||||
#include "frame.h"
|
||||
//#include "imgutils.h"
|
||||
#include "pixdesc.h"
|
||||
#include "util_internal.h"
|
||||
#include "mem.h"
|
||||
#include "samplefmt.h"
|
||||
@@ -35,65 +32,14 @@ MAKE_ACCESSORS(AVFrame, frame, int64_t, pkt_pos)
|
||||
MAKE_ACCESSORS(AVFrame, frame, int64_t, channel_layout)
|
||||
MAKE_ACCESSORS(AVFrame, frame, int, channels)
|
||||
MAKE_ACCESSORS(AVFrame, frame, int, sample_rate)
|
||||
MAKE_ACCESSORS(AVFrame, frame, AVDictionary *, metadata)
|
||||
MAKE_ACCESSORS(AVFrame, frame, int, decode_error_flags)
|
||||
MAKE_ACCESSORS(AVFrame, frame, int, pkt_size)
|
||||
MAKE_ACCESSORS(AVFrame, frame, enum AVColorSpace, colorspace)
|
||||
MAKE_ACCESSORS(AVFrame, frame, enum AVColorRange, color_range)
|
||||
|
||||
#define CHECK_CHANNELS_CONSISTENCY(frame) \
|
||||
av_assert2(!(frame)->channel_layout || \
|
||||
(frame)->channels == \
|
||||
av_get_channel_layout_nb_channels((frame)->channel_layout))
|
||||
|
||||
AVDictionary **avpriv_frame_get_metadatap(AVFrame *frame) {return &frame->metadata;};
|
||||
|
||||
#if FF_API_FRAME_QP
|
||||
int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int qp_type)
|
||||
{
|
||||
av_buffer_unref(&f->qp_table_buf);
|
||||
|
||||
f->qp_table_buf = buf;
|
||||
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
f->qscale_table = buf->data;
|
||||
f->qstride = stride;
|
||||
f->qscale_type = qp_type;
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type)
|
||||
{
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
*stride = f->qstride;
|
||||
*type = f->qscale_type;
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
|
||||
if (!f->qp_table_buf)
|
||||
return NULL;
|
||||
|
||||
return f->qp_table_buf->data;
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *av_get_colorspace_name(enum AVColorSpace val)
|
||||
{
|
||||
static const char * const name[] = {
|
||||
[AVCOL_SPC_RGB] = "GBR",
|
||||
[AVCOL_SPC_BT709] = "bt709",
|
||||
[AVCOL_SPC_FCC] = "fcc",
|
||||
[AVCOL_SPC_BT470BG] = "bt470bg",
|
||||
[AVCOL_SPC_SMPTE170M] = "smpte170m",
|
||||
[AVCOL_SPC_SMPTE240M] = "smpte240m",
|
||||
[AVCOL_SPC_YCOCG] = "YCgCo",
|
||||
};
|
||||
if ((unsigned)val >= FF_ARRAY_ELEMS(name))
|
||||
return NULL;
|
||||
return name[val];
|
||||
}
|
||||
|
||||
static void get_frame_defaults(AVFrame *frame)
|
||||
{
|
||||
if (frame->extended_data != frame->data)
|
||||
@@ -101,43 +47,12 @@ static void get_frame_defaults(AVFrame *frame)
|
||||
|
||||
memset(frame, 0, sizeof(*frame));
|
||||
|
||||
frame->pts =
|
||||
frame->pkt_dts =
|
||||
frame->pkt_pts = AV_NOPTS_VALUE;
|
||||
av_frame_set_best_effort_timestamp(frame, AV_NOPTS_VALUE);
|
||||
av_frame_set_pkt_duration (frame, 0);
|
||||
av_frame_set_pkt_pos (frame, -1);
|
||||
av_frame_set_pkt_size (frame, -1);
|
||||
frame->key_frame = 1;
|
||||
frame->sample_aspect_ratio = (AVRational){ 0, 1 };
|
||||
frame->format = -1; /* unknown */
|
||||
frame->extended_data = frame->data;
|
||||
frame->color_primaries = AVCOL_PRI_UNSPECIFIED;
|
||||
frame->color_trc = AVCOL_TRC_UNSPECIFIED;
|
||||
frame->colorspace = AVCOL_SPC_UNSPECIFIED;
|
||||
frame->color_range = AVCOL_RANGE_UNSPECIFIED;
|
||||
frame->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
|
||||
}
|
||||
|
||||
static void free_side_data(AVFrameSideData **ptr_sd)
|
||||
{
|
||||
AVFrameSideData *sd = *ptr_sd;
|
||||
|
||||
av_buffer_unref(&sd->buf);
|
||||
av_dict_free(&sd->metadata);
|
||||
av_freep(ptr_sd);
|
||||
}
|
||||
|
||||
static void wipe_side_data(AVFrame *frame)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < frame->nb_side_data; i++) {
|
||||
free_side_data(&frame->side_data[i]);
|
||||
}
|
||||
frame->nb_side_data = 0;
|
||||
|
||||
av_freep(&frame->side_data);
|
||||
}
|
||||
|
||||
AVFrame *av_frame_alloc(void)
|
||||
@@ -223,8 +138,6 @@ int av_frame_get_buffer(AVFrame *frame, int align)
|
||||
if (frame->format < 0)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
if (frame->width > 0 && frame->height > 0)
|
||||
return AVERROR(EINVAL);
|
||||
else if (frame->nb_samples > 0 && (frame->channel_layout || frame->channels > 0))
|
||||
return get_audio_buffer(frame, align);
|
||||
|
||||
@@ -233,90 +146,19 @@ int av_frame_get_buffer(AVFrame *frame, int align)
|
||||
|
||||
static int frame_copy_props(AVFrame *dst, const AVFrame *src, int force_copy)
|
||||
{
|
||||
int i;
|
||||
|
||||
dst->key_frame = src->key_frame;
|
||||
dst->pict_type = src->pict_type;
|
||||
dst->sample_aspect_ratio = src->sample_aspect_ratio;
|
||||
dst->pts = src->pts;
|
||||
dst->repeat_pict = src->repeat_pict;
|
||||
dst->interlaced_frame = src->interlaced_frame;
|
||||
dst->top_field_first = src->top_field_first;
|
||||
dst->palette_has_changed = src->palette_has_changed;
|
||||
dst->sample_rate = src->sample_rate;
|
||||
dst->opaque = src->opaque;
|
||||
dst->pkt_pts = src->pkt_pts;
|
||||
dst->pkt_dts = src->pkt_dts;
|
||||
dst->pkt_pos = src->pkt_pos;
|
||||
dst->pkt_size = src->pkt_size;
|
||||
dst->pkt_duration = src->pkt_duration;
|
||||
dst->reordered_opaque = src->reordered_opaque;
|
||||
dst->quality = src->quality;
|
||||
dst->best_effort_timestamp = src->best_effort_timestamp;
|
||||
dst->coded_picture_number = src->coded_picture_number;
|
||||
dst->display_picture_number = src->display_picture_number;
|
||||
dst->flags = src->flags;
|
||||
dst->decode_error_flags = src->decode_error_flags;
|
||||
dst->color_primaries = src->color_primaries;
|
||||
dst->color_trc = src->color_trc;
|
||||
dst->colorspace = src->colorspace;
|
||||
dst->color_range = src->color_range;
|
||||
dst->chroma_location = src->chroma_location;
|
||||
|
||||
av_dict_copy(&dst->metadata, src->metadata, 0);
|
||||
|
||||
#if FF_API_ERROR_FRAME
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
memcpy(dst->error, src->error, sizeof(dst->error));
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
for (i = 0; i < src->nb_side_data; i++) {
|
||||
const AVFrameSideData *sd_src = src->side_data[i];
|
||||
AVFrameSideData *sd_dst;
|
||||
if ( sd_src->type == AV_FRAME_DATA_PANSCAN
|
||||
&& (src->width != dst->width || src->height != dst->height))
|
||||
continue;
|
||||
if (force_copy) {
|
||||
sd_dst = av_frame_new_side_data(dst, sd_src->type,
|
||||
sd_src->size);
|
||||
if (!sd_dst) {
|
||||
wipe_side_data(dst);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
memcpy(sd_dst->data, sd_src->data, sd_src->size);
|
||||
} else {
|
||||
sd_dst = av_frame_new_side_data(dst, sd_src->type, 0);
|
||||
if (!sd_dst) {
|
||||
wipe_side_data(dst);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
sd_dst->buf = av_buffer_ref(sd_src->buf);
|
||||
if (!sd_dst->buf) {
|
||||
wipe_side_data(dst);
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
sd_dst->data = sd_dst->buf->data;
|
||||
sd_dst->size = sd_dst->buf->size;
|
||||
}
|
||||
av_dict_copy(&sd_dst->metadata, sd_src->metadata, 0);
|
||||
}
|
||||
|
||||
#if FF_API_FRAME_QP
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
dst->qscale_table = NULL;
|
||||
dst->qstride = 0;
|
||||
dst->qscale_type = 0;
|
||||
av_buffer_unref(&dst->qp_table_buf);
|
||||
if (src->qp_table_buf) {
|
||||
dst->qp_table_buf = av_buffer_ref(src->qp_table_buf);
|
||||
if (dst->qp_table_buf) {
|
||||
dst->qscale_table = dst->qp_table_buf->data;
|
||||
dst->qstride = src->qstride;
|
||||
dst->qscale_type = src->qscale_type;
|
||||
}
|
||||
}
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
@@ -327,8 +169,6 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src)
|
||||
int i, ret = 0;
|
||||
|
||||
dst->format = src->format;
|
||||
dst->width = src->width;
|
||||
dst->height = src->height;
|
||||
dst->channels = src->channels;
|
||||
dst->channel_layout = src->channel_layout;
|
||||
dst->nb_samples = src->nb_samples;
|
||||
@@ -428,17 +268,11 @@ void av_frame_unref(AVFrame *frame)
|
||||
if (!frame)
|
||||
return;
|
||||
|
||||
wipe_side_data(frame);
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(frame->buf); i++)
|
||||
av_buffer_unref(&frame->buf[i]);
|
||||
for (i = 0; i < frame->nb_extended_buf; i++)
|
||||
av_buffer_unref(&frame->extended_buf[i]);
|
||||
av_freep(&frame->extended_buf);
|
||||
av_dict_free(&frame->metadata);
|
||||
#if FF_API_FRAME_QP
|
||||
av_buffer_unref(&frame->qp_table_buf);
|
||||
#endif
|
||||
|
||||
get_frame_defaults(frame);
|
||||
}
|
||||
@@ -469,49 +303,6 @@ int av_frame_is_writable(AVFrame *frame)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int av_frame_make_writable(AVFrame *frame)
|
||||
{
|
||||
AVFrame tmp;
|
||||
int ret;
|
||||
|
||||
if (!frame->buf[0])
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
if (av_frame_is_writable(frame))
|
||||
return 0;
|
||||
|
||||
memset(&tmp, 0, sizeof(tmp));
|
||||
tmp.format = frame->format;
|
||||
tmp.width = frame->width;
|
||||
tmp.height = frame->height;
|
||||
tmp.channels = frame->channels;
|
||||
tmp.channel_layout = frame->channel_layout;
|
||||
tmp.nb_samples = frame->nb_samples;
|
||||
ret = av_frame_get_buffer(&tmp, 32);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = av_frame_copy(&tmp, frame);
|
||||
if (ret < 0) {
|
||||
av_frame_unref(&tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = av_frame_copy_props(&tmp, frame);
|
||||
if (ret < 0) {
|
||||
av_frame_unref(&tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
av_frame_unref(frame);
|
||||
|
||||
*frame = tmp;
|
||||
if (tmp.data == tmp.extended_data)
|
||||
frame->extended_data = frame->data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
|
||||
{
|
||||
return frame_copy_props(dst, src, 1);
|
||||
@@ -548,54 +339,6 @@ AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
|
||||
enum AVFrameSideDataType type,
|
||||
int size)
|
||||
{
|
||||
AVFrameSideData *ret, **tmp;
|
||||
|
||||
if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1)
|
||||
return NULL;
|
||||
|
||||
tmp = av_realloc(frame->side_data,
|
||||
(frame->nb_side_data + 1) * sizeof(*frame->side_data));
|
||||
if (!tmp)
|
||||
return NULL;
|
||||
frame->side_data = tmp;
|
||||
|
||||
ret = av_mallocz(sizeof(*ret));
|
||||
if (!ret)
|
||||
return NULL;
|
||||
|
||||
if (size > 0) {
|
||||
ret->buf = av_buffer_alloc(size);
|
||||
if (!ret->buf) {
|
||||
av_freep(&ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret->data = ret->buf->data;
|
||||
ret->size = size;
|
||||
}
|
||||
ret->type = type;
|
||||
|
||||
frame->side_data[frame->nb_side_data++] = ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
|
||||
enum AVFrameSideDataType type)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < frame->nb_side_data; i++) {
|
||||
if (frame->side_data[i]->type == type)
|
||||
return frame->side_data[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int frame_copy_audio(AVFrame *dst, const AVFrame *src)
|
||||
{
|
||||
int planar = av_sample_fmt_is_planar(dst->format);
|
||||
@@ -624,45 +367,7 @@ int av_frame_copy(AVFrame *dst, const AVFrame *src)
|
||||
{
|
||||
if (dst->format != src->format || dst->format < 0)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
if (dst->width > 0 && dst->height > 0)
|
||||
return AVERROR(EINVAL);
|
||||
else if (dst->nb_samples > 0 && dst->channel_layout)
|
||||
return frame_copy_audio(dst, src);
|
||||
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < frame->nb_side_data; i++) {
|
||||
AVFrameSideData *sd = frame->side_data[i];
|
||||
if (sd->type == type) {
|
||||
free_side_data(&frame->side_data[i]);
|
||||
frame->side_data[i] = frame->side_data[frame->nb_side_data - 1];
|
||||
frame->nb_side_data--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char *av_frame_side_data_name(enum AVFrameSideDataType type)
|
||||
{
|
||||
switch(type) {
|
||||
case AV_FRAME_DATA_PANSCAN: return "AVPanScan";
|
||||
case AV_FRAME_DATA_A53_CC: return "ATSC A53 Part 4 Closed Captions";
|
||||
case AV_FRAME_DATA_STEREO3D: return "Stereoscopic 3d metadata";
|
||||
case AV_FRAME_DATA_MATRIXENCODING: return "AVMatrixEncoding";
|
||||
case AV_FRAME_DATA_DOWNMIX_INFO: return "Metadata relevant to a downmix procedure";
|
||||
case AV_FRAME_DATA_REPLAYGAIN: return "AVReplayGain";
|
||||
case AV_FRAME_DATA_DISPLAYMATRIX: return "3x3 displaymatrix";
|
||||
case AV_FRAME_DATA_AFD: return "Active format description";
|
||||
case AV_FRAME_DATA_MOTION_VECTORS: return "Motion vectors";
|
||||
case AV_FRAME_DATA_SKIP_SAMPLES: return "Skip samples";
|
||||
case AV_FRAME_DATA_AUDIO_SERVICE_TYPE: return "Audio service type";
|
||||
case AV_FRAME_DATA_MASTERING_DISPLAY_METADATA: return "Mastering display metadata";
|
||||
case AV_FRAME_DATA_GOP_TIMECODE: return "GOP timecode";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "dict.h"
|
||||
#include "rational.h"
|
||||
#include "samplefmt.h"
|
||||
#include "pixfmt.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
@@ -124,31 +123,6 @@ enum AVFrameSideDataType {
|
||||
AV_FRAME_DATA_GOP_TIMECODE
|
||||
};
|
||||
|
||||
enum AVActiveFormatDescription {
|
||||
AV_AFD_SAME = 8,
|
||||
AV_AFD_4_3 = 9,
|
||||
AV_AFD_16_9 = 10,
|
||||
AV_AFD_14_9 = 11,
|
||||
AV_AFD_4_3_SP_14_9 = 13,
|
||||
AV_AFD_16_9_SP_14_9 = 14,
|
||||
AV_AFD_SP_4_3 = 15,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Structure to hold side data for an AVFrame.
|
||||
*
|
||||
* sizeof(AVFrameSideData) is not a part of the public ABI, so new fields may be added
|
||||
* to the end with a minor bump.
|
||||
*/
|
||||
typedef struct AVFrameSideData {
|
||||
enum AVFrameSideDataType type;
|
||||
uint8_t *data;
|
||||
int size;
|
||||
AVDictionary *metadata;
|
||||
AVBufferRef *buf;
|
||||
} AVFrameSideData;
|
||||
|
||||
/**
|
||||
* This structure describes decoded (raw) audio or video data.
|
||||
*
|
||||
@@ -224,11 +198,6 @@ typedef struct AVFrame {
|
||||
*/
|
||||
uint8_t **extended_data;
|
||||
|
||||
/**
|
||||
* width and height of the video frame
|
||||
*/
|
||||
int width, height;
|
||||
|
||||
/**
|
||||
* number of audio samples (per channel) described by this frame
|
||||
*/
|
||||
@@ -241,57 +210,11 @@ typedef struct AVFrame {
|
||||
*/
|
||||
int format;
|
||||
|
||||
/**
|
||||
* 1 -> keyframe, 0-> not
|
||||
*/
|
||||
int key_frame;
|
||||
|
||||
/**
|
||||
* Picture type of the frame.
|
||||
*/
|
||||
enum AVPictureType pict_type;
|
||||
|
||||
/**
|
||||
* Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
|
||||
*/
|
||||
AVRational sample_aspect_ratio;
|
||||
|
||||
/**
|
||||
* Presentation timestamp in time_base units (time when frame should be shown to user).
|
||||
*/
|
||||
int64_t pts;
|
||||
|
||||
/**
|
||||
* PTS copied from the AVPacket that was decoded to produce this frame.
|
||||
*/
|
||||
int64_t pkt_pts;
|
||||
|
||||
/**
|
||||
* DTS copied from the AVPacket that triggered returning this frame. (if frame threading isn't used)
|
||||
* This is also the Presentation time of this AVFrame calculated from
|
||||
* only AVPacket.dts values without pts values.
|
||||
*/
|
||||
int64_t pkt_dts;
|
||||
|
||||
/**
|
||||
* picture number in bitstream order
|
||||
*/
|
||||
int coded_picture_number;
|
||||
/**
|
||||
* picture number in display order
|
||||
*/
|
||||
int display_picture_number;
|
||||
|
||||
/**
|
||||
* quality (between 1 (good) and FF_LAMBDA_MAX (bad))
|
||||
*/
|
||||
int quality;
|
||||
|
||||
/**
|
||||
* for some private data of the user
|
||||
*/
|
||||
void *opaque;
|
||||
|
||||
#if FF_API_ERROR_FRAME
|
||||
/**
|
||||
* @deprecated unused
|
||||
@@ -300,38 +223,6 @@ typedef struct AVFrame {
|
||||
uint64_t error[AV_NUM_DATA_POINTERS];
|
||||
#endif
|
||||
|
||||
/**
|
||||
* When decoding, this signals how much the picture must be delayed.
|
||||
* extra_delay = repeat_pict / (2*fps)
|
||||
*/
|
||||
int repeat_pict;
|
||||
|
||||
/**
|
||||
* The content of the picture is interlaced.
|
||||
*/
|
||||
int interlaced_frame;
|
||||
|
||||
/**
|
||||
* If the content is interlaced, is top field displayed first.
|
||||
*/
|
||||
int top_field_first;
|
||||
|
||||
/**
|
||||
* Tell user application that palette has changed from previous frame.
|
||||
*/
|
||||
int palette_has_changed;
|
||||
|
||||
/**
|
||||
* reordered opaque 64bit (generally an integer or a double precision float
|
||||
* PTS but can be anything).
|
||||
* The user sets AVCodecContext.reordered_opaque to represent the input at
|
||||
* that time,
|
||||
* the decoder reorders values as needed and sets AVFrame.reordered_opaque
|
||||
* to exactly one of the values provided by the user through AVCodecContext.reordered_opaque
|
||||
* @deprecated in favor of pkt_pts
|
||||
*/
|
||||
int64_t reordered_opaque;
|
||||
|
||||
/**
|
||||
* Sample rate of the audio data.
|
||||
*/
|
||||
@@ -374,9 +265,6 @@ typedef struct AVFrame {
|
||||
*/
|
||||
int nb_extended_buf;
|
||||
|
||||
AVFrameSideData **side_data;
|
||||
int nb_side_data;
|
||||
|
||||
/**
|
||||
* @defgroup lavu_frame_flags AV_FRAME_FLAGS
|
||||
* Flags describing additional frame properties.
|
||||
@@ -397,30 +285,6 @@ typedef struct AVFrame {
|
||||
*/
|
||||
int flags;
|
||||
|
||||
/**
|
||||
* MPEG vs JPEG YUV range.
|
||||
* It must be accessed using av_frame_get_color_range() and
|
||||
* av_frame_set_color_range().
|
||||
* - encoding: Set by user
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
enum AVColorRange color_range;
|
||||
|
||||
enum AVColorPrimaries color_primaries;
|
||||
|
||||
enum AVColorTransferCharacteristic color_trc;
|
||||
|
||||
/**
|
||||
* YUV colorspace type.
|
||||
* It must be accessed using av_frame_get_colorspace() and
|
||||
* av_frame_set_colorspace().
|
||||
* - encoding: Set by user
|
||||
* - decoding: Set by libavcodec
|
||||
*/
|
||||
enum AVColorSpace colorspace;
|
||||
|
||||
enum AVChromaLocation chroma_location;
|
||||
|
||||
/**
|
||||
* frame timestamp estimated using various heuristics, in stream time base
|
||||
* Code outside libavutil should access this field using:
|
||||
@@ -449,15 +313,6 @@ typedef struct AVFrame {
|
||||
*/
|
||||
int64_t pkt_duration;
|
||||
|
||||
/**
|
||||
* metadata.
|
||||
* Code outside libavutil should access this field using:
|
||||
* av_frame_get_metadata(frame)
|
||||
* - encoding: Set by user.
|
||||
* - decoding: Set by libavcodec.
|
||||
*/
|
||||
AVDictionary *metadata;
|
||||
|
||||
/**
|
||||
* decode error flags of the frame, set to a combination of
|
||||
* FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there
|
||||
@@ -489,29 +344,6 @@ typedef struct AVFrame {
|
||||
* - decoding: set by libavcodec, read by user.
|
||||
*/
|
||||
int pkt_size;
|
||||
|
||||
#if FF_API_FRAME_QP
|
||||
/**
|
||||
* QP table
|
||||
* Not to be accessed directly from outside libavutil
|
||||
*/
|
||||
attribute_deprecated
|
||||
int8_t *qscale_table;
|
||||
/**
|
||||
* QP store stride
|
||||
* Not to be accessed directly from outside libavutil
|
||||
*/
|
||||
attribute_deprecated
|
||||
int qstride;
|
||||
|
||||
attribute_deprecated
|
||||
int qscale_type;
|
||||
|
||||
/**
|
||||
* Not to be accessed directly from outside libavutil
|
||||
*/
|
||||
AVBufferRef *qp_table_buf;
|
||||
#endif
|
||||
} AVFrame;
|
||||
|
||||
/**
|
||||
@@ -531,21 +363,11 @@ int av_frame_get_channels (const AVFrame *frame);
|
||||
void av_frame_set_channels (AVFrame *frame, int val);
|
||||
int av_frame_get_sample_rate (const AVFrame *frame);
|
||||
void av_frame_set_sample_rate (AVFrame *frame, int val);
|
||||
AVDictionary *av_frame_get_metadata (const AVFrame *frame);
|
||||
void av_frame_set_metadata (AVFrame *frame, AVDictionary *val);
|
||||
int av_frame_get_decode_error_flags (const AVFrame *frame);
|
||||
void av_frame_set_decode_error_flags (AVFrame *frame, int val);
|
||||
int av_frame_get_pkt_size(const AVFrame *frame);
|
||||
void av_frame_set_pkt_size(AVFrame *frame, int val);
|
||||
AVDictionary **avpriv_frame_get_metadatap(AVFrame *frame);
|
||||
#if FF_API_FRAME_QP
|
||||
int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type);
|
||||
int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int type);
|
||||
#endif
|
||||
enum AVColorSpace av_frame_get_colorspace(const AVFrame *frame);
|
||||
void av_frame_set_colorspace(AVFrame *frame, enum AVColorSpace val);
|
||||
enum AVColorRange av_frame_get_color_range(const AVFrame *frame);
|
||||
void av_frame_set_color_range(AVFrame *frame, enum AVColorRange val);
|
||||
|
||||
/**
|
||||
* Get the name of a colorspace.
|
||||
@@ -639,19 +461,6 @@ int av_frame_get_buffer(AVFrame *frame, int align);
|
||||
*/
|
||||
int av_frame_is_writable(AVFrame *frame);
|
||||
|
||||
/**
|
||||
* Ensure that the frame data is writable, avoiding data copy if possible.
|
||||
*
|
||||
* Do nothing if the frame is writable, allocate new buffers and copy the data
|
||||
* if it is not.
|
||||
*
|
||||
* @return 0 on success, a negative AVERROR on error.
|
||||
*
|
||||
* @see av_frame_is_writable(), av_buffer_is_writable(),
|
||||
* av_buffer_make_writable()
|
||||
*/
|
||||
int av_frame_make_writable(AVFrame *frame);
|
||||
|
||||
/**
|
||||
* Copy the frame data from src to dst.
|
||||
*
|
||||
@@ -685,37 +494,6 @@ int av_frame_copy_props(AVFrame *dst, const AVFrame *src);
|
||||
*/
|
||||
AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane);
|
||||
|
||||
/**
|
||||
* Add a new side data to a frame.
|
||||
*
|
||||
* @param frame a frame to which the side data should be added
|
||||
* @param type type of the added side data
|
||||
* @param size size of the side data
|
||||
*
|
||||
* @return newly added side data on success, NULL on error
|
||||
*/
|
||||
AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
|
||||
enum AVFrameSideDataType type,
|
||||
int size);
|
||||
|
||||
/**
|
||||
* @return a pointer to the side data of a given type on success, NULL if there
|
||||
* is no side data with such type in this frame.
|
||||
*/
|
||||
AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
|
||||
enum AVFrameSideDataType type);
|
||||
|
||||
/**
|
||||
* If side data of the supplied type exists in the frame, free it and remove it
|
||||
* from the frame.
|
||||
*/
|
||||
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type);
|
||||
|
||||
/**
|
||||
* @return a string identifying the side data type
|
||||
*/
|
||||
const char *av_frame_side_data_name(enum AVFrameSideDataType type);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "buffer.h"
|
||||
#include "channel_layout.h"
|
||||
#include "mathematics.h"
|
||||
#include "pixfmt.h"
|
||||
#include "avcodec.h"
|
||||
#include "config.h"
|
||||
|
||||
@@ -155,11 +154,6 @@ typedef struct AVCodecInternal {
|
||||
* Number of audio samples to skip at the start of the next decoded frame
|
||||
*/
|
||||
int skip_samples;
|
||||
|
||||
/**
|
||||
* hwaccel-specific private data
|
||||
*/
|
||||
void *hwaccel_priv_data;
|
||||
} AVCodecInternal;
|
||||
|
||||
struct AVCodecDefault {
|
||||
|
||||
@@ -138,27 +138,6 @@ static av_always_inline av_const int ff_ctzll_c(long long v)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef ff_clz
|
||||
#define ff_clz ff_clz_c
|
||||
static av_always_inline av_const unsigned ff_clz_c(unsigned x)
|
||||
{
|
||||
unsigned i = sizeof(x) * 8;
|
||||
|
||||
while (x) {
|
||||
x >>= 1;
|
||||
i--;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,4)
|
||||
#ifndef av_parity
|
||||
#define av_parity __builtin_parity
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -84,69 +84,6 @@ typedef union {
|
||||
* Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers.
|
||||
*/
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
|
||||
# if defined(AV_RN16) && !defined(AV_RB16)
|
||||
# define AV_RB16(p) AV_RN16(p)
|
||||
# elif !defined(AV_RN16) && defined(AV_RB16)
|
||||
# define AV_RN16(p) AV_RB16(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN16) && !defined(AV_WB16)
|
||||
# define AV_WB16(p, v) AV_WN16(p, v)
|
||||
# elif !defined(AV_WN16) && defined(AV_WB16)
|
||||
# define AV_WN16(p, v) AV_WB16(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN24) && !defined(AV_RB24)
|
||||
# define AV_RB24(p) AV_RN24(p)
|
||||
# elif !defined(AV_RN24) && defined(AV_RB24)
|
||||
# define AV_RN24(p) AV_RB24(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN24) && !defined(AV_WB24)
|
||||
# define AV_WB24(p, v) AV_WN24(p, v)
|
||||
# elif !defined(AV_WN24) && defined(AV_WB24)
|
||||
# define AV_WN24(p, v) AV_WB24(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_RN32) && !defined(AV_RB32)
|
||||
# define AV_RB32(p) AV_RN32(p)
|
||||
# elif !defined(AV_RN32) && defined(AV_RB32)
|
||||
# define AV_RN32(p) AV_RB32(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN32) && !defined(AV_WB32)
|
||||
# define AV_WB32(p, v) AV_WN32(p, v)
|
||||
# elif !defined(AV_WN32) && defined(AV_WB32)
|
||||
# define AV_WN32(p, v) AV_WB32(p, v)
|
||||
# endif
|
||||
|
||||
# if defined(AV_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)
|
||||
# define AV_RN64(p) AV_RB64(p)
|
||||
# endif
|
||||
|
||||
# if defined(AV_WN64) && !defined(AV_WB64)
|
||||
# define AV_WB64(p, v) AV_WN64(p, v)
|
||||
# elif !defined(AV_WN64) && defined(AV_WB64)
|
||||
# define AV_WN64(p, v) AV_WB64(p, v)
|
||||
# endif
|
||||
|
||||
#else /* AV_HAVE_BIGENDIAN */
|
||||
|
||||
# if defined(AV_RN16) && !defined(AV_RL16)
|
||||
# define AV_RL16(p) AV_RN16(p)
|
||||
@@ -208,8 +145,6 @@ typedef union {
|
||||
# define AV_WN64(p, v) AV_WL64(p, v)
|
||||
# endif
|
||||
|
||||
#endif /* !AV_HAVE_BIGENDIAN */
|
||||
|
||||
/*
|
||||
* Define AV_[RW]N helper macros to simplify definitions not provided
|
||||
* by per-arch headers.
|
||||
|
||||
@@ -362,28 +362,6 @@ static av_always_inline av_const int avpriv_isfinite(double x)
|
||||
: avpriv_isfinite(x))
|
||||
#endif /* HAVE_ISFINITE */
|
||||
|
||||
#if !HAVE_HYPOT
|
||||
static inline av_const double hypot(double x, double y)
|
||||
{
|
||||
double ret, temp;
|
||||
x = fabs(x);
|
||||
y = fabs(y);
|
||||
|
||||
if (isinf(x) || isinf(y))
|
||||
return av_int2double(0x7ff0000000000000);
|
||||
if (x == 0 || y == 0)
|
||||
return x + y;
|
||||
if (x < y) {
|
||||
temp = x;
|
||||
x = y;
|
||||
y = temp;
|
||||
}
|
||||
|
||||
y = y/x;
|
||||
return x*sqrt(1 + y*y);
|
||||
}
|
||||
#endif /* HAVE_HYPOT */
|
||||
|
||||
#if !HAVE_LDEXPF
|
||||
#undef ldexpf
|
||||
#define ldexpf(x, exp) ((float)ldexp(x, exp))
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#include "mathops.h"
|
||||
|
||||
#ifdef TEST
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
unsigned u;
|
||||
|
||||
for(u=0; u<65536; u++) {
|
||||
unsigned s = u*u;
|
||||
unsigned root = ff_sqrt(s);
|
||||
unsigned root_m1 = ff_sqrt(s-1);
|
||||
if (s && root != u) {
|
||||
fprintf(stderr, "ff_sqrt failed at %u with %u\n", s, root);
|
||||
return 1;
|
||||
}
|
||||
if (u && root_m1 != u - 1) {
|
||||
fprintf(stderr, "ff_sqrt failed at %u with %u\n", s, root);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* TEST */
|
||||
@@ -60,18 +60,6 @@
|
||||
#define DECLARE_ASM_CONST(n,t,v) static const t v
|
||||
#endif
|
||||
|
||||
#if AV_GCC_VERSION_AT_LEAST(3,1)
|
||||
#define av_malloc_attrib __attribute__((__malloc__))
|
||||
#else
|
||||
#define av_malloc_attrib
|
||||
#endif
|
||||
|
||||
#if AV_GCC_VERSION_AT_LEAST(4,3)
|
||||
#define av_alloc_size(...) __attribute__((alloc_size(__VA_ARGS__)))
|
||||
#else
|
||||
#define av_alloc_size(...)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Allocate a block of size bytes with alignment suitable for all
|
||||
* memory accesses (including vectors if available on the CPU).
|
||||
@@ -80,7 +68,7 @@
|
||||
* be allocated.
|
||||
* @see av_mallocz()
|
||||
*/
|
||||
void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1);
|
||||
void *av_malloc(size_t size);
|
||||
|
||||
/**
|
||||
* Allocate a block of size * nmemb bytes with av_malloc().
|
||||
@@ -90,7 +78,7 @@ void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1);
|
||||
* be allocated.
|
||||
* @see av_malloc()
|
||||
*/
|
||||
av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t size)
|
||||
static inline void *av_malloc_array(size_t nmemb, size_t size)
|
||||
{
|
||||
if (!size || nmemb >= INT_MAX / size)
|
||||
return NULL;
|
||||
@@ -115,7 +103,7 @@ av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t siz
|
||||
* some libc implementations.
|
||||
* @see av_fast_realloc()
|
||||
*/
|
||||
void *av_realloc(void *ptr, size_t size) av_alloc_size(2);
|
||||
void *av_realloc(void *ptr, size_t size);
|
||||
|
||||
/**
|
||||
* Allocate or reallocate a block of memory.
|
||||
@@ -164,7 +152,7 @@ int av_reallocp(void *ptr, size_t size);
|
||||
* The situation is undefined according to POSIX and may crash with
|
||||
* some libc implementations.
|
||||
*/
|
||||
av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size);
|
||||
void *av_realloc_array(void *ptr, size_t nmemb, size_t size);
|
||||
|
||||
/**
|
||||
* Allocate or reallocate an array through a pointer to a pointer.
|
||||
@@ -203,7 +191,7 @@ void av_free(void *ptr);
|
||||
* @return Pointer to the allocated block, NULL if it cannot be allocated.
|
||||
* @see av_malloc()
|
||||
*/
|
||||
void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1);
|
||||
void *av_mallocz(size_t size);
|
||||
|
||||
/**
|
||||
* Allocate a block of nmemb * size bytes with alignment suitable for all
|
||||
@@ -215,7 +203,7 @@ void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1);
|
||||
* @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;
|
||||
void *av_calloc(size_t nmemb, size_t size);
|
||||
|
||||
/**
|
||||
* Allocate a block of size * nmemb bytes with av_mallocz().
|
||||
@@ -226,7 +214,7 @@ void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib;
|
||||
* @see av_mallocz()
|
||||
* @see av_malloc_array()
|
||||
*/
|
||||
av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t size)
|
||||
static inline void *av_mallocz_array(size_t nmemb, size_t size)
|
||||
{
|
||||
if (!size || nmemb >= INT_MAX / size)
|
||||
return NULL;
|
||||
@@ -239,7 +227,7 @@ av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t si
|
||||
* @return Pointer to a newly-allocated string containing a
|
||||
* copy of s or NULL if the string cannot be allocated.
|
||||
*/
|
||||
char *av_strdup(const char *s) av_malloc_attrib;
|
||||
char *av_strdup(const char *s);
|
||||
|
||||
/**
|
||||
* Duplicate a substring of the string s.
|
||||
@@ -249,7 +237,7 @@ char *av_strdup(const char *s) av_malloc_attrib;
|
||||
* @return Pointer to a newly-allocated string containing a
|
||||
* copy of s or NULL if the string cannot be allocated.
|
||||
*/
|
||||
char *av_strndup(const char *s, size_t len) av_malloc_attrib;
|
||||
char *av_strndup(const char *s, size_t len);
|
||||
|
||||
/**
|
||||
* Duplicate the buffer p.
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "dict.h"
|
||||
#include "avstring.h"
|
||||
#include "log.h"
|
||||
#include "pixdesc.h"
|
||||
#include "mathematics.h"
|
||||
#include "samplefmt.h"
|
||||
|
||||
@@ -1223,7 +1222,7 @@ int av_opt_is_set_to_default(void *obj, const AVOption *o)
|
||||
double d, d2;
|
||||
float f;
|
||||
AVRational q;
|
||||
int ret, w, h;
|
||||
int ret;
|
||||
char *str;
|
||||
void *dst;
|
||||
|
||||
@@ -1408,7 +1407,6 @@ int main(void)
|
||||
printf("rational=%d/%d\n", test_ctx.rational.num, test_ctx.rational.den);
|
||||
printf("video_rate=%d/%d\n", test_ctx.video_rate.num, test_ctx.video_rate.den);
|
||||
printf("width=%d height=%d\n", test_ctx.w, test_ctx.h);
|
||||
printf("pix_fmt=%s\n", av_get_pix_fmt_name(test_ctx.pix_fmt));
|
||||
printf("sample_fmt=%s\n", av_get_sample_fmt_name(test_ctx.sample_fmt));
|
||||
printf("duration=%"PRId64"\n", test_ctx.duration);
|
||||
printf("color=%d %d %d %d\n", test_ctx.color[0], test_ctx.color[1], test_ctx.color[2], test_ctx.color[3]);
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "avutil.h"
|
||||
#include "dict.h"
|
||||
#include "log.h"
|
||||
#include "pixfmt.h"
|
||||
#include "samplefmt.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ static AVClassCategory get_category(void *ptr)
|
||||
static const AVClass av_codec_context_class = {
|
||||
.class_name = "AVCodecContext",
|
||||
.item_name = context_to_name,
|
||||
.option = avcodec_options,
|
||||
.option = NULL,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
.log_level_offset_offset = offsetof(AVCodecContext, log_level_offset),
|
||||
.child_next = codec_child_next,
|
||||
@@ -110,17 +110,12 @@ int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec)
|
||||
av_opt_set_defaults2(s, flags, flags);
|
||||
|
||||
s->time_base = (AVRational){0,1};
|
||||
s->framerate = (AVRational){ 0, 1 };
|
||||
s->pkt_timebase = (AVRational){ 0, 1 };
|
||||
s->get_buffer2 = avcodec_default_get_buffer2;
|
||||
s->get_format = avcodec_default_get_format;
|
||||
s->execute = avcodec_default_execute;
|
||||
s->execute2 = avcodec_default_execute2;
|
||||
s->sample_aspect_ratio = (AVRational){0,1};
|
||||
s->pix_fmt = AV_PIX_FMT_NONE;
|
||||
s->sample_fmt = AV_SAMPLE_FMT_NONE;
|
||||
|
||||
s->reordered_opaque = AV_NOPTS_VALUE;
|
||||
if(codec && codec->priv_data_size){
|
||||
if(!s->priv_data){
|
||||
s->priv_data= av_mallocz(codec->priv_data_size);
|
||||
@@ -133,17 +128,6 @@ int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec)
|
||||
av_opt_set_defaults(s->priv_data);
|
||||
}
|
||||
}
|
||||
if (codec && codec->defaults) {
|
||||
int ret;
|
||||
const AVCodecDefault *d = codec->defaults;
|
||||
/*
|
||||
while (d->key) {
|
||||
ret = av_opt_set(s, d->key, d->value, 0);
|
||||
av_assert0(ret >= 0);
|
||||
d++;
|
||||
}
|
||||
*/
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -212,7 +196,6 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
|
||||
|
||||
/* set values specific to opened codecs back to their default state */
|
||||
dest->slice_offset = NULL;
|
||||
dest->hwaccel = NULL;
|
||||
dest->internal = NULL;
|
||||
#if FF_API_CODED_FRAME
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
@@ -271,9 +254,6 @@ static const AVOption frame_options[]={
|
||||
{"best_effort_timestamp", "", FOFFSET(best_effort_timestamp), AV_OPT_TYPE_INT64, {.i64 = AV_NOPTS_VALUE }, INT64_MIN, INT64_MAX, 0},
|
||||
{"pkt_pos", "", FOFFSET(pkt_pos), AV_OPT_TYPE_INT64, {.i64 = -1 }, INT64_MIN, INT64_MAX, 0},
|
||||
{"pkt_size", "", FOFFSET(pkt_size), AV_OPT_TYPE_INT64, {.i64 = -1 }, INT64_MIN, INT64_MAX, 0},
|
||||
{"sample_aspect_ratio", "", FOFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, 0, INT_MAX, 0},
|
||||
{"width", "", FOFFSET(width), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
|
||||
{"height", "", FOFFSET(height), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
|
||||
{"format", "", FOFFSET(format), AV_OPT_TYPE_INT, {.i64 = -1 }, 0, INT_MAX, 0},
|
||||
{"channel_layout", "", FOFFSET(channel_layout), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, 0},
|
||||
{"sample_rate", "", FOFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
|
||||
@@ -293,195 +273,3 @@ const AVClass *avcodec_get_frame_class(void)
|
||||
}
|
||||
|
||||
#define SROFFSET(x) offsetof(AVSubtitleRect,x)
|
||||
|
||||
static const AVOption subtitle_rect_options[]={
|
||||
{"x", "", SROFFSET(x), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
|
||||
{"y", "", SROFFSET(y), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
|
||||
{"w", "", SROFFSET(w), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
|
||||
{"h", "", SROFFSET(h), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
|
||||
{"type", "", SROFFSET(type), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, 0},
|
||||
{"flags", "", SROFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, 1, 0, "flags"},
|
||||
{"forced", "", SROFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, 0, 1, 0},
|
||||
{NULL},
|
||||
};
|
||||
|
||||
static const AVClass av_subtitle_rect_class = {
|
||||
.class_name = "AVSubtitleRect",
|
||||
.item_name = NULL,
|
||||
.option = subtitle_rect_options,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
const AVClass *avcodec_get_subtitle_rect_class(void)
|
||||
{
|
||||
return &av_subtitle_rect_class;
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
static int dummy_init(AVCodecContext *ctx)
|
||||
{
|
||||
//TODO: this code should set every possible pointer that could be set by codec and is not an option;
|
||||
ctx->extradata_size = 8;
|
||||
ctx->extradata = av_malloc(ctx->extradata_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dummy_close(AVCodecContext *ctx)
|
||||
{
|
||||
av_freep(&ctx->extradata);
|
||||
ctx->extradata_size = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dummy_encode(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
|
||||
{
|
||||
return AVERROR(ENOSYS);
|
||||
}
|
||||
|
||||
typedef struct Dummy12Context {
|
||||
AVClass *av_class;
|
||||
int num;
|
||||
char* str;
|
||||
} Dummy12Context;
|
||||
|
||||
typedef struct Dummy3Context {
|
||||
void *fake_av_class;
|
||||
int num;
|
||||
char* str;
|
||||
} Dummy3Context;
|
||||
|
||||
#define OFFSET(x) offsetof(Dummy12Context, x)
|
||||
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
|
||||
static const AVOption dummy_options[] = {
|
||||
{ "str", "set str", OFFSET(str), AV_OPT_TYPE_STRING, { .str = "i'm src default value" }, 0, 0, VE},
|
||||
{ "num", "set num", OFFSET(num), AV_OPT_TYPE_INT, { .i64 = 1500100900 }, 0, INT_MAX, VE},
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
static const AVClass dummy_v1_class = {
|
||||
.class_name = "dummy_v1_class",
|
||||
.item_name = av_default_item_name,
|
||||
.option = dummy_options,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
static const AVClass dummy_v2_class = {
|
||||
.class_name = "dummy_v2_class",
|
||||
.item_name = av_default_item_name,
|
||||
.option = dummy_options,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
/* codec with options */
|
||||
static AVCodec dummy_v1_encoder = {
|
||||
.name = "dummy_v1_codec",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.id = AV_CODEC_ID_NONE - 1,
|
||||
.encode2 = dummy_encode,
|
||||
.init = dummy_init,
|
||||
.close = dummy_close,
|
||||
.priv_class = &dummy_v1_class,
|
||||
.priv_data_size = sizeof(Dummy12Context),
|
||||
};
|
||||
|
||||
/* codec with options, different class */
|
||||
static AVCodec dummy_v2_encoder = {
|
||||
.name = "dummy_v2_codec",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.id = AV_CODEC_ID_NONE - 2,
|
||||
.encode2 = dummy_encode,
|
||||
.init = dummy_init,
|
||||
.close = dummy_close,
|
||||
.priv_class = &dummy_v2_class,
|
||||
.priv_data_size = sizeof(Dummy12Context),
|
||||
};
|
||||
|
||||
/* codec with priv data, but no class */
|
||||
static AVCodec dummy_v3_encoder = {
|
||||
.name = "dummy_v3_codec",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.id = AV_CODEC_ID_NONE - 3,
|
||||
.encode2 = dummy_encode,
|
||||
.init = dummy_init,
|
||||
.close = dummy_close,
|
||||
.priv_data_size = sizeof(Dummy3Context),
|
||||
};
|
||||
|
||||
/* codec without priv data */
|
||||
static AVCodec dummy_v4_encoder = {
|
||||
.name = "dummy_v4_codec",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.id = AV_CODEC_ID_NONE - 4,
|
||||
.encode2 = dummy_encode,
|
||||
.init = dummy_init,
|
||||
.close = dummy_close,
|
||||
};
|
||||
|
||||
static void test_copy_print_codec(const AVCodecContext *ctx)
|
||||
{
|
||||
printf("%-14s: %dx%d prv: %s",
|
||||
ctx->codec ? ctx->codec->name : "NULL",
|
||||
ctx->width, ctx->height,
|
||||
ctx->priv_data ? "set" : "null");
|
||||
if (ctx->codec && ctx->codec->priv_class && ctx->codec->priv_data_size) {
|
||||
int64_t i64;
|
||||
char *str = NULL;
|
||||
av_opt_get_int(ctx->priv_data, "num", 0, &i64);
|
||||
av_opt_get(ctx->priv_data, "str", 0, (uint8_t**)&str);
|
||||
printf(" opts: %"PRId64" %s", i64, str);
|
||||
av_free(str);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static void test_copy(const AVCodec *c1, const AVCodec *c2)
|
||||
{
|
||||
AVCodecContext *ctx1, *ctx2;
|
||||
printf("%s -> %s\nclosed:\n", c1 ? c1->name : "NULL", c2 ? c2->name : "NULL");
|
||||
ctx1 = avcodec_alloc_context3(c1);
|
||||
ctx2 = avcodec_alloc_context3(c2);
|
||||
ctx1->width = ctx1->height = 128;
|
||||
if (ctx2->codec && ctx2->codec->priv_class && ctx2->codec->priv_data_size) {
|
||||
av_opt_set(ctx2->priv_data, "num", "667", 0);
|
||||
av_opt_set(ctx2->priv_data, "str", "i'm dest value before copy", 0);
|
||||
}
|
||||
avcodec_copy_context(ctx2, ctx1);
|
||||
test_copy_print_codec(ctx1);
|
||||
test_copy_print_codec(ctx2);
|
||||
if (ctx1->codec) {
|
||||
printf("opened:\n");
|
||||
avcodec_open2(ctx1, ctx1->codec, NULL);
|
||||
if (ctx2->codec && ctx2->codec->priv_class && ctx2->codec->priv_data_size) {
|
||||
av_opt_set(ctx2->priv_data, "num", "667", 0);
|
||||
av_opt_set(ctx2->priv_data, "str", "i'm dest value before copy", 0);
|
||||
}
|
||||
avcodec_copy_context(ctx2, ctx1);
|
||||
test_copy_print_codec(ctx1);
|
||||
test_copy_print_codec(ctx2);
|
||||
avcodec_close(ctx1);
|
||||
}
|
||||
avcodec_free_context(&ctx1);
|
||||
avcodec_free_context(&ctx2);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
AVCodec *dummy_codec[] = {
|
||||
&dummy_v1_encoder,
|
||||
&dummy_v2_encoder,
|
||||
&dummy_v3_encoder,
|
||||
&dummy_v4_encoder,
|
||||
NULL,
|
||||
};
|
||||
int i, j;
|
||||
|
||||
for (i = 0; dummy_codec[i]; i++)
|
||||
avcodec_register(dummy_codec[i]);
|
||||
|
||||
printf("testing avcodec_copy_context()\n");
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(dummy_codec); i++)
|
||||
for (j = 0; j < FF_ARRAY_ELEMS(dummy_codec); j++)
|
||||
test_copy(dummy_codec[i], dummy_codec[j]);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -106,7 +106,6 @@ static const AVOption avcodec_options[] = {
|
||||
{"iter", "iter motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_ITER }, INT_MIN, INT_MAX, V|E, "me_method" },
|
||||
#endif
|
||||
{"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, INT_MIN, INT_MAX},
|
||||
{"g", "set the group of picture (GOP) size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E},
|
||||
{"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E},
|
||||
{"ac", "set number of audio channels", OFFSET(channels), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E},
|
||||
{"cutoff", "set cutoff bandwidth", OFFSET(cutoff), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|E},
|
||||
@@ -120,8 +119,6 @@ static const AVOption avcodec_options[] = {
|
||||
{"qmin", "minimum video quantizer scale (VBR)", OFFSET(qmin), AV_OPT_TYPE_INT, {.i64 = 2 }, -1, 69, V|E},
|
||||
{"qmax", "maximum video quantizer scale (VBR)", OFFSET(qmax), AV_OPT_TYPE_INT, {.i64 = 31 }, -1, 1024, V|E},
|
||||
{"qdiff", "maximum difference between the quantizer scales (VBR)", OFFSET(max_qdiff), AV_OPT_TYPE_INT, {.i64 = 3 }, INT_MIN, INT_MAX, V|E},
|
||||
{"bf", "set maximum number of B frames between non-B-frames", OFFSET(max_b_frames), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, -1, INT_MAX, V|E},
|
||||
{"b_qfactor", "QP factor between P- and B-frames", OFFSET(b_quant_factor), AV_OPT_TYPE_FLOAT, {.dbl = 1.25 }, -FLT_MAX, FLT_MAX, V|E},
|
||||
#if FF_API_RC_STRATEGY
|
||||
{"rc_strategy", "ratecontrol method", OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
|
||||
#endif
|
||||
@@ -199,11 +196,6 @@ static const AVOption avcodec_options[] = {
|
||||
#if FF_API_MPV_OPT
|
||||
{"rc_buf_aggressivity", "deprecated, use encoder private options instead", OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, V|E},
|
||||
#endif
|
||||
{"i_qfactor", "QP factor between P- and I-frames", OFFSET(i_quant_factor), AV_OPT_TYPE_FLOAT, {.dbl = -0.8 }, -FLT_MAX, FLT_MAX, V|E},
|
||||
{"i_qoffset", "QP offset between P- and I-frames", OFFSET(i_quant_offset), AV_OPT_TYPE_FLOAT, {.dbl = 0.0 }, -FLT_MAX, FLT_MAX, V|E},
|
||||
#if FF_API_MPV_OPT
|
||||
{"rc_init_cplx", "deprecated, use encoder private options instead", OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, -FLT_MAX, FLT_MAX, V|E},
|
||||
#endif
|
||||
{"dct", "DCT algorithm", OFFSET(dct_algo), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, V|E, "dct"},
|
||||
{"auto", "autoselect a good one", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_AUTO }, INT_MIN, INT_MAX, V|E, "dct"},
|
||||
{"fastint", "fast integer", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_FASTINT }, INT_MIN, INT_MAX, V|E, "dct"},
|
||||
@@ -211,11 +203,6 @@ static const AVOption avcodec_options[] = {
|
||||
{"mmx", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_MMX }, INT_MIN, INT_MAX, V|E, "dct"},
|
||||
{"altivec", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_ALTIVEC }, INT_MIN, INT_MAX, V|E, "dct"},
|
||||
{"faan", "floating point AAN DCT", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_FAAN }, INT_MIN, INT_MAX, V|E, "dct"},
|
||||
{"lumi_mask", "compresses bright areas stronger than medium ones", OFFSET(lumi_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E},
|
||||
{"tcplx_mask", "temporal complexity masking", OFFSET(temporal_cplx_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E},
|
||||
{"scplx_mask", "spatial complexity masking", OFFSET(spatial_cplx_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E},
|
||||
{"p_mask", "inter masking", OFFSET(p_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E},
|
||||
{"dark_mask", "compresses dark areas stronger than medium ones", OFFSET(dark_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E},
|
||||
{"idct", "select IDCT implementation", OFFSET(idct_algo), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, V|E|D, "idct"},
|
||||
{"auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_AUTO }, INT_MIN, INT_MAX, V|E|D, "idct"},
|
||||
{"int", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_INT }, INT_MIN, INT_MAX, V|E|D, "idct"},
|
||||
@@ -252,7 +239,6 @@ static const AVOption avcodec_options[] = {
|
||||
{"plane", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PRED_PLANE }, INT_MIN, INT_MAX, V|E, "pred"},
|
||||
{"median", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PRED_MEDIAN }, INT_MIN, INT_MAX, V|E, "pred"},
|
||||
#endif
|
||||
{"aspect", "sample aspect ratio", OFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 10, V|E},
|
||||
{"debug", "print specific debug info", OFFSET(debug), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT }, 0, INT_MAX, V|A|S|E|D, "debug"},
|
||||
{"pict", "picture info", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_PICT_INFO }, INT_MIN, INT_MAX, V|D, "debug"},
|
||||
{"rc", "rate control", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DEBUG_RC }, INT_MIN, INT_MAX, V|E, "debug"},
|
||||
@@ -395,22 +381,8 @@ static const AVOption avcodec_options[] = {
|
||||
{"mpeg4_asp", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_MPEG4_ADVANCED_SIMPLE }, INT_MIN, INT_MAX, V|E, "profile"},
|
||||
{"level", NULL, OFFSET(level), AV_OPT_TYPE_INT, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"},
|
||||
{"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"},
|
||||
{"lowres", "decode at 1= 1/2, 2=1/4, 3=1/8 resolutions", OFFSET(lowres), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|A|D},
|
||||
#if FF_API_PRIVATE_OPT
|
||||
{"skip_threshold", "frame skip threshold", OFFSET(frame_skip_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
|
||||
{"skip_factor", "frame skip factor", OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
|
||||
{"skip_exp", "frame skip exponent", OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
|
||||
{"skipcmp", "frame skip compare function", OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.i64 = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, V|E, "cmp_func"},
|
||||
#endif
|
||||
#if FF_API_MPV_OPT
|
||||
{"border_mask", "deprecated, use encoder private options instead", OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, -FLT_MAX, FLT_MAX, V|E},
|
||||
#endif
|
||||
{"mblmin", "minimum macroblock Lagrange factor (VBR)", OFFSET(mb_lmin), AV_OPT_TYPE_INT, {.i64 = FF_QP2LAMBDA * 2 }, 1, FF_LAMBDA_MAX, V|E},
|
||||
{"mblmax", "maximum macroblock Lagrange factor (VBR)", OFFSET(mb_lmax), AV_OPT_TYPE_INT, {.i64 = FF_QP2LAMBDA * 31 }, 1, FF_LAMBDA_MAX, V|E},
|
||||
#if FF_API_PRIVATE_OPT
|
||||
{"mepc", "motion estimation bitrate penalty compensation (1.0 = 256)", OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.i64 = 256 }, INT_MIN, INT_MAX, V|E},
|
||||
#endif
|
||||
{"skip_loop_filter", "skip loop filtering process for the selected frames", OFFSET(skip_loop_filter), AV_OPT_TYPE_INT, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"},
|
||||
{"skip_idct" , "skip IDCT/dequantization for the selected frames", OFFSET(skip_idct), AV_OPT_TYPE_INT, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"},
|
||||
{"skip_frame" , "skip decoding for the selected frames", OFFSET(skip_frame), AV_OPT_TYPE_INT, {.i64 = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"},
|
||||
{"none" , "discard no frame", 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONE }, INT_MIN, INT_MAX, V|D, "avdiscard"},
|
||||
@@ -421,18 +393,9 @@ static const AVOption avcodec_options[] = {
|
||||
{"nointra" , "discard all frames except I frames", 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONINTRA}, INT_MIN, INT_MAX, V|D, "avdiscard"},
|
||||
{"all" , "discard all frames", 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_ALL }, INT_MIN, INT_MAX, V|D, "avdiscard"},
|
||||
{"bidir_refine", "refine the two motion vectors used in bidirectional macroblocks", OFFSET(bidir_refine), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 4, V|E},
|
||||
#if FF_API_PRIVATE_OPT
|
||||
{"brd_scale", "downscale frames for dynamic B-frame decision", OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, 10, V|E},
|
||||
#endif
|
||||
{"keyint_min", "minimum interval between IDR-frames", OFFSET(keyint_min), AV_OPT_TYPE_INT, {.i64 = 25 }, INT_MIN, INT_MAX, V|E},
|
||||
{"refs", "reference frames to consider for motion compensation", OFFSET(refs), AV_OPT_TYPE_INT, {.i64 = 1 }, INT_MIN, INT_MAX, V|E},
|
||||
#if FF_API_PRIVATE_OPT
|
||||
{"chromaoffset", "chroma QP offset from luma", OFFSET(chromaoffset), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
|
||||
#endif
|
||||
{"trellis", "rate-distortion optimal quantization", OFFSET(trellis), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
|
||||
#if FF_API_UNUSED_MEMBERS
|
||||
{"sc_factor", "multiplied by qscale for each frame and added to scene_change_score", OFFSET(scenechange_factor), AV_OPT_TYPE_INT, {.i64 = 6 }, 0, INT_MAX, V|E},
|
||||
#endif /* FF_API_UNUSED_MEMBERS */
|
||||
{"mv0_threshold", NULL, OFFSET(mv0_threshold), AV_OPT_TYPE_INT, {.i64 = 256 }, 0, INT_MAX, V|E},
|
||||
#if FF_API_PRIVATE_OPT
|
||||
{"b_sensitivity", "adjust sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, V|E},
|
||||
@@ -449,56 +412,6 @@ static const AVOption avcodec_options[] = {
|
||||
{"rc_max_vbv_use", NULL, OFFSET(rc_max_available_vbv_use), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, 0.0, FLT_MAX, V|E},
|
||||
{"rc_min_vbv_use", NULL, OFFSET(rc_min_vbv_overflow_use), AV_OPT_TYPE_FLOAT, {.dbl = 3 }, 0.0, FLT_MAX, V|E},
|
||||
{"ticks_per_frame", NULL, OFFSET(ticks_per_frame), AV_OPT_TYPE_INT, {.i64 = 1 }, 1, INT_MAX, A|V|E|D},
|
||||
{"color_primaries", "color primaries", OFFSET(color_primaries), AV_OPT_TYPE_INT, {.i64 = AVCOL_PRI_UNSPECIFIED }, 1, AVCOL_PRI_NB-1, V|E|D, "color_primaries_type"},
|
||||
{"bt709", "BT.709", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_PRI_BT709 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
|
||||
{"unspecified", "Unspecified", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_PRI_UNSPECIFIED }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
|
||||
{"bt470m", "BT.470 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_PRI_BT470M }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
|
||||
{"bt470bg", "BT.470 BG", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_PRI_BT470BG }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
|
||||
{"smpte170m", "SMPTE 170 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_PRI_SMPTE170M }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
|
||||
{"smpte240m", "SMPTE 240 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_PRI_SMPTE240M }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
|
||||
{"film", "Film", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_PRI_FILM }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
|
||||
{"bt2020", "BT.2020", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_PRI_BT2020 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
|
||||
{"smpte428_1", "SMPTE ST 428-1", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_PRI_SMPTEST428_1 }, INT_MIN, INT_MAX, V|E|D, "color_primaries_type"},
|
||||
{"color_trc", "color transfer characteristics", OFFSET(color_trc), AV_OPT_TYPE_INT, {.i64 = AVCOL_TRC_UNSPECIFIED }, 1, AVCOL_TRC_NB-1, V|E|D, "color_trc_type"},
|
||||
{"bt709", "BT.709", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_BT709 }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"unspecified", "Unspecified", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_UNSPECIFIED }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"gamma22", "BT.470 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_GAMMA22 }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"gamma28", "BT.470 BG", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_GAMMA28 }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"smpte170m", "SMPTE 170 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_SMPTE170M }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"smpte240m", "SMPTE 240 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_SMPTE240M }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"linear", "Linear", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_LINEAR }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"log", "Log", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_LOG }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"log_sqrt", "Log square root", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_LOG_SQRT }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"iec61966_2_4", "IEC 61966-2-4", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_IEC61966_2_4 }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"bt1361", "BT.1361", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_BT1361_ECG }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"iec61966_2_1", "IEC 61966-2-1", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_IEC61966_2_1 }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"bt2020_10bit", "BT.2020 - 10 bit", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_BT2020_10 }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"bt2020_12bit", "BT.2020 - 12 bit", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_BT2020_12 }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"smpte2084", "SMPTE ST 2084", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_SMPTEST2084 }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"smpte428_1", "SMPTE ST 428-1", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_TRC_SMPTEST428_1 }, INT_MIN, INT_MAX, V|E|D, "color_trc_type"},
|
||||
{"colorspace", "color space", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64 = AVCOL_SPC_UNSPECIFIED }, 0, AVCOL_SPC_NB-1, V|E|D, "colorspace_type"},
|
||||
{"rgb", "RGB", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_RGB }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"},
|
||||
{"bt709", "BT.709", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT709 }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"},
|
||||
{"unspecified", "Unspecified", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_UNSPECIFIED }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"},
|
||||
{"fcc", "FCC", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_FCC }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"},
|
||||
{"bt470bg", "BT.470 BG", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT470BG }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"},
|
||||
{"smpte170m", "SMPTE 170 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_SMPTE170M }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"},
|
||||
{"smpte240m", "SMPTE 240 M", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_SMPTE240M }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"},
|
||||
{"ycocg", "YCOCG", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_YCOCG }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"},
|
||||
{"bt2020_ncl", "BT.2020 NCL", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT2020_NCL }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"},
|
||||
{"bt2020_cl", "BT.2020 CL", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_SPC_BT2020_CL }, INT_MIN, INT_MAX, V|E|D, "colorspace_type"},
|
||||
{"color_range", "color range", OFFSET(color_range), AV_OPT_TYPE_INT, {.i64 = AVCOL_RANGE_UNSPECIFIED }, 0, AVCOL_RANGE_NB-1, V|E|D, "color_range_type"},
|
||||
{"unspecified", "Unspecified", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_UNSPECIFIED }, INT_MIN, INT_MAX, V|E|D, "color_range_type"},
|
||||
{"mpeg", "MPEG (219*2^(n-8))", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_MPEG }, INT_MIN, INT_MAX, V|E|D, "color_range_type"},
|
||||
{"jpeg", "JPEG (2^n-1)", 0, AV_OPT_TYPE_CONST, {.i64 = AVCOL_RANGE_JPEG }, INT_MIN, INT_MAX, V|E|D, "color_range_type"},
|
||||
{"chroma_sample_location", "chroma sample location", OFFSET(chroma_sample_location), AV_OPT_TYPE_INT, {.i64 = AVCHROMA_LOC_UNSPECIFIED }, 0, AVCHROMA_LOC_NB-1, V|E|D, "chroma_sample_location_type"},
|
||||
{"unspecified", "Unspecified", 0, AV_OPT_TYPE_CONST, {.i64 = AVCHROMA_LOC_UNSPECIFIED }, INT_MIN, INT_MAX, V|E|D, "chroma_sample_location_type"},
|
||||
{"left", "Left", 0, AV_OPT_TYPE_CONST, {.i64 = AVCHROMA_LOC_LEFT }, INT_MIN, INT_MAX, V|E|D, "chroma_sample_location_type"},
|
||||
{"center", "Center", 0, AV_OPT_TYPE_CONST, {.i64 = AVCHROMA_LOC_CENTER }, INT_MIN, INT_MAX, V|E|D, "chroma_sample_location_type"},
|
||||
{"topleft", "Top-left", 0, AV_OPT_TYPE_CONST, {.i64 = AVCHROMA_LOC_TOPLEFT }, INT_MIN, INT_MAX, V|E|D, "chroma_sample_location_type"},
|
||||
{"top", "Top", 0, AV_OPT_TYPE_CONST, {.i64 = AVCHROMA_LOC_TOP }, INT_MIN, INT_MAX, V|E|D, "chroma_sample_location_type"},
|
||||
{"bottomleft", "Bottom-left", 0, AV_OPT_TYPE_CONST, {.i64 = AVCHROMA_LOC_BOTTOMLEFT }, INT_MIN, INT_MAX, V|E|D, "chroma_sample_location_type"},
|
||||
{"bottom", "Bottom", 0, AV_OPT_TYPE_CONST, {.i64 = AVCHROMA_LOC_BOTTOM }, INT_MIN, INT_MAX, V|E|D, "chroma_sample_location_type"},
|
||||
{"log_level_offset", "set the log level offset", OFFSET(log_level_offset), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX },
|
||||
{"slices", "set the number of slices, used in parallelized encoding", OFFSET(slices), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|E},
|
||||
{"thread_type", "select multithreading type", OFFSET(thread_type), AV_OPT_TYPE_FLAGS, {.i64 = FF_THREAD_SLICE|FF_THREAD_FRAME }, 0, INT_MAX, V|A|E|D, "thread_type"},
|
||||
@@ -516,26 +429,10 @@ static const AVOption avcodec_options[] = {
|
||||
{"ka", "Karaoke", 0, AV_OPT_TYPE_CONST, {.i64 = AV_AUDIO_SERVICE_TYPE_KARAOKE }, INT_MIN, INT_MAX, A|E, "audio_service_type"},
|
||||
{"request_sample_fmt", "sample format audio decoders should prefer", OFFSET(request_sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, {.i64=AV_SAMPLE_FMT_NONE}, -1, INT_MAX, A|D, "request_sample_fmt"},
|
||||
{"pkt_timebase", NULL, OFFSET(pkt_timebase), AV_OPT_TYPE_RATIONAL, {.dbl = 0 }, 0, INT_MAX, 0},
|
||||
{"sub_charenc", "set input text subtitles character encoding", OFFSET(sub_charenc), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, S|D},
|
||||
{"sub_charenc_mode", "set input text subtitles character encoding mode", OFFSET(sub_charenc_mode), AV_OPT_TYPE_FLAGS, {.i64 = FF_SUB_CHARENC_MODE_AUTOMATIC}, -1, INT_MAX, S|D, "sub_charenc_mode"},
|
||||
{"do_nothing", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_CHARENC_MODE_DO_NOTHING}, INT_MIN, INT_MAX, S|D, "sub_charenc_mode"},
|
||||
{"auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_CHARENC_MODE_AUTOMATIC}, INT_MIN, INT_MAX, S|D, "sub_charenc_mode"},
|
||||
{"pre_decoder", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_CHARENC_MODE_PRE_DECODER}, INT_MIN, INT_MAX, S|D, "sub_charenc_mode"},
|
||||
{"refcounted_frames", NULL, OFFSET(refcounted_frames), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, A|V|D },
|
||||
#if FF_API_SIDEDATA_ONLY_PKT
|
||||
{"side_data_only_packets", NULL, OFFSET(side_data_only_packets), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, A|V|E },
|
||||
#endif
|
||||
{"skip_alpha", "Skip processing alpha", OFFSET(skip_alpha), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, V|D },
|
||||
{"field_order", "Field order", OFFSET(field_order), AV_OPT_TYPE_INT, {.i64 = AV_FIELD_UNKNOWN }, 0, 5, V|D|E, "field_order" },
|
||||
{"progressive", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AV_FIELD_PROGRESSIVE }, 0, 0, V|D|E, "field_order" },
|
||||
{"tt", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AV_FIELD_TT }, 0, 0, V|D|E, "field_order" },
|
||||
{"bb", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AV_FIELD_BB }, 0, 0, V|D|E, "field_order" },
|
||||
{"tb", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AV_FIELD_TB }, 0, 0, V|D|E, "field_order" },
|
||||
{"bt", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AV_FIELD_BT }, 0, 0, V|D|E, "field_order" },
|
||||
{"dump_separator", "set information dump field separator", OFFSET(dump_separator), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, A|V|S|D|E},
|
||||
{"codec_whitelist", "List of decoders that are allowed to be used", OFFSET(codec_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, A|V|S|D },
|
||||
{"pixel_format", "set pixel format", OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT, {.i64=AV_PIX_FMT_NONE}, -1, INT_MAX, 0 },
|
||||
{"video_size", "set video size", OFFSET(width), AV_OPT_TYPE_IMAGE_SIZE, {.str=NULL}, 0, INT_MAX, 0 },
|
||||
{NULL},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,394 +0,0 @@
|
||||
/*
|
||||
* pixel format descriptor
|
||||
* Copyright (c) 2009 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_PIXDESC_H
|
||||
#define AVUTIL_PIXDESC_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "pixfmt.h"
|
||||
#include "version.h"
|
||||
|
||||
typedef struct AVComponentDescriptor {
|
||||
/**
|
||||
* Which of the 4 planes contains the component.
|
||||
*/
|
||||
int plane;
|
||||
|
||||
/**
|
||||
* Number of elements between 2 horizontally consecutive pixels.
|
||||
* Elements are bits for bitstream formats, bytes otherwise.
|
||||
*/
|
||||
int step;
|
||||
|
||||
/**
|
||||
* Number of elements before the component of the first pixel.
|
||||
* Elements are bits for bitstream formats, bytes otherwise.
|
||||
*/
|
||||
int offset;
|
||||
|
||||
/**
|
||||
* Number of least significant bits that must be shifted away
|
||||
* to get the value.
|
||||
*/
|
||||
int shift;
|
||||
|
||||
/**
|
||||
* Number of bits in the component.
|
||||
*/
|
||||
int depth;
|
||||
|
||||
#if FF_API_PLUS1_MINUS1
|
||||
/** deprecated, use step instead */
|
||||
attribute_deprecated int step_minus1;
|
||||
|
||||
/** deprecated, use depth instead */
|
||||
attribute_deprecated int depth_minus1;
|
||||
|
||||
/** deprecated, use offset instead */
|
||||
attribute_deprecated int offset_plus1;
|
||||
#endif
|
||||
} AVComponentDescriptor;
|
||||
|
||||
/**
|
||||
* Descriptor that unambiguously describes how the bits of a pixel are
|
||||
* stored in the up to 4 data planes of an image. It also stores the
|
||||
* subsampling factors and number of components.
|
||||
*
|
||||
* @note This is separate of the colorspace (RGB, YCbCr, YPbPr, JPEG-style YUV
|
||||
* and all the YUV variants) AVPixFmtDescriptor just stores how values
|
||||
* are stored not what these values represent.
|
||||
*/
|
||||
typedef struct AVPixFmtDescriptor {
|
||||
const char *name;
|
||||
uint8_t nb_components; ///< The number of components each pixel has, (1-4)
|
||||
|
||||
/**
|
||||
* Amount to shift the luma width right to find the chroma width.
|
||||
* For YV12 this is 1 for example.
|
||||
* chroma_width = -((-luma_width) >> log2_chroma_w)
|
||||
* The note above is needed to ensure rounding up.
|
||||
* This value only refers to the chroma components.
|
||||
*/
|
||||
uint8_t log2_chroma_w; ///< chroma_width = -((-luma_width )>>log2_chroma_w)
|
||||
|
||||
/**
|
||||
* Amount to shift the luma height right to find the chroma height.
|
||||
* For YV12 this is 1 for example.
|
||||
* chroma_height= -((-luma_height) >> log2_chroma_h)
|
||||
* The note above is needed to ensure rounding up.
|
||||
* This value only refers to the chroma components.
|
||||
*/
|
||||
uint8_t log2_chroma_h;
|
||||
|
||||
/**
|
||||
* Combination of AV_PIX_FMT_FLAG_... flags.
|
||||
*/
|
||||
uint64_t flags;
|
||||
|
||||
/**
|
||||
* Parameters that describe how pixels are packed.
|
||||
* 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.
|
||||
*
|
||||
* If present, the Alpha channel is always the last component.
|
||||
*/
|
||||
AVComponentDescriptor comp[4];
|
||||
|
||||
/**
|
||||
* Alternative comma-separated names.
|
||||
*/
|
||||
const char *alias;
|
||||
} AVPixFmtDescriptor;
|
||||
|
||||
/**
|
||||
* Pixel format is big-endian.
|
||||
*/
|
||||
#define AV_PIX_FMT_FLAG_BE (1 << 0)
|
||||
/**
|
||||
* Pixel format has a palette in data[1], values are indexes in this palette.
|
||||
*/
|
||||
#define AV_PIX_FMT_FLAG_PAL (1 << 1)
|
||||
/**
|
||||
* All values of a component are bit-wise packed end to end.
|
||||
*/
|
||||
#define AV_PIX_FMT_FLAG_BITSTREAM (1 << 2)
|
||||
/**
|
||||
* Pixel format is an HW accelerated format.
|
||||
*/
|
||||
#define AV_PIX_FMT_FLAG_HWACCEL (1 << 3)
|
||||
/**
|
||||
* At least one pixel component is not in the first data plane.
|
||||
*/
|
||||
#define AV_PIX_FMT_FLAG_PLANAR (1 << 4)
|
||||
/**
|
||||
* The pixel format contains RGB-like data (as opposed to YUV/grayscale).
|
||||
*/
|
||||
#define AV_PIX_FMT_FLAG_RGB (1 << 5)
|
||||
|
||||
/**
|
||||
* The pixel format is "pseudo-paletted". This means that it contains a
|
||||
* fixed palette in the 2nd plane but the palette is fixed/constant for each
|
||||
* PIX_FMT. This allows interpreting the data as if it was PAL8, which can
|
||||
* in some cases be simpler. Or the data can be interpreted purely based on
|
||||
* the pixel format without using the palette.
|
||||
* An example of a pseudo-paletted format is AV_PIX_FMT_GRAY8
|
||||
*/
|
||||
#define AV_PIX_FMT_FLAG_PSEUDOPAL (1 << 6)
|
||||
|
||||
/**
|
||||
* The pixel format has an alpha channel. This is set on all formats that
|
||||
* support alpha in some way. The exception is AV_PIX_FMT_PAL8, which can
|
||||
* carry alpha as part of the palette. Details are explained in the
|
||||
* AVPixelFormat enum, and are also encoded in the corresponding
|
||||
* AVPixFmtDescriptor.
|
||||
*
|
||||
* The alpha is always straight, never pre-multiplied.
|
||||
*
|
||||
* If a codec or a filter does not support alpha, it should set all alpha to
|
||||
* opaque, or use the equivalent pixel formats without alpha component, e.g.
|
||||
* AV_PIX_FMT_RGB0 (or AV_PIX_FMT_RGB24 etc.) instead of AV_PIX_FMT_RGBA.
|
||||
*/
|
||||
#define AV_PIX_FMT_FLAG_ALPHA (1 << 7)
|
||||
|
||||
/**
|
||||
* Read a line from an image, and write the values of the
|
||||
* pixel format component c to dst.
|
||||
*
|
||||
* @param data the array containing the pointers to the planes of the image
|
||||
* @param linesize the array containing the linesizes of the image
|
||||
* @param desc the pixel format descriptor for the image
|
||||
* @param x the horizontal coordinate of the first pixel to read
|
||||
* @param y the vertical coordinate of the first pixel to read
|
||||
* @param w the width of the line to read, that is the number of
|
||||
* values to write to dst
|
||||
* @param read_pal_component if not zero and the format is a paletted
|
||||
* format writes the values corresponding to the palette
|
||||
* component c in data[1] to dst, rather than the palette indexes in
|
||||
* data[0]. The behavior is undefined if the format is not paletted.
|
||||
*/
|
||||
void av_read_image_line(uint16_t *dst, const uint8_t *data[4],
|
||||
const int linesize[4], const AVPixFmtDescriptor *desc,
|
||||
int x, int y, int c, int w, int read_pal_component);
|
||||
|
||||
/**
|
||||
* Write the values from src to the pixel format component c of an
|
||||
* image line.
|
||||
*
|
||||
* @param src array containing the values to write
|
||||
* @param data the array containing the pointers to the planes of the
|
||||
* image to write into. It is supposed to be zeroed.
|
||||
* @param linesize the array containing the linesizes of the image
|
||||
* @param desc the pixel format descriptor for the image
|
||||
* @param x the horizontal coordinate of the first pixel to write
|
||||
* @param y the vertical coordinate of the first pixel to write
|
||||
* @param w the width of the line to write, that is the number of
|
||||
* values to write to the image line
|
||||
*/
|
||||
void av_write_image_line(const uint16_t *src, uint8_t *data[4],
|
||||
const int linesize[4], const AVPixFmtDescriptor *desc,
|
||||
int x, int y, int c, int w);
|
||||
|
||||
/**
|
||||
* Return the pixel format corresponding to name.
|
||||
*
|
||||
* If there is no pixel format with name name, then looks for a
|
||||
* pixel format with the name corresponding to the native endian
|
||||
* format of name.
|
||||
* For example in a little-endian system, first looks for "gray16",
|
||||
* then for "gray16le".
|
||||
*
|
||||
* Finally if no pixel format has been found, returns AV_PIX_FMT_NONE.
|
||||
*/
|
||||
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 a 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
|
||||
* described by pixdesc. Note that this is not the same as the number
|
||||
* of bits per sample.
|
||||
*
|
||||
* The returned number of bits refers to the number of bits actually
|
||||
* used for storing the pixel information, that is padding bits are
|
||||
* not counted.
|
||||
*/
|
||||
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 av_get_chroma_sub_sample() for a function that asserts a
|
||||
* valid pixel format instead of returning an error code.
|
||||
* Its recommended 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_w (horizontal/width shift)
|
||||
* @param[out] v_shift store log2_chroma_h (vertical/height shift)
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @return number of planes in pix_fmt, a negative AVERROR if pix_fmt is not a
|
||||
* valid pixel format.
|
||||
*/
|
||||
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt);
|
||||
|
||||
/**
|
||||
* Utility function to swap the endianness of a pixel format.
|
||||
*
|
||||
* @param[in] pix_fmt the pixel format
|
||||
*
|
||||
* @return pixel format with swapped endianness if it exists,
|
||||
* otherwise AV_PIX_FMT_NONE
|
||||
*/
|
||||
enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt);
|
||||
|
||||
#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */
|
||||
#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */
|
||||
#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */
|
||||
#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */
|
||||
#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */
|
||||
#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */
|
||||
|
||||
/**
|
||||
* Compute what kind of losses will occur when converting from one specific
|
||||
* pixel format to another.
|
||||
* When converting from one pixel format to another, information loss may occur.
|
||||
* For example, when converting from RGB24 to GRAY, the color information will
|
||||
* be lost. Similarly, other losses occur when converting from some formats to
|
||||
* other formats. These losses can involve loss of chroma, but also loss of
|
||||
* resolution, loss of color depth, loss due to the color space conversion, loss
|
||||
* of the alpha bits or loss due to color quantization.
|
||||
* av_get_fix_fmt_loss() informs you about the various types of losses
|
||||
* which will occur when converting from one pixel format to another.
|
||||
*
|
||||
* @param[in] dst_pix_fmt destination pixel format
|
||||
* @param[in] src_pix_fmt source pixel format
|
||||
* @param[in] has_alpha Whether the source pixel format alpha channel is used.
|
||||
* @return Combination of flags informing you what kind of losses will occur
|
||||
* (maximum loss for an invalid dst_pix_fmt).
|
||||
*/
|
||||
int av_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt,
|
||||
enum AVPixelFormat src_pix_fmt,
|
||||
int has_alpha);
|
||||
|
||||
/**
|
||||
* Compute what kind of losses will occur when converting from one specific
|
||||
* pixel format to another.
|
||||
* When converting from one pixel format to another, information loss may occur.
|
||||
* For example, when converting from RGB24 to GRAY, the color information will
|
||||
* be lost. Similarly, other losses occur when converting from some formats to
|
||||
* other formats. These losses can involve loss of chroma, but also loss of
|
||||
* resolution, loss of color depth, loss due to the color space conversion, loss
|
||||
* of the alpha bits or loss due to color quantization.
|
||||
* av_get_fix_fmt_loss() informs you about the various types of losses
|
||||
* which will occur when converting from one pixel format to another.
|
||||
*
|
||||
* @param[in] dst_pix_fmt destination pixel format
|
||||
* @param[in] src_pix_fmt source pixel format
|
||||
* @param[in] has_alpha Whether the source pixel format alpha channel is used.
|
||||
* @return Combination of flags informing you what kind of losses will occur
|
||||
* (maximum loss for an invalid dst_pix_fmt).
|
||||
*/
|
||||
enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
|
||||
enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
|
||||
|
||||
/**
|
||||
* @return the name for provided color range or NULL if unknown.
|
||||
*/
|
||||
const char *av_color_range_name(enum AVColorRange range);
|
||||
|
||||
/**
|
||||
* @return the name for provided color primaries or NULL if unknown.
|
||||
*/
|
||||
const char *av_color_primaries_name(enum AVColorPrimaries primaries);
|
||||
|
||||
/**
|
||||
* @return the name for provided color transfer or NULL if unknown.
|
||||
*/
|
||||
const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer);
|
||||
|
||||
/**
|
||||
* @return the name for provided color space or NULL if unknown.
|
||||
*/
|
||||
const char *av_color_space_name(enum AVColorSpace space);
|
||||
|
||||
/**
|
||||
* @return the name for provided chroma location or NULL if unknown.
|
||||
*/
|
||||
const char *av_chroma_location_name(enum AVChromaLocation location);
|
||||
|
||||
#endif /* AVUTIL_PIXDESC_H */
|
||||
@@ -1,473 +0,0 @@
|
||||
/*
|
||||
* copyright (c) 2006 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_PIXFMT_H
|
||||
#define AVUTIL_PIXFMT_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* pixel format definitions
|
||||
*
|
||||
*/
|
||||
|
||||
// #include "libavutil/avconfig.h"
|
||||
#include "version.h"
|
||||
|
||||
#define AVPALETTE_SIZE 1024
|
||||
#define AVPALETTE_COUNT 256
|
||||
|
||||
/**
|
||||
* Pixel format.
|
||||
*
|
||||
* @note
|
||||
* AV_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 RGB32 (AV_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
|
||||
* formatted the same as in AV_PIX_FMT_RGB32 described above (i.e., it is
|
||||
* also endian-specific). Note also that the individual RGB32 palette
|
||||
* components stored in AVFrame.data[1] should be in the range 0..255.
|
||||
* 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.
|
||||
*/
|
||||
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 AV_PIX_FMT_RGB32 palette
|
||||
AV_PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting color_range
|
||||
AV_PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting color_range
|
||||
AV_PIX_FMT_YUVJ444P, ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting color_range
|
||||
#if FF_API_XVMC
|
||||
AV_PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing
|
||||
AV_PIX_FMT_XVMC_MPEG2_IDCT,
|
||||
#define AV_PIX_FMT_XVMC AV_PIX_FMT_XVMC_MPEG2_IDCT
|
||||
#endif /* FF_API_XVMC */
|
||||
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
|
||||
|
||||
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...
|
||||
|
||||
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 AV_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)
|
||||
#if FF_API_VDPAU
|
||||
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
|
||||
#endif
|
||||
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
|
||||
|
||||
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)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
|
||||
AV_PIX_FMT_RGB555LE, ///< packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined
|
||||
|
||||
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)1X 5B 5G 5R(lsb), big-endian , X=unused/undefined
|
||||
AV_PIX_FMT_BGR555LE, ///< packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), little-endian, X=unused/undefined
|
||||
|
||||
#if FF_API_VAAPI
|
||||
/** @name Deprecated pixel formats */
|
||||
/**@{*/
|
||||
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
|
||||
/**@}*/
|
||||
AV_PIX_FMT_VAAPI = AV_PIX_FMT_VAAPI_VLD,
|
||||
#else
|
||||
/**
|
||||
* Hardware acceleration through VA-API, data[3] contains a
|
||||
* VASurfaceID.
|
||||
*/
|
||||
AV_PIX_FMT_VAAPI,
|
||||
#endif
|
||||
|
||||
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
|
||||
#if FF_API_VDPAU
|
||||
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
|
||||
#endif
|
||||
AV_PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer
|
||||
|
||||
AV_PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), little-endian, X=unused/undefined
|
||||
AV_PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), big-endian, X=unused/undefined
|
||||
AV_PIX_FMT_BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), little-endian, X=unused/undefined
|
||||
AV_PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), big-endian, X=unused/undefined
|
||||
AV_PIX_FMT_YA8, ///< 8bit gray, 8bit alpha
|
||||
|
||||
AV_PIX_FMT_Y400A = AV_PIX_FMT_YA8, ///< alias for AV_PIX_FMT_YA8
|
||||
AV_PIX_FMT_GRAY8A= AV_PIX_FMT_YA8, ///< alias for AV_PIX_FMT_YA8
|
||||
|
||||
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 12 formats have the disadvantage of needing 1 format for each bit depth.
|
||||
* Notice that each 9/10 bits sample is stored in 16 bits with extra padding.
|
||||
* 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
|
||||
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
|
||||
AV_PIX_FMT_YUVA422P, ///< planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
|
||||
AV_PIX_FMT_YUVA444P, ///< 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
|
||||
|
||||
AV_PIX_FMT_XYZ12LE, ///< packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as little-endian, the 4 lower bits are set to 0
|
||||
AV_PIX_FMT_XYZ12BE, ///< packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as big-endian, the 4 lower bits are set to 0
|
||||
AV_PIX_FMT_NV16, ///< interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
|
||||
AV_PIX_FMT_NV20LE, ///< interleaved chroma YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
|
||||
AV_PIX_FMT_NV20BE, ///< interleaved chroma YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
|
||||
|
||||
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
|
||||
|
||||
AV_PIX_FMT_YVYU422, ///< packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
|
||||
|
||||
AV_PIX_FMT_VDA, ///< HW acceleration through VDA, data[3] contains a CVPixelBufferRef
|
||||
|
||||
AV_PIX_FMT_YA16BE, ///< 16bit gray, 16bit alpha (big-endian)
|
||||
AV_PIX_FMT_YA16LE, ///< 16bit gray, 16bit alpha (little-endian)
|
||||
|
||||
AV_PIX_FMT_GBRAP, ///< planar GBRA 4:4:4:4 32bpp
|
||||
AV_PIX_FMT_GBRAP16BE, ///< planar GBRA 4:4:4:4 64bpp, big-endian
|
||||
AV_PIX_FMT_GBRAP16LE, ///< planar GBRA 4:4:4:4 64bpp, little-endian
|
||||
/**
|
||||
* HW acceleration through QSV, data[3] contains a pointer to the
|
||||
* mfxFrameSurface1 structure.
|
||||
*/
|
||||
AV_PIX_FMT_QSV,
|
||||
/**
|
||||
* HW acceleration though MMAL, data[3] contains a pointer to the
|
||||
* MMAL_BUFFER_HEADER_T structure.
|
||||
*/
|
||||
AV_PIX_FMT_MMAL,
|
||||
|
||||
AV_PIX_FMT_D3D11VA_VLD, ///< HW decoding through Direct3D11, Picture.data[3] contains a ID3D11VideoDecoderOutputView pointer
|
||||
|
||||
AV_PIX_FMT_0RGB=0x123+4,///< packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
|
||||
AV_PIX_FMT_RGB0, ///< packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
|
||||
AV_PIX_FMT_0BGR, ///< packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
|
||||
AV_PIX_FMT_BGR0, ///< packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
|
||||
|
||||
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_YUVJ411P, ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV411P and setting color_range
|
||||
|
||||
AV_PIX_FMT_BAYER_BGGR8, ///< bayer, BGBG..(odd line), GRGR..(even line), 8-bit samples */
|
||||
AV_PIX_FMT_BAYER_RGGB8, ///< bayer, RGRG..(odd line), GBGB..(even line), 8-bit samples */
|
||||
AV_PIX_FMT_BAYER_GBRG8, ///< bayer, GBGB..(odd line), RGRG..(even line), 8-bit samples */
|
||||
AV_PIX_FMT_BAYER_GRBG8, ///< bayer, GRGR..(odd line), BGBG..(even line), 8-bit samples */
|
||||
AV_PIX_FMT_BAYER_BGGR16LE, ///< bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, little-endian */
|
||||
AV_PIX_FMT_BAYER_BGGR16BE, ///< bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, big-endian */
|
||||
AV_PIX_FMT_BAYER_RGGB16LE, ///< bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, little-endian */
|
||||
AV_PIX_FMT_BAYER_RGGB16BE, ///< bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, big-endian */
|
||||
AV_PIX_FMT_BAYER_GBRG16LE, ///< bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, little-endian */
|
||||
AV_PIX_FMT_BAYER_GBRG16BE, ///< bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, big-endian */
|
||||
AV_PIX_FMT_BAYER_GRBG16LE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian */
|
||||
AV_PIX_FMT_BAYER_GRBG16BE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, big-endian */
|
||||
#if !FF_API_XVMC
|
||||
AV_PIX_FMT_XVMC,///< XVideo Motion Acceleration via common packet passing
|
||||
#endif /* !FF_API_XVMC */
|
||||
AV_PIX_FMT_YUV440P10LE, ///< planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV440P10BE, ///< planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
|
||||
AV_PIX_FMT_YUV440P12LE, ///< planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
|
||||
AV_PIX_FMT_YUV440P12BE, ///< planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
|
||||
AV_PIX_FMT_AYUV64LE, ///< packed AYUV 4:4:4,64bpp (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
|
||||
AV_PIX_FMT_AYUV64BE, ///< packed AYUV 4:4:4,64bpp (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
|
||||
|
||||
AV_PIX_FMT_VIDEOTOOLBOX, ///< hardware decoding through Videotoolbox
|
||||
|
||||
AV_PIX_FMT_P010LE, ///< like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, little-endian
|
||||
AV_PIX_FMT_P010BE, ///< like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, big-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
|
||||
};
|
||||
|
||||
#define AV_PIX_FMT_Y400A AV_PIX_FMT_GRAY8A
|
||||
#define AV_PIX_FMT_GBR24P AV_PIX_FMT_GBRP
|
||||
|
||||
#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_YA16 AV_PIX_FMT_NE(YA16BE, YA16LE)
|
||||
#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_RGBA64 AV_PIX_FMT_NE(RGBA64BE, RGBA64LE)
|
||||
#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_BGRA64 AV_PIX_FMT_NE(BGRA64BE, BGRA64LE)
|
||||
|
||||
#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_YUV440P10 AV_PIX_FMT_NE(YUV440P10BE, YUV440P10LE)
|
||||
#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_YUV440P12 AV_PIX_FMT_NE(YUV440P12BE, YUV440P12LE)
|
||||
#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_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_GBRAP16 AV_PIX_FMT_NE(GBRAP16BE, GBRAP16LE)
|
||||
|
||||
#define AV_PIX_FMT_BAYER_BGGR16 AV_PIX_FMT_NE(BAYER_BGGR16BE, BAYER_BGGR16LE)
|
||||
#define AV_PIX_FMT_BAYER_RGGB16 AV_PIX_FMT_NE(BAYER_RGGB16BE, BAYER_RGGB16LE)
|
||||
#define AV_PIX_FMT_BAYER_GBRG16 AV_PIX_FMT_NE(BAYER_GBRG16BE, BAYER_GBRG16LE)
|
||||
#define AV_PIX_FMT_BAYER_GRBG16 AV_PIX_FMT_NE(BAYER_GRBG16BE, BAYER_GRBG16LE)
|
||||
|
||||
|
||||
#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)
|
||||
|
||||
#define AV_PIX_FMT_XYZ12 AV_PIX_FMT_NE(XYZ12BE, XYZ12LE)
|
||||
#define AV_PIX_FMT_NV20 AV_PIX_FMT_NE(NV20BE, NV20LE)
|
||||
#define AV_PIX_FMT_AYUV64 AV_PIX_FMT_NE(AYUV64BE, AYUV64LE)
|
||||
#define AV_PIX_FMT_P010 AV_PIX_FMT_NE(P010BE, P010LE)
|
||||
|
||||
/**
|
||||
* Chromaticity coordinates of the source primaries.
|
||||
*/
|
||||
enum AVColorPrimaries {
|
||||
AVCOL_PRI_RESERVED0 = 0,
|
||||
AVCOL_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
|
||||
AVCOL_PRI_UNSPECIFIED = 2,
|
||||
AVCOL_PRI_RESERVED = 3,
|
||||
AVCOL_PRI_BT470M = 4, ///< also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
|
||||
|
||||
AVCOL_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
|
||||
AVCOL_PRI_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
|
||||
AVCOL_PRI_SMPTE240M = 7, ///< functionally identical to above
|
||||
AVCOL_PRI_FILM = 8, ///< colour filters using Illuminant C
|
||||
AVCOL_PRI_BT2020 = 9, ///< ITU-R BT2020
|
||||
AVCOL_PRI_SMPTEST428_1= 10, ///< SMPTE ST 428-1 (CIE 1931 XYZ)
|
||||
AVCOL_PRI_NB, ///< Not part of ABI
|
||||
};
|
||||
|
||||
/**
|
||||
* Color Transfer Characteristic.
|
||||
*/
|
||||
enum AVColorTransferCharacteristic {
|
||||
AVCOL_TRC_RESERVED0 = 0,
|
||||
AVCOL_TRC_BT709 = 1, ///< also ITU-R BT1361
|
||||
AVCOL_TRC_UNSPECIFIED = 2,
|
||||
AVCOL_TRC_RESERVED = 3,
|
||||
AVCOL_TRC_GAMMA22 = 4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
|
||||
AVCOL_TRC_GAMMA28 = 5, ///< also ITU-R BT470BG
|
||||
AVCOL_TRC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
|
||||
AVCOL_TRC_SMPTE240M = 7,
|
||||
AVCOL_TRC_LINEAR = 8, ///< "Linear transfer characteristics"
|
||||
AVCOL_TRC_LOG = 9, ///< "Logarithmic transfer characteristic (100:1 range)"
|
||||
AVCOL_TRC_LOG_SQRT = 10, ///< "Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
|
||||
AVCOL_TRC_IEC61966_2_4 = 11, ///< IEC 61966-2-4
|
||||
AVCOL_TRC_BT1361_ECG = 12, ///< ITU-R BT1361 Extended Colour Gamut
|
||||
AVCOL_TRC_IEC61966_2_1 = 13, ///< IEC 61966-2-1 (sRGB or sYCC)
|
||||
AVCOL_TRC_BT2020_10 = 14, ///< ITU-R BT2020 for 10 bit system
|
||||
AVCOL_TRC_BT2020_12 = 15, ///< ITU-R BT2020 for 12 bit system
|
||||
AVCOL_TRC_SMPTEST2084 = 16, ///< SMPTE ST 2084 for 10, 12, 14 and 16 bit systems
|
||||
AVCOL_TRC_SMPTEST428_1 = 17, ///< SMPTE ST 428-1
|
||||
AVCOL_TRC_NB, ///< Not part of ABI
|
||||
};
|
||||
|
||||
/**
|
||||
* YUV colorspace type.
|
||||
*/
|
||||
enum AVColorSpace {
|
||||
AVCOL_SPC_RGB = 0, ///< order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
|
||||
AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
|
||||
AVCOL_SPC_UNSPECIFIED = 2,
|
||||
AVCOL_SPC_RESERVED = 3,
|
||||
AVCOL_SPC_FCC = 4, ///< FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
|
||||
AVCOL_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
|
||||
AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
|
||||
AVCOL_SPC_SMPTE240M = 7,
|
||||
AVCOL_SPC_YCOCG = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
|
||||
AVCOL_SPC_BT2020_NCL = 9, ///< ITU-R BT2020 non-constant luminance system
|
||||
AVCOL_SPC_BT2020_CL = 10, ///< ITU-R BT2020 constant luminance system
|
||||
AVCOL_SPC_NB, ///< Not part of ABI
|
||||
};
|
||||
#define AVCOL_SPC_YCGCO AVCOL_SPC_YCOCG
|
||||
|
||||
|
||||
/**
|
||||
* MPEG vs JPEG YUV range.
|
||||
*/
|
||||
enum AVColorRange {
|
||||
AVCOL_RANGE_UNSPECIFIED = 0,
|
||||
AVCOL_RANGE_MPEG = 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
|
||||
AVCOL_RANGE_JPEG = 2, ///< the normal 2^n-1 "JPEG" YUV ranges
|
||||
AVCOL_RANGE_NB, ///< Not part of ABI
|
||||
};
|
||||
|
||||
/**
|
||||
* Location of chroma samples.
|
||||
*
|
||||
* Illustration showing the location of the first (top left) chroma sample of the
|
||||
* image, the left shows only luma, the right
|
||||
* shows the location of the chroma sample, the 2 could be imagined to overlay
|
||||
* each other but are drawn separately due to limitations of ASCII
|
||||
*
|
||||
* 1st 2nd 1st 2nd horizontal luma sample positions
|
||||
* v v v v
|
||||
* ______ ______
|
||||
*1st luma line > |X X ... |3 4 X ... X are luma samples,
|
||||
* | |1 2 1-6 are possible chroma positions
|
||||
*2nd luma line > |X X ... |5 6 X ... 0 is undefined/unknown position
|
||||
*/
|
||||
enum AVChromaLocation {
|
||||
AVCHROMA_LOC_UNSPECIFIED = 0,
|
||||
AVCHROMA_LOC_LEFT = 1, ///< mpeg2/4 4:2:0, h264 default for 4:2:0
|
||||
AVCHROMA_LOC_CENTER = 2, ///< mpeg1 4:2:0, jpeg 4:2:0, h263 4:2:0
|
||||
AVCHROMA_LOC_TOPLEFT = 3, ///< ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2
|
||||
AVCHROMA_LOC_TOP = 4,
|
||||
AVCHROMA_LOC_BOTTOMLEFT = 5,
|
||||
AVCHROMA_LOC_BOTTOM = 6,
|
||||
AVCHROMA_LOC_NB, ///< Not part of ABI
|
||||
};
|
||||
|
||||
#endif /* AVUTIL_PIXFMT_H */
|
||||
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
* (I)RDFT transforms
|
||||
* Copyright (c) 2009 Alex Converse <alex dot converse at gmail dot 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
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "mathematics.h"
|
||||
#include "rdft.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
* (Inverse) Real Discrete Fourier Transforms.
|
||||
*/
|
||||
|
||||
/* sin(2*pi*x/n) for 0<=x<n/4, followed by n/2<=x<3n/4 */
|
||||
#if !CONFIG_HARDCODED_TABLES
|
||||
SINTABLE(16);
|
||||
SINTABLE(32);
|
||||
SINTABLE(64);
|
||||
SINTABLE(128);
|
||||
SINTABLE(256);
|
||||
SINTABLE(512);
|
||||
SINTABLE(1024);
|
||||
SINTABLE(2048);
|
||||
SINTABLE(4096);
|
||||
SINTABLE(8192);
|
||||
SINTABLE(16384);
|
||||
SINTABLE(32768);
|
||||
SINTABLE(65536);
|
||||
#endif
|
||||
static SINTABLE_CONST FFTSample * const ff_sin_tabs[] = {
|
||||
NULL, NULL, NULL, NULL,
|
||||
ff_sin_16, ff_sin_32, ff_sin_64, ff_sin_128, ff_sin_256, ff_sin_512, ff_sin_1024,
|
||||
ff_sin_2048, ff_sin_4096, ff_sin_8192, ff_sin_16384, ff_sin_32768, ff_sin_65536,
|
||||
};
|
||||
|
||||
/** Map one real FFT into two parallel real even and odd FFTs. Then interleave
|
||||
* the two real FFTs into one complex FFT. Unmangle the results.
|
||||
* ref: http://www.engineeringproductivitytools.com/stuff/T0001/PT10.HTM
|
||||
*/
|
||||
static void rdft_calc_c(RDFTContext *s, FFTSample *data)
|
||||
{
|
||||
int i, i1, i2;
|
||||
FFTComplex ev, od;
|
||||
const int n = 1 << s->nbits;
|
||||
const float k1 = 0.5;
|
||||
const float k2 = 0.5 - s->inverse;
|
||||
const FFTSample *tcos = s->tcos;
|
||||
const FFTSample *tsin = s->tsin;
|
||||
|
||||
if (!s->inverse) {
|
||||
s->fft.fft_permute(&s->fft, (FFTComplex*)data);
|
||||
s->fft.fft_calc(&s->fft, (FFTComplex*)data);
|
||||
}
|
||||
/* i=0 is a special case because of packing, the DC term is real, so we
|
||||
are going to throw the N/2 term (also real) in with it. */
|
||||
ev.re = data[0];
|
||||
data[0] = ev.re+data[1];
|
||||
data[1] = ev.re-data[1];
|
||||
for (i = 1; i < (n>>2); i++) {
|
||||
i1 = 2*i;
|
||||
i2 = n-i1;
|
||||
/* Separate even and odd FFTs */
|
||||
ev.re = k1*(data[i1 ]+data[i2 ]);
|
||||
od.im = -k2*(data[i1 ]-data[i2 ]);
|
||||
ev.im = k1*(data[i1+1]-data[i2+1]);
|
||||
od.re = k2*(data[i1+1]+data[i2+1]);
|
||||
/* Apply twiddle factors to the odd FFT and add to the even FFT */
|
||||
data[i1 ] = ev.re + od.re*tcos[i] - od.im*tsin[i];
|
||||
data[i1+1] = ev.im + od.im*tcos[i] + od.re*tsin[i];
|
||||
data[i2 ] = ev.re - od.re*tcos[i] + od.im*tsin[i];
|
||||
data[i2+1] = -ev.im + od.im*tcos[i] + od.re*tsin[i];
|
||||
}
|
||||
data[2*i+1]=s->sign_convention*data[2*i+1];
|
||||
if (s->inverse) {
|
||||
data[0] *= k1;
|
||||
data[1] *= k1;
|
||||
s->fft.fft_permute(&s->fft, (FFTComplex*)data);
|
||||
s->fft.fft_calc(&s->fft, (FFTComplex*)data);
|
||||
}
|
||||
}
|
||||
|
||||
av_cold int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans)
|
||||
{
|
||||
int n = 1 << nbits;
|
||||
int ret;
|
||||
|
||||
s->nbits = nbits;
|
||||
s->inverse = trans == IDFT_C2R || trans == DFT_C2R;
|
||||
s->sign_convention = trans == IDFT_R2C || trans == DFT_C2R ? 1 : -1;
|
||||
|
||||
if (nbits < 4 || nbits > 16)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
if ((ret = ff_fft_init(&s->fft, nbits-1, trans == IDFT_C2R || trans == IDFT_R2C)) < 0)
|
||||
return ret;
|
||||
|
||||
ff_init_ff_cos_tabs(nbits);
|
||||
s->tcos = ff_cos_tabs[nbits];
|
||||
s->tsin = ff_sin_tabs[nbits]+(trans == DFT_R2C || trans == DFT_C2R)*(n>>2);
|
||||
#if !CONFIG_HARDCODED_TABLES
|
||||
{
|
||||
int i;
|
||||
const double theta = (trans == DFT_R2C || trans == DFT_C2R ? -1 : 1) * 2 * M_PI / n;
|
||||
for (i = 0; i < (n >> 2); i++)
|
||||
s->tsin[i] = sin(i * theta);
|
||||
}
|
||||
#endif
|
||||
s->rdft_calc = rdft_calc_c;
|
||||
|
||||
if (ARCH_ARM) ff_rdft_init_arm(s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
av_cold void ff_rdft_end(RDFTContext *s)
|
||||
{
|
||||
ff_fft_end(&s->fft);
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* (I)RDFT transforms
|
||||
* Copyright (c) 2009 Alex Converse <alex dot converse at gmail dot 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
|
||||
*/
|
||||
|
||||
#if !defined(AVCODEC_RDFT_H) && (!defined(FFT_FLOAT) || FFT_FLOAT)
|
||||
#define AVCODEC_RDFT_H
|
||||
|
||||
#include "config.h"
|
||||
#include "fft.h"
|
||||
|
||||
#if CONFIG_HARDCODED_TABLES
|
||||
# define SINTABLE_CONST const
|
||||
#else
|
||||
# define SINTABLE_CONST
|
||||
#endif
|
||||
|
||||
#define SINTABLE(size) \
|
||||
SINTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_sin_##size)[size/2]
|
||||
|
||||
extern SINTABLE(16);
|
||||
extern SINTABLE(32);
|
||||
extern SINTABLE(64);
|
||||
extern SINTABLE(128);
|
||||
extern SINTABLE(256);
|
||||
extern SINTABLE(512);
|
||||
extern SINTABLE(1024);
|
||||
extern SINTABLE(2048);
|
||||
extern SINTABLE(4096);
|
||||
extern SINTABLE(8192);
|
||||
extern SINTABLE(16384);
|
||||
extern SINTABLE(32768);
|
||||
extern SINTABLE(65536);
|
||||
|
||||
struct RDFTContext {
|
||||
int nbits;
|
||||
int inverse;
|
||||
int sign_convention;
|
||||
|
||||
/* pre/post rotation tables */
|
||||
const FFTSample *tcos;
|
||||
SINTABLE_CONST FFTSample *tsin;
|
||||
FFTContext fft;
|
||||
void (*rdft_calc)(struct RDFTContext *s, FFTSample *z);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set up a real FFT.
|
||||
* @param nbits log2 of the length of the input array
|
||||
* @param trans the type of transform
|
||||
*/
|
||||
int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans);
|
||||
void ff_rdft_end(RDFTContext *s);
|
||||
|
||||
void ff_rdft_init_arm(RDFTContext *s);
|
||||
|
||||
|
||||
#endif /* AVCODEC_RDFT_H */
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "attributes.h"
|
||||
#include "dict.h"
|
||||
#include "macros.h"
|
||||
#include "pixfmt.h"
|
||||
#include "version.h"
|
||||
|
||||
#if ARCH_X86
|
||||
@@ -213,16 +212,6 @@
|
||||
# define ONLY_IF_THREADS_ENABLED(x) NULL
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Log a generic warning message about a missing feature.
|
||||
*
|
||||
* @param[in] avc a pointer to an arbitrary struct of which the first
|
||||
* field is a pointer to an AVClass struct
|
||||
* @param[in] msg string containing the name of the missing feature
|
||||
*/
|
||||
void avpriv_report_missing_feature(void *avc,
|
||||
const char *msg, ...) av_printf_format(2, 3);
|
||||
|
||||
/**
|
||||
* Log a generic warning message about a missing feature.
|
||||
* Additionally request that a sample showcasing the feature be uploaded.
|
||||
@@ -232,7 +221,7 @@ void avpriv_report_missing_feature(void *avc,
|
||||
* @param[in] msg string containing the name of the missing feature
|
||||
*/
|
||||
void avpriv_request_sample(void *avc,
|
||||
const char *msg, ...) av_printf_format(2, 3);
|
||||
const char *msg, ...);
|
||||
|
||||
#if HAVE_LIBC_MSVCRT
|
||||
#include <crtversion.h>
|
||||
|
||||
+2
-362
@@ -27,14 +27,12 @@
|
||||
|
||||
#include "util_internal.h"
|
||||
#include "config.h"
|
||||
#include "atomic.h"
|
||||
#include "avcodec.h"
|
||||
#include "attributes.h"
|
||||
#include "channel_layout.h"
|
||||
#include "frame.h"
|
||||
#include "internal.h"
|
||||
#include "mathematics.h"
|
||||
#include "pixdesc.h"
|
||||
#include "avstring.h"
|
||||
#include "samplefmt.h"
|
||||
#include "dict.h"
|
||||
@@ -47,56 +45,8 @@
|
||||
#include <stdarg.h>
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
#if CONFIG_ICONV
|
||||
# include <iconv.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS
|
||||
static int default_lockmgr_cb(void **arg, enum AVLockOp op)
|
||||
{
|
||||
void * volatile * mutex = arg;
|
||||
int err;
|
||||
|
||||
switch (op) {
|
||||
case AV_LOCK_CREATE:
|
||||
return 0;
|
||||
case AV_LOCK_OBTAIN:
|
||||
if (!*mutex) {
|
||||
pthread_mutex_t *tmp = av_malloc(sizeof(pthread_mutex_t));
|
||||
if (!tmp)
|
||||
return AVERROR(ENOMEM);
|
||||
if ((err = pthread_mutex_init(tmp, NULL))) {
|
||||
av_free(tmp);
|
||||
return AVERROR(err);
|
||||
}
|
||||
if (avpriv_atomic_ptr_cas(mutex, NULL, tmp)) {
|
||||
pthread_mutex_destroy(tmp);
|
||||
av_free(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if ((err = pthread_mutex_lock(*mutex)))
|
||||
return AVERROR(err);
|
||||
|
||||
return 0;
|
||||
case AV_LOCK_RELEASE:
|
||||
if ((err = pthread_mutex_unlock(*mutex)))
|
||||
return AVERROR(err);
|
||||
|
||||
return 0;
|
||||
case AV_LOCK_DESTROY:
|
||||
if (*mutex)
|
||||
pthread_mutex_destroy(*mutex);
|
||||
av_free(*mutex);
|
||||
avpriv_atomic_ptr_cas(mutex, *mutex, NULL);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) = default_lockmgr_cb;
|
||||
#else
|
||||
static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
volatile int ff_avcodec_locked;
|
||||
@@ -159,21 +109,6 @@ int av_codec_is_decoder(const AVCodec *codec)
|
||||
return codec && codec->decode;
|
||||
}
|
||||
|
||||
av_cold void avcodec_register(AVCodec *codec)
|
||||
{
|
||||
AVCodec **p;
|
||||
avcodec_init();
|
||||
p = last_avcodec;
|
||||
codec->next = NULL;
|
||||
|
||||
while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, codec))
|
||||
p = &(*p)->next;
|
||||
last_avcodec = &codec->next;
|
||||
|
||||
if (codec->init_static_data)
|
||||
codec->init_static_data(codec);
|
||||
}
|
||||
|
||||
#if FF_API_EMU_EDGE
|
||||
unsigned avcodec_get_edge_width(void)
|
||||
{
|
||||
@@ -181,26 +116,6 @@ unsigned avcodec_get_edge_width(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
int ff_side_data_update_matrix_encoding(AVFrame *frame,
|
||||
enum AVMatrixEncoding matrix_encoding)
|
||||
{
|
||||
AVFrameSideData *side_data;
|
||||
enum AVMatrixEncoding *data;
|
||||
|
||||
side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_MATRIXENCODING);
|
||||
if (!side_data)
|
||||
side_data = av_frame_new_side_data(frame, AV_FRAME_DATA_MATRIXENCODING,
|
||||
sizeof(enum AVMatrixEncoding));
|
||||
|
||||
if (!side_data)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
data = (enum AVMatrixEncoding*)side_data->data;
|
||||
*data = matrix_encoding;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
|
||||
enum AVSampleFormat sample_fmt, const uint8_t *buf,
|
||||
int buf_size, int align)
|
||||
@@ -344,70 +259,20 @@ int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags
|
||||
}
|
||||
}
|
||||
|
||||
static int add_metadata_from_side_data(AVPacket *avpkt, AVFrame *frame)
|
||||
{
|
||||
int size;
|
||||
const uint8_t *side_metadata;
|
||||
|
||||
AVDictionary **frame_md = avpriv_frame_get_metadatap(frame);
|
||||
|
||||
side_metadata = av_packet_get_side_data(avpkt,
|
||||
AV_PKT_DATA_STRINGS_METADATA, &size);
|
||||
return av_packet_unpack_dictionary(side_metadata, size, frame_md);
|
||||
}
|
||||
|
||||
int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame)
|
||||
{
|
||||
AVPacket *pkt = avctx->internal->pkt;
|
||||
int i;
|
||||
static const struct {
|
||||
enum AVPacketSideDataType packet;
|
||||
enum AVFrameSideDataType frame;
|
||||
} sd[] = {
|
||||
{ AV_PKT_DATA_REPLAYGAIN , AV_FRAME_DATA_REPLAYGAIN },
|
||||
{ AV_PKT_DATA_DISPLAYMATRIX, AV_FRAME_DATA_DISPLAYMATRIX },
|
||||
{ AV_PKT_DATA_STEREO3D, AV_FRAME_DATA_STEREO3D },
|
||||
{ AV_PKT_DATA_AUDIO_SERVICE_TYPE, AV_FRAME_DATA_AUDIO_SERVICE_TYPE },
|
||||
};
|
||||
|
||||
|
||||
if (pkt) {
|
||||
frame->pkt_pts = pkt->pts;
|
||||
av_frame_set_pkt_pos (frame, pkt->pos);
|
||||
av_frame_set_pkt_duration(frame, pkt->duration);
|
||||
av_frame_set_pkt_size (frame, pkt->size);
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(sd); i++) {
|
||||
int size;
|
||||
uint8_t *packet_sd = av_packet_get_side_data(pkt, sd[i].packet, &size);
|
||||
if (packet_sd) {
|
||||
AVFrameSideData *frame_sd = av_frame_new_side_data(frame,
|
||||
sd[i].frame,
|
||||
size);
|
||||
if (!frame_sd)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
memcpy(frame_sd->data, packet_sd, size);
|
||||
}
|
||||
}
|
||||
add_metadata_from_side_data(pkt, frame);
|
||||
} else {
|
||||
frame->pkt_pts = AV_NOPTS_VALUE;
|
||||
av_frame_set_pkt_pos (frame, -1);
|
||||
av_frame_set_pkt_duration(frame, 0);
|
||||
av_frame_set_pkt_size (frame, -1);
|
||||
}
|
||||
frame->reordered_opaque = avctx->reordered_opaque;
|
||||
|
||||
if (frame->color_primaries == AVCOL_PRI_UNSPECIFIED)
|
||||
frame->color_primaries = avctx->color_primaries;
|
||||
if (frame->color_trc == AVCOL_TRC_UNSPECIFIED)
|
||||
frame->color_trc = avctx->color_trc;
|
||||
if (av_frame_get_colorspace(frame) == AVCOL_SPC_UNSPECIFIED)
|
||||
av_frame_set_colorspace(frame, avctx->colorspace);
|
||||
if (av_frame_get_color_range(frame) == AVCOL_RANGE_UNSPECIFIED)
|
||||
av_frame_set_color_range(frame, avctx->color_range);
|
||||
if (frame->chroma_location == AVCHROMA_LOC_UNSPECIFIED)
|
||||
frame->chroma_location = avctx->chroma_sample_location;
|
||||
|
||||
switch (avctx->codec->type) {
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
@@ -448,7 +313,6 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
|
||||
|
||||
static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
|
||||
{
|
||||
const AVHWAccel *hwaccel = avctx->hwaccel;
|
||||
int override_dimensions = 1;
|
||||
int ret;
|
||||
|
||||
@@ -456,14 +320,6 @@ static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (hwaccel) {
|
||||
if (hwaccel->alloc_frame) {
|
||||
ret = hwaccel->alloc_frame(avctx, frame);
|
||||
goto end;
|
||||
}
|
||||
} else
|
||||
avctx->sw_pix_fmt = avctx->pix_fmt;
|
||||
|
||||
ret = avctx->get_buffer2(avctx, frame, flags);
|
||||
|
||||
end:
|
||||
@@ -472,12 +328,7 @@ end:
|
||||
|
||||
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
|
||||
{
|
||||
int ret = get_buffer_internal(avctx, frame, flags);
|
||||
if (ret < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||
frame->width = frame->height = 0;
|
||||
}
|
||||
return ret;
|
||||
return get_buffer_internal(avctx, frame, flags);
|
||||
}
|
||||
|
||||
int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2), void *arg, int *ret, int count, int size)
|
||||
@@ -504,92 +355,14 @@ int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2,
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
|
||||
{
|
||||
while (*fmt != AV_PIX_FMT_NONE)
|
||||
++fmt;
|
||||
return fmt[0];
|
||||
}
|
||||
|
||||
static AVHWAccel *find_hwaccel(enum AVCodecID codec_id,
|
||||
enum AVPixelFormat pix_fmt)
|
||||
{
|
||||
AVHWAccel *hwaccel = NULL;
|
||||
|
||||
while ((hwaccel = av_hwaccel_next(hwaccel)))
|
||||
if (hwaccel->id == codec_id
|
||||
&& hwaccel->pix_fmt == pix_fmt)
|
||||
return hwaccel;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int setup_hwaccel(AVCodecContext *avctx,
|
||||
const enum AVPixelFormat fmt,
|
||||
const char *name)
|
||||
{
|
||||
AVHWAccel *hwa = find_hwaccel(avctx->codec_id, fmt);
|
||||
int ret = 0;
|
||||
|
||||
if (avctx->active_thread_type & FF_THREAD_FRAME) {
|
||||
av_log(avctx, AV_LOG_WARNING,
|
||||
"Hardware accelerated decoding with frame threading is known to be unstable and its use is discouraged.\n");
|
||||
}
|
||||
|
||||
if (!hwa) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Could not find an AVHWAccel for the pixel format: %s",
|
||||
name);
|
||||
return AVERROR(ENOENT);
|
||||
}
|
||||
|
||||
if (hwa->capabilities & HWACCEL_CODEC_CAP_EXPERIMENTAL &&
|
||||
avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
|
||||
av_log(avctx, AV_LOG_WARNING, "Ignoring experimental hwaccel: %s\n",
|
||||
hwa->name);
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
|
||||
if (hwa->priv_data_size) {
|
||||
avctx->internal->hwaccel_priv_data = av_mallocz(hwa->priv_data_size);
|
||||
if (!avctx->internal->hwaccel_priv_data)
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
if (hwa->init) {
|
||||
ret = hwa->init(avctx);
|
||||
if (ret < 0) {
|
||||
av_freep(&avctx->internal->hwaccel_priv_data);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
avctx->hwaccel = hwa;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
MAKE_ACCESSORS(AVCodecContext, codec, AVRational, pkt_timebase)
|
||||
MAKE_ACCESSORS(AVCodecContext, codec, const AVCodecDescriptor *, codec_descriptor)
|
||||
MAKE_ACCESSORS(AVCodecContext, codec, int, lowres)
|
||||
MAKE_ACCESSORS(AVCodecContext, codec, int, seek_preroll)
|
||||
MAKE_ACCESSORS(AVCodecContext, codec, uint16_t*, chroma_intra_matrix)
|
||||
|
||||
unsigned av_codec_get_codec_properties(const AVCodecContext *codec)
|
||||
{
|
||||
return codec->properties;
|
||||
}
|
||||
|
||||
int av_codec_get_max_lowres(const AVCodec *codec)
|
||||
{
|
||||
return codec->max_lowres;
|
||||
}
|
||||
|
||||
static void get_subtitle_defaults(AVSubtitle *sub)
|
||||
{
|
||||
memset(sub, 0, sizeof(*sub));
|
||||
sub->pts = AV_NOPTS_VALUE;
|
||||
}
|
||||
|
||||
static int64_t get_bit_rate(AVCodecContext *ctx)
|
||||
{
|
||||
int64_t bit_rate;
|
||||
@@ -628,15 +401,10 @@ int attribute_align_arg ff_codec_open2_recursive(AVCodecContext *avctx, const AV
|
||||
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
|
||||
{
|
||||
int ret = 0;
|
||||
const AVPixFmtDescriptor *pixdesc;
|
||||
|
||||
if (avcodec_is_open(avctx))
|
||||
return 0;
|
||||
|
||||
if ((!codec && !avctx->codec)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "No codec provided to avcodec_open2()\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if ((codec && avctx->codec && codec != avctx->codec)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "This AVCodecContext was allocated for %s, "
|
||||
"but %s passed to avcodec_open2()\n", avctx->codec->name, codec->name);
|
||||
@@ -709,7 +477,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
|
||||
goto free_and_end;
|
||||
}
|
||||
avctx->frame_number = 0;
|
||||
avctx->codec_descriptor = avcodec_descriptor_get(avctx->codec_id);
|
||||
|
||||
if ((avctx->codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) &&
|
||||
avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
|
||||
@@ -733,19 +500,9 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
|
||||
avctx->time_base.den = avctx->sample_rate;
|
||||
}
|
||||
|
||||
if (!HAVE_THREADS)
|
||||
av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n");
|
||||
|
||||
if (!HAVE_THREADS && !(codec->capabilities & AV_CODEC_CAP_AUTO_THREADS))
|
||||
avctx->thread_count = 1;
|
||||
|
||||
if (avctx->codec->max_lowres < avctx->lowres || avctx->lowres < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n",
|
||||
avctx->codec->max_lowres);
|
||||
ret = AVERROR(EINVAL);
|
||||
goto free_and_end;
|
||||
}
|
||||
|
||||
#if FF_API_VISMV
|
||||
if (avctx->debug_mv)
|
||||
av_log(avctx, AV_LOG_WARNING, "The 'vismv' option is deprecated, "
|
||||
@@ -758,11 +515,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
|
||||
avctx->pts_correction_last_pts =
|
||||
avctx->pts_correction_last_dts = INT64_MIN;
|
||||
|
||||
if ( !CONFIG_GRAY && avctx->flags & AV_CODEC_FLAG_GRAY
|
||||
&& avctx->codec_descriptor->type == AVMEDIA_TYPE_VIDEO)
|
||||
av_log(avctx, AV_LOG_WARNING,
|
||||
"gray decoding requested but not enabled at configuration time\n");
|
||||
|
||||
if ( avctx->codec->init && (!(avctx->active_thread_type&FF_THREAD_FRAME)
|
||||
|| avctx->internal->frame_thread_encoder)) {
|
||||
ret = avctx->codec->init(avctx);
|
||||
@@ -902,19 +654,9 @@ av_cold int avcodec_close(AVCodecContext *avctx)
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++)
|
||||
av_buffer_pool_uninit(&pool->pools[i]);
|
||||
av_freep(&avctx->internal->pool);
|
||||
|
||||
if (avctx->hwaccel && avctx->hwaccel->uninit)
|
||||
avctx->hwaccel->uninit(avctx);
|
||||
av_freep(&avctx->internal->hwaccel_priv_data);
|
||||
|
||||
av_freep(&avctx->internal);
|
||||
}
|
||||
|
||||
for (i = 0; i < avctx->nb_coded_side_data; i++)
|
||||
av_freep(&avctx->coded_side_data[i].data);
|
||||
av_freep(&avctx->coded_side_data);
|
||||
avctx->nb_coded_side_data = 0;
|
||||
|
||||
if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)
|
||||
av_opt_free(avctx->priv_data);
|
||||
av_opt_free(avctx);
|
||||
@@ -998,54 +740,6 @@ AVCodec *avcodec_find_decoder_by_name(const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *avcodec_get_name(enum AVCodecID id)
|
||||
{
|
||||
const AVCodecDescriptor *cd;
|
||||
AVCodec *codec;
|
||||
|
||||
if (id == AV_CODEC_ID_NONE)
|
||||
return "none";
|
||||
cd = avcodec_descriptor_get(id);
|
||||
if (cd)
|
||||
return cd->name;
|
||||
av_log(NULL, AV_LOG_WARNING, "Codec 0x%x is not in the full list.\n", id);
|
||||
codec = avcodec_find_decoder(id);
|
||||
if (codec)
|
||||
return codec->name;
|
||||
codec = avcodec_find_encoder(id);
|
||||
if (codec)
|
||||
return codec->name;
|
||||
return "unknown_codec";
|
||||
}
|
||||
|
||||
const char *av_get_profile_name(const AVCodec *codec, int profile)
|
||||
{
|
||||
const AVProfile *p;
|
||||
if (profile == FF_PROFILE_UNKNOWN || !codec->profiles)
|
||||
return NULL;
|
||||
|
||||
for (p = codec->profiles; p->profile != FF_PROFILE_UNKNOWN; p++)
|
||||
if (p->profile == profile)
|
||||
return p->name;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *avcodec_profile_name(enum AVCodecID codec_id, int profile)
|
||||
{
|
||||
const AVCodecDescriptor *desc = avcodec_descriptor_get(codec_id);
|
||||
const AVProfile *p;
|
||||
|
||||
if (profile == FF_PROFILE_UNKNOWN || !desc || !desc->profiles)
|
||||
return NULL;
|
||||
|
||||
for (p = desc->profiles; p->profile != FF_PROFILE_UNKNOWN; p++)
|
||||
if (p->profile == profile)
|
||||
return p->name;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void avcodec_flush_buffers(AVCodecContext *avctx)
|
||||
{
|
||||
if (avctx->codec->flush)
|
||||
@@ -1394,22 +1088,6 @@ void av_log_ask_for_sample(void *avc, const char *msg, ...)
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif /* FF_API_MISSING_SAMPLE */
|
||||
|
||||
static AVHWAccel *first_hwaccel = NULL;
|
||||
static AVHWAccel **last_hwaccel = &first_hwaccel;
|
||||
|
||||
void av_register_hwaccel(AVHWAccel *hwaccel)
|
||||
{
|
||||
AVHWAccel **p = last_hwaccel;
|
||||
hwaccel->next = NULL;
|
||||
while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, hwaccel))
|
||||
p = &(*p)->next;
|
||||
last_hwaccel = &hwaccel->next;
|
||||
}
|
||||
|
||||
AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel)
|
||||
{
|
||||
return hwaccel ? hwaccel->next : first_hwaccel;
|
||||
}
|
||||
|
||||
int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
|
||||
{
|
||||
@@ -1453,17 +1131,6 @@ int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (avpriv_atomic_int_add_and_fetch(&entangled_thread_counter, 1) != 1) {
|
||||
av_log(log_ctx, AV_LOG_ERROR,
|
||||
"Insufficient thread locking. At least %d threads are "
|
||||
"calling avcodec_open2() at the same time right now.\n",
|
||||
entangled_thread_counter);
|
||||
if (!lockmgr_cb)
|
||||
av_log(log_ctx, AV_LOG_ERROR, "No lock manager is set, please see av_lockmgr_register()\n");
|
||||
ff_avcodec_locked = 1;
|
||||
ff_unlock_avcodec(codec);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
av_assert0(!ff_avcodec_locked);
|
||||
ff_avcodec_locked = 1;
|
||||
return 0;
|
||||
@@ -1476,7 +1143,6 @@ int ff_unlock_avcodec(const AVCodec *codec)
|
||||
|
||||
av_assert0(ff_avcodec_locked);
|
||||
ff_avcodec_locked = 0;
|
||||
avpriv_atomic_int_add_and_fetch(&entangled_thread_counter, -1);
|
||||
if (lockmgr_cb) {
|
||||
if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE))
|
||||
return -1;
|
||||
@@ -1562,29 +1228,3 @@ AVCPBProperties *av_cpb_properties_alloc(size_t *size)
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
AVCPBProperties *ff_add_cpb_side_data(AVCodecContext *avctx)
|
||||
{
|
||||
AVPacketSideData *tmp;
|
||||
AVCPBProperties *props;
|
||||
size_t size;
|
||||
|
||||
props = av_cpb_properties_alloc(&size);
|
||||
if (!props)
|
||||
return NULL;
|
||||
|
||||
tmp = av_realloc_array(avctx->coded_side_data, avctx->nb_coded_side_data + 1, sizeof(*tmp));
|
||||
if (!tmp) {
|
||||
av_freep(&props);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
avctx->coded_side_data = tmp;
|
||||
avctx->nb_coded_side_data++;
|
||||
|
||||
avctx->coded_side_data[avctx->nb_coded_side_data - 1].type = AV_PKT_DATA_CPB_PROPERTIES;
|
||||
avctx->coded_side_data[avctx->nb_coded_side_data - 1].data = (uint8_t*)props;
|
||||
avctx->coded_side_data[avctx->nb_coded_side_data - 1].size = size;
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user