mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Delete attributes.h/compat.h, more
This commit is contained in:
parent
d617aec8c8
commit
202886f750
@ -390,33 +390,28 @@
|
||||
<ClInclude Include="..\ext\at3_standalone\atrac3data.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\atrac3plus.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\atrac3plus_data.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\attributes.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\avcodec.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\avfft.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\bswap.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\bytestream.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\channel_layout.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\common.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\compat.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\config.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\error.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\fft-internal.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\fft.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\float_dsp.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\get_bits.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\internal.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\intfloat.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\intmath.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\intreadwrite.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\libm.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\log.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\macros.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\mathematics.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\mathops.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\mem.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\rational.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\qsort.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\samplefmt.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\sinewin.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\sinewin_tablegen.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\util_internal.h" />
|
||||
<ClInclude Include="..\ext\at3_standalone\version.h" />
|
||||
<ClInclude Include="..\ext\basis_universal\basisu.h" />
|
||||
@ -623,7 +618,6 @@
|
||||
<ClCompile Include="..\ext\at3_standalone\atrac3plus.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\atrac3plusdec.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\atrac3plusdsp.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\avfft.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\bitstream.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\channel_layout.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\compat.c" />
|
||||
@ -633,8 +627,7 @@
|
||||
<ClCompile Include="..\ext\at3_standalone\mathematics.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\mdct_template.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\mem.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\options.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\rational.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\avcodec.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\samplefmt.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\sinewin.c" />
|
||||
<ClCompile Include="..\ext\at3_standalone\utils.c" />
|
||||
|
@ -542,12 +542,6 @@
|
||||
<ClInclude Include="..\ext\at3_standalone\compat.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\config.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\bswap.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\bytestream.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
@ -569,12 +563,6 @@
|
||||
<ClInclude Include="..\ext\at3_standalone\common.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\mathops.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\macros.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\version.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
@ -599,9 +587,6 @@
|
||||
<ClInclude Include="..\ext\at3_standalone\at3_decoders.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\internal.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\util_internal.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
@ -611,9 +596,6 @@
|
||||
<ClInclude Include="..\ext\at3_standalone\sinewin.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\attributes.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\log.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
@ -623,7 +605,10 @@
|
||||
<ClInclude Include="..\ext\at3_standalone\fft-internal.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\rational.h">
|
||||
<ClInclude Include="..\ext\at3_standalone\sinewin_tablegen.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\at3_standalone\qsort.h">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
@ -1098,9 +1083,6 @@
|
||||
<ClCompile Include="..\ext\at3_standalone\float_dsp.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\at3_standalone\avfft.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\at3_standalone\samplefmt.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
@ -1110,7 +1092,7 @@
|
||||
<ClCompile Include="..\ext\at3_standalone\sinewin.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\at3_standalone\options.c">
|
||||
<ClCompile Include="..\ext\at3_standalone\avcodec.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\at3_standalone\channel_layout.c">
|
||||
@ -1131,9 +1113,6 @@
|
||||
<ClCompile Include="..\ext\at3_standalone\fft_template.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\at3_standalone\rational.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\at3_standalone\intmath.c">
|
||||
<Filter>ext\at3_standalone</Filter>
|
||||
</ClCompile>
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include "float_dsp.h"
|
||||
#include "bytestream.h"
|
||||
#include "fft.h"
|
||||
#include "internal.h"
|
||||
#include "common.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
#include "avcodec.h"
|
||||
|
@ -25,6 +25,9 @@
|
||||
* Bitstream parser for ATRAC3+ decoder.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
//#include "avcodec.h"
|
||||
#include "get_bits.h"
|
||||
#include "atrac3plus.h"
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "float_dsp.h"
|
||||
#include "avcodec.h"
|
||||
#include "get_bits.h"
|
||||
#include "internal.h"
|
||||
#include "common.h"
|
||||
#include "atrac.h"
|
||||
#include "atrac3plus.h"
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "float_dsp.h"
|
||||
#include "libm.h"
|
||||
@ -606,8 +607,8 @@ void ff_atrac3p_ipqf(FFTContext *dct_ctx, Atrac3pIPQFChannelCtx *hist,
|
||||
const float *in, float *out)
|
||||
{
|
||||
int i, s, sb, t, pos_now, pos_next;
|
||||
LOCAL_ALIGNED(32, float, idct_in, [ATRAC3P_SUBBANDS]);
|
||||
LOCAL_ALIGNED(32, float, idct_out, [ATRAC3P_SUBBANDS]);
|
||||
float idct_in [ATRAC3P_SUBBANDS];
|
||||
float idct_out[ATRAC3P_SUBBANDS];
|
||||
|
||||
memset(out, 0, ATRAC3P_FRAME_SAMPLES * sizeof(*out));
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define av_cold
|
||||
#define DECLARE_ALIGNED(bits, type, name) type name
|
||||
#define LOCAL_ALIGNED(bits, type, name, subscript) type name subscript
|
||||
#define av_restrict
|
||||
#define av_always_inline __forceinline
|
||||
#define av_const
|
||||
#define av_alias
|
||||
#define av_unused
|
||||
#define av_pure
|
||||
#define av_warn_unused_result
|
||||
#define av_assert0(cond)
|
||||
#define av_assert1(cond)
|
||||
#define av_assert2(cond)
|
||||
#define attribute_deprecated
|
||||
#define av_printf_format(a,b)
|
||||
#define avpriv_report_missing_feature(...)
|
77
ext/at3_standalone/avcodec.c
Normal file
77
ext/at3_standalone/avcodec.c
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2001 Fabrice Bellard
|
||||
* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Options definition for AVCodecContext.
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "common.h"
|
||||
#include "util_internal.h"
|
||||
#include "mem.h"
|
||||
#include <string.h>
|
||||
|
||||
static const AVClass av_codec_context_class = {
|
||||
.class_name = "AVCodecContext",
|
||||
.category = AV_CLASS_CATEGORY_DECODER,
|
||||
};
|
||||
|
||||
AVCodecContext *avcodec_alloc_context3(const AVCodec *codec)
|
||||
{
|
||||
AVCodecContext *avctx = av_mallocz(sizeof(AVCodecContext));
|
||||
if (!avctx)
|
||||
return NULL;
|
||||
int flags = 0;
|
||||
memset(avctx, 0, sizeof(AVCodecContext));
|
||||
|
||||
avctx->av_class = &av_codec_context_class;
|
||||
|
||||
if (codec) {
|
||||
avctx->codec = codec;
|
||||
avctx->codec_id = codec->id;
|
||||
}
|
||||
|
||||
if (codec && codec->priv_data_size) {
|
||||
if (!avctx->priv_data) {
|
||||
avctx->priv_data = av_mallocz(codec->priv_data_size);
|
||||
if (!avctx->priv_data) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (codec->priv_class) {
|
||||
*(const AVClass**)avctx->priv_data = codec->priv_class;
|
||||
}
|
||||
}
|
||||
return avctx;
|
||||
}
|
||||
|
||||
void avcodec_free_context(AVCodecContext **pavctx)
|
||||
{
|
||||
AVCodecContext *avctx = *pavctx;
|
||||
|
||||
if (!avctx)
|
||||
return;
|
||||
|
||||
avcodec_close(avctx);
|
||||
av_freep(&avctx->extradata);
|
||||
av_freep(pavctx);
|
||||
}
|
@ -28,10 +28,9 @@
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include "attributes.h"
|
||||
#include "compat.h"
|
||||
#include "channel_layout.h"
|
||||
#include "log.h"
|
||||
#include "rational.h"
|
||||
#include "version.h"
|
||||
|
||||
/**
|
||||
@ -98,26 +97,6 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_ATRAC1,
|
||||
};
|
||||
|
||||
/**
|
||||
* This struct describes the properties of a single codec described by an
|
||||
* AVCodecID.
|
||||
* @see avcodec_descriptor_get()
|
||||
*/
|
||||
typedef struct AVCodecDescriptor {
|
||||
enum AVCodecID id;
|
||||
enum AVMediaType type;
|
||||
/**
|
||||
* Name of the codec described by this descriptor. It is non-empty and
|
||||
* unique for each codec descriptor. It should contain alphanumeric
|
||||
* characters and '_' only.
|
||||
*/
|
||||
const char *name;
|
||||
/**
|
||||
* A more descriptive name for this codec. May be NULL.
|
||||
*/
|
||||
const char *long_name;
|
||||
} AVCodecDescriptor;
|
||||
|
||||
/**
|
||||
* @ingroup lavc_decoding
|
||||
* Required number of additionally allocated bytes at the end of the input bitstream for decoding.
|
||||
@ -205,17 +184,6 @@ typedef struct AVCodecDescriptor {
|
||||
* Use only bitexact stuff (except (I)DCT).
|
||||
*/
|
||||
#define AV_CODEC_FLAG_BITEXACT (1 << 23)
|
||||
/* Fx : Flag for h263+ extra options */
|
||||
/**
|
||||
* H.263 advanced intra coding / MPEG-4 AC prediction
|
||||
*/
|
||||
#define AV_CODEC_FLAG_AC_PRED (1 << 24)
|
||||
/**
|
||||
* interlaced motion estimation
|
||||
*/
|
||||
#define AV_CODEC_FLAG_INTERLACED_ME (1 << 29)
|
||||
#define AV_CODEC_FLAG_CLOSED_GOP (1U << 31)
|
||||
|
||||
/**
|
||||
* Allow non spec compliant speedup tricks.
|
||||
*/
|
||||
@ -264,17 +232,6 @@ typedef struct AVCodecDescriptor {
|
||||
/* /Fx */
|
||||
/* codec capabilities */
|
||||
|
||||
/**
|
||||
* Decoder can use draw_horiz_band callback.
|
||||
*/
|
||||
#define AV_CODEC_CAP_DRAW_HORIZ_BAND (1 << 0)
|
||||
/**
|
||||
* Codec uses get_buffer() for allocating buffers and supports custom allocators.
|
||||
* If not set, it might not use get_buffer() at all or use operations that
|
||||
* assume the buffer was allocated by avcodec_default_get_buffer.
|
||||
*/
|
||||
#define AV_CODEC_CAP_DR1 (1 << 1)
|
||||
#define AV_CODEC_CAP_TRUNCATED (1 << 3)
|
||||
/**
|
||||
* Encoder or decoder requires flushing with NULL input at the end in order to
|
||||
* give the complete and correct output.
|
||||
@ -338,8 +295,6 @@ typedef struct AVCodecContext {
|
||||
* - set by avcodec_alloc_context3
|
||||
*/
|
||||
const AVClass *av_class;
|
||||
int log_level_offset;
|
||||
|
||||
const struct AVCodec *codec;
|
||||
#if FF_API_CODEC_NAME
|
||||
/**
|
||||
@ -573,13 +528,6 @@ typedef struct AVCodec {
|
||||
int caps_internal;
|
||||
} AVCodec;
|
||||
|
||||
/**
|
||||
* If c is NULL, returns the first registered codec,
|
||||
* if c is non-NULL, returns the next registered codec after c,
|
||||
* or NULL if c is the last one.
|
||||
*/
|
||||
AVCodec *av_codec_next(const AVCodec *c);
|
||||
|
||||
/**
|
||||
* Allocate an AVCodecContext and set its fields to default values. The
|
||||
* resulting struct should be freed with avcodec_free_context().
|
||||
@ -602,17 +550,6 @@ AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
|
||||
*/
|
||||
void avcodec_free_context(AVCodecContext **avctx);
|
||||
|
||||
/**
|
||||
* Set the fields of the given AVCodecContext to default values corresponding
|
||||
* to the given codec (defaults may be codec-dependent).
|
||||
*
|
||||
* Do not call this function if a non-NULL codec has been passed
|
||||
* to avcodec_alloc_context3() that allocated this AVCodecContext.
|
||||
* If codec is non-NULL, it is illegal to call avcodec_open2() with a
|
||||
* different codec on this AVCodecContext.
|
||||
*/
|
||||
int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec);
|
||||
|
||||
/**
|
||||
* Initialize the AVCodecContext to use the given AVCodec. Prior to using this
|
||||
* function the context has to be allocated with avcodec_alloc_context3().
|
||||
@ -665,195 +602,6 @@ int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, void *options);
|
||||
*/
|
||||
int avcodec_close(AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup lavc_decoding
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef struct AVCodecParserContext {
|
||||
void *priv_data;
|
||||
struct AVCodecParser *parser;
|
||||
int64_t frame_offset; /* offset of the current frame */
|
||||
int64_t cur_offset; /* current offset
|
||||
(incremented by each av_parser_parse()) */
|
||||
int64_t next_frame_offset; /* offset of the next frame */
|
||||
/**
|
||||
* This field is used for proper frame duration computation in lavf.
|
||||
* It signals, how much longer the frame duration of the current frame
|
||||
* is compared to normal frame duration.
|
||||
*
|
||||
* frame_duration = (1 + repeat_pict) * time_base
|
||||
*
|
||||
* It is used by codecs like H.264 to display telecined material.
|
||||
*/
|
||||
int64_t pts; /* pts of the current frame */
|
||||
int64_t dts; /* dts of the current frame */
|
||||
|
||||
/* private data */
|
||||
int64_t last_pts;
|
||||
int64_t last_dts;
|
||||
int fetch_timestamp;
|
||||
|
||||
#define AV_PARSER_PTS_NB 4
|
||||
int cur_frame_start_index;
|
||||
int64_t cur_frame_offset[AV_PARSER_PTS_NB];
|
||||
int64_t cur_frame_pts[AV_PARSER_PTS_NB];
|
||||
int64_t cur_frame_dts[AV_PARSER_PTS_NB];
|
||||
|
||||
int flags;
|
||||
#define PARSER_FLAG_COMPLETE_FRAMES 0x0001
|
||||
#define PARSER_FLAG_ONCE 0x0002
|
||||
/// Set if the parser has a valid file offset
|
||||
#define PARSER_FLAG_FETCHED_OFFSET 0x0004
|
||||
#define PARSER_FLAG_USE_CODEC_TS 0x1000
|
||||
|
||||
int64_t offset; ///< byte offset from starting packet start
|
||||
int64_t cur_frame_end[AV_PARSER_PTS_NB];
|
||||
|
||||
/**
|
||||
* Set by parser to 1 for key frames and 0 for non-key frames.
|
||||
* It is initialized to -1, so if the parser doesn't set this flag,
|
||||
* old-style fallback using AV_PICTURE_TYPE_I picture type as key frames
|
||||
* will be used.
|
||||
*/
|
||||
int key_frame;
|
||||
|
||||
#if FF_API_CONVERGENCE_DURATION
|
||||
/**
|
||||
* @deprecated unused
|
||||
*/
|
||||
attribute_deprecated
|
||||
int64_t convergence_duration;
|
||||
#endif
|
||||
|
||||
// Timestamp generation support:
|
||||
/**
|
||||
* Synchronization point for start of timestamp generation.
|
||||
*
|
||||
* Set to >0 for sync point, 0 for no sync point and <0 for undefined
|
||||
* (default).
|
||||
*
|
||||
* For example, this corresponds to presence of H.264 buffering period
|
||||
* SEI message.
|
||||
*/
|
||||
int dts_sync_point;
|
||||
|
||||
/**
|
||||
* Offset of the current timestamp against last timestamp sync point in
|
||||
* units of AVCodecContext.time_base.
|
||||
*
|
||||
* Set to INT_MIN when dts_sync_point unused. Otherwise, it must
|
||||
* contain a valid timestamp offset.
|
||||
*
|
||||
* Note that the timestamp of sync point has usually a nonzero
|
||||
* dts_ref_dts_delta, which refers to the previous sync point. Offset of
|
||||
* the next frame after timestamp sync point will be usually 1.
|
||||
*
|
||||
* For example, this corresponds to H.264 cpb_removal_delay.
|
||||
*/
|
||||
int dts_ref_dts_delta;
|
||||
|
||||
/**
|
||||
* Presentation delay of current frame in units of AVCodecContext.time_base.
|
||||
*
|
||||
* Set to INT_MIN when dts_sync_point unused. Otherwise, it must
|
||||
* contain valid non-negative timestamp delta (presentation time of a frame
|
||||
* must not lie in the past).
|
||||
*
|
||||
* This delay represents the difference between decoding and presentation
|
||||
* time of the frame.
|
||||
*
|
||||
* For example, this corresponds to H.264 dpb_output_delay.
|
||||
*/
|
||||
int pts_dts_delta;
|
||||
|
||||
/**
|
||||
* Position of the packet in file.
|
||||
*
|
||||
* Analogous to cur_frame_pts/dts
|
||||
*/
|
||||
int64_t cur_frame_pos[AV_PARSER_PTS_NB];
|
||||
|
||||
/**
|
||||
* Byte position of currently parsed frame in stream.
|
||||
*/
|
||||
int64_t pos;
|
||||
|
||||
/**
|
||||
* Previous frame byte position.
|
||||
*/
|
||||
int64_t last_pos;
|
||||
|
||||
/**
|
||||
* Duration of the current frame.
|
||||
* For audio, this is in units of 1 / AVCodecContext.sample_rate.
|
||||
* For all other types, this is in units of AVCodecContext.time_base.
|
||||
*/
|
||||
int duration;
|
||||
|
||||
enum AVFieldOrder field_order;
|
||||
|
||||
/**
|
||||
* Indicate whether a picture is coded as a frame, top field or bottom field.
|
||||
*
|
||||
* For example, H.264 field_pic_flag equal to 0 corresponds to
|
||||
* AV_PICTURE_STRUCTURE_FRAME. An H.264 picture with field_pic_flag
|
||||
* equal to 1 and bottom_field_flag equal to 0 corresponds to
|
||||
* AV_PICTURE_STRUCTURE_TOP_FIELD.
|
||||
*/
|
||||
enum AVPictureStructure picture_structure;
|
||||
|
||||
/**
|
||||
* Picture number incremented in presentation or output order.
|
||||
* This field may be reinitialized at the first picture of a new sequence.
|
||||
*
|
||||
* For example, this corresponds to H.264 PicOrderCnt.
|
||||
*/
|
||||
int output_picture_number;
|
||||
|
||||
/**
|
||||
* Dimensions of the decoded video intended for presentation.
|
||||
*/
|
||||
int width;
|
||||
int height;
|
||||
|
||||
/**
|
||||
* Dimensions of the coded video.
|
||||
*/
|
||||
int coded_width;
|
||||
int coded_height;
|
||||
|
||||
/**
|
||||
* The format of the coded data, corresponds to enum AVPixelFormat for video
|
||||
* and for enum AVSampleFormat for audio.
|
||||
*
|
||||
* Note that a decoder can have considerable freedom in how exactly it
|
||||
* decodes the data, so the format reported here might be different from the
|
||||
* one returned by a decoder.
|
||||
*/
|
||||
int format;
|
||||
} AVCodecParserContext;
|
||||
|
||||
/**
|
||||
* @defgroup lavc_misc Utility functions
|
||||
* @ingroup libavc
|
||||
*
|
||||
* Miscellaneous utility functions related to both encoding and decoding
|
||||
* (or neither).
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lavc_misc_pixfmt Pixel formats
|
||||
*
|
||||
* Functions for working with pixel formats.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Reset the internal decoder state / flush internal buffers. Should be called
|
||||
* e.g. when seeking or when switching to a different stream.
|
||||
@ -865,51 +613,4 @@ typedef struct AVCodecParserContext {
|
||||
*/
|
||||
void avcodec_flush_buffers(AVCodecContext *avctx);
|
||||
|
||||
/* memory */
|
||||
|
||||
/**
|
||||
* Same behaviour av_fast_malloc but the buffer has additional
|
||||
* AV_INPUT_BUFFER_PADDING_SIZE at the end which will always be 0.
|
||||
*
|
||||
* In addition the whole buffer will initially and after resizes
|
||||
* be 0-initialized so that no uninitialized data will ever appear.
|
||||
*/
|
||||
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size);
|
||||
|
||||
/**
|
||||
* Lock operation used by lockmgr
|
||||
*/
|
||||
enum AVLockOp {
|
||||
AV_LOCK_CREATE, ///< Create a mutex
|
||||
AV_LOCK_OBTAIN, ///< Lock the mutex
|
||||
AV_LOCK_RELEASE, ///< Unlock the mutex
|
||||
AV_LOCK_DESTROY, ///< Free mutex resources
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the type of the given codec.
|
||||
*/
|
||||
enum AVMediaType avcodec_get_type(enum AVCodecID codec_id);
|
||||
|
||||
/**
|
||||
* Get the name of a codec.
|
||||
* @return a static string identifying the codec; never NULL
|
||||
*/
|
||||
const char *avcodec_get_name(enum AVCodecID id);
|
||||
|
||||
/**
|
||||
* @return a positive value if s is open (i.e. avcodec_open2() was called on it
|
||||
* with no corresponding avcodec_close()), 0 otherwise.
|
||||
*/
|
||||
int avcodec_is_open(AVCodecContext *s);
|
||||
|
||||
/**
|
||||
* @return a non-zero number if codec is a decoder, zero otherwise
|
||||
*/
|
||||
int av_codec_is_decoder(const AVCodec *codec);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVCODEC_AVCODEC_H */
|
||||
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* 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 "attributes.h"
|
||||
#include "avfft.h"
|
||||
#include "fft.h"
|
||||
#include "mem.h"
|
||||
|
||||
#if CONFIG_MDCT
|
||||
|
||||
FFTContext *av_mdct_init(int nbits, int inverse, double scale)
|
||||
{
|
||||
FFTContext *s = av_malloc(sizeof(*s));
|
||||
|
||||
if (s && ff_mdct_init(s, nbits, inverse, scale))
|
||||
av_freep(&s);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
|
||||
{
|
||||
s->imdct_calc(s, output, input);
|
||||
}
|
||||
|
||||
void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input)
|
||||
{
|
||||
s->imdct_half(s, output, input);
|
||||
}
|
||||
|
||||
void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input)
|
||||
{
|
||||
s->mdct_calc(s, output, input);
|
||||
}
|
||||
|
||||
av_cold void av_mdct_end(FFTContext *s)
|
||||
{
|
||||
if (s) {
|
||||
ff_mdct_end(s);
|
||||
av_free(s);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_MDCT */
|
@ -19,19 +19,6 @@
|
||||
#ifndef AVCODEC_AVFFT_H
|
||||
#define AVCODEC_AVFFT_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavc_fft
|
||||
* FFT functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lavc_fft FFT functions
|
||||
* @ingroup lavc_misc
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef float FFTSample;
|
||||
|
||||
typedef struct FFTComplex {
|
||||
@ -40,77 +27,6 @@ typedef struct FFTComplex {
|
||||
|
||||
typedef struct FFTContext FFTContext;
|
||||
|
||||
/**
|
||||
* Set up a complex FFT.
|
||||
* @param nbits log2 of the length of the input array
|
||||
* @param inverse if 0 perform the forward transform, if 1 perform the inverse
|
||||
*/
|
||||
FFTContext *av_fft_init(int nbits, int inverse);
|
||||
|
||||
/**
|
||||
* Do the permutation needed BEFORE calling ff_fft_calc().
|
||||
*/
|
||||
void av_fft_permute(FFTContext *s, FFTComplex *z);
|
||||
|
||||
/**
|
||||
* Do a complex FFT with the parameters defined in av_fft_init(). The
|
||||
* input data must be permuted before. No 1.0/sqrt(n) normalization is done.
|
||||
*/
|
||||
void av_fft_calc(FFTContext *s, FFTComplex *z);
|
||||
|
||||
void av_fft_end(FFTContext *s);
|
||||
|
||||
FFTContext *av_mdct_init(int nbits, int inverse, double scale);
|
||||
void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input);
|
||||
void av_mdct_end(FFTContext *s);
|
||||
|
||||
/* Real Discrete Fourier Transform */
|
||||
|
||||
enum RDFTransformType {
|
||||
DFT_R2C,
|
||||
IDFT_C2R,
|
||||
IDFT_R2C,
|
||||
DFT_C2R,
|
||||
};
|
||||
|
||||
typedef struct RDFTContext RDFTContext;
|
||||
|
||||
/**
|
||||
* Set up a real FFT.
|
||||
* @param nbits log2 of the length of the input array
|
||||
* @param trans the type of transform
|
||||
*/
|
||||
RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans);
|
||||
void av_rdft_calc(RDFTContext *s, FFTSample *data);
|
||||
void av_rdft_end(RDFTContext *s);
|
||||
|
||||
/* Discrete Cosine Transform */
|
||||
|
||||
typedef struct DCTContext DCTContext;
|
||||
|
||||
enum DCTTransformType {
|
||||
DCT_II = 0,
|
||||
DCT_III,
|
||||
DCT_I,
|
||||
DST_I,
|
||||
};
|
||||
|
||||
/**
|
||||
* Set up DCT.
|
||||
*
|
||||
* @param nbits size of the input array:
|
||||
* (1 << nbits) for DCT-II, DCT-III and DST-I
|
||||
* (1 << nbits) + 1 for DCT-I
|
||||
* @param type the type of transform
|
||||
*
|
||||
* @note the first element of the input of DST-I is ignored
|
||||
*/
|
||||
DCTContext *av_dct_init(int nbits, enum DCTTransformType type);
|
||||
void av_dct_calc(DCTContext *s, FFTSample *data);
|
||||
void av_dct_end (DCTContext *s);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -188,9 +188,7 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "error.h"
|
||||
#include "rational.h"
|
||||
#include "version.h"
|
||||
#include "macros.h"
|
||||
#include "mathematics.h"
|
||||
#include "log.h"
|
||||
|
||||
@ -223,17 +221,6 @@ unsigned av_int_list_length_for_size(unsigned elsize,
|
||||
#define av_int_list_length(list, term) \
|
||||
av_int_list_length_for_size(sizeof(*(list)), list, term)
|
||||
|
||||
/**
|
||||
* Open a file using a UTF-8 filename.
|
||||
* The API of this function matches POSIX fopen(), errors are returned through
|
||||
* errno.
|
||||
*/
|
||||
FILE *av_fopen_utf8(const char *path, const char *mode);
|
||||
|
||||
/**
|
||||
* Return the fractional representation of the internal time base.
|
||||
*/
|
||||
AVRational av_get_time_base_q(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
@ -28,22 +28,16 @@
|
||||
* bitstream api.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "qsort.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "common.h"
|
||||
#include "util_internal.h"
|
||||
#include "mathops.h"
|
||||
#include "mathematics.h"
|
||||
#include "get_bits.h"
|
||||
|
||||
const uint8_t ff_log2_run[41]={
|
||||
0, 0, 0, 0, 1, 1, 1, 1,
|
||||
2, 2, 2, 2, 3, 3, 3, 3,
|
||||
4, 4, 5, 5, 6, 6, 7, 7,
|
||||
8, 9,10,11,12,13,14,15,
|
||||
16,17,18,19,20,21,22,23,
|
||||
24,
|
||||
};
|
||||
|
||||
/* VLC decoding */
|
||||
|
||||
#define GET_DATA(v, table, i, wrap, size) \
|
||||
@ -62,7 +56,6 @@ const uint8_t ff_log2_run[41]={
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
static int alloc_table(VLC *vlc, int size, int use_static)
|
||||
{
|
||||
int index = vlc->table_size;
|
||||
|
@ -1,108 +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
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* byte swapping routines
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_BSWAP_H
|
||||
#define AVUTIL_BSWAP_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "compat.h"
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if ARCH_AARCH64
|
||||
# include "aarch64/bswap.h"
|
||||
#elif ARCH_ARM
|
||||
# include "arm/bswap.h"
|
||||
#elif ARCH_AVR32
|
||||
# include "avr32/bswap.h"
|
||||
#elif ARCH_SH4
|
||||
# include "sh4/bswap.h"
|
||||
#elif ARCH_X86
|
||||
# include "x86/bswap.h"
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_AV_CONFIG_H */
|
||||
|
||||
#define AV_BSWAP16C(x) (((x) << 8 & 0xff00) | ((x) >> 8 & 0x00ff))
|
||||
#define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C((x) >> 16))
|
||||
#define AV_BSWAP64C(x) (AV_BSWAP32C(x) << 32 | AV_BSWAP32C((x) >> 32))
|
||||
|
||||
#define AV_BSWAPC(s, x) AV_BSWAP##s##C(x)
|
||||
|
||||
#ifndef av_bswap16
|
||||
static av_always_inline av_const uint16_t av_bswap16(uint16_t x)
|
||||
{
|
||||
x= (x>>8) | (x<<8);
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef av_bswap32
|
||||
static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
|
||||
{
|
||||
return AV_BSWAP32C(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef av_bswap64
|
||||
static inline uint64_t av_const av_bswap64(uint64_t x)
|
||||
{
|
||||
return (uint64_t)av_bswap32((uint32_t)x) << 32 | av_bswap32(x >> 32);
|
||||
}
|
||||
#endif
|
||||
|
||||
// be2ne ... big-endian to native-endian
|
||||
// le2ne ... little-endian to native-endian
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
#define av_be2ne16(x) (x)
|
||||
#define av_be2ne32(x) (x)
|
||||
#define av_be2ne64(x) (x)
|
||||
#define av_le2ne16(x) av_bswap16(x)
|
||||
#define av_le2ne32(x) av_bswap32(x)
|
||||
#define av_le2ne64(x) av_bswap64(x)
|
||||
#define AV_BE2NEC(s, x) (x)
|
||||
#define AV_LE2NEC(s, x) AV_BSWAPC(s, x)
|
||||
#else
|
||||
#define av_be2ne16(x) av_bswap16(x)
|
||||
#define av_be2ne32(x) av_bswap32(x)
|
||||
#define av_be2ne64(x) av_bswap64(x)
|
||||
#define av_le2ne16(x) (x)
|
||||
#define av_le2ne32(x) (x)
|
||||
#define av_le2ne64(x) (x)
|
||||
#define AV_BE2NEC(s, x) AV_BSWAPC(s, x)
|
||||
#define AV_LE2NEC(s, x) (x)
|
||||
#endif
|
||||
|
||||
#define AV_BE2NE16C(x) AV_BE2NEC(16, x)
|
||||
#define AV_BE2NE32C(x) AV_BE2NEC(32, x)
|
||||
#define AV_BE2NE64C(x) AV_BE2NEC(64, x)
|
||||
#define AV_LE2NE16C(x) AV_LE2NEC(16, x)
|
||||
#define AV_LE2NE32C(x) AV_LE2NEC(32, x)
|
||||
#define AV_LE2NE64C(x) AV_LE2NEC(64, x)
|
||||
|
||||
#endif /* AVUTIL_BSWAP_H */
|
@ -68,24 +68,6 @@ DEF(unsigned int, be24, 3, AV_RB24, AV_WB24)
|
||||
DEF(unsigned int, be16, 2, AV_RB16, AV_WB16)
|
||||
DEF(unsigned int, byte, 1, AV_RB8 , AV_WB8)
|
||||
|
||||
#if HAVE_BIGENDIAN
|
||||
# define bytestream2_get_ne16 bytestream2_get_be16
|
||||
# define bytestream2_get_ne24 bytestream2_get_be24
|
||||
# define bytestream2_get_ne32 bytestream2_get_be32
|
||||
# define bytestream2_get_ne64 bytestream2_get_be64
|
||||
# define bytestream2_get_ne16u bytestream2_get_be16u
|
||||
# define bytestream2_get_ne24u bytestream2_get_be24u
|
||||
# define bytestream2_get_ne32u bytestream2_get_be32u
|
||||
# define bytestream2_get_ne64u bytestream2_get_be64u
|
||||
# define bytestream2_put_ne16 bytestream2_put_be16
|
||||
# define bytestream2_put_ne24 bytestream2_put_be24
|
||||
# define bytestream2_put_ne32 bytestream2_put_be32
|
||||
# define bytestream2_put_ne64 bytestream2_put_be64
|
||||
# define bytestream2_peek_ne16 bytestream2_peek_be16
|
||||
# define bytestream2_peek_ne24 bytestream2_peek_be24
|
||||
# define bytestream2_peek_ne32 bytestream2_peek_be32
|
||||
# define bytestream2_peek_ne64 bytestream2_peek_be64
|
||||
#else
|
||||
# define bytestream2_get_ne16 bytestream2_get_le16
|
||||
# define bytestream2_get_ne24 bytestream2_get_le24
|
||||
# define bytestream2_get_ne32 bytestream2_get_le32
|
||||
@ -94,23 +76,9 @@ DEF(unsigned int, byte, 1, AV_RB8 , AV_WB8)
|
||||
# define bytestream2_get_ne24u bytestream2_get_le24u
|
||||
# define bytestream2_get_ne32u bytestream2_get_le32u
|
||||
# define bytestream2_get_ne64u bytestream2_get_le64u
|
||||
# define bytestream2_put_ne16 bytestream2_put_le16
|
||||
# define bytestream2_put_ne24 bytestream2_put_le24
|
||||
# define bytestream2_put_ne32 bytestream2_put_le32
|
||||
# define bytestream2_put_ne64 bytestream2_put_le64
|
||||
# define bytestream2_peek_ne16 bytestream2_peek_le16
|
||||
# define bytestream2_peek_ne24 bytestream2_peek_le24
|
||||
# define bytestream2_peek_ne32 bytestream2_peek_le32
|
||||
# define bytestream2_peek_ne64 bytestream2_peek_le64
|
||||
#endif
|
||||
|
||||
static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b,
|
||||
uint8_t *dst,
|
||||
unsigned int size)
|
||||
{
|
||||
memcpy(dst, *b, size);
|
||||
(*b) += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
#endif /* AVCODEC_BYTESTREAM_H */
|
||||
|
@ -76,32 +76,6 @@ static const struct {
|
||||
} channel_layout_map[] = {
|
||||
{ "mono", 1, AV_CH_LAYOUT_MONO },
|
||||
{ "stereo", 2, AV_CH_LAYOUT_STEREO },
|
||||
{ "2.1", 3, AV_CH_LAYOUT_2POINT1 },
|
||||
{ "3.0", 3, AV_CH_LAYOUT_SURROUND },
|
||||
{ "3.0(back)", 3, AV_CH_LAYOUT_2_1 },
|
||||
{ "4.0", 4, AV_CH_LAYOUT_4POINT0 },
|
||||
{ "quad", 4, AV_CH_LAYOUT_QUAD },
|
||||
{ "quad(side)", 4, AV_CH_LAYOUT_2_2 },
|
||||
{ "3.1", 4, AV_CH_LAYOUT_3POINT1 },
|
||||
{ "5.0", 5, AV_CH_LAYOUT_5POINT0_BACK },
|
||||
{ "5.0(side)", 5, AV_CH_LAYOUT_5POINT0 },
|
||||
{ "4.1", 5, AV_CH_LAYOUT_4POINT1 },
|
||||
{ "5.1", 6, AV_CH_LAYOUT_5POINT1_BACK },
|
||||
{ "5.1(side)", 6, AV_CH_LAYOUT_5POINT1 },
|
||||
{ "6.0", 6, AV_CH_LAYOUT_6POINT0 },
|
||||
{ "6.0(front)", 6, AV_CH_LAYOUT_6POINT0_FRONT },
|
||||
{ "hexagonal", 6, AV_CH_LAYOUT_HEXAGONAL },
|
||||
{ "6.1", 7, AV_CH_LAYOUT_6POINT1 },
|
||||
{ "6.1(back)", 7, AV_CH_LAYOUT_6POINT1_BACK },
|
||||
{ "6.1(front)", 7, AV_CH_LAYOUT_6POINT1_FRONT },
|
||||
{ "7.0", 7, AV_CH_LAYOUT_7POINT0 },
|
||||
{ "7.0(front)", 7, AV_CH_LAYOUT_7POINT0_FRONT },
|
||||
{ "7.1", 8, AV_CH_LAYOUT_7POINT1 },
|
||||
{ "7.1(wide)", 8, AV_CH_LAYOUT_7POINT1_WIDE_BACK },
|
||||
{ "7.1(wide-side)", 8, AV_CH_LAYOUT_7POINT1_WIDE },
|
||||
{ "octagonal", 8, AV_CH_LAYOUT_OCTAGONAL },
|
||||
{ "hexadecagonal", 16, AV_CH_LAYOUT_HEXADECAGONAL },
|
||||
{ "downmix", 2, AV_CH_LAYOUT_STEREO_DOWNMIX, },
|
||||
};
|
||||
|
||||
static uint64_t get_channel_layout_single(const char *name, int name_len)
|
||||
|
@ -30,38 +30,51 @@
|
||||
#error missing -D__STDC_CONSTANT_MACROS / #define __STDC_CONSTANT_MACROS
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "compat.h"
|
||||
#include "macros.h"
|
||||
#include "version.h"
|
||||
|
||||
#if AV_HAVE_BIGENDIAN
|
||||
# define AV_NE(be, le) (be)
|
||||
#else
|
||||
# define AV_NE(be, le) (le)
|
||||
#endif
|
||||
#include "mem.h"
|
||||
|
||||
//rounded division & shift
|
||||
#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
|
||||
/* assume b>0 */
|
||||
#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
|
||||
/* Fast a/(1<<b) rounded toward +inf. Assume a>=0 and b>=0 */
|
||||
#define AV_CEIL_RSHIFT(a,b) (!av_builtin_constant_p(b) ? -((-(a)) >> (b)) \
|
||||
: ((a) + (1<<(b)) - 1) >> (b))
|
||||
/* Backwards compat. */
|
||||
#define FF_CEIL_RSHIFT AV_CEIL_RSHIFT
|
||||
|
||||
#define FFUDIV(a,b) (((a)>0 ?(a):(a)-(b)+1) / (b))
|
||||
#define FFUMOD(a,b) ((a)-(b)*FFUDIV(a,b))
|
||||
|
||||
#define FF_SANE_NB_CHANNELS 64U
|
||||
|
||||
/**
|
||||
* @addtogroup preproc_misc Preprocessor String Macros
|
||||
*
|
||||
* String manipulation macros
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AV_STRINGIFY(s) AV_TOSTRING(s)
|
||||
#define AV_TOSTRING(s) #s
|
||||
|
||||
#define AV_GLUE(a, b) a ## b
|
||||
#define AV_JOIN(a, b) AV_GLUE(a, b)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#define AV_PRAGMA(s) _Pragma(#s)
|
||||
|
||||
#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
|
||||
|
||||
/**
|
||||
* Maximum size in bytes of extradata.
|
||||
* This value was chosen such that every bit of the buffer is
|
||||
* addressable by a 32-bit signed integer as used by get_bits.
|
||||
*/
|
||||
#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE)
|
||||
|
||||
/**
|
||||
* Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they
|
||||
* are not representable as absolute values of their type. This is the same
|
||||
@ -69,45 +82,13 @@
|
||||
* @see FFNABS()
|
||||
*/
|
||||
#define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
|
||||
#define FFSIGN(a) ((a) > 0 ? 1 : -1)
|
||||
|
||||
/**
|
||||
* Negative Absolute value.
|
||||
* this works for all integers of all types.
|
||||
* As with many macros, this evaluates its argument twice, it thus must not have
|
||||
* a sideeffect, that is FFNABS(x++) has undefined behavior.
|
||||
*/
|
||||
#define FFNABS(a) ((a) <= 0 ? (a) : (-(a)))
|
||||
|
||||
/**
|
||||
* Comparator.
|
||||
* For two numerical expressions x and y, gives 1 if x > y, -1 if x < y, and 0
|
||||
* if x == y. This is useful for instance in a qsort comparator callback.
|
||||
* Furthermore, compilers are able to optimize this to branchless code, and
|
||||
* there is no risk of overflow with signed types.
|
||||
* As with many macros, this evaluates its argument multiple times, it thus
|
||||
* must not have a side-effect.
|
||||
*/
|
||||
#define FFDIFFSIGN(x,y) (((x)>(y)) - ((x)<(y)))
|
||||
|
||||
#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
|
||||
#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c)
|
||||
#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
|
||||
#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c)
|
||||
|
||||
#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
|
||||
#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
|
||||
|
||||
/* misc math functions */
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
# include "config.h"
|
||||
# include "intmath.h"
|
||||
#endif
|
||||
|
||||
/* Pull in unguarded fallback defines at the end of this file. */
|
||||
#include "common.h"
|
||||
|
||||
#ifndef av_log2
|
||||
av_const int av_log2(unsigned v);
|
||||
#endif
|
||||
@ -116,205 +97,23 @@ av_const int av_log2(unsigned v);
|
||||
av_const int av_log2_16bit(unsigned v);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the amin-amax range.
|
||||
* @param a value to clip
|
||||
* @param amin minimum value of the clip range
|
||||
* @param amax maximum value of the clip range
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int av_clip_c(int a, int amin, int amax)
|
||||
{
|
||||
#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
|
||||
if (amin > amax) abort();
|
||||
#endif
|
||||
if (a < amin) return amin;
|
||||
else if (a > amax) return amax;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed 64bit integer value into the amin-amax range.
|
||||
* @param a value to clip
|
||||
* @param amin minimum value of the clip range
|
||||
* @param amax maximum value of the clip range
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, int64_t amax)
|
||||
{
|
||||
#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
|
||||
if (amin > amax) abort();
|
||||
#endif
|
||||
if (a < amin) return amin;
|
||||
else if (a > amax) return amax;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the 0-255 range.
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const uint8_t av_clip_uint8_c(int a)
|
||||
{
|
||||
if (a&(~0xFF)) return (-a)>>31;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the -128,127 range.
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int8_t av_clip_int8_c(int a)
|
||||
{
|
||||
if ((a+0x80U) & ~0xFF) return (a>>31) ^ 0x7F;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the 0-65535 range.
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const uint16_t av_clip_uint16_c(int a)
|
||||
{
|
||||
if (a&(~0xFFFF)) return (-a)>>31;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer value into the -32768,32767 range.
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int16_t av_clip_int16_c(int a)
|
||||
{
|
||||
if ((a+0x8000U) & ~0xFFFF) return (a>>31) ^ 0x7FFF;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed 64-bit integer value into the -2147483648,2147483647 range.
|
||||
* @param a value to clip
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a)
|
||||
{
|
||||
if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (int32_t)((a>>63) ^ 0x7FFFFFFF);
|
||||
else return (int32_t)a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer into the -(2^p),(2^p-1) range.
|
||||
* @param a value to clip
|
||||
* @param p bit position to clip at
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const int av_clip_intp2_c(int a, int p)
|
||||
{
|
||||
if (((unsigned)a + (1 << p)) & ~((2 << p) - 1))
|
||||
return (a >> 31) ^ ((1 << p) - 1);
|
||||
else
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a signed integer to an unsigned power of two range.
|
||||
* @param a value to clip
|
||||
* @param p bit position to clip at
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
|
||||
{
|
||||
if (a & ~((1<<p) - 1)) return -a >> 31 & ((1<<p) - 1);
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear high bits from an unsigned integer starting with specific bit position
|
||||
* @param a value to clip
|
||||
* @param p bit position to clip at
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const unsigned av_mod_uintp2_c(unsigned a, unsigned p)
|
||||
static av_always_inline av_const unsigned av_mod_uintp2(unsigned a, unsigned p)
|
||||
{
|
||||
return a & ((1 << p) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add two signed 32-bit values with saturation.
|
||||
*
|
||||
* @param a one value
|
||||
* @param b another value
|
||||
* @return sum with signed saturation
|
||||
*/
|
||||
static av_always_inline int av_sat_add32_c(int a, int b)
|
||||
{
|
||||
return av_clipl_int32((int64_t)a + b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a doubled value to another value with saturation at both stages.
|
||||
*
|
||||
* @param a first value
|
||||
* @param b value doubled and added to a
|
||||
* @return sum with signed saturation
|
||||
*/
|
||||
static av_always_inline int av_sat_dadd32_c(int a, int b)
|
||||
{
|
||||
return av_sat_add32(a, av_sat_add32(b, b));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a float value into the amin-amax range.
|
||||
* @param a value to clip
|
||||
* @param amin minimum value of the clip range
|
||||
* @param amax maximum value of the clip range
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const float av_clipf_c(float a, float amin, float amax)
|
||||
{
|
||||
#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
|
||||
if (amin > amax) abort();
|
||||
#endif
|
||||
if (a < amin) return amin;
|
||||
else if (a > amax) return amax;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip a double value into the amin-amax range.
|
||||
* @param a value to clip
|
||||
* @param amin minimum value of the clip range
|
||||
* @param amax maximum value of the clip range
|
||||
* @return clipped value
|
||||
*/
|
||||
static av_always_inline av_const double av_clipd_c(double a, double amin, double amax)
|
||||
{
|
||||
#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
|
||||
if (amin > amax) abort();
|
||||
#endif
|
||||
if (a < amin) return amin;
|
||||
else if (a > amax) return amax;
|
||||
else return a;
|
||||
}
|
||||
|
||||
/** Compute ceil(log2(x)).
|
||||
* @param x value used to compute ceil(log2(x))
|
||||
* @return computed ceiling of log2(x)
|
||||
*/
|
||||
static av_always_inline av_const int av_ceil_log2_c(int x)
|
||||
{
|
||||
return av_log2((x - 1) << 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Count number of bits set to one in x
|
||||
* @param x value to count bits of
|
||||
* @return the number of bits set to one in x
|
||||
*/
|
||||
static av_always_inline av_const int av_popcount_c(uint32_t x)
|
||||
static av_always_inline av_const int av_popcount(uint32_t x)
|
||||
{
|
||||
x -= (x >> 1) & 0x55555555;
|
||||
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
|
||||
@ -328,202 +127,11 @@ static av_always_inline av_const int av_popcount_c(uint32_t x)
|
||||
* @param x value to count bits of
|
||||
* @return the number of bits set to one in x
|
||||
*/
|
||||
static av_always_inline av_const int av_popcount64_c(uint64_t x)
|
||||
static av_always_inline av_const int av_popcount64(uint64_t x)
|
||||
{
|
||||
return av_popcount((uint32_t)x) + av_popcount((uint32_t)(x >> 32));
|
||||
}
|
||||
|
||||
static av_always_inline av_const int av_parity_c(uint32_t v)
|
||||
{
|
||||
return av_popcount(v) & 1;
|
||||
}
|
||||
|
||||
#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24))
|
||||
#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24))
|
||||
|
||||
/**
|
||||
* Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
|
||||
*
|
||||
* @param val Output value, must be an lvalue of type uint32_t.
|
||||
* @param GET_BYTE Expression reading one byte from the input.
|
||||
* Evaluated up to 7 times (4 for the currently
|
||||
* assigned Unicode range). With a memory buffer
|
||||
* input, this could be *ptr++.
|
||||
* @param ERROR Expression to be evaluated on invalid input,
|
||||
* typically a goto statement.
|
||||
*
|
||||
* @warning ERROR should not contain a loop control statement which
|
||||
* could interact with the internal while loop, and should force an
|
||||
* exit from the macro code (e.g. through a goto or a return) in order
|
||||
* to prevent undefined results.
|
||||
*/
|
||||
#define GET_UTF8(val, GET_BYTE, ERROR)\
|
||||
val= (GET_BYTE);\
|
||||
{\
|
||||
uint32_t top = (val & 128) >> 1;\
|
||||
if ((val & 0xc0) == 0x80 || val >= 0xFE)\
|
||||
ERROR\
|
||||
while (val & top) {\
|
||||
int tmp= (GET_BYTE) - 128;\
|
||||
if(tmp>>6)\
|
||||
ERROR\
|
||||
val= (val<<6) + tmp;\
|
||||
top <<= 5;\
|
||||
}\
|
||||
val &= (top << 1) - 1;\
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form.
|
||||
*
|
||||
* @param val Output value, must be an lvalue of type uint32_t.
|
||||
* @param GET_16BIT Expression returning two bytes of UTF-16 data converted
|
||||
* to native byte order. Evaluated one or two times.
|
||||
* @param ERROR Expression to be evaluated on invalid input,
|
||||
* typically a goto statement.
|
||||
*/
|
||||
#define GET_UTF16(val, GET_16BIT, ERROR)\
|
||||
val = GET_16BIT;\
|
||||
{\
|
||||
unsigned int hi = val - 0xD800;\
|
||||
if (hi < 0x800) {\
|
||||
val = GET_16BIT - 0xDC00;\
|
||||
if (val > 0x3FFU || hi > 0x3FFU)\
|
||||
ERROR\
|
||||
val += (hi<<10) + 0x10000;\
|
||||
}\
|
||||
}\
|
||||
|
||||
/**
|
||||
* @def PUT_UTF8(val, tmp, PUT_BYTE)
|
||||
* Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long).
|
||||
* @param val is an input-only argument and should be of type uint32_t. It holds
|
||||
* a UCS-4 encoded Unicode character that is to be converted to UTF-8. If
|
||||
* val is given as a function it is executed only once.
|
||||
* @param tmp is a temporary variable and should be of type uint8_t. It
|
||||
* represents an intermediate value during conversion that is to be
|
||||
* output by PUT_BYTE.
|
||||
* @param PUT_BYTE writes the converted UTF-8 bytes to any proper destination.
|
||||
* It could be a function or a statement, and uses tmp as the input byte.
|
||||
* For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be
|
||||
* executed up to 4 times for values in the valid UTF-8 range and up to
|
||||
* 7 times in the general case, depending on the length of the converted
|
||||
* Unicode character.
|
||||
*/
|
||||
#define PUT_UTF8(val, tmp, PUT_BYTE)\
|
||||
{\
|
||||
int bytes, shift;\
|
||||
uint32_t in = val;\
|
||||
if (in < 0x80) {\
|
||||
tmp = in;\
|
||||
PUT_BYTE\
|
||||
} else {\
|
||||
bytes = (av_log2(in) + 4) / 5;\
|
||||
shift = (bytes - 1) * 6;\
|
||||
tmp = (256 - (256 >> bytes)) | (in >> shift);\
|
||||
PUT_BYTE\
|
||||
while (shift >= 6) {\
|
||||
shift -= 6;\
|
||||
tmp = 0x80 | ((in >> shift) & 0x3f);\
|
||||
PUT_BYTE\
|
||||
}\
|
||||
}\
|
||||
}
|
||||
|
||||
/**
|
||||
* @def PUT_UTF16(val, tmp, PUT_16BIT)
|
||||
* Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes).
|
||||
* @param val is an input-only argument and should be of type uint32_t. It holds
|
||||
* a UCS-4 encoded Unicode character that is to be converted to UTF-16. If
|
||||
* val is given as a function it is executed only once.
|
||||
* @param tmp is a temporary variable and should be of type uint16_t. It
|
||||
* represents an intermediate value during conversion that is to be
|
||||
* output by PUT_16BIT.
|
||||
* @param PUT_16BIT writes the converted UTF-16 data to any proper destination
|
||||
* in desired endianness. It could be a function or a statement, and uses tmp
|
||||
* as the input byte. For example, PUT_BYTE could be "*output++ = tmp;"
|
||||
* PUT_BYTE will be executed 1 or 2 times depending on input character.
|
||||
*/
|
||||
#define PUT_UTF16(val, tmp, PUT_16BIT)\
|
||||
{\
|
||||
uint32_t in = val;\
|
||||
if (in < 0x10000) {\
|
||||
tmp = in;\
|
||||
PUT_16BIT\
|
||||
} else {\
|
||||
tmp = 0xD800 | ((in - 0x10000) >> 10);\
|
||||
PUT_16BIT\
|
||||
tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\
|
||||
PUT_16BIT\
|
||||
}\
|
||||
}\
|
||||
|
||||
|
||||
|
||||
#include "mem.h"
|
||||
|
||||
#ifdef HAVE_AV_CONFIG_H
|
||||
# include "internal.h"
|
||||
#endif /* HAVE_AV_CONFIG_H */
|
||||
|
||||
#endif /* AVUTIL_COMMON_H */
|
||||
|
||||
/*
|
||||
* The following definitions are outside the multiple inclusion guard
|
||||
* to ensure they are immediately available in intmath.h.
|
||||
*/
|
||||
|
||||
#ifndef av_ceil_log2
|
||||
# define av_ceil_log2 av_ceil_log2_c
|
||||
#endif
|
||||
#ifndef av_clip
|
||||
# define av_clip av_clip_c
|
||||
#endif
|
||||
#ifndef av_clip64
|
||||
# define av_clip64 av_clip64_c
|
||||
#endif
|
||||
#ifndef av_clip_uint8
|
||||
# define av_clip_uint8 av_clip_uint8_c
|
||||
#endif
|
||||
#ifndef av_clip_int8
|
||||
# define av_clip_int8 av_clip_int8_c
|
||||
#endif
|
||||
#ifndef av_clip_uint16
|
||||
# define av_clip_uint16 av_clip_uint16_c
|
||||
#endif
|
||||
#ifndef av_clip_int16
|
||||
# define av_clip_int16 av_clip_int16_c
|
||||
#endif
|
||||
#ifndef av_clipl_int32
|
||||
# define av_clipl_int32 av_clipl_int32_c
|
||||
#endif
|
||||
#ifndef av_clip_intp2
|
||||
# define av_clip_intp2 av_clip_intp2_c
|
||||
#endif
|
||||
#ifndef av_clip_uintp2
|
||||
# define av_clip_uintp2 av_clip_uintp2_c
|
||||
#endif
|
||||
#ifndef av_mod_uintp2
|
||||
# define av_mod_uintp2 av_mod_uintp2_c
|
||||
#endif
|
||||
#ifndef av_sat_add32
|
||||
# define av_sat_add32 av_sat_add32_c
|
||||
#endif
|
||||
#ifndef av_sat_dadd32
|
||||
# define av_sat_dadd32 av_sat_dadd32_c
|
||||
#endif
|
||||
#ifndef av_clipf
|
||||
# define av_clipf av_clipf_c
|
||||
#endif
|
||||
#ifndef av_clipd
|
||||
# define av_clipd av_clipd_c
|
||||
#endif
|
||||
#ifndef av_popcount
|
||||
# define av_popcount av_popcount_c
|
||||
#endif
|
||||
#ifndef av_popcount64
|
||||
# define av_popcount64 av_popcount64_c
|
||||
#endif
|
||||
#ifndef av_parity
|
||||
# define av_parity av_parity_c
|
||||
#endif
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
// Compat hacks
|
||||
|
||||
#include "attributes.h"
|
||||
|
||||
#include "error.h"
|
||||
|
||||
#define CONFIG_MEMORY_POISONING 0
|
||||
@ -25,6 +23,24 @@
|
||||
#define CONFIG_MDCT 1
|
||||
#define CONFIG_FFT 1
|
||||
|
||||
#define av_cold
|
||||
#define DECLARE_ALIGNED(bits, type, name) type name
|
||||
#define LOCAL_ALIGNED(bits, type, name, subscript) type name subscript
|
||||
#define av_restrict
|
||||
#define av_always_inline __forceinline
|
||||
#define av_const
|
||||
#define av_alias
|
||||
#define av_unused
|
||||
#define av_pure
|
||||
#define av_warn_unused_result
|
||||
#define av_assert0(cond)
|
||||
#define av_assert1(cond)
|
||||
#define av_assert2(cond)
|
||||
#define attribute_deprecated
|
||||
#define attribute_align_arg
|
||||
#define av_printf_format(a,b)
|
||||
#define avpriv_report_missing_feature(...)
|
||||
|
||||
#pragma warning(disable:4305)
|
||||
#pragma warning(disable:4244)
|
||||
|
||||
@ -56,3 +72,8 @@ static inline av_const int av_toupper(int c)
|
||||
c ^= 0x20;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
#define AV_BSWAP16C(x) (((x) << 8 & 0xff00) | ((x) >> 8 & 0x00ff))
|
||||
#define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C((x) >> 16))
|
||||
#define av_be2ne32(x) AV_BSWAP32C((x))
|
||||
|
@ -1,3 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "compat.h"
|
@ -27,13 +27,6 @@
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_error
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/* error handling */
|
||||
#if EDOM > 0
|
||||
#define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions.
|
||||
@ -46,40 +39,7 @@
|
||||
|
||||
#define FFERRTAG(a, b, c, d) (-(int)MKTAG(a, b, c, d))
|
||||
|
||||
#define AVERROR_BSF_NOT_FOUND FFERRTAG(0xF8,'B','S','F') ///< Bitstream filter not found
|
||||
#define AVERROR_BUG FFERRTAG( 'B','U','G','!') ///< Internal bug, also see AVERROR_BUG2
|
||||
#define AVERROR_BUFFER_TOO_SMALL FFERRTAG( 'B','U','F','S') ///< Buffer too small
|
||||
#define AVERROR_DECODER_NOT_FOUND FFERRTAG(0xF8,'D','E','C') ///< Decoder not found
|
||||
#define AVERROR_DEMUXER_NOT_FOUND FFERRTAG(0xF8,'D','E','M') ///< Demuxer not found
|
||||
#define AVERROR_ENCODER_NOT_FOUND FFERRTAG(0xF8,'E','N','C') ///< Encoder not found
|
||||
#define AVERROR_EOF FFERRTAG( 'E','O','F',' ') ///< End of file
|
||||
#define AVERROR_EXIT FFERRTAG( 'E','X','I','T') ///< Immediate exit was requested; the called function should not be restarted
|
||||
#define AVERROR_EXTERNAL FFERRTAG( 'E','X','T',' ') ///< Generic error in an external library
|
||||
#define AVERROR_FILTER_NOT_FOUND FFERRTAG(0xF8,'F','I','L') ///< Filter not found
|
||||
#define AVERROR_INVALIDDATA FFERRTAG( 'I','N','D','A') ///< Invalid data found when processing input
|
||||
#define AVERROR_MUXER_NOT_FOUND FFERRTAG(0xF8,'M','U','X') ///< Muxer not found
|
||||
#define AVERROR_OPTION_NOT_FOUND FFERRTAG(0xF8,'O','P','T') ///< Option not found
|
||||
#define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') ///< Not yet implemented in FFmpeg, patches welcome
|
||||
#define AVERROR_PROTOCOL_NOT_FOUND FFERRTAG(0xF8,'P','R','O') ///< Protocol not found
|
||||
|
||||
#define AVERROR_STREAM_NOT_FOUND FFERRTAG(0xF8,'S','T','R') ///< Stream not found
|
||||
/**
|
||||
* This is semantically identical to AVERROR_BUG
|
||||
* it has been introduced in Libav after our AVERROR_BUG and with a modified value.
|
||||
*/
|
||||
#define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ')
|
||||
#define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') ///< Unknown error, typically from an external library
|
||||
#define AVERROR_EXPERIMENTAL (-0x2bb2afa8) ///< Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
|
||||
#define AVERROR_INPUT_CHANGED (-0x636e6701) ///< Input changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_OUTPUT_CHANGED)
|
||||
#define AVERROR_OUTPUT_CHANGED (-0x636e6702) ///< Output changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_INPUT_CHANGED)
|
||||
/* HTTP & RTSP errors */
|
||||
#define AVERROR_HTTP_BAD_REQUEST FFERRTAG(0xF8,'4','0','0')
|
||||
#define AVERROR_HTTP_UNAUTHORIZED FFERRTAG(0xF8,'4','0','1')
|
||||
#define AVERROR_HTTP_FORBIDDEN FFERRTAG(0xF8,'4','0','3')
|
||||
#define AVERROR_HTTP_NOT_FOUND FFERRTAG(0xF8,'4','0','4')
|
||||
#define AVERROR_HTTP_OTHER_4XX FFERRTAG(0xF8,'4','X','X')
|
||||
#define AVERROR_HTTP_SERVER_ERROR FFERRTAG(0xF8,'5','X','X')
|
||||
|
||||
#define AV_ERROR_MAX_STRING_SIZE 64
|
||||
|
||||
#endif /* AVUTIL_ERROR_H */
|
||||
|
@ -19,8 +19,6 @@
|
||||
#ifndef AVCODEC_FFT_INTERNAL_H
|
||||
#define AVCODEC_FFT_INTERNAL_H
|
||||
|
||||
#if FFT_FLOAT
|
||||
|
||||
#define FIX15(v) (v)
|
||||
#define sqrthalf (float)M_SQRT1_2
|
||||
|
||||
@ -34,55 +32,6 @@
|
||||
(dim) = (are) * (bim) + (aim) * (bre); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
||||
#define SCALE_FLOAT(a, bits) lrint((a) * (double)(1 << (bits)))
|
||||
|
||||
#if FFT_FIXED_32
|
||||
|
||||
#define CMUL(dre, dim, are, aim, bre, bim) do { \
|
||||
int64_t accu; \
|
||||
(accu) = (int64_t)(bre) * (are); \
|
||||
(accu) -= (int64_t)(bim) * (aim); \
|
||||
(dre) = (int)(((accu) + 0x40000000) >> 31); \
|
||||
(accu) = (int64_t)(bre) * (aim); \
|
||||
(accu) += (int64_t)(bim) * (are); \
|
||||
(dim) = (int)(((accu) + 0x40000000) >> 31); \
|
||||
} while (0)
|
||||
|
||||
#define FIX15(a) av_clip(SCALE_FLOAT(a, 31), -2147483647, 2147483647)
|
||||
|
||||
#else /* FFT_FIXED_32 */
|
||||
|
||||
#include "fft.h"
|
||||
#include "mathops.h"
|
||||
|
||||
void ff_mdct_calcw_c(FFTContext *s, FFTDouble *output, const FFTSample *input);
|
||||
|
||||
#define FIX15(a) av_clip(SCALE_FLOAT(a, 15), -32767, 32767)
|
||||
|
||||
#define sqrthalf ((int16_t)((1<<15)*M_SQRT1_2))
|
||||
|
||||
#define BF(x, y, a, b) do { \
|
||||
x = (a - b) >> 1; \
|
||||
y = (a + b) >> 1; \
|
||||
} while (0)
|
||||
|
||||
#define CMULS(dre, dim, are, aim, bre, bim, sh) do { \
|
||||
(dre) = (MUL16(are, bre) - MUL16(aim, bim)) >> sh; \
|
||||
(dim) = (MUL16(are, bim) + MUL16(aim, bre)) >> sh; \
|
||||
} while (0)
|
||||
|
||||
#define CMUL(dre, dim, are, aim, bre, bim) \
|
||||
CMULS(dre, dim, are, aim, bre, bim, 15)
|
||||
|
||||
#define CMULL(dre, dim, are, aim, bre, bim) \
|
||||
CMULS(dre, dim, are, aim, bre, bim, 0)
|
||||
|
||||
#endif /* FFT_FIXED_32 */
|
||||
|
||||
#endif /* FFT_FLOAT */
|
||||
|
||||
#define ff_imdct_calc_c FFT_NAME(ff_imdct_calc_c)
|
||||
#define ff_imdct_half_c FFT_NAME(ff_imdct_half_c)
|
||||
#define ff_mdct_calc_c FFT_NAME(ff_mdct_calc_c)
|
||||
|
@ -31,7 +31,6 @@
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include "config.h"
|
||||
|
||||
#if FFT_FLOAT
|
||||
|
||||
|
@ -34,10 +34,6 @@
|
||||
#include "fft.h"
|
||||
#include "fft-internal.h"
|
||||
|
||||
#if FFT_FIXED_32
|
||||
#include "fft_table.h"
|
||||
#else /* FFT_FIXED_32 */
|
||||
|
||||
/* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */
|
||||
#if !CONFIG_HARDCODED_TABLES
|
||||
COSTABLE(16);
|
||||
@ -71,8 +67,6 @@ COSTABLE_CONST FFTSample * const FFT_NAME(ff_cos_tabs)[] = {
|
||||
FFT_NAME(ff_cos_65536),
|
||||
};
|
||||
|
||||
#endif /* FFT_FIXED_32 */
|
||||
|
||||
static void fft_permute_c(FFTContext *s, FFTComplex *z);
|
||||
static void fft_calc_c(FFTContext *s, FFTComplex *z);
|
||||
|
||||
@ -165,12 +159,6 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
|
||||
s->mdct_calc = ff_mdct_calc_c;
|
||||
#endif
|
||||
|
||||
#if FFT_FIXED_32
|
||||
{
|
||||
int n=0;
|
||||
ff_fft_lut_init(ff_fft_offsets_lut, 0, 1 << 16, &n);
|
||||
}
|
||||
#else /* FFT_FIXED_32 */
|
||||
#if FFT_FLOAT
|
||||
if (ARCH_AARCH64) ff_fft_init_aarch64(s);
|
||||
if (ARCH_ARM) ff_fft_init_arm(s);
|
||||
@ -185,8 +173,6 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
|
||||
for(j=4; j<=nbits; j++) {
|
||||
ff_init_ff_cos_tabs(j);
|
||||
}
|
||||
#endif /* FFT_FIXED_32 */
|
||||
|
||||
|
||||
if (s->fft_permutation == FF_FFT_PERM_AVX) {
|
||||
fft_perm_avx(s);
|
||||
@ -223,165 +209,6 @@ av_cold void ff_fft_end(FFTContext *s)
|
||||
av_freep(&s->tmp_buf);
|
||||
}
|
||||
|
||||
#if FFT_FIXED_32
|
||||
|
||||
static void fft_calc_c(FFTContext *s, FFTComplex *z) {
|
||||
|
||||
int nbits, i, n, num_transforms, offset, step;
|
||||
int n4, n2, n34;
|
||||
FFTSample tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
|
||||
FFTComplex *tmpz;
|
||||
const int fft_size = (1 << s->nbits);
|
||||
int64_t accu;
|
||||
|
||||
num_transforms = (0x2aab >> (16 - s->nbits)) | 1;
|
||||
|
||||
for (n=0; n<num_transforms; n++){
|
||||
offset = ff_fft_offsets_lut[n] << 2;
|
||||
tmpz = z + offset;
|
||||
|
||||
tmp1 = tmpz[0].re + tmpz[1].re;
|
||||
tmp5 = tmpz[2].re + tmpz[3].re;
|
||||
tmp2 = tmpz[0].im + tmpz[1].im;
|
||||
tmp6 = tmpz[2].im + tmpz[3].im;
|
||||
tmp3 = tmpz[0].re - tmpz[1].re;
|
||||
tmp8 = tmpz[2].im - tmpz[3].im;
|
||||
tmp4 = tmpz[0].im - tmpz[1].im;
|
||||
tmp7 = tmpz[2].re - tmpz[3].re;
|
||||
|
||||
tmpz[0].re = tmp1 + tmp5;
|
||||
tmpz[2].re = tmp1 - tmp5;
|
||||
tmpz[0].im = tmp2 + tmp6;
|
||||
tmpz[2].im = tmp2 - tmp6;
|
||||
tmpz[1].re = tmp3 + tmp8;
|
||||
tmpz[3].re = tmp3 - tmp8;
|
||||
tmpz[1].im = tmp4 - tmp7;
|
||||
tmpz[3].im = tmp4 + tmp7;
|
||||
}
|
||||
|
||||
if (fft_size < 8)
|
||||
return;
|
||||
|
||||
num_transforms = (num_transforms >> 1) | 1;
|
||||
|
||||
for (n=0; n<num_transforms; n++){
|
||||
offset = ff_fft_offsets_lut[n] << 3;
|
||||
tmpz = z + offset;
|
||||
|
||||
tmp1 = tmpz[4].re + tmpz[5].re;
|
||||
tmp3 = tmpz[6].re + tmpz[7].re;
|
||||
tmp2 = tmpz[4].im + tmpz[5].im;
|
||||
tmp4 = tmpz[6].im + tmpz[7].im;
|
||||
tmp5 = tmp1 + tmp3;
|
||||
tmp7 = tmp1 - tmp3;
|
||||
tmp6 = tmp2 + tmp4;
|
||||
tmp8 = tmp2 - tmp4;
|
||||
|
||||
tmp1 = tmpz[4].re - tmpz[5].re;
|
||||
tmp2 = tmpz[4].im - tmpz[5].im;
|
||||
tmp3 = tmpz[6].re - tmpz[7].re;
|
||||
tmp4 = tmpz[6].im - tmpz[7].im;
|
||||
|
||||
tmpz[4].re = tmpz[0].re - tmp5;
|
||||
tmpz[0].re = tmpz[0].re + tmp5;
|
||||
tmpz[4].im = tmpz[0].im - tmp6;
|
||||
tmpz[0].im = tmpz[0].im + tmp6;
|
||||
tmpz[6].re = tmpz[2].re - tmp8;
|
||||
tmpz[2].re = tmpz[2].re + tmp8;
|
||||
tmpz[6].im = tmpz[2].im + tmp7;
|
||||
tmpz[2].im = tmpz[2].im - tmp7;
|
||||
|
||||
accu = (int64_t)Q31(M_SQRT1_2)*(tmp1 + tmp2);
|
||||
tmp5 = (int32_t)((accu + 0x40000000) >> 31);
|
||||
accu = (int64_t)Q31(M_SQRT1_2)*(tmp3 - tmp4);
|
||||
tmp7 = (int32_t)((accu + 0x40000000) >> 31);
|
||||
accu = (int64_t)Q31(M_SQRT1_2)*(tmp2 - tmp1);
|
||||
tmp6 = (int32_t)((accu + 0x40000000) >> 31);
|
||||
accu = (int64_t)Q31(M_SQRT1_2)*(tmp3 + tmp4);
|
||||
tmp8 = (int32_t)((accu + 0x40000000) >> 31);
|
||||
tmp1 = tmp5 + tmp7;
|
||||
tmp3 = tmp5 - tmp7;
|
||||
tmp2 = tmp6 + tmp8;
|
||||
tmp4 = tmp6 - tmp8;
|
||||
|
||||
tmpz[5].re = tmpz[1].re - tmp1;
|
||||
tmpz[1].re = tmpz[1].re + tmp1;
|
||||
tmpz[5].im = tmpz[1].im - tmp2;
|
||||
tmpz[1].im = tmpz[1].im + tmp2;
|
||||
tmpz[7].re = tmpz[3].re - tmp4;
|
||||
tmpz[3].re = tmpz[3].re + tmp4;
|
||||
tmpz[7].im = tmpz[3].im + tmp3;
|
||||
tmpz[3].im = tmpz[3].im - tmp3;
|
||||
}
|
||||
|
||||
step = 1 << ((MAX_LOG2_NFFT-4) - 4);
|
||||
n4 = 4;
|
||||
|
||||
for (nbits=4; nbits<=s->nbits; nbits++){
|
||||
n2 = 2*n4;
|
||||
n34 = 3*n4;
|
||||
num_transforms = (num_transforms >> 1) | 1;
|
||||
|
||||
for (n=0; n<num_transforms; n++){
|
||||
const FFTSample *w_re_ptr = ff_w_tab_sr + step;
|
||||
const FFTSample *w_im_ptr = ff_w_tab_sr + MAX_FFT_SIZE/(4*16) - step;
|
||||
offset = ff_fft_offsets_lut[n] << nbits;
|
||||
tmpz = z + offset;
|
||||
|
||||
tmp5 = tmpz[ n2].re + tmpz[n34].re;
|
||||
tmp1 = tmpz[ n2].re - tmpz[n34].re;
|
||||
tmp6 = tmpz[ n2].im + tmpz[n34].im;
|
||||
tmp2 = tmpz[ n2].im - tmpz[n34].im;
|
||||
|
||||
tmpz[ n2].re = tmpz[ 0].re - tmp5;
|
||||
tmpz[ 0].re = tmpz[ 0].re + tmp5;
|
||||
tmpz[ n2].im = tmpz[ 0].im - tmp6;
|
||||
tmpz[ 0].im = tmpz[ 0].im + tmp6;
|
||||
tmpz[n34].re = tmpz[n4].re - tmp2;
|
||||
tmpz[ n4].re = tmpz[n4].re + tmp2;
|
||||
tmpz[n34].im = tmpz[n4].im + tmp1;
|
||||
tmpz[ n4].im = tmpz[n4].im - tmp1;
|
||||
|
||||
for (i=1; i<n4; i++){
|
||||
FFTSample w_re = w_re_ptr[0];
|
||||
FFTSample w_im = w_im_ptr[0];
|
||||
accu = (int64_t)w_re*tmpz[ n2+i].re;
|
||||
accu += (int64_t)w_im*tmpz[ n2+i].im;
|
||||
tmp1 = (int32_t)((accu + 0x40000000) >> 31);
|
||||
accu = (int64_t)w_re*tmpz[ n2+i].im;
|
||||
accu -= (int64_t)w_im*tmpz[ n2+i].re;
|
||||
tmp2 = (int32_t)((accu + 0x40000000) >> 31);
|
||||
accu = (int64_t)w_re*tmpz[n34+i].re;
|
||||
accu -= (int64_t)w_im*tmpz[n34+i].im;
|
||||
tmp3 = (int32_t)((accu + 0x40000000) >> 31);
|
||||
accu = (int64_t)w_re*tmpz[n34+i].im;
|
||||
accu += (int64_t)w_im*tmpz[n34+i].re;
|
||||
tmp4 = (int32_t)((accu + 0x40000000) >> 31);
|
||||
|
||||
tmp5 = tmp1 + tmp3;
|
||||
tmp1 = tmp1 - tmp3;
|
||||
tmp6 = tmp2 + tmp4;
|
||||
tmp2 = tmp2 - tmp4;
|
||||
|
||||
tmpz[ n2+i].re = tmpz[ i].re - tmp5;
|
||||
tmpz[ i].re = tmpz[ i].re + tmp5;
|
||||
tmpz[ n2+i].im = tmpz[ i].im - tmp6;
|
||||
tmpz[ i].im = tmpz[ i].im + tmp6;
|
||||
tmpz[n34+i].re = tmpz[n4+i].re - tmp2;
|
||||
tmpz[ n4+i].re = tmpz[n4+i].re + tmp2;
|
||||
tmpz[n34+i].im = tmpz[n4+i].im + tmp1;
|
||||
tmpz[ n4+i].im = tmpz[n4+i].im - tmp1;
|
||||
|
||||
w_re_ptr += step;
|
||||
w_im_ptr -= step;
|
||||
}
|
||||
}
|
||||
step >>= 1;
|
||||
n4 <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
#else /* FFT_FIXED_32 */
|
||||
|
||||
#define BUTTERFLIES(a0,a1,a2,a3) {\
|
||||
BF(t3, t5, t5, t1);\
|
||||
@ -528,4 +355,3 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z)
|
||||
{
|
||||
fft_dispatch[s->nbits-2](z);
|
||||
}
|
||||
#endif /* FFT_FIXED_32 */
|
||||
|
@ -19,8 +19,7 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "attributes.h"
|
||||
#include "compat.h"
|
||||
#include "float_dsp.h"
|
||||
#include "mem.h"
|
||||
|
||||
|
@ -19,8 +19,6 @@
|
||||
#ifndef AVUTIL_FLOAT_DSP_H
|
||||
#define AVUTIL_FLOAT_DSP_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
typedef struct AVFloatDSPContext {
|
||||
/**
|
||||
* Calculate the entry wise product of two vectors of floats and store the result in
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "common.h"
|
||||
#include "common.h"
|
||||
#include "intreadwrite.h"
|
||||
#include "mathops.h"
|
||||
#include "mathematics.h"
|
||||
/*
|
||||
#include "libavutil/log.h"
|
||||
#include "libavutil/avassert.h"
|
||||
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* common internal api header.
|
||||
*/
|
||||
|
||||
#ifndef AVCODEC_INTERNAL_H
|
||||
#define AVCODEC_INTERNAL_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "channel_layout.h"
|
||||
#include "mathematics.h"
|
||||
#include "avcodec.h"
|
||||
#include "config.h"
|
||||
|
||||
#define FF_SANE_NB_CHANNELS 64U
|
||||
|
||||
extern const uint8_t ff_log2_run[41];
|
||||
|
||||
/**
|
||||
* Maximum size in bytes of extradata.
|
||||
* This value was chosen such that every bit of the buffer is
|
||||
* addressable by a 32-bit signed integer as used by get_bits.
|
||||
*/
|
||||
#define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE)
|
||||
|
||||
#endif /* AVCODEC_INTERNAL_H */
|
@ -23,8 +23,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "attributes.h"
|
||||
#include "compat.h"
|
||||
|
||||
#if ARCH_ARM
|
||||
# include "arm/intmath.h"
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "compat.h"
|
||||
#include "bswap.h"
|
||||
|
||||
typedef union {
|
||||
uint64_t u64;
|
||||
|
@ -26,8 +26,7 @@
|
||||
#define AVUTIL_LIBM_H
|
||||
|
||||
#include <math.h>
|
||||
#include "config.h"
|
||||
#include "attributes.h"
|
||||
#include "compat.h"
|
||||
#include "intfloat.h"
|
||||
#include "mathematics.h"
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "avutil.h"
|
||||
#include "attributes.h"
|
||||
#include "compat.h"
|
||||
#include "version.h"
|
||||
|
||||
typedef enum {
|
||||
@ -352,6 +352,12 @@ void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
|
||||
void av_log_set_flags(int arg);
|
||||
int av_log_get_flags(void);
|
||||
|
||||
#ifdef DEBUG
|
||||
# define ff_dlog(ctx, ...) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__)
|
||||
#else
|
||||
# define ff_dlog(ctx, ...) do { if (0) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2012 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
const uint8_t ff_log2_tab[256]={
|
||||
0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
|
||||
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
|
||||
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
|
||||
};
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup lavu
|
||||
* Utility Preprocessor macros
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_MACROS_H
|
||||
#define AVUTIL_MACROS_H
|
||||
|
||||
/**
|
||||
* @addtogroup preproc_misc Preprocessor String Macros
|
||||
*
|
||||
* String manipulation macros
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define AV_STRINGIFY(s) AV_TOSTRING(s)
|
||||
#define AV_TOSTRING(s) #s
|
||||
|
||||
#define AV_GLUE(a, b) a ## b
|
||||
#define AV_JOIN(a, b) AV_GLUE(a, b)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#define AV_PRAGMA(s) _Pragma(#s)
|
||||
|
||||
#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
|
||||
|
||||
#endif /* AVUTIL_MACROS_H */
|
@ -142,3 +142,90 @@ int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
|
||||
{
|
||||
return av_rescale_q_rnd(a, bq, cq, AV_ROUND_NEAR_INF);
|
||||
}
|
||||
|
||||
|
||||
int av_reduce(int *dst_num, int *dst_den,
|
||||
int64_t num, int64_t den, int64_t max)
|
||||
{
|
||||
AVRational a0 = { 0, 1 }, a1 = { 1, 0 };
|
||||
int sign = (num < 0) ^ (den < 0);
|
||||
int64_t gcd = av_gcd(FFABS(num), FFABS(den));
|
||||
|
||||
if (gcd) {
|
||||
num = FFABS(num) / gcd;
|
||||
den = FFABS(den) / gcd;
|
||||
}
|
||||
if (num <= max && den <= max) {
|
||||
a1 = (AVRational){ num, den };
|
||||
den = 0;
|
||||
}
|
||||
|
||||
while (den) {
|
||||
uint64_t x = num / den;
|
||||
int64_t next_den = num - den * x;
|
||||
int64_t a2n = x * a1.num + a0.num;
|
||||
int64_t a2d = x * a1.den + a0.den;
|
||||
|
||||
if (a2n > max || a2d > max) {
|
||||
if (a1.num) x = (max - a0.num) / a1.num;
|
||||
if (a1.den) x = FFMIN(x, (max - a0.den) / a1.den);
|
||||
|
||||
if (den * (2 * x * a1.den + a0.den) > num * a1.den)
|
||||
a1 = (AVRational){ x * a1.num + a0.num, x * a1.den + a0.den };
|
||||
break;
|
||||
}
|
||||
|
||||
a0 = a1;
|
||||
a1 = (AVRational){ a2n, a2d };
|
||||
num = den;
|
||||
den = next_den;
|
||||
}
|
||||
av_assert2(av_gcd(a1.num, a1.den) <= 1U);
|
||||
av_assert2(a1.num <= max && a1.den <= max);
|
||||
|
||||
*dst_num = sign ? -a1.num : a1.num;
|
||||
*dst_den = a1.den;
|
||||
|
||||
return den == 0;
|
||||
}
|
||||
|
||||
AVRational av_mul_q(AVRational b, AVRational c)
|
||||
{
|
||||
av_reduce(&b.num, &b.den,
|
||||
b.num * (int64_t)c.num,
|
||||
b.den * (int64_t)c.den, INT_MAX);
|
||||
return b;
|
||||
}
|
||||
|
||||
AVRational av_div_q(AVRational b, AVRational c)
|
||||
{
|
||||
return av_mul_q(b, (AVRational) { c.den, c.num });
|
||||
}
|
||||
|
||||
AVRational av_add_q(AVRational b, AVRational c) {
|
||||
av_reduce(&b.num, &b.den,
|
||||
b.num * (int64_t)c.den +
|
||||
c.num * (int64_t)b.den,
|
||||
b.den * (int64_t)c.den, INT_MAX);
|
||||
return b;
|
||||
}
|
||||
|
||||
AVRational av_d2q(double d, int max)
|
||||
{
|
||||
AVRational a;
|
||||
int exponent;
|
||||
int64_t den;
|
||||
if (isnan(d))
|
||||
return (AVRational) { 0, 0 };
|
||||
if (fabs(d) > INT_MAX + 3LL)
|
||||
return (AVRational) { d < 0 ? -1 : 1, 0 };
|
||||
frexp(d, &exponent);
|
||||
exponent = FFMAX(exponent - 1, 0);
|
||||
den = 1LL << (61 - exponent);
|
||||
// (int64_t)rint() and llrint() do not work with gcc on ia64 and sparc64
|
||||
av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, max);
|
||||
if ((!a.num || !a.den) && d && max > 0 && max < INT_MAX)
|
||||
av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, INT_MAX);
|
||||
|
||||
return a;
|
||||
}
|
||||
|
@ -23,10 +23,37 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include "attributes.h"
|
||||
#include "rational.h"
|
||||
#include "compat.h"
|
||||
#include "common.h"
|
||||
#include "intfloat.h"
|
||||
|
||||
extern const uint32_t ff_inverse[257];
|
||||
extern const uint8_t ff_sqrt_tab[256];
|
||||
|
||||
#ifndef sign_extend
|
||||
static inline av_const int sign_extend(int val, unsigned bits)
|
||||
{
|
||||
unsigned shift = 8 * sizeof(int) - bits;
|
||||
union { unsigned u; int s; } v = { (unsigned)val << shift };
|
||||
return v.s >> shift;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef zero_extend
|
||||
static inline av_const unsigned zero_extend(unsigned val, unsigned bits)
|
||||
{
|
||||
return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEG_SSR32
|
||||
# define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s)))
|
||||
#endif
|
||||
|
||||
#ifndef NEG_USR32
|
||||
# define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s)))
|
||||
#endif
|
||||
|
||||
#ifndef M_E
|
||||
#define M_E 2.7182818284590452354 /* e */
|
||||
#endif
|
||||
@ -76,19 +103,27 @@ enum AVRounding {
|
||||
AV_ROUND_PASS_MINMAX = 8192, ///< Flag to pass INT64_MIN/MAX through instead of rescaling, this avoids special cases for AV_NOPTS_VALUE
|
||||
};
|
||||
|
||||
/**
|
||||
* rational number numerator/denominator
|
||||
*/
|
||||
typedef struct AVRational {
|
||||
int num; ///< numerator
|
||||
int den; ///< denominator
|
||||
} AVRational;
|
||||
|
||||
/**
|
||||
* Compute the greatest common divisor of a and b.
|
||||
*
|
||||
* @return gcd of a and b up to sign; if a >= 0 and b >= 0, return value is >= 0;
|
||||
* if a == 0 and b == 0, returns 0.
|
||||
*/
|
||||
int64_t av_const av_gcd(int64_t a, int64_t b);
|
||||
int64_t av_gcd(int64_t a, int64_t b);
|
||||
|
||||
/**
|
||||
* Rescale a 64-bit integer with rounding to nearest.
|
||||
* A simple a*b/c isn't possible as it can overflow.
|
||||
*/
|
||||
int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const;
|
||||
int64_t av_rescale(int64_t a, int64_t b, int64_t c);
|
||||
|
||||
/**
|
||||
* Rescale a 64-bit integer with specified rounding.
|
||||
@ -97,12 +132,12 @@ int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const;
|
||||
* @return rescaled value a, or if AV_ROUND_PASS_MINMAX is set and a is
|
||||
* INT64_MIN or INT64_MAX then a is passed through unchanged.
|
||||
*/
|
||||
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const;
|
||||
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding);
|
||||
|
||||
/**
|
||||
* Rescale a 64-bit integer by 2 rational numbers.
|
||||
*/
|
||||
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const;
|
||||
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq);
|
||||
|
||||
/**
|
||||
* Rescale a 64-bit integer by 2 rational numbers with specified rounding.
|
||||
@ -111,11 +146,100 @@ int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const;
|
||||
* INT64_MIN or INT64_MAX then a is passed through unchanged.
|
||||
*/
|
||||
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq,
|
||||
enum AVRounding) av_const;
|
||||
enum AVRounding);
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
/**
|
||||
* Create a rational.
|
||||
* Useful for compilers that do not support compound literals.
|
||||
* @note The return value is not reduced.
|
||||
*/
|
||||
static inline AVRational av_make_q(int num, int den)
|
||||
{
|
||||
AVRational r = { num, den };
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two rationals.
|
||||
* @param a first rational
|
||||
* @param b second rational
|
||||
* @return 0 if a==b, 1 if a>b, -1 if a<b, and INT_MIN if one of the
|
||||
* values is of the form 0/0
|
||||
*/
|
||||
static inline int av_cmp_q(AVRational a, AVRational b) {
|
||||
const int64_t tmp = a.num * (int64_t)b.den - b.num * (int64_t)a.den;
|
||||
|
||||
if (tmp) return (int)((tmp ^ a.den ^ b.den) >> 63) | 1;
|
||||
else if (b.den && a.den) return 0;
|
||||
else if (a.num && b.num) return (a.num >> 31) - (b.num >> 31);
|
||||
else return INT_MIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert rational to double.
|
||||
* @param a rational to convert
|
||||
* @return (double) a
|
||||
*/
|
||||
static inline double av_q2d(AVRational a) {
|
||||
return a.num / (double)a.den;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce a fraction.
|
||||
* This is useful for framerate calculations.
|
||||
* @param dst_num destination numerator
|
||||
* @param dst_den destination denominator
|
||||
* @param num source numerator
|
||||
* @param den source denominator
|
||||
* @param max the maximum allowed for dst_num & dst_den
|
||||
* @return 1 if exact, 0 otherwise
|
||||
*/
|
||||
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max);
|
||||
|
||||
/**
|
||||
* Multiply two rationals.
|
||||
* @param b first rational
|
||||
* @param c second rational
|
||||
* @return b*c
|
||||
*/
|
||||
AVRational av_mul_q(AVRational b, AVRational c) av_const;
|
||||
|
||||
/**
|
||||
* Divide one rational by another.
|
||||
* @param b first rational
|
||||
* @param c second rational
|
||||
* @return b/c
|
||||
*/
|
||||
AVRational av_div_q(AVRational b, AVRational c) av_const;
|
||||
|
||||
/**
|
||||
* Add two rationals.
|
||||
* @param b first rational
|
||||
* @param c second rational
|
||||
* @return b+c
|
||||
*/
|
||||
AVRational av_add_q(AVRational b, AVRational c) av_const;
|
||||
|
||||
/**
|
||||
* Invert a rational.
|
||||
* @param q value
|
||||
* @return 1 / q
|
||||
*/
|
||||
static av_always_inline AVRational av_inv_q(AVRational q)
|
||||
{
|
||||
AVRational r = { q.den, q.num };
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a double precision floating point number to a rational.
|
||||
* inf is expressed as {1,0} or {-1,0} depending on the sign.
|
||||
*
|
||||
* @param d double to convert
|
||||
* @param max the maximum allowed numerator and denominator
|
||||
* @return (AVRational) d
|
||||
*/
|
||||
AVRational av_d2q(double d, int max) av_const;
|
||||
|
||||
#endif /* AVUTIL_MATHEMATICS_H */
|
||||
|
@ -1,251 +0,0 @@
|
||||
/*
|
||||
* simple math operations
|
||||
* Copyright (c) 2001, 2002 Fabrice Bellard
|
||||
* Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef AVCODEC_MATHOPS_H
|
||||
#define AVCODEC_MATHOPS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "config.h"
|
||||
|
||||
#define MAX_NEG_CROP 1024
|
||||
|
||||
extern const uint32_t ff_inverse[257];
|
||||
extern const uint8_t ff_sqrt_tab[256];
|
||||
extern const uint8_t ff_crop_tab[256 + 2 * MAX_NEG_CROP];
|
||||
extern const uint8_t ff_zigzag_direct[64];
|
||||
|
||||
#if ARCH_ARM
|
||||
# include "arm/mathops.h"
|
||||
#elif ARCH_AVR32
|
||||
# include "avr32/mathops.h"
|
||||
#elif ARCH_MIPS
|
||||
# include "mips/mathops.h"
|
||||
#elif ARCH_PPC
|
||||
# include "ppc/mathops.h"
|
||||
#elif ARCH_X86
|
||||
# include "x86/mathops.h"
|
||||
#endif
|
||||
|
||||
/* generic implementation */
|
||||
|
||||
#ifndef MUL64
|
||||
# define MUL64(a,b) ((int64_t)(a) * (int64_t)(b))
|
||||
#endif
|
||||
|
||||
#ifndef MULL
|
||||
# define MULL(a,b,s) (MUL64(a, b) >> (s))
|
||||
#endif
|
||||
|
||||
#ifndef MULH
|
||||
static av_always_inline int MULH(int a, int b){
|
||||
return MUL64(a, b) >> 32;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef UMULH
|
||||
static av_always_inline unsigned UMULH(unsigned a, unsigned b){
|
||||
return ((uint64_t)(a) * (uint64_t)(b))>>32;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef MAC64
|
||||
# define MAC64(d, a, b) ((d) += MUL64(a, b))
|
||||
#endif
|
||||
|
||||
#ifndef MLS64
|
||||
# define MLS64(d, a, b) ((d) -= MUL64(a, b))
|
||||
#endif
|
||||
|
||||
/* signed 16x16 -> 32 multiply add accumulate */
|
||||
#ifndef MAC16
|
||||
# define MAC16(rt, ra, rb) rt += (ra) * (rb)
|
||||
#endif
|
||||
|
||||
/* signed 16x16 -> 32 multiply */
|
||||
#ifndef MUL16
|
||||
# define MUL16(ra, rb) ((ra) * (rb))
|
||||
#endif
|
||||
|
||||
#ifndef MLS16
|
||||
# define MLS16(rt, ra, rb) ((rt) -= (ra) * (rb))
|
||||
#endif
|
||||
|
||||
/* median of 3 */
|
||||
#ifndef mid_pred
|
||||
#define mid_pred mid_pred
|
||||
static inline av_const int mid_pred(int a, int b, int c)
|
||||
{
|
||||
#if 0
|
||||
int t= (a-b)&((a-b)>>31);
|
||||
a-=t;
|
||||
b+=t;
|
||||
b-= (b-c)&((b-c)>>31);
|
||||
b+= (a-b)&((a-b)>>31);
|
||||
|
||||
return b;
|
||||
#else
|
||||
if(a>b){
|
||||
if(c>b){
|
||||
if(c>a) b=a;
|
||||
else b=c;
|
||||
}
|
||||
}else{
|
||||
if(b>c){
|
||||
if(c>a) b=c;
|
||||
else b=a;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef median4
|
||||
#define median4 median4
|
||||
static inline av_const int median4(int a, int b, int c, int d)
|
||||
{
|
||||
if (a < b) {
|
||||
if (c < d) return (FFMIN(b, d) + FFMAX(a, c)) / 2;
|
||||
else return (FFMIN(b, c) + FFMAX(a, d)) / 2;
|
||||
} else {
|
||||
if (c < d) return (FFMIN(a, d) + FFMAX(b, c)) / 2;
|
||||
else return (FFMIN(a, c) + FFMAX(b, d)) / 2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef sign_extend
|
||||
static inline av_const int sign_extend(int val, unsigned bits)
|
||||
{
|
||||
unsigned shift = 8 * sizeof(int) - bits;
|
||||
union { unsigned u; int s; } v = { (unsigned) val << shift };
|
||||
return v.s >> shift;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef zero_extend
|
||||
static inline av_const unsigned zero_extend(unsigned val, unsigned bits)
|
||||
{
|
||||
return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef COPY3_IF_LT
|
||||
#define COPY3_IF_LT(x, y, a, b, c, d)\
|
||||
if ((y) < (x)) {\
|
||||
(x) = (y);\
|
||||
(a) = (b);\
|
||||
(c) = (d);\
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef MASK_ABS
|
||||
#define MASK_ABS(mask, level) do { \
|
||||
mask = level >> 31; \
|
||||
level = (level ^ mask) - mask; \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef NEG_SSR32
|
||||
# define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s)))
|
||||
#endif
|
||||
|
||||
#ifndef NEG_USR32
|
||||
# define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s)))
|
||||
#endif
|
||||
|
||||
#if HAVE_BIGENDIAN
|
||||
# ifndef PACK_2U8
|
||||
# define PACK_2U8(a,b) (((a) << 8) | (b))
|
||||
# endif
|
||||
# ifndef PACK_4U8
|
||||
# define PACK_4U8(a,b,c,d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
|
||||
# endif
|
||||
# ifndef PACK_2U16
|
||||
# define PACK_2U16(a,b) (((a) << 16) | (b))
|
||||
# endif
|
||||
#else
|
||||
# ifndef PACK_2U8
|
||||
# define PACK_2U8(a,b) (((b) << 8) | (a))
|
||||
# endif
|
||||
# ifndef PACK_4U2
|
||||
# define PACK_4U8(a,b,c,d) (((d) << 24) | ((c) << 16) | ((b) << 8) | (a))
|
||||
# endif
|
||||
# ifndef PACK_2U16
|
||||
# define PACK_2U16(a,b) (((b) << 16) | (a))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PACK_2S8
|
||||
# define PACK_2S8(a,b) PACK_2U8((a)&255, (b)&255)
|
||||
#endif
|
||||
#ifndef PACK_4S8
|
||||
# define PACK_4S8(a,b,c,d) PACK_4U8((a)&255, (b)&255, (c)&255, (d)&255)
|
||||
#endif
|
||||
#ifndef PACK_2S16
|
||||
# define PACK_2S16(a,b) PACK_2U16((a)&0xffff, (b)&0xffff)
|
||||
#endif
|
||||
|
||||
#ifndef FASTDIV
|
||||
# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32))
|
||||
#endif /* FASTDIV */
|
||||
|
||||
#ifndef ff_sqrt
|
||||
#define ff_sqrt ff_sqrt
|
||||
static inline av_const unsigned int ff_sqrt(unsigned int a)
|
||||
{
|
||||
unsigned int b;
|
||||
|
||||
if (a < 255) return (ff_sqrt_tab[a + 1] - 1) >> 4;
|
||||
else if (a < (1 << 12)) b = ff_sqrt_tab[a >> 4] >> 2;
|
||||
#if !CONFIG_SMALL
|
||||
else if (a < (1 << 14)) b = ff_sqrt_tab[a >> 6] >> 1;
|
||||
else if (a < (1 << 16)) b = ff_sqrt_tab[a >> 8] ;
|
||||
#endif
|
||||
else {
|
||||
int s = av_log2_16bit(a >> 16) >> 1;
|
||||
unsigned int c = a >> (s + 2);
|
||||
b = ff_sqrt_tab[c >> (s + 8)];
|
||||
b = FASTDIV(c,b) + (b << s);
|
||||
}
|
||||
|
||||
return b - (a < b * b);
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline av_const float ff_sqrf(float a)
|
||||
{
|
||||
return a*a;
|
||||
}
|
||||
|
||||
static inline int8_t ff_u8_to_s8(uint8_t a)
|
||||
{
|
||||
union {
|
||||
uint8_t u8;
|
||||
int8_t s8;
|
||||
} b;
|
||||
b.u8 = a;
|
||||
return b.s8;
|
||||
}
|
||||
|
||||
#endif /* AVCODEC_MATHOPS_H */
|
@ -60,110 +60,20 @@ int ff_fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_real
|
||||
|
||||
#define ALIGN (HAVE_AVX ? 32 : 16)
|
||||
|
||||
/* NOTE: if you want to override these functions with your own
|
||||
* implementations (not recommended) you have to link libav* as
|
||||
* dynamic libraries and remove -Wl,-Bsymbolic from the linker flags.
|
||||
* Note that this will cost performance. */
|
||||
|
||||
static size_t max_alloc_size= INT_MAX;
|
||||
|
||||
void av_max_alloc(size_t max){
|
||||
max_alloc_size = max;
|
||||
}
|
||||
|
||||
void *av_malloc(size_t size)
|
||||
{
|
||||
void *ptr = NULL;
|
||||
#if CONFIG_MEMALIGN_HACK
|
||||
long diff;
|
||||
#endif
|
||||
|
||||
/* let's disallow possibly ambiguous cases */
|
||||
if (size > (max_alloc_size - 32))
|
||||
return NULL;
|
||||
|
||||
#if CONFIG_MEMALIGN_HACK
|
||||
ptr = malloc(size + ALIGN);
|
||||
if (!ptr)
|
||||
return ptr;
|
||||
diff = ((~(long)ptr)&(ALIGN - 1)) + 1;
|
||||
ptr = (char *)ptr + diff;
|
||||
((char *)ptr)[-1] = diff;
|
||||
#elif HAVE_POSIX_MEMALIGN
|
||||
if (size) //OS X on SDK 10.6 has a broken posix_memalign implementation
|
||||
if (posix_memalign(&ptr, ALIGN, size))
|
||||
ptr = NULL;
|
||||
#elif HAVE_ALIGNED_MALLOC
|
||||
ptr = _aligned_malloc(size, ALIGN);
|
||||
#elif HAVE_MEMALIGN
|
||||
#ifndef __DJGPP__
|
||||
ptr = memalign(ALIGN, size);
|
||||
#else
|
||||
ptr = memalign(size, ALIGN);
|
||||
#endif
|
||||
/* Why 64?
|
||||
* Indeed, we should align it:
|
||||
* on 4 for 386
|
||||
* on 16 for 486
|
||||
* on 32 for 586, PPro - K6-III
|
||||
* on 64 for K7 (maybe for P3 too).
|
||||
* Because L1 and L2 caches are aligned on those values.
|
||||
* But I don't want to code such logic here!
|
||||
*/
|
||||
/* Why 32?
|
||||
* For AVX ASM. SSE / NEON needs only 16.
|
||||
* Why not larger? Because I did not see a difference in benchmarks ...
|
||||
*/
|
||||
/* benchmarks with P3
|
||||
* memalign(64) + 1 3071, 3051, 3032
|
||||
* memalign(64) + 2 3051, 3032, 3041
|
||||
* memalign(64) + 4 2911, 2896, 2915
|
||||
* memalign(64) + 8 2545, 2554, 2550
|
||||
* memalign(64) + 16 2543, 2572, 2563
|
||||
* memalign(64) + 32 2546, 2545, 2571
|
||||
* memalign(64) + 64 2570, 2533, 2558
|
||||
*
|
||||
* BTW, malloc seems to do 8-byte alignment by default here.
|
||||
*/
|
||||
#else
|
||||
ptr = malloc(size);
|
||||
#endif
|
||||
if(!ptr && !size) {
|
||||
size = 1;
|
||||
ptr= av_malloc(1);
|
||||
}
|
||||
#if CONFIG_MEMORY_POISONING
|
||||
if (ptr)
|
||||
memset(ptr, FF_MEMORY_POISON, size);
|
||||
#endif
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *av_realloc(void *ptr, size_t size)
|
||||
{
|
||||
#if CONFIG_MEMALIGN_HACK
|
||||
int diff;
|
||||
#endif
|
||||
|
||||
/* let's disallow possibly ambiguous cases */
|
||||
if (size > (max_alloc_size - 32))
|
||||
return NULL;
|
||||
|
||||
#if CONFIG_MEMALIGN_HACK
|
||||
//FIXME this isn't aligned correctly, though it probably isn't needed
|
||||
if (!ptr)
|
||||
return av_malloc(size);
|
||||
diff = ((char *)ptr)[-1];
|
||||
av_assert0(diff>0 && diff<=ALIGN);
|
||||
ptr = realloc((char *)ptr - diff, size + diff);
|
||||
if (ptr)
|
||||
ptr = (char *)ptr + diff;
|
||||
return ptr;
|
||||
#elif HAVE_ALIGNED_MALLOC
|
||||
return _aligned_realloc(ptr, size + !size, ALIGN);
|
||||
#else
|
||||
return realloc(ptr, size + !size);
|
||||
#endif
|
||||
}
|
||||
|
||||
void *av_realloc_f(void *ptr, size_t nelem, size_t elsize)
|
||||
@ -190,17 +100,7 @@ void *av_realloc_array(void *ptr, size_t nmemb, size_t size)
|
||||
|
||||
void av_free(void *ptr)
|
||||
{
|
||||
#if CONFIG_MEMALIGN_HACK
|
||||
if (ptr) {
|
||||
int v= ((char *)ptr)[-1];
|
||||
av_assert0(v>0 && v<=ALIGN);
|
||||
free((char *)ptr - v);
|
||||
}
|
||||
#elif HAVE_ALIGNED_MALLOC
|
||||
_aligned_free(ptr);
|
||||
#else
|
||||
free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void av_freep(void *arg)
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "attributes.h"
|
||||
#include "compat.h"
|
||||
#include "error.h"
|
||||
#include "avutil.h"
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
* @addtogroup lavu_mem
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define FF_MEMORY_POISON 0x2a
|
||||
|
||||
#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C)
|
||||
#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
|
||||
@ -195,11 +195,6 @@ static inline int av_size_mult(size_t a, size_t b, size_t *r)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the maximum size that may me allocated in one block.
|
||||
*/
|
||||
void av_max_alloc(size_t max);
|
||||
|
||||
/**
|
||||
* Reallocate the given block if it is not large enough, otherwise do nothing.
|
||||
*
|
||||
|
@ -1,109 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2001 Fabrice Bellard
|
||||
* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Options definition for AVCodecContext.
|
||||
*/
|
||||
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "util_internal.h"
|
||||
#include "mem.h"
|
||||
#include <float.h> /* FLT_MIN, FLT_MAX */
|
||||
#include <string.h>
|
||||
|
||||
static const AVClass av_codec_context_class = {
|
||||
.class_name = "AVCodecContext",
|
||||
.item_name = NULL,
|
||||
.option = NULL,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
.log_level_offset_offset = offsetof(AVCodecContext, log_level_offset),
|
||||
.child_next = NULL,
|
||||
.child_class_next = NULL,
|
||||
.category = AV_CLASS_CATEGORY_DECODER,
|
||||
};
|
||||
|
||||
int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec)
|
||||
{
|
||||
int flags=0;
|
||||
memset(s, 0, sizeof(AVCodecContext));
|
||||
|
||||
s->av_class = &av_codec_context_class;
|
||||
|
||||
if (codec) {
|
||||
s->codec = codec;
|
||||
s->codec_id = codec->id;
|
||||
}
|
||||
|
||||
if(codec && codec->priv_data_size){
|
||||
if(!s->priv_data){
|
||||
s->priv_data= av_mallocz(codec->priv_data_size);
|
||||
if (!s->priv_data) {
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
}
|
||||
if(codec->priv_class){
|
||||
*(const AVClass**)s->priv_data = codec->priv_class;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
AVCodecContext *avcodec_alloc_context3(const AVCodec *codec)
|
||||
{
|
||||
AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
|
||||
|
||||
if (!avctx)
|
||||
return NULL;
|
||||
|
||||
if(avcodec_get_context_defaults3(avctx, codec) < 0){
|
||||
av_free(avctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return avctx;
|
||||
}
|
||||
|
||||
void avcodec_free_context(AVCodecContext **pavctx)
|
||||
{
|
||||
AVCodecContext *avctx = *pavctx;
|
||||
|
||||
if (!avctx)
|
||||
return;
|
||||
|
||||
avcodec_close(avctx);
|
||||
|
||||
av_freep(&avctx->extradata);
|
||||
|
||||
av_freep(pavctx);
|
||||
}
|
||||
|
||||
#define FOFFSET(x) offsetof(AVFrame,x)
|
||||
|
||||
static const AVClass av_frame_class = {
|
||||
.class_name = "AVFrame",
|
||||
.item_name = NULL,
|
||||
.option = NULL,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
#define SROFFSET(x) offsetof(AVSubtitleRect,x)
|
@ -1,118 +0,0 @@
|
||||
/*
|
||||
* rational numbers
|
||||
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* rational numbers
|
||||
* @author Michael Niedermayer <michaelni@gmx.at>
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "mathematics.h"
|
||||
#include "rational.h"
|
||||
|
||||
int av_reduce(int *dst_num, int *dst_den,
|
||||
int64_t num, int64_t den, int64_t max)
|
||||
{
|
||||
AVRational a0 = { 0, 1 }, a1 = { 1, 0 };
|
||||
int sign = (num < 0) ^ (den < 0);
|
||||
int64_t gcd = av_gcd(FFABS(num), FFABS(den));
|
||||
|
||||
if (gcd) {
|
||||
num = FFABS(num) / gcd;
|
||||
den = FFABS(den) / gcd;
|
||||
}
|
||||
if (num <= max && den <= max) {
|
||||
a1 = (AVRational) { num, den };
|
||||
den = 0;
|
||||
}
|
||||
|
||||
while (den) {
|
||||
uint64_t x = num / den;
|
||||
int64_t next_den = num - den * x;
|
||||
int64_t a2n = x * a1.num + a0.num;
|
||||
int64_t a2d = x * a1.den + a0.den;
|
||||
|
||||
if (a2n > max || a2d > max) {
|
||||
if (a1.num) x = (max - a0.num) / a1.num;
|
||||
if (a1.den) x = FFMIN(x, (max - a0.den) / a1.den);
|
||||
|
||||
if (den * (2 * x * a1.den + a0.den) > num * a1.den)
|
||||
a1 = (AVRational) { x * a1.num + a0.num, x * a1.den + a0.den };
|
||||
break;
|
||||
}
|
||||
|
||||
a0 = a1;
|
||||
a1 = (AVRational) { a2n, a2d };
|
||||
num = den;
|
||||
den = next_den;
|
||||
}
|
||||
av_assert2(av_gcd(a1.num, a1.den) <= 1U);
|
||||
av_assert2(a1.num <= max && a1.den <= max);
|
||||
|
||||
*dst_num = sign ? -a1.num : a1.num;
|
||||
*dst_den = a1.den;
|
||||
|
||||
return den == 0;
|
||||
}
|
||||
|
||||
AVRational av_mul_q(AVRational b, AVRational c)
|
||||
{
|
||||
av_reduce(&b.num, &b.den,
|
||||
b.num * (int64_t) c.num,
|
||||
b.den * (int64_t) c.den, INT_MAX);
|
||||
return b;
|
||||
}
|
||||
|
||||
AVRational av_div_q(AVRational b, AVRational c)
|
||||
{
|
||||
return av_mul_q(b, (AVRational) { c.den, c.num });
|
||||
}
|
||||
|
||||
AVRational av_add_q(AVRational b, AVRational c) {
|
||||
av_reduce(&b.num, &b.den,
|
||||
b.num * (int64_t) c.den +
|
||||
c.num * (int64_t) b.den,
|
||||
b.den * (int64_t) c.den, INT_MAX);
|
||||
return b;
|
||||
}
|
||||
|
||||
AVRational av_d2q(double d, int max)
|
||||
{
|
||||
AVRational a;
|
||||
int exponent;
|
||||
int64_t den;
|
||||
if (isnan(d))
|
||||
return (AVRational) { 0,0 };
|
||||
if (fabs(d) > INT_MAX + 3LL)
|
||||
return (AVRational) { d < 0 ? -1 : 1, 0 };
|
||||
frexp(d, &exponent);
|
||||
exponent = FFMAX(exponent-1, 0);
|
||||
den = 1LL << (61 - exponent);
|
||||
// (int64_t)rint() and llrint() do not work with gcc on ia64 and sparc64
|
||||
av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, max);
|
||||
if ((!a.num || !a.den) && d && max>0 && max<INT_MAX)
|
||||
av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, INT_MAX);
|
||||
|
||||
return a;
|
||||
}
|
@ -1,146 +0,0 @@
|
||||
/*
|
||||
* rational numbers
|
||||
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* rational numbers
|
||||
* @author Michael Niedermayer <michaelni@gmx.at>
|
||||
*/
|
||||
|
||||
#ifndef AVUTIL_RATIONAL_H
|
||||
#define AVUTIL_RATIONAL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "attributes.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_math
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* rational number numerator/denominator
|
||||
*/
|
||||
typedef struct AVRational{
|
||||
int num; ///< numerator
|
||||
int den; ///< denominator
|
||||
} AVRational;
|
||||
|
||||
/**
|
||||
* Create a rational.
|
||||
* Useful for compilers that do not support compound literals.
|
||||
* @note The return value is not reduced.
|
||||
*/
|
||||
static inline AVRational av_make_q(int num, int den)
|
||||
{
|
||||
AVRational r = { num, den };
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two rationals.
|
||||
* @param a first rational
|
||||
* @param b second rational
|
||||
* @return 0 if a==b, 1 if a>b, -1 if a<b, and INT_MIN if one of the
|
||||
* values is of the form 0/0
|
||||
*/
|
||||
static inline int av_cmp_q(AVRational a, AVRational b){
|
||||
const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den;
|
||||
|
||||
if(tmp) return (int)((tmp ^ a.den ^ b.den)>>63)|1;
|
||||
else if(b.den && a.den) return 0;
|
||||
else if(a.num && b.num) return (a.num>>31) - (b.num>>31);
|
||||
else return INT_MIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert rational to double.
|
||||
* @param a rational to convert
|
||||
* @return (double) a
|
||||
*/
|
||||
static inline double av_q2d(AVRational a){
|
||||
return a.num / (double) a.den;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce a fraction.
|
||||
* This is useful for framerate calculations.
|
||||
* @param dst_num destination numerator
|
||||
* @param dst_den destination denominator
|
||||
* @param num source numerator
|
||||
* @param den source denominator
|
||||
* @param max the maximum allowed for dst_num & dst_den
|
||||
* @return 1 if exact, 0 otherwise
|
||||
*/
|
||||
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max);
|
||||
|
||||
/**
|
||||
* Multiply two rationals.
|
||||
* @param b first rational
|
||||
* @param c second rational
|
||||
* @return b*c
|
||||
*/
|
||||
AVRational av_mul_q(AVRational b, AVRational c) av_const;
|
||||
|
||||
/**
|
||||
* Divide one rational by another.
|
||||
* @param b first rational
|
||||
* @param c second rational
|
||||
* @return b/c
|
||||
*/
|
||||
AVRational av_div_q(AVRational b, AVRational c) av_const;
|
||||
|
||||
/**
|
||||
* Add two rationals.
|
||||
* @param b first rational
|
||||
* @param c second rational
|
||||
* @return b+c
|
||||
*/
|
||||
AVRational av_add_q(AVRational b, AVRational c) av_const;
|
||||
|
||||
/**
|
||||
* Invert a rational.
|
||||
* @param q value
|
||||
* @return 1 / q
|
||||
*/
|
||||
static av_always_inline AVRational av_inv_q(AVRational q)
|
||||
{
|
||||
AVRational r = { q.den, q.num };
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a double precision floating point number to a rational.
|
||||
* inf is expressed as {1,0} or {-1,0} depending on the sign.
|
||||
*
|
||||
* @param d double to convert
|
||||
* @param max the maximum allowed numerator and denominator
|
||||
* @return (AVRational) d
|
||||
*/
|
||||
AVRational av_d2q(double d, int max) av_const;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* AVUTIL_RATIONAL_H */
|
@ -22,7 +22,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "avutil.h"
|
||||
#include "attributes.h"
|
||||
#include "compat.h"
|
||||
|
||||
/**
|
||||
* @addtogroup lavu_audio
|
||||
|
@ -21,7 +21,6 @@
|
||||
#ifndef AVCODEC_SINEWIN_H
|
||||
#define AVCODEC_SINEWIN_H
|
||||
|
||||
#include "config.h"
|
||||
#include "mem.h"
|
||||
#include "aac_defines.h"
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "aac_defines.h"
|
||||
#include "attributes.h"
|
||||
#include "compat.h"
|
||||
#include "common.h"
|
||||
|
||||
#if !CONFIG_HARDCODED_TABLES
|
||||
|
@ -32,121 +32,9 @@
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <assert.h>
|
||||
#include "config.h"
|
||||
#include "attributes.h"
|
||||
#include "macros.h"
|
||||
#include "version.h"
|
||||
|
||||
# define attribute_align_arg
|
||||
|
||||
#if defined(_MSC_VER) && CONFIG_SHARED
|
||||
# define av_export __declspec(dllimport)
|
||||
#else
|
||||
# define av_export
|
||||
#endif
|
||||
|
||||
#define FF_MEMORY_POISON 0x2a
|
||||
|
||||
#define MAKE_ACCESSORS(str, name, type, field) \
|
||||
type av_##name##_get_##field(const str *s) { return s->field; } \
|
||||
void av_##name##_set_##field(str *s, type v) { s->field = v; }
|
||||
|
||||
// Some broken preprocessors need a second expansion
|
||||
// to be forced to tokenize __VA_ARGS__
|
||||
#define E1(x) x
|
||||
|
||||
#define LOCAL_ALIGNED_A(a, t, v, s, o, ...) \
|
||||
uint8_t la_##v[sizeof(t s o) + (a)]; \
|
||||
t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a)
|
||||
|
||||
#define LOCAL_ALIGNED_D(a, t, v, s, o, ...) \
|
||||
DECLARE_ALIGNED(a, t, la_##v) s o; \
|
||||
t (*v) o = la_##v
|
||||
|
||||
#define LOCAL_ALIGNED(a, t, v, ...) E1(LOCAL_ALIGNED_A(a, t, v, __VA_ARGS__,,))
|
||||
|
||||
#if HAVE_LOCAL_ALIGNED_8
|
||||
# define LOCAL_ALIGNED_8(t, v, ...) E1(LOCAL_ALIGNED_D(8, t, v, __VA_ARGS__,,))
|
||||
#else
|
||||
# define LOCAL_ALIGNED_8(t, v, ...) LOCAL_ALIGNED(8, t, v, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if HAVE_LOCAL_ALIGNED_16
|
||||
# define LOCAL_ALIGNED_16(t, v, ...) E1(LOCAL_ALIGNED_D(16, t, v, __VA_ARGS__,,))
|
||||
#else
|
||||
# define LOCAL_ALIGNED_16(t, v, ...) LOCAL_ALIGNED(16, t, v, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#if HAVE_LOCAL_ALIGNED_32
|
||||
# define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_D(32, t, v, __VA_ARGS__,,))
|
||||
#else
|
||||
# define LOCAL_ALIGNED_32(t, v, ...) LOCAL_ALIGNED(32, t, v, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#include "libm.h"
|
||||
|
||||
/**
|
||||
* Define a function with only the non-default version specified.
|
||||
*
|
||||
* On systems with ELF shared libraries, all symbols exported from
|
||||
* FFmpeg libraries are tagged with the name and major version of the
|
||||
* library to which they belong. If a function is moved from one
|
||||
* library to another, a wrapper must be retained in the original
|
||||
* location to preserve binary compatibility.
|
||||
*
|
||||
* Functions defined with this macro will never be used to resolve
|
||||
* symbols by the build-time linker.
|
||||
*
|
||||
* @param type return type of function
|
||||
* @param name name of function
|
||||
* @param args argument list of function
|
||||
* @param ver version tag to assign function
|
||||
*/
|
||||
#if HAVE_SYMVER_ASM_LABEL
|
||||
# define FF_SYMVER(type, name, args, ver) \
|
||||
type ff_##name args __asm__ (EXTERN_PREFIX #name "@" ver); \
|
||||
type ff_##name args
|
||||
#elif HAVE_SYMVER_GNU_ASM
|
||||
# define FF_SYMVER(type, name, args, ver) \
|
||||
__asm__ (".symver ff_" #name "," EXTERN_PREFIX #name "@" ver); \
|
||||
type ff_##name args; \
|
||||
type ff_##name args
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return NULL if a threading library has not been enabled.
|
||||
* Used to disable threading functions in AVCodec definitions
|
||||
* when not needed.
|
||||
*/
|
||||
#if HAVE_THREADS
|
||||
# define ONLY_IF_THREADS_ENABLED(x) x
|
||||
#else
|
||||
# define ONLY_IF_THREADS_ENABLED(x) NULL
|
||||
#endif
|
||||
|
||||
#if HAVE_LIBC_MSVCRT
|
||||
#include <crtversion.h>
|
||||
#if defined(_VC_CRT_MAJOR_VERSION) && _VC_CRT_MAJOR_VERSION < 14
|
||||
#pragma comment(linker, "/include:" EXTERN_PREFIX "avpriv_strtod")
|
||||
#pragma comment(linker, "/include:" EXTERN_PREFIX "avpriv_snprintf")
|
||||
#endif
|
||||
|
||||
#define avpriv_open ff_open
|
||||
#define PTRDIFF_SPECIFIER "Id"
|
||||
#define SIZE_SPECIFIER "Iu"
|
||||
#else
|
||||
#define PTRDIFF_SPECIFIER "td"
|
||||
#define SIZE_SPECIFIER "zu"
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
# define ff_dlog(ctx, ...) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__)
|
||||
#else
|
||||
# define ff_dlog(ctx, ...) do { if (0) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0)
|
||||
#endif
|
||||
|
||||
extern const uint8_t ff_reverse[256];
|
||||
|
||||
#endif /* AVUTIL_INTERNAL_H */
|
||||
|
@ -26,15 +26,13 @@
|
||||
*/
|
||||
|
||||
#include "util_internal.h"
|
||||
#include "config.h"
|
||||
#include "avcodec.h"
|
||||
#include "attributes.h"
|
||||
#include "compat.h"
|
||||
#include "channel_layout.h"
|
||||
#include "internal.h"
|
||||
#include "common.h"
|
||||
#include "mathematics.h"
|
||||
#include "samplefmt.h"
|
||||
#include "avcodec.h"
|
||||
#include "internal.h"
|
||||
#include "bytestream.h"
|
||||
#include "version.h"
|
||||
#include <stdlib.h>
|
||||
@ -42,60 +40,8 @@
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
|
||||
static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) = NULL;
|
||||
|
||||
|
||||
volatile int ff_avcodec_locked;
|
||||
static int volatile entangled_thread_counter = 0;
|
||||
static void *codec_mutex;
|
||||
static void *avformat_mutex;
|
||||
|
||||
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
|
||||
{
|
||||
uint8_t **p = ptr;
|
||||
if (min_size > SIZE_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
|
||||
av_freep(p);
|
||||
*size = 0;
|
||||
return;
|
||||
}
|
||||
if (!ff_fast_malloc(p, size, min_size + AV_INPUT_BUFFER_PADDING_SIZE, 1))
|
||||
memset(*p + min_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
}
|
||||
|
||||
static av_cold void avcodec_init(void)
|
||||
{
|
||||
static int initialized = 0;
|
||||
|
||||
if (initialized != 0)
|
||||
return;
|
||||
initialized = 1;
|
||||
}
|
||||
|
||||
int av_codec_is_decoder(const AVCodec *codec)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if FF_API_EMU_EDGE
|
||||
unsigned avcodec_get_edge_width(void)
|
||||
{
|
||||
return EDGE_WIDTH;
|
||||
}
|
||||
#endif
|
||||
|
||||
int attribute_align_arg ff_codec_open2_recursive(AVCodecContext *avctx, const AVCodec *codec, void **options)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = avcodec_open2(avctx, codec, options);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, void **options)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
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);
|
||||
@ -107,6 +53,8 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
|
||||
if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
int ret = 0;
|
||||
|
||||
if (codec->priv_data_size > 0) {
|
||||
if (!avctx->priv_data) {
|
||||
avctx->priv_data = av_mallocz(codec->priv_data_size);
|
||||
@ -132,13 +80,6 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
|
||||
|
||||
avctx->frame_number = 0;
|
||||
|
||||
#if FF_API_VISMV
|
||||
if (avctx->debug_mv)
|
||||
av_log(avctx, AV_LOG_WARNING, "The 'vismv' option is deprecated, "
|
||||
"see the codecview filter instead.\n");
|
||||
#endif
|
||||
|
||||
|
||||
if (avctx->codec->init) {
|
||||
ret = avctx->codec->init(avctx);
|
||||
if (ret < 0) {
|
||||
@ -148,36 +89,24 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
|
||||
|
||||
ret=0;
|
||||
|
||||
#if FF_API_AUDIOENC_DELAY
|
||||
if (av_codec_is_encoder(avctx->codec))
|
||||
avctx->delay = avctx->initial_padding;
|
||||
#endif
|
||||
|
||||
if (av_codec_is_decoder(avctx->codec)) {
|
||||
/* validate channel layout from the decoder */
|
||||
if (avctx->channel_layout) {
|
||||
int channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
|
||||
if (!avctx->channels)
|
||||
avctx->channels = channels;
|
||||
else if (channels != avctx->channels) {
|
||||
char buf[512] = "";
|
||||
av_log(avctx, AV_LOG_WARNING,
|
||||
"Channel layout '%s' with %d channels does not match specified number of channels %d: "
|
||||
"ignoring specified channel layout\n",
|
||||
buf, channels, avctx->channels);
|
||||
avctx->channel_layout = 0;
|
||||
}
|
||||
/* validate channel layout from the decoder */
|
||||
if (avctx->channel_layout) {
|
||||
int channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
|
||||
if (!avctx->channels)
|
||||
avctx->channels = channels;
|
||||
else if (channels != avctx->channels) {
|
||||
char buf[512] = "";
|
||||
av_log(avctx, AV_LOG_WARNING,
|
||||
"Channel layout '%s' with %d channels does not match specified number of channels %d: "
|
||||
"ignoring specified channel layout\n",
|
||||
buf, channels, avctx->channels);
|
||||
avctx->channel_layout = 0;
|
||||
}
|
||||
if (avctx->channels && avctx->channels < 0 ||
|
||||
avctx->channels > FF_SANE_NB_CHANNELS) {
|
||||
ret = AVERROR(EINVAL);
|
||||
goto free_and_end;
|
||||
}
|
||||
|
||||
#if FF_API_AVCTX_TIMEBASE
|
||||
if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
|
||||
avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
|
||||
#endif
|
||||
}
|
||||
if (avctx->channels && avctx->channels < 0 ||
|
||||
avctx->channels > FF_SANE_NB_CHANNELS) {
|
||||
ret = AVERROR(EINVAL);
|
||||
goto free_and_end;
|
||||
}
|
||||
if (codec->priv_data_size > 0 && avctx->priv_data && codec->priv_class) {
|
||||
av_assert0(*(const AVClass **)avctx->priv_data == codec->priv_class);
|
||||
@ -190,12 +119,6 @@ free_and_end:
|
||||
if (avctx->codec)
|
||||
avctx->codec->close(avctx);
|
||||
|
||||
#if FF_API_CODED_FRAME
|
||||
FF_DISABLE_DEPRECATION_WARNINGS
|
||||
av_frame_free(&avctx->coded_frame);
|
||||
FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#endif
|
||||
|
||||
av_freep(&avctx->priv_data);
|
||||
avctx->codec = NULL;
|
||||
goto end;
|
||||
|
@ -21,7 +21,7 @@
|
||||
#ifndef AVUTIL_VERSION_H
|
||||
#define AVUTIL_VERSION_H
|
||||
|
||||
#include "macros.h"
|
||||
#include "common.h"
|
||||
|
||||
/**
|
||||
* @addtogroup version_utils
|
||||
@ -54,72 +54,6 @@
|
||||
* Libavutil version macros
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lavu_ver Version and Build diagnostics
|
||||
*
|
||||
* Macros and function useful to check at compiletime and at runtime
|
||||
* which version of libavutil is in use.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define LIBAVUTIL_VERSION_MAJOR 55
|
||||
#define LIBAVUTIL_VERSION_MINOR 17
|
||||
#define LIBAVUTIL_VERSION_MICRO 103
|
||||
|
||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||
LIBAVUTIL_VERSION_MINOR, \
|
||||
LIBAVUTIL_VERSION_MICRO)
|
||||
#define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \
|
||||
LIBAVUTIL_VERSION_MINOR, \
|
||||
LIBAVUTIL_VERSION_MICRO)
|
||||
#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
|
||||
|
||||
#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
* @defgroup depr_guards Deprecation guards
|
||||
* FF_API_* defines may be placed below to indicate public API that will be
|
||||
* dropped at a future version bump. The defines themselves are not part of
|
||||
* the public API and may change, break or disappear at any time.
|
||||
*
|
||||
* @note, when bumping the major version it is recommended to manually
|
||||
* disable each FF_API_* in its own commit instead of disabling them all
|
||||
* at once through the bump. This improves the git bisect-ability of the change.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef FF_API_VDPAU
|
||||
#define FF_API_VDPAU (LIBAVUTIL_VERSION_MAJOR < 56)
|
||||
#endif
|
||||
#ifndef FF_API_XVMC
|
||||
#define FF_API_XVMC (LIBAVUTIL_VERSION_MAJOR < 56)
|
||||
#endif
|
||||
#ifndef FF_API_OPT_TYPE_METADATA
|
||||
#define FF_API_OPT_TYPE_METADATA (LIBAVUTIL_VERSION_MAJOR < 56)
|
||||
#endif
|
||||
#ifndef FF_API_DLOG
|
||||
#define FF_API_DLOG (LIBAVUTIL_VERSION_MAJOR < 56)
|
||||
#endif
|
||||
#ifndef FF_API_VAAPI
|
||||
#define FF_API_VAAPI (LIBAVUTIL_VERSION_MAJOR < 56)
|
||||
#endif
|
||||
#ifndef FF_API_FRAME_QP
|
||||
#define FF_API_FRAME_QP (LIBAVUTIL_VERSION_MAJOR < 56)
|
||||
#endif
|
||||
#ifndef FF_API_PLUS1_MINUS1
|
||||
#define FF_API_PLUS1_MINUS1 (LIBAVUTIL_VERSION_MAJOR < 56)
|
||||
#endif
|
||||
#ifndef FF_API_ERROR_FRAME
|
||||
#define FF_API_ERROR_FRAME (LIBAVUTIL_VERSION_MAJOR < 56)
|
||||
#endif
|
||||
#ifndef FF_API_CRC_BIG_TABLE
|
||||
#define FF_API_CRC_BIG_TABLE (LIBAVUTIL_VERSION_MAJOR < 56)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
Loading…
Reference in New Issue
Block a user