mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
Remove context parameter from av_log
This commit is contained in:
parent
e10b90b718
commit
0d30728832
@ -42,7 +42,6 @@ public:
|
||||
ctx_->block_align = inbytes;
|
||||
ctx_->channels = 2;
|
||||
ctx_->channel_layout = ctx_->channels == 2 ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
|
||||
ctx_->sample_rate = 44100;
|
||||
int retval;
|
||||
if (audioType_ == PSP_CODEC_AT3PLUS) {
|
||||
retval = avcodec_open2(ctx_, &ff_atrac3p_decoder, nullptr);
|
||||
|
@ -578,12 +578,12 @@ static int decode_channel_sound_unit(ATRAC3Context *q, GetBitContext *gb,
|
||||
|
||||
if (coding_mode == JOINT_STEREO && channel_num == 1) {
|
||||
if (get_bits(gb, 2) != 3) {
|
||||
av_log(NULL,AV_LOG_ERROR,"JS mono Sound Unit id != 3.\n");
|
||||
av_log(AV_LOG_ERROR,"JS mono Sound Unit id != 3.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
} else {
|
||||
if (get_bits(gb, 6) != 0x28) {
|
||||
av_log(NULL,AV_LOG_ERROR,"Sound Unit id != 0x28.\n");
|
||||
av_log(AV_LOG_ERROR,"Sound Unit id != 0x28.\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
}
|
||||
@ -737,7 +737,7 @@ int atrac3_decode_frame(AVCodecContext *avctx, float *out_data[2], int *nb_sampl
|
||||
const uint8_t *databuf;
|
||||
|
||||
if (buf_size < avctx->block_align) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
av_log(AV_LOG_ERROR,
|
||||
"Frame too small (%d bytes). Truncated file?\n", buf_size);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@ -755,7 +755,7 @@ int atrac3_decode_frame(AVCodecContext *avctx, float *out_data[2], int *nb_sampl
|
||||
|
||||
ret = decode_frame(avctx, databuf, out_data);
|
||||
if (ret) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Frame decoding error!\n");
|
||||
av_log( AV_LOG_ERROR, "Frame decoding error!\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -792,7 +792,7 @@ static int atrac3_decode_init(AVCodecContext *avctx)
|
||||
ATRAC3Context *q = (ATRAC3Context * )avctx->priv_data;
|
||||
|
||||
if (avctx->channels <= 0 || avctx->channels > 2) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n");
|
||||
av_log(AV_LOG_ERROR, "Channel configuration error!\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
@ -803,14 +803,14 @@ static int atrac3_decode_init(AVCodecContext *avctx)
|
||||
/* Take care of the codec-specific extradata. */
|
||||
if (avctx->extradata_size == 14) {
|
||||
/* Parse the extradata, WAV format */
|
||||
av_log(avctx, AV_LOG_DEBUG, "[0-1] %d\n",
|
||||
av_log(AV_LOG_DEBUG, "[0-1] %d\n",
|
||||
bytestream_get_le16(&edata_ptr)); // Unknown value always 1
|
||||
edata_ptr += 4; // samples per channel
|
||||
q->coding_mode = bytestream_get_le16(&edata_ptr);
|
||||
av_log(avctx, AV_LOG_DEBUG,"[8-9] %d\n",
|
||||
av_log(AV_LOG_DEBUG,"[8-9] %d\n",
|
||||
bytestream_get_le16(&edata_ptr)); //Dupe of coding mode
|
||||
frame_factor = bytestream_get_le16(&edata_ptr); // Unknown always 1
|
||||
av_log(avctx, AV_LOG_DEBUG,"[12-13] %d\n",
|
||||
av_log(AV_LOG_DEBUG,"[12-13] %d\n",
|
||||
bytestream_get_le16(&edata_ptr)); // Unknown always 0
|
||||
|
||||
/* setup */
|
||||
@ -823,7 +823,7 @@ static int atrac3_decode_init(AVCodecContext *avctx)
|
||||
if (avctx->block_align != 96 * avctx->channels * frame_factor &&
|
||||
avctx->block_align != 152 * avctx->channels * frame_factor &&
|
||||
avctx->block_align != 192 * avctx->channels * frame_factor) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Unknown frame/channel/frame_factor "
|
||||
av_log(AV_LOG_ERROR, "Unknown frame/channel/frame_factor "
|
||||
"configuration %d/%d/%d\n", avctx->block_align,
|
||||
avctx->channels, frame_factor);
|
||||
return AVERROR_INVALIDDATA;
|
||||
@ -837,7 +837,7 @@ static int atrac3_decode_init(AVCodecContext *avctx)
|
||||
q->scrambled_stream = 1;
|
||||
|
||||
} else {
|
||||
av_log(NULL, AV_LOG_ERROR, "Unknown extradata size %d.\n",
|
||||
av_log(AV_LOG_ERROR, "Unknown extradata size %d.\n",
|
||||
avctx->extradata_size);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
@ -845,33 +845,33 @@ static int atrac3_decode_init(AVCodecContext *avctx)
|
||||
/* Check the extradata */
|
||||
|
||||
if (version != 4) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Version %d != 4.\n", version);
|
||||
av_log(AV_LOG_ERROR, "Version %d != 4.\n", version);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (samples_per_frame != SAMPLES_PER_FRAME &&
|
||||
samples_per_frame != SAMPLES_PER_FRAME * 2) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Unknown amount of samples per frame %d.\n",
|
||||
av_log(AV_LOG_ERROR, "Unknown amount of samples per frame %d.\n",
|
||||
samples_per_frame);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (delay != 0x88E) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Unknown amount of delay %x != 0x88E.\n",
|
||||
av_log(AV_LOG_ERROR, "Unknown amount of delay %x != 0x88E.\n",
|
||||
delay);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (q->coding_mode == STEREO)
|
||||
av_log(avctx, AV_LOG_DEBUG, "Normal stereo detected.\n");
|
||||
av_log(AV_LOG_DEBUG, "Normal stereo detected.\n");
|
||||
else if (q->coding_mode == JOINT_STEREO) {
|
||||
if (avctx->channels != 2) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid coding mode\n");
|
||||
av_log(AV_LOG_ERROR, "Invalid coding mode\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
av_log(avctx, AV_LOG_DEBUG, "Joint stereo detected.\n");
|
||||
av_log(AV_LOG_DEBUG, "Joint stereo detected.\n");
|
||||
} else {
|
||||
av_log(avctx, AV_LOG_ERROR, "Unknown channel coding mode %x!\n",
|
||||
av_log(AV_LOG_ERROR, "Unknown channel coding mode %x!\n",
|
||||
q->coding_mode);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@ -885,7 +885,7 @@ static int atrac3_decode_init(AVCodecContext *avctx)
|
||||
|
||||
/* initialize the MDCT transform */
|
||||
if ((ret = ff_mdct_init(&q->mdct_ctx, 9, 1, 1.0 / 32768)) < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n");
|
||||
av_log(AV_LOG_ERROR, "Error initializing MDCT\n");
|
||||
av_freep(&q->decoded_bytes_buffer);
|
||||
return ret;
|
||||
}
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
//#include "avcodec.h"
|
||||
#include "mathematics.h"
|
||||
#include "get_bits.h"
|
||||
#include "atrac3plus.h"
|
||||
@ -230,7 +229,7 @@ static int num_coded_units(GetBitContext *gb, Atrac3pChanParams *chan,
|
||||
} else {
|
||||
chan->num_coded_vals = get_bits(gb, 5);
|
||||
if (chan->num_coded_vals > ctx->num_quant_units) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
av_log(AV_LOG_ERROR,
|
||||
"Invalid number of transmitted units!\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@ -262,7 +261,7 @@ static int add_wordlen_weights(Atrac3pChanUnitCtx *ctx,
|
||||
for (i = 0; i < ctx->num_quant_units; i++) {
|
||||
chan->qu_wordlen[i] += weights_tab[i];
|
||||
if (chan->qu_wordlen[i] < 0 || chan->qu_wordlen[i] > 7) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
av_log(AV_LOG_ERROR,
|
||||
"WL index out of range: pos=%d, val=%d!\n",
|
||||
i, chan->qu_wordlen[i]);
|
||||
return AVERROR_INVALIDDATA;
|
||||
@ -291,7 +290,7 @@ static int subtract_sf_weights(Atrac3pChanUnitCtx *ctx,
|
||||
for (i = 0; i < ctx->used_quant_units; i++) {
|
||||
chan->qu_sf_idx[i] -= weights_tab[i];
|
||||
if (chan->qu_sf_idx[i] < 0 || chan->qu_sf_idx[i] > 63) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
av_log(AV_LOG_ERROR,
|
||||
"SF index out of range: pos=%d, val=%d!\n",
|
||||
i, chan->qu_sf_idx[i]);
|
||||
return AVERROR_INVALIDDATA;
|
||||
@ -372,7 +371,7 @@ static int decode_channel_wordlen(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
|
||||
if (chan->num_coded_vals) {
|
||||
pos = get_bits(gb, 5);
|
||||
if (pos > chan->num_coded_vals) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
av_log(AV_LOG_ERROR,
|
||||
"WL mode 1: invalid position!\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@ -460,7 +459,7 @@ static int decode_channel_wordlen(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
|
||||
pos = ch_num ? chan->num_coded_vals + chan->split_point
|
||||
: ctx->num_quant_units - chan->split_point;
|
||||
if (pos > FF_ARRAY_ELEMS(chan->qu_wordlen)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Split point beyond array\n");
|
||||
av_log(AV_LOG_ERROR, "Split point beyond array\n");
|
||||
pos = FF_ARRAY_ELEMS(chan->qu_wordlen);
|
||||
}
|
||||
for (i = chan->num_coded_vals; i < pos; i++)
|
||||
@ -526,7 +525,7 @@ static int decode_channel_sf_idx(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
|
||||
delta_bits = get_bits(gb, 3);
|
||||
min_val = get_bits(gb, 6);
|
||||
if (num_long_vals > ctx->used_quant_units || delta_bits == 7) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
av_log(AV_LOG_ERROR,
|
||||
"SF mode 1: invalid parameters!\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@ -685,7 +684,7 @@ static int get_num_ct_values(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
|
||||
if (get_bits1(gb)) {
|
||||
num_coded_vals = get_bits(gb, 5);
|
||||
if (num_coded_vals > ctx->used_quant_units) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
av_log(AV_LOG_ERROR,
|
||||
"Invalid number of code table indexes: %d!\n", num_coded_vals);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@ -1346,7 +1345,7 @@ static int decode_gainc_loc_codes(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
|
||||
for (i = 0; i < chan->gain_data[sb].num_points; i++) {
|
||||
if (dst->loc_code[i] < 0 || dst->loc_code[i] > 31 ||
|
||||
(i && dst->loc_code[i] <= dst->loc_code[i - 1])) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
av_log(AV_LOG_ERROR,
|
||||
"Invalid gain location: ch=%d, sb=%d, pos=%d, val=%d\n",
|
||||
ch_num, sb, i, dst->loc_code[i]);
|
||||
return AVERROR_INVALIDDATA;
|
||||
@ -1492,10 +1491,9 @@ static int decode_band_numwavs(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
|
||||
for (sb = 0; sb < ctx->waves_info->num_tone_bands; sb++)
|
||||
if (band_has_tones[sb]) {
|
||||
if (ctx->waves_info->tones_index + dst[sb].num_wavs > 48) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
"Too many tones: %d (max. 48), frame: %d!\n",
|
||||
ctx->waves_info->tones_index + dst[sb].num_wavs,
|
||||
avctx->frame_number);
|
||||
av_log(AV_LOG_ERROR,
|
||||
"Too many tones: %d (max. 48)!\n",
|
||||
ctx->waves_info->tones_index + dst[sb].num_wavs);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
dst[sb].start_index = ctx->waves_info->tones_index;
|
||||
@ -1769,7 +1767,7 @@ int ff_atrac3p_decode_channel_unit(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
|
||||
/* parse sound header */
|
||||
ctx->num_quant_units = get_bits(gb, 5) + 1;
|
||||
if (ctx->num_quant_units > 28 && ctx->num_quant_units < 32) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
av_log(AV_LOG_ERROR,
|
||||
"Invalid number of quantization units: %d!\n",
|
||||
ctx->num_quant_units);
|
||||
return AVERROR_INVALIDDATA;
|
||||
|
@ -173,10 +173,9 @@ int ff_atrac3p_decode_channel_unit(GetBitContext *gb, Atrac3pChanUnitCtx *ctx,
|
||||
/**
|
||||
* Initialize IMDCT transform.
|
||||
*
|
||||
* @param[in] avctx ptr to the AVCodecContext
|
||||
* @param[in] mdct_ctx pointer to MDCT transform context
|
||||
*/
|
||||
void ff_atrac3p_init_imdct(AVCodecContext *avctx, FFTContext *mdct_ctx);
|
||||
void ff_atrac3p_init_imdct(FFTContext *mdct_ctx);
|
||||
|
||||
/**
|
||||
* Initialize sine waves synthesizer.
|
||||
|
@ -45,7 +45,7 @@
|
||||
#include "atrac.h"
|
||||
#include "atrac3plus.h"
|
||||
|
||||
typedef struct ATRAC3PContext {
|
||||
struct ATRAC3PContext {
|
||||
GetBitContext gb;
|
||||
|
||||
DECLARE_ALIGNED(32, float, samples)[2][ATRAC3P_FRAME_SAMPLES]; ///< quantized MDCT spectrum
|
||||
@ -62,7 +62,7 @@ typedef struct ATRAC3PContext {
|
||||
int num_channel_blocks; ///< number of channel blocks
|
||||
uint8_t channel_blocks[5]; ///< channel configuration descriptor
|
||||
uint64_t my_channel_layout; ///< current channel layout
|
||||
} ATRAC3PContext;
|
||||
};
|
||||
|
||||
int atrac3p_decode_close(AVCodecContext *avctx)
|
||||
{
|
||||
@ -76,16 +76,12 @@ int atrac3p_decode_close(AVCodecContext *avctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_channel_params(ATRAC3PContext *ctx,
|
||||
AVCodecContext *avctx)
|
||||
{
|
||||
static int set_channel_params(ATRAC3PContext *ctx, AVCodecContext *avctx) {
|
||||
memset(ctx->channel_blocks, 0, sizeof(ctx->channel_blocks));
|
||||
|
||||
switch (avctx->channels) {
|
||||
case 1:
|
||||
if (avctx->channel_layout != AV_CH_FRONT_LEFT)
|
||||
avctx->channel_layout = AV_CH_LAYOUT_MONO;
|
||||
|
||||
ctx->num_channel_blocks = 1;
|
||||
ctx->channel_blocks[0] = CH_UNIT_MONO;
|
||||
break;
|
||||
@ -134,7 +130,7 @@ static int set_channel_params(ATRAC3PContext *ctx,
|
||||
ctx->channel_blocks[4] = CH_UNIT_MONO;
|
||||
break;
|
||||
default:
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
av_log(AV_LOG_ERROR,
|
||||
"Unsupported channel count: %d!\n", avctx->channels);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@ -148,7 +144,7 @@ int atrac3p_decode_init(AVCodecContext *avctx)
|
||||
int i, ch, ret;
|
||||
|
||||
if (!avctx->block_align) {
|
||||
av_log(avctx, AV_LOG_ERROR, "block_align is not set\n");
|
||||
av_log(AV_LOG_ERROR, "block_align is not set\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
@ -157,7 +153,7 @@ int atrac3p_decode_init(AVCodecContext *avctx)
|
||||
/* initialize IPQF */
|
||||
ff_mdct_init(&ctx->ipqf_dct_ctx, 5, 1, 32.0 / 32768.0);
|
||||
|
||||
ff_atrac3p_init_imdct(avctx, &ctx->mdct_ctx);
|
||||
ff_atrac3p_init_imdct(&ctx->mdct_ctx);
|
||||
|
||||
ff_atrac_init_gain_compensation(&ctx->gainc_ctx, 6, 2);
|
||||
|
||||
@ -333,7 +329,7 @@ int atrac3p_decode_frame(AVCodecContext *avctx, float *out_data[2], int *nb_samp
|
||||
return ret;
|
||||
|
||||
if (get_bits1(&ctx->gb)) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid start bit!\n");
|
||||
av_log(AV_LOG_ERROR, "Invalid start bit!\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
@ -345,7 +341,7 @@ int atrac3p_decode_frame(AVCodecContext *avctx, float *out_data[2], int *nb_samp
|
||||
}
|
||||
if (ch_block >= ctx->num_channel_blocks ||
|
||||
ctx->channel_blocks[ch_block] != ch_unit_id) {
|
||||
av_log(avctx, AV_LOG_ERROR,
|
||||
av_log(AV_LOG_ERROR,
|
||||
"Frame data doesn't match channel configuration!\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ const float ff_atrac3p_mant_tab[8] = {
|
||||
|
||||
#define ATRAC3P_MDCT_SIZE (ATRAC3P_SUBBAND_SAMPLES * 2)
|
||||
|
||||
void ff_atrac3p_init_imdct(AVCodecContext *avctx, FFTContext *mdct_ctx)
|
||||
void ff_atrac3p_init_imdct(FFTContext *mdct_ctx)
|
||||
{
|
||||
ff_init_ff_sine_windows(7);
|
||||
ff_init_ff_sine_windows(6);
|
||||
|
@ -47,7 +47,6 @@ AVCodecContext *avcodec_alloc_context3(const AVCodec *codec)
|
||||
|
||||
if (codec) {
|
||||
avctx->codec = codec;
|
||||
avctx->codec_id = codec->id;
|
||||
}
|
||||
|
||||
if (codec && codec->priv_data_size) {
|
||||
@ -90,9 +89,6 @@ int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, void *options)
|
||||
}
|
||||
|
||||
avctx->codec = codec;
|
||||
avctx->codec_id = codec->id;
|
||||
|
||||
avctx->frame_number = 0;
|
||||
|
||||
if (avctx->codec->init) {
|
||||
ret = avctx->codec->init(avctx);
|
||||
@ -110,7 +106,7 @@ int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, void *options)
|
||||
avctx->channels = channels;
|
||||
else if (channels != avctx->channels) {
|
||||
char buf[512] = "";
|
||||
av_log(avctx, AV_LOG_WARNING,
|
||||
av_log(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);
|
||||
|
@ -21,79 +21,14 @@
|
||||
#ifndef AVCODEC_AVCODEC_H
|
||||
#define AVCODEC_AVCODEC_H
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @ingroup libavc
|
||||
* Libavcodec external API header
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include "compat.h"
|
||||
#include "channel_layout.h"
|
||||
#include "mem.h"
|
||||
|
||||
/**
|
||||
* @defgroup libavc Encoding/Decoding Library
|
||||
* @{
|
||||
*
|
||||
* @defgroup lavc_decoding Decoding
|
||||
* @{
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavc_encoding Encoding
|
||||
* @{
|
||||
* @}
|
||||
*
|
||||
* @defgroup lavc_codec Codecs
|
||||
* @{
|
||||
* @defgroup lavc_codec_native Native Codecs
|
||||
* @{
|
||||
* @}
|
||||
* @defgroup lavc_codec_wrappers External library wrappers
|
||||
* @{
|
||||
* @}
|
||||
* @defgroup lavc_codec_hwaccel Hardware Accelerators bridge
|
||||
* @{
|
||||
* @}
|
||||
* @}
|
||||
* @defgroup lavc_internal Internal
|
||||
* @{
|
||||
* @}
|
||||
* @}
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup lavc_core Core functions/structures.
|
||||
* @ingroup libavc
|
||||
*
|
||||
* Basic definitions, functions for querying libavcodec capabilities,
|
||||
* allocating core structures, etc.
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Identify the syntax and semantics of the bitstream.
|
||||
* The principle is roughly:
|
||||
* Two decoders with the same ID can decode the same streams.
|
||||
* Two encoders with the same ID can encode compatible streams.
|
||||
* There may be slight deviations from the principle due to implementation
|
||||
* details.
|
||||
*
|
||||
* If you add a codec ID to this list, add it so that
|
||||
* 1. no value of a existing codec ID changes (that would break ABI),
|
||||
* 2. it is as close as possible to similar codecs
|
||||
*
|
||||
* After adding new codec IDs, do not forget to add an entry to the codec
|
||||
* descriptor list and bump libavcodec minor version.
|
||||
*/
|
||||
enum AVCodecID {
|
||||
AV_CODEC_ID_NONE,
|
||||
|
||||
AV_CODEC_ID_ATRAC3,
|
||||
AV_CODEC_ID_ATRAC3P,
|
||||
AV_CODEC_ID_ATRAC1,
|
||||
};
|
||||
|
||||
/**
|
||||
@ -106,179 +41,6 @@ enum AVCodecID {
|
||||
*/
|
||||
#define AV_INPUT_BUFFER_PADDING_SIZE 32
|
||||
|
||||
/**
|
||||
* @ingroup lavc_encoding
|
||||
* minimum encoding buffer size
|
||||
* Used to avoid some checks during header writing.
|
||||
*/
|
||||
#define AV_INPUT_BUFFER_MIN_SIZE 16384
|
||||
|
||||
#if FF_API_MAX_BFRAMES
|
||||
/**
|
||||
* @deprecated there is no libavcodec-wide limit on the number of B-frames
|
||||
*/
|
||||
#define FF_MAX_B_FRAMES 16
|
||||
#endif
|
||||
|
||||
/* encoding support
|
||||
These flags can be passed in AVCodecContext.flags before initialization.
|
||||
Note: Not everything is supported yet.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allow decoders to produce frames with data planes that are not aligned
|
||||
* to CPU requirements (e.g. due to cropping).
|
||||
*/
|
||||
#define AV_CODEC_FLAG_UNALIGNED (1 << 0)
|
||||
/**
|
||||
* Use fixed qscale.
|
||||
*/
|
||||
#define AV_CODEC_FLAG_QSCALE (1 << 1)
|
||||
/**
|
||||
* 4 MV per MB allowed / advanced prediction for H.263.
|
||||
*/
|
||||
#define AV_CODEC_FLAG_4MV (1 << 2)
|
||||
/**
|
||||
* Output even those frames that might be corrupted.
|
||||
*/
|
||||
#define AV_CODEC_FLAG_OUTPUT_CORRUPT (1 << 3)
|
||||
/**
|
||||
* Use qpel MC.
|
||||
*/
|
||||
#define AV_CODEC_FLAG_QPEL (1 << 4)
|
||||
/**
|
||||
* Use internal 2pass ratecontrol in first pass mode.
|
||||
*/
|
||||
#define AV_CODEC_FLAG_PASS1 (1 << 9)
|
||||
/**
|
||||
* Use internal 2pass ratecontrol in second pass mode.
|
||||
*/
|
||||
#define AV_CODEC_FLAG_PASS2 (1 << 10)
|
||||
/**
|
||||
* loop filter.
|
||||
*/
|
||||
#define AV_CODEC_FLAG_LOOP_FILTER (1 << 11)
|
||||
/**
|
||||
* Only decode/encode grayscale.
|
||||
*/
|
||||
#define AV_CODEC_FLAG_GRAY (1 << 13)
|
||||
/**
|
||||
* error[?] variables will be set during encoding.
|
||||
*/
|
||||
#define AV_CODEC_FLAG_PSNR (1 << 15)
|
||||
/**
|
||||
* Input bitstream might be truncated at a random location
|
||||
* instead of only at frame boundaries.
|
||||
*/
|
||||
#define AV_CODEC_FLAG_TRUNCATED (1 << 16)
|
||||
/**
|
||||
* Force low delay.
|
||||
*/
|
||||
#define AV_CODEC_FLAG_LOW_DELAY (1 << 19)
|
||||
/**
|
||||
* Place global headers in extradata instead of every keyframe.
|
||||
*/
|
||||
#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22)
|
||||
/**
|
||||
* Use only bitexact stuff (except (I)DCT).
|
||||
*/
|
||||
#define AV_CODEC_FLAG_BITEXACT (1 << 23)
|
||||
/**
|
||||
* Allow non spec compliant speedup tricks.
|
||||
*/
|
||||
#define AV_CODEC_FLAG2_FAST (1 << 0)
|
||||
/**
|
||||
* Skip bitstream encoding.
|
||||
*/
|
||||
#define AV_CODEC_FLAG2_NO_OUTPUT (1 << 2)
|
||||
/**
|
||||
* Place global headers at every keyframe instead of in extradata.
|
||||
*/
|
||||
#define AV_CODEC_FLAG2_LOCAL_HEADER (1 << 3)
|
||||
|
||||
/**
|
||||
* timecode is in drop frame format. DEPRECATED!!!!
|
||||
*/
|
||||
#define AV_CODEC_FLAG2_DROP_FRAME_TIMECODE (1 << 13)
|
||||
|
||||
/**
|
||||
* Input bitstream might be truncated at a packet boundaries
|
||||
* instead of only at frame boundaries.
|
||||
*/
|
||||
#define AV_CODEC_FLAG2_CHUNKS (1 << 15)
|
||||
/**
|
||||
* Discard cropping information from SPS.
|
||||
*/
|
||||
#define AV_CODEC_FLAG2_IGNORE_CROP (1 << 16)
|
||||
|
||||
/**
|
||||
* Show all frames before the first keyframe
|
||||
*/
|
||||
#define AV_CODEC_FLAG2_SHOW_ALL (1 << 22)
|
||||
/**
|
||||
* Export motion vectors through frame side data
|
||||
*/
|
||||
#define AV_CODEC_FLAG2_EXPORT_MVS (1 << 28)
|
||||
/**
|
||||
* Do not skip samples and export skip information as frame side data
|
||||
*/
|
||||
#define AV_CODEC_FLAG2_SKIP_MANUAL (1 << 29)
|
||||
|
||||
/* Unsupported options :
|
||||
* Syntax Arithmetic coding (SAC)
|
||||
* Reference Picture Selection
|
||||
* Independent Segment Decoding */
|
||||
/* /Fx */
|
||||
/* codec capabilities */
|
||||
|
||||
/**
|
||||
* Encoder or decoder requires flushing with NULL input at the end in order to
|
||||
* give the complete and correct output.
|
||||
*
|
||||
* NOTE: If this flag is not set, the codec is guaranteed to never be fed with
|
||||
* with NULL data. The user can still send NULL data to the public encode
|
||||
* or decode function, but libavcodec will not pass it along to the codec
|
||||
* unless this flag is set.
|
||||
*
|
||||
* Decoders:
|
||||
* The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL,
|
||||
* avpkt->size=0 at the end to get the delayed data until the decoder no longer
|
||||
* returns frames.
|
||||
*
|
||||
* Encoders:
|
||||
* The encoder needs to be fed with NULL data at the end of encoding until the
|
||||
* encoder no longer returns data.
|
||||
*
|
||||
* NOTE: For encoders implementing the AVCodec.encode2() function, setting this
|
||||
* flag also means that the encoder must set the pts and duration for
|
||||
* each output packet. If this flag is not set, the pts and duration will
|
||||
* be determined by libavcodec from the input frame.
|
||||
*/
|
||||
#define AV_CODEC_CAP_DELAY (1 << 5)
|
||||
/**
|
||||
* Codec can be fed a final frame with a smaller size.
|
||||
* This can be used to prevent truncation of the last audio samples.
|
||||
*/
|
||||
#define AV_CODEC_CAP_SMALL_LAST_FRAME (1 << 6)
|
||||
|
||||
#if FF_API_CAP_VDPAU
|
||||
/**
|
||||
* Codec can export data for HW decoding (VDPAU).
|
||||
*/
|
||||
#define AV_CODEC_CAP_HWACCEL_VDPAU (1 << 7)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The decoder will keep a reference to the frame and may reuse it later.
|
||||
*/
|
||||
#define AV_GET_BUFFER_FLAG_REF (1 << 0)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
struct AVCodecInternal;
|
||||
|
||||
/**
|
||||
* main external API structure.
|
||||
* New fields can be added to the end with minor version bumps.
|
||||
@ -294,47 +56,9 @@ typedef struct AVCodecContext {
|
||||
* - set by avcodec_alloc_context3
|
||||
*/
|
||||
const struct AVCodec *codec;
|
||||
#if FF_API_CODEC_NAME
|
||||
/**
|
||||
* @deprecated this field is not used for anything in libavcodec
|
||||
*/
|
||||
attribute_deprecated
|
||||
char codec_name[32];
|
||||
#endif
|
||||
enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */
|
||||
|
||||
/**
|
||||
* fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
|
||||
* This is used to work around some encoder bugs.
|
||||
* A demuxer should set this to what is stored in the field used to identify the codec.
|
||||
* If there are multiple such fields in a container then the demuxer should choose the one
|
||||
* which maximizes the information about the used codec.
|
||||
* If the codec tag field in a container is larger than 32 bits then the demuxer should
|
||||
* remap the longer ID to 32 bits with a table or other structure. Alternatively a new
|
||||
* extra_codec_tag + size could be added but for this a clear advantage must be demonstrated
|
||||
* first.
|
||||
* - encoding: Set by user, if not then the default based on codec_id will be used.
|
||||
* - decoding: Set by user, will be converted to uppercase by libavcodec during init.
|
||||
*/
|
||||
unsigned int codec_tag;
|
||||
|
||||
#if FF_API_STREAM_CODEC_TAG
|
||||
/**
|
||||
* @deprecated this field is unused
|
||||
*/
|
||||
attribute_deprecated
|
||||
unsigned int stream_codec_tag;
|
||||
#endif
|
||||
|
||||
void *priv_data;
|
||||
|
||||
/**
|
||||
* AV_CODEC_FLAG_*.
|
||||
* - encoding: Set by user.
|
||||
* - decoding: Set by user.
|
||||
*/
|
||||
int flags;
|
||||
|
||||
/**
|
||||
* some codecs need / can use extradata like Huffman tables.
|
||||
* mjpeg: Huffman tables
|
||||
@ -372,106 +96,20 @@ typedef struct AVCodecContext {
|
||||
* - decoding: Set by libavcodec.
|
||||
*/
|
||||
int delay;
|
||||
|
||||
/* audio only */
|
||||
int sample_rate; ///< samples per second
|
||||
int channels; ///< number of audio channels
|
||||
|
||||
/* The following data should not be initialized. */
|
||||
/**
|
||||
* Number of samples per channel in an audio frame.
|
||||
*
|
||||
* - encoding: set by libavcodec in avcodec_open2(). Each submitted frame
|
||||
* except the last must contain exactly frame_size samples per channel.
|
||||
* May be 0 when the codec has AV_CODEC_CAP_VARIABLE_FRAME_SIZE set, then the
|
||||
* frame size is not restricted.
|
||||
* - decoding: may be set by some decoders to indicate constant frame size
|
||||
*/
|
||||
int frame_size;
|
||||
|
||||
/**
|
||||
* Frame counter, set by libavcodec.
|
||||
*
|
||||
* - decoding: total number of frames returned from the decoder so far.
|
||||
* - encoding: total number of frames passed to the encoder so far.
|
||||
*
|
||||
* @note the counter is not incremented if encoding/decoding resulted in
|
||||
* an error.
|
||||
*/
|
||||
int frame_number;
|
||||
|
||||
/**
|
||||
* number of bytes per packet if constant and known or 0
|
||||
* Used by some WAV based audio codecs.
|
||||
*/
|
||||
int block_align;
|
||||
|
||||
/**
|
||||
* Audio cutoff bandwidth (0 means "automatic")
|
||||
* - encoding: Set by user.
|
||||
* - decoding: unused
|
||||
*/
|
||||
int cutoff;
|
||||
|
||||
/**
|
||||
* Audio channel layout.
|
||||
* - encoding: set by user.
|
||||
* - decoding: set by user, may be overwritten by libavcodec.
|
||||
*/
|
||||
uint64_t channel_layout;
|
||||
|
||||
/**
|
||||
* IDCT algorithm, see FF_IDCT_* below.
|
||||
* - encoding: Set by user.
|
||||
* - decoding: Set by user.
|
||||
*/
|
||||
int idct_algo;
|
||||
#define FF_IDCT_AUTO 0
|
||||
#define FF_IDCT_INT 1
|
||||
#define FF_IDCT_SIMPLE 2
|
||||
#define FF_IDCT_SIMPLEMMX 3
|
||||
#define FF_IDCT_ARM 7
|
||||
#define FF_IDCT_ALTIVEC 8
|
||||
#if FF_API_ARCH_SH4
|
||||
#define FF_IDCT_SH4 9
|
||||
#endif
|
||||
#define FF_IDCT_SIMPLEARM 10
|
||||
#if FF_API_UNUSED_MEMBERS
|
||||
#define FF_IDCT_IPP 13
|
||||
#endif /* FF_API_UNUSED_MEMBERS */
|
||||
#define FF_IDCT_XVID 14
|
||||
#if FF_API_IDCT_XVIDMMX
|
||||
#define FF_IDCT_XVIDMMX 14
|
||||
#endif /* FF_API_IDCT_XVIDMMX */
|
||||
#define FF_IDCT_SIMPLEARMV5TE 16
|
||||
#define FF_IDCT_SIMPLEARMV6 17
|
||||
#if FF_API_ARCH_SPARC
|
||||
#define FF_IDCT_SIMPLEVIS 18
|
||||
#endif
|
||||
#define FF_IDCT_FAAN 20
|
||||
#define FF_IDCT_SIMPLENEON 22
|
||||
#if FF_API_ARCH_ALPHA
|
||||
#define FF_IDCT_SIMPLEALPHA 23
|
||||
#endif
|
||||
#define FF_IDCT_SIMPLEAUTO 128
|
||||
|
||||
|
||||
/**
|
||||
* Audio only. The number of "priming" samples (padding) inserted by the
|
||||
* encoder at the beginning of the audio. I.e. this number of leading
|
||||
* decoded samples must be discarded by the caller to get the original audio
|
||||
* without leading padding.
|
||||
*
|
||||
* - decoding: unused
|
||||
* - encoding: Set by libavcodec. The timestamps on the output packets are
|
||||
* adjusted by the encoder so that they always refer to the
|
||||
* first sample of the data actually contained in the packet,
|
||||
* including any added padding. E.g. if the timebase is
|
||||
* 1/samplerate and the timestamp of the first input sample is
|
||||
* 0, the timestamp of the first output packet will be
|
||||
* -initial_padding.
|
||||
*/
|
||||
int initial_padding;
|
||||
} AVCodecContext;
|
||||
|
||||
/**
|
||||
@ -515,78 +153,10 @@ typedef struct AVCodec {
|
||||
void (*flush)(AVCodecContext *);
|
||||
} AVCodec;
|
||||
|
||||
/**
|
||||
* Allocate an AVCodecContext and set its fields to default values. The
|
||||
* resulting struct should be freed with avcodec_free_context().
|
||||
*
|
||||
* @param codec if non-NULL, allocate private data and initialize defaults
|
||||
* for the given codec. It is illegal to then call avcodec_open2()
|
||||
* with a different codec.
|
||||
* If NULL, then the codec-specific defaults won't be initialized,
|
||||
* which may result in suboptimal default settings (this is
|
||||
* important mainly for encoders, e.g. libx264).
|
||||
*
|
||||
* @return An AVCodecContext filled with default values or NULL on failure.
|
||||
* @see avcodec_get_context_defaults
|
||||
*/
|
||||
AVCodecContext *avcodec_alloc_context3(const AVCodec *codec);
|
||||
|
||||
/**
|
||||
* Free the codec context and everything associated with it and write NULL to
|
||||
* the provided pointer.
|
||||
*/
|
||||
void avcodec_free_context(AVCodecContext **avctx);
|
||||
|
||||
/**
|
||||
* Initialize the AVCodecContext to use the given AVCodec. Prior to using this
|
||||
* function the context has to be allocated with avcodec_alloc_context3().
|
||||
*
|
||||
* The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(),
|
||||
* avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for
|
||||
* retrieving a codec.
|
||||
*
|
||||
* @warning This function is not thread safe!
|
||||
*
|
||||
* @note Always call this function before using decoding routines (such as
|
||||
* @ref avcodec_decode_video2()).
|
||||
*
|
||||
* @code
|
||||
* avcodec_register_all();
|
||||
* av_dict_set(&opts, "b", "2.5M", 0);
|
||||
* codec = avcodec_find_decoder(AV_CODEC_ID_H264);
|
||||
* if (!codec)
|
||||
* exit(1);
|
||||
*
|
||||
* context = avcodec_alloc_context3(codec);
|
||||
*
|
||||
* if (avcodec_open2(context, codec, opts) < 0)
|
||||
* exit(1);
|
||||
* @endcode
|
||||
*
|
||||
* @param avctx The context to initialize.
|
||||
* @param codec The codec to open this context for. If a non-NULL codec has been
|
||||
* previously passed to avcodec_alloc_context3() or
|
||||
* avcodec_get_context_defaults3() for this context, then this
|
||||
* parameter MUST be either NULL or equal to the previously passed
|
||||
* codec.
|
||||
* @param options A dictionary filled with AVCodecContext and codec-private options.
|
||||
* On return this object will be filled with options that were not found.
|
||||
*
|
||||
* @return zero on success, a negative value on error
|
||||
* @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(),
|
||||
* av_dict_set(), av_opt_find().
|
||||
*/
|
||||
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, void *options);
|
||||
|
||||
/**
|
||||
* Close a given AVCodecContext and free all the data associated with it
|
||||
* (but not the AVCodecContext itself).
|
||||
*
|
||||
* Calling this function on an AVCodecContext that hasn't been opened will free
|
||||
* the codec-specific data allocated in avcodec_alloc_context3() /
|
||||
* avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will
|
||||
* do nothing.
|
||||
*/
|
||||
int avcodec_close(AVCodecContext *avctx);
|
||||
|
||||
/**
|
||||
|
@ -4,9 +4,7 @@
|
||||
|
||||
#include "ext/at3_standalone/compat.h"
|
||||
|
||||
void av_log(void *avcl, int level, const char *fmt, ...) {
|
||||
|
||||
}
|
||||
void av_log(int level, const char *fmt, ...) {}
|
||||
|
||||
int av_get_cpu_flags(void) {
|
||||
return 0;
|
||||
|
@ -20,7 +20,17 @@
|
||||
#define FF_ENABLE_DEPRECATION_WARNINGS
|
||||
#define CONFIG_FFT 1
|
||||
|
||||
#define DECLARE_ALIGNED(bits, type, name) type name
|
||||
#if defined(__GNUC__)
|
||||
#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
|
||||
#define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v
|
||||
#elif defined(_MSC_VER)
|
||||
#define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
|
||||
#define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
|
||||
#else
|
||||
#define DECLARE_ALIGNED(n,t,v) t v
|
||||
#define DECLARE_ASM_CONST(n,t,v) static const t v
|
||||
#endif
|
||||
|
||||
#define LOCAL_ALIGNED(bits, type, name, subscript) type name subscript
|
||||
#define av_restrict
|
||||
#define av_always_inline __forceinline
|
||||
@ -57,7 +67,7 @@
|
||||
#define AV_LOG_DEBUG 48
|
||||
#define AV_LOG_TRACE 56
|
||||
|
||||
void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4);
|
||||
void av_log(int level, const char *fmt, ...) av_printf_format(3, 4);
|
||||
|
||||
/**
|
||||
* Maximum size in bytes of extradata.
|
||||
|
@ -162,7 +162,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes,
|
||||
for (k = 0; k < nb; k++) {
|
||||
int bits = table[j][1];
|
||||
if (bits != 0 && bits != n) {
|
||||
av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
|
||||
av_log( AV_LOG_ERROR, "incorrect codes\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
table[j][1] = n; //bits
|
||||
@ -273,14 +273,14 @@ int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes,
|
||||
if (!(condition)) \
|
||||
continue; \
|
||||
if (buf[j].bits > 3*nb_bits || buf[j].bits>32) { \
|
||||
av_log(NULL, AV_LOG_ERROR, "Too long VLC (%d) in init_vlc\n", buf[j].bits);\
|
||||
av_log( AV_LOG_ERROR, "Too long VLC (%d) in init_vlc\n", buf[j].bits);\
|
||||
if (!(flags & INIT_VLC_USE_NEW_STATIC)) \
|
||||
av_free(buf); \
|
||||
return -1; \
|
||||
} \
|
||||
GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size); \
|
||||
if (buf[j].code >= (1LL<<buf[j].bits)) { \
|
||||
av_log(NULL, AV_LOG_ERROR, "Invalid code in init_vlc\n"); \
|
||||
av_log( AV_LOG_ERROR, "Invalid code in init_vlc\n"); \
|
||||
if (!(flags & INIT_VLC_USE_NEW_STATIC)) \
|
||||
av_free(buf); \
|
||||
return -1; \
|
||||
@ -305,7 +305,7 @@ int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes,
|
||||
|
||||
if (flags & INIT_VLC_USE_NEW_STATIC) {
|
||||
if(vlc->table_size != vlc->table_allocated)
|
||||
av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", vlc->table_size, vlc->table_allocated);
|
||||
av_log( AV_LOG_ERROR, "needed %d had %d\n", vlc->table_size, vlc->table_allocated);
|
||||
|
||||
av_assert0(ret >= 0);
|
||||
*vlc_arg = *vlc;
|
||||
|
@ -52,7 +52,7 @@ int64_t av_gcd(int64_t a, int64_t b) {
|
||||
return (uint64_t)u << k;
|
||||
}
|
||||
|
||||
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
|
||||
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, AVRounding rnd)
|
||||
{
|
||||
int64_t r = 0;
|
||||
av_assert2(c > 0);
|
||||
@ -128,8 +128,7 @@ int64_t av_rescale(int64_t a, int64_t b, int64_t c)
|
||||
return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF);
|
||||
}
|
||||
|
||||
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq,
|
||||
enum AVRounding rnd)
|
||||
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, AVRounding rnd)
|
||||
{
|
||||
int64_t b = bq.num * (int64_t)cq.den;
|
||||
int64_t c = cq.num * (int64_t)bq.den;
|
||||
@ -141,7 +140,6 @@ 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)
|
||||
{
|
||||
@ -208,26 +206,6 @@ AVRational av_add_q(AVRational b, AVRational c) {
|
||||
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;
|
||||
}
|
||||
|
||||
static const uint8_t ff_logg2_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,
|
||||
|
@ -140,7 +140,6 @@ static inline unsigned zero_extend(unsigned val, unsigned bits)
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
enum AVRounding {
|
||||
AV_ROUND_ZERO = 0, ///< Round toward zero.
|
||||
AV_ROUND_INF = 1, ///< Round away from zero.
|
||||
@ -179,7 +178,7 @@ int64_t av_rescale(int64_t a, int64_t b, int64_t c);
|
||||
* @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);
|
||||
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, AVRounding);
|
||||
|
||||
/**
|
||||
* Rescale a 64-bit integer by 2 rational numbers.
|
||||
@ -192,8 +191,7 @@ int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq);
|
||||
* @return rescaled value a, or if AV_ROUND_PASS_MINMAX is set and a is
|
||||
* INT64_MIN or INT64_MAX then a is passed through unchanged.
|
||||
*/
|
||||
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq,
|
||||
enum AVRounding);
|
||||
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, AVRounding);
|
||||
|
||||
|
||||
/**
|
||||
@ -279,17 +277,6 @@ static inline AVRational av_inv_q(AVRational q)
|
||||
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);
|
||||
|
||||
|
||||
/**
|
||||
* Clear high bits from an unsigned integer starting with specific bit position
|
||||
* @param a value to clip
|
||||
|
@ -29,17 +29,6 @@
|
||||
|
||||
#define FF_MEMORY_POISON 0x2a
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v
|
||||
#define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v
|
||||
#elif defined(_MSC_VER)
|
||||
#define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
|
||||
#define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
|
||||
#else
|
||||
#define DECLARE_ALIGNED(n,t,v) t v
|
||||
#define DECLARE_ASM_CONST(n,t,v) static const t v
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Allocate a block of size bytes with alignment suitable for all
|
||||
* memory accesses (including vectors if available on the CPU).
|
||||
|
Loading…
Reference in New Issue
Block a user