* qatar/master:
vorbisdec: Rename silly "class_" variable to plain "class".
simple_idct_alpha: Drop some useless casts.
Simplify av_log_missing_feature().
ac3enc: remove check for mismatching channels and channel_layout
If AVCodecContext.channels is 0 and AVCodecContext.channel_layout is non-zero, set channels based on channel_layout.
If AVCodecContext.channel_layout and AVCodecContext.channels are both non-zero, check to make sure they do not contradict eachother.
cosmetics: indentation
Check AVCodec.supported_samplerates and AVCodec.channel_layouts in avcodec_open().
aacdec: remove sf_scale and sf_offset.
aacdec: use a scale of 2 in the LTP MDCT rather than doubling the coefficient table values from the spec.
Define POW_SF2_ZERO in aac.h and use for ff_aac_pow2sf_tabp[] offsets instead of hardcoding 200 everywhere.
Large intensity stereo and PNS indices are legal. Clip them instead of erroring out. A magnitude of 100 corresponds to 2^25 so the will most likely result in clipped output anyway.
qpeg: use reget_buffer() in decode_frame()
ultimotion: use reget_buffer() in ulti_decode_frame()
smacker: remove unnecessary call to avctx->release_buffer in decode_frame()
avparser: don't av_malloc(0).
Merged-by: Michael Niedermayer <michaelni@gmx.at>
| ... | ... |
@@ -130,6 +130,7 @@ typedef struct {
|
| 130 | 130 |
#define SCALE_MAX_POS 255 ///< scalefactor index maximum value |
| 131 | 131 |
#define SCALE_MAX_DIFF 60 ///< maximum scalefactor difference allowed by standard |
| 132 | 132 |
#define SCALE_DIFF_ZERO 60 ///< codebook index corresponding to zero scalefactor indices difference |
| 133 |
+#define POW_SF2_ZERO 200 ///< ff_aac_pow2sf_tab index corresponding to pow(2, 0); |
|
| 133 | 134 |
|
| 134 | 135 |
/** |
| 135 | 136 |
* Long Term Prediction |
| ... | ... |
@@ -292,8 +293,6 @@ typedef struct {
|
| 292 | 292 |
* @{
|
| 293 | 293 |
*/ |
| 294 | 294 |
float *output_data[MAX_CHANNELS]; ///< Points to each element's 'ret' buffer (PCM output). |
| 295 |
- float sf_scale; ///< Pre-scale for correct IMDCT and dsp.float_to_int16. |
|
| 296 |
- int sf_offset; ///< offset into pow2sf_tab as appropriate for dsp.float_to_int16 |
|
| 297 | 295 |
/** @} */ |
| 298 | 296 |
|
| 299 | 297 |
DECLARE_ALIGNED(32, float, temp)[128]; |
| ... | ... |
@@ -29,13 +29,14 @@ |
| 29 | 29 |
#include "libavcodec/aac_tables.h" |
| 30 | 30 |
#else |
| 31 | 31 |
#include "libavutil/mathematics.h" |
| 32 |
+#include "libavcodec/aac.h" |
|
| 32 | 33 |
float ff_aac_pow2sf_tab[428]; |
| 33 | 34 |
|
| 34 | 35 |
void ff_aac_tableinit(void) |
| 35 | 36 |
{
|
| 36 | 37 |
int i; |
| 37 | 38 |
for (i = 0; i < 428; i++) |
| 38 |
- ff_aac_pow2sf_tab[i] = pow(2, (i - 200) / 4.); |
|
| 39 |
+ ff_aac_pow2sf_tab[i] = pow(2, (i - POW_SF2_ZERO) / 4.); |
|
| 39 | 40 |
} |
| 40 | 41 |
#endif /* CONFIG_HARDCODED_TABLES */ |
| 41 | 42 |
|
| ... | ... |
@@ -109,8 +109,8 @@ static av_always_inline float quantize_and_encode_band_cost_template( |
| 109 | 109 |
int *bits, int BT_ZERO, int BT_UNSIGNED, |
| 110 | 110 |
int BT_PAIR, int BT_ESC) |
| 111 | 111 |
{
|
| 112 |
- const float IQ = ff_aac_pow2sf_tab[200 + scale_idx - SCALE_ONE_POS + SCALE_DIV_512]; |
|
| 113 |
- const float Q = ff_aac_pow2sf_tab[200 - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; |
|
| 112 |
+ const float IQ = ff_aac_pow2sf_tab[POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512]; |
|
| 113 |
+ const float Q = ff_aac_pow2sf_tab[POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; |
|
| 114 | 114 |
const float CLIPPED_ESCAPE = 165140.0f*IQ; |
| 115 | 115 |
int i, j; |
| 116 | 116 |
float cost = 0; |
| ... | ... |
@@ -281,7 +281,7 @@ static float find_max_val(int group_len, int swb_size, const float *scaled) {
|
| 281 | 281 |
} |
| 282 | 282 |
|
| 283 | 283 |
static int find_min_book(float maxval, int sf) {
|
| 284 |
- float Q = ff_aac_pow2sf_tab[200 - sf + SCALE_ONE_POS - SCALE_DIV_512]; |
|
| 284 |
+ float Q = ff_aac_pow2sf_tab[POW_SF2_ZERO - sf + SCALE_ONE_POS - SCALE_DIV_512]; |
|
| 285 | 285 |
float Q34 = sqrtf(Q * sqrtf(Q)); |
| 286 | 286 |
int qmaxval, cb; |
| 287 | 287 |
qmaxval = maxval * Q34 + 0.4054f; |
| ... | ... |
@@ -956,7 +956,7 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, |
| 956 | 956 |
dist -= b; |
| 957 | 957 |
} |
| 958 | 958 |
dist *= 1.0f / 512.0f / lambda; |
| 959 |
- quant_max = quant(maxq[w*16+g], ff_aac_pow2sf_tab[200 - scf + SCALE_ONE_POS - SCALE_DIV_512]); |
|
| 959 |
+ quant_max = quant(maxq[w*16+g], ff_aac_pow2sf_tab[POW_SF2_ZERO - scf + SCALE_ONE_POS - SCALE_DIV_512]); |
|
| 960 | 960 |
if (quant_max >= 8191) { // too much, return to the previous quantizer
|
| 961 | 961 |
sce->sf_idx[w*16+g] = prev_scf; |
| 962 | 962 |
break; |
| ... | ... |
@@ -579,12 +579,6 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) |
| 579 | 579 |
|
| 580 | 580 |
ac->random_state = 0x1f2e3d4c; |
| 581 | 581 |
|
| 582 |
- // -1024 - Compensate wrong IMDCT method. |
|
| 583 |
- // 60 - Required to scale values to the correct range [-32768,32767] |
|
| 584 |
- // for float to int16 conversion. (1 << (60 / 4)) == 32768 |
|
| 585 |
- ac->sf_scale = 1. / -1024.; |
|
| 586 |
- ac->sf_offset = 60; |
|
| 587 |
- |
|
| 588 | 582 |
ff_aac_tableinit(); |
| 589 | 583 |
|
| 590 | 584 |
INIT_VLC_STATIC(&vlc_scalefactors,7,FF_ARRAY_ELEMS(ff_aac_scalefactor_code), |
| ... | ... |
@@ -592,9 +586,9 @@ static av_cold int aac_decode_init(AVCodecContext *avctx) |
| 592 | 592 |
ff_aac_scalefactor_code, sizeof(ff_aac_scalefactor_code[0]), sizeof(ff_aac_scalefactor_code[0]), |
| 593 | 593 |
352); |
| 594 | 594 |
|
| 595 |
- ff_mdct_init(&ac->mdct, 11, 1, 1.0); |
|
| 596 |
- ff_mdct_init(&ac->mdct_small, 8, 1, 1.0); |
|
| 597 |
- ff_mdct_init(&ac->mdct_ltp, 11, 0, 1.0); |
|
| 595 |
+ ff_mdct_init(&ac->mdct, 11, 1, 1.0/1024.0); |
|
| 596 |
+ ff_mdct_init(&ac->mdct_small, 8, 1, 1.0/128.0); |
|
| 597 |
+ ff_mdct_init(&ac->mdct_ltp, 11, 0, -2.0); |
|
| 598 | 598 |
// window initialization |
| 599 | 599 |
ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); |
| 600 | 600 |
ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128); |
| ... | ... |
@@ -652,7 +646,7 @@ static void decode_ltp(AACContext *ac, LongTermPrediction *ltp, |
| 652 | 652 |
int sfb; |
| 653 | 653 |
|
| 654 | 654 |
ltp->lag = get_bits(gb, 11); |
| 655 |
- ltp->coef = ltp_coef[get_bits(gb, 3)] * ac->sf_scale; |
|
| 655 |
+ ltp->coef = ltp_coef[get_bits(gb, 3)]; |
|
| 656 | 656 |
for (sfb = 0; sfb < FFMIN(max_sfb, MAX_LTP_LONG_SFB); sfb++) |
| 657 | 657 |
ltp->used[sfb] = get_bits1(gb); |
| 658 | 658 |
} |
| ... | ... |
@@ -790,9 +784,9 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, |
| 790 | 790 |
enum BandType band_type[120], |
| 791 | 791 |
int band_type_run_end[120]) |
| 792 | 792 |
{
|
| 793 |
- const int sf_offset = ac->sf_offset + (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE ? 12 : 0); |
|
| 794 | 793 |
int g, i, idx = 0; |
| 795 |
- int offset[3] = { global_gain, global_gain - 90, 100 };
|
|
| 794 |
+ int offset[3] = { global_gain, global_gain - 90, 0 };
|
|
| 795 |
+ int clipped_offset; |
|
| 796 | 796 |
int noise_flag = 1; |
| 797 | 797 |
static const char *sf_str[3] = { "Global gain", "Noise gain", "Intensity stereo position" };
|
| 798 | 798 |
for (g = 0; g < ics->num_window_groups; g++) {
|
| ... | ... |
@@ -804,12 +798,14 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, |
| 804 | 804 |
} else if ((band_type[idx] == INTENSITY_BT) || (band_type[idx] == INTENSITY_BT2)) {
|
| 805 | 805 |
for (; i < run_end; i++, idx++) {
|
| 806 | 806 |
offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; |
| 807 |
- if (offset[2] > 255U) {
|
|
| 808 |
- av_log(ac->avctx, AV_LOG_ERROR, |
|
| 809 |
- "%s (%d) out of range.\n", sf_str[2], offset[2]); |
|
| 810 |
- return -1; |
|
| 807 |
+ clipped_offset = av_clip(offset[2], -155, 100); |
|
| 808 |
+ if (offset[2] != clipped_offset) {
|
|
| 809 |
+ av_log_ask_for_sample(ac->avctx, "Intensity stereo " |
|
| 810 |
+ "position clipped (%d -> %d).\nIf you heard an " |
|
| 811 |
+ "audible artifact, there may be a bug in the " |
|
| 812 |
+ "decoder. ", offset[2], clipped_offset); |
|
| 811 | 813 |
} |
| 812 |
- sf[idx] = ff_aac_pow2sf_tab[-offset[2] + 300]; |
|
| 814 |
+ sf[idx] = ff_aac_pow2sf_tab[-clipped_offset + POW_SF2_ZERO]; |
|
| 813 | 815 |
} |
| 814 | 816 |
} else if (band_type[idx] == NOISE_BT) {
|
| 815 | 817 |
for (; i < run_end; i++, idx++) {
|
| ... | ... |
@@ -817,12 +813,14 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, |
| 817 | 817 |
offset[1] += get_bits(gb, 9) - 256; |
| 818 | 818 |
else |
| 819 | 819 |
offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; |
| 820 |
- if (offset[1] > 255U) {
|
|
| 821 |
- av_log(ac->avctx, AV_LOG_ERROR, |
|
| 822 |
- "%s (%d) out of range.\n", sf_str[1], offset[1]); |
|
| 823 |
- return -1; |
|
| 820 |
+ clipped_offset = av_clip(offset[1], -100, 155); |
|
| 821 |
+ if (offset[2] != clipped_offset) {
|
|
| 822 |
+ av_log_ask_for_sample(ac->avctx, "Noise gain clipped " |
|
| 823 |
+ "(%d -> %d).\nIf you heard an audible " |
|
| 824 |
+ "artifact, there may be a bug in the decoder. ", |
|
| 825 |
+ offset[1], clipped_offset); |
|
| 824 | 826 |
} |
| 825 |
- sf[idx] = -ff_aac_pow2sf_tab[offset[1] + sf_offset + 100]; |
|
| 827 |
+ sf[idx] = -ff_aac_pow2sf_tab[clipped_offset + POW_SF2_ZERO]; |
|
| 826 | 828 |
} |
| 827 | 829 |
} else {
|
| 828 | 830 |
for (; i < run_end; i++, idx++) {
|
| ... | ... |
@@ -832,7 +830,7 @@ static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, |
| 832 | 832 |
"%s (%d) out of range.\n", sf_str[0], offset[0]); |
| 833 | 833 |
return -1; |
| 834 | 834 |
} |
| 835 |
- sf[idx] = -ff_aac_pow2sf_tab[ offset[0] + sf_offset]; |
|
| 835 |
+ sf[idx] = -ff_aac_pow2sf_tab[offset[0] - 100 + POW_SF2_ZERO]; |
|
| 836 | 836 |
} |
| 837 | 837 |
} |
| 838 | 838 |
} |
| ... | ... |
@@ -1243,7 +1241,6 @@ static av_always_inline float flt16_trunc(float pf) |
| 1243 | 1243 |
} |
| 1244 | 1244 |
|
| 1245 | 1245 |
static av_always_inline void predict(PredictorState *ps, float *coef, |
| 1246 |
- float sf_scale, float inv_sf_scale, |
|
| 1247 | 1246 |
int output_enable) |
| 1248 | 1247 |
{
|
| 1249 | 1248 |
const float a = 0.953125; // 61.0 / 64 |
| ... | ... |
@@ -1260,9 +1257,9 @@ static av_always_inline void predict(PredictorState *ps, float *coef, |
| 1260 | 1260 |
|
| 1261 | 1261 |
pv = flt16_round(k1 * r0 + k2 * r1); |
| 1262 | 1262 |
if (output_enable) |
| 1263 |
- *coef += pv * sf_scale; |
|
| 1263 |
+ *coef += pv; |
|
| 1264 | 1264 |
|
| 1265 |
- e0 = *coef * inv_sf_scale; |
|
| 1265 |
+ e0 = *coef; |
|
| 1266 | 1266 |
e1 = e0 - k1 * r0; |
| 1267 | 1267 |
|
| 1268 | 1268 |
ps->cor1 = flt16_trunc(alpha * cor1 + r1 * e1); |
| ... | ... |
@@ -1280,7 +1277,6 @@ static av_always_inline void predict(PredictorState *ps, float *coef, |
| 1280 | 1280 |
static void apply_prediction(AACContext *ac, SingleChannelElement *sce) |
| 1281 | 1281 |
{
|
| 1282 | 1282 |
int sfb, k; |
| 1283 |
- float sf_scale = ac->sf_scale, inv_sf_scale = 1 / ac->sf_scale; |
|
| 1284 | 1283 |
|
| 1285 | 1284 |
if (!sce->ics.predictor_initialized) {
|
| 1286 | 1285 |
reset_all_predictors(sce->predictor_state); |
| ... | ... |
@@ -1291,7 +1287,6 @@ static void apply_prediction(AACContext *ac, SingleChannelElement *sce) |
| 1291 | 1291 |
for (sfb = 0; sfb < ff_aac_pred_sfb_max[ac->m4ac.sampling_index]; sfb++) {
|
| 1292 | 1292 |
for (k = sce->ics.swb_offset[sfb]; k < sce->ics.swb_offset[sfb + 1]; k++) {
|
| 1293 | 1293 |
predict(&sce->predictor_state[k], &sce->coeffs[k], |
| 1294 |
- sf_scale, inv_sf_scale, |
|
| 1295 | 1294 |
sce->ics.predictor_present && sce->ics.prediction_used[sfb]); |
| 1296 | 1295 |
} |
| 1297 | 1296 |
} |
| ... | ... |
@@ -36,11 +36,11 @@ |
| 36 | 36 |
#include <stdint.h> |
| 37 | 37 |
|
| 38 | 38 |
/* @name ltp_coef |
| 39 |
- * Table of the LTP coefficient (multiplied by 2) |
|
| 39 |
+ * Table of the LTP coefficients |
|
| 40 | 40 |
*/ |
| 41 | 41 |
static const float ltp_coef[8] = {
|
| 42 |
- 1.141658, 1.393232, 1.626008, 1.822608, |
|
| 43 |
- 1.969800, 2.135788, 2.2389202, 2.739066, |
|
| 42 |
+ 0.570829, 0.696616, 0.813004, 0.911304, |
|
| 43 |
+ 0.984900, 1.067894, 1.194601, 1.369533, |
|
| 44 | 44 |
}; |
| 45 | 45 |
|
| 46 | 46 |
/* @name tns_tmp2_map |
| ... | ... |
@@ -1962,8 +1962,6 @@ static av_cold int set_channel_info(AC3EncodeContext *s, int channels, |
| 1962 | 1962 |
ch_layout = *channel_layout; |
| 1963 | 1963 |
if (!ch_layout) |
| 1964 | 1964 |
ch_layout = avcodec_guess_channel_layout(channels, CODEC_ID_AC3, NULL); |
| 1965 |
- if (av_get_channel_layout_nb_channels(ch_layout) != channels) |
|
| 1966 |
- return AVERROR(EINVAL); |
|
| 1967 | 1965 |
|
| 1968 | 1966 |
s->lfe_on = !!(ch_layout & AV_CH_LOW_FREQUENCY); |
| 1969 | 1967 |
s->channels = channels; |
| ... | ... |
@@ -33,13 +33,13 @@ |
| 33 | 33 |
// cos(i * M_PI / 16) * sqrt(2) * (1 << 14) |
| 34 | 34 |
// W4 is actually exactly 16384, but using 16383 works around |
| 35 | 35 |
// accumulating rounding errors for some encoders |
| 36 |
-#define W1 ((int_fast32_t) 22725) |
|
| 37 |
-#define W2 ((int_fast32_t) 21407) |
|
| 38 |
-#define W3 ((int_fast32_t) 19266) |
|
| 39 |
-#define W4 ((int_fast32_t) 16383) |
|
| 40 |
-#define W5 ((int_fast32_t) 12873) |
|
| 41 |
-#define W6 ((int_fast32_t) 8867) |
|
| 42 |
-#define W7 ((int_fast32_t) 4520) |
|
| 36 |
+#define W1 22725 |
|
| 37 |
+#define W2 21407 |
|
| 38 |
+#define W3 19266 |
|
| 39 |
+#define W4 16383 |
|
| 40 |
+#define W5 12873 |
|
| 41 |
+#define W6 8867 |
|
| 42 |
+#define W7 4520 |
|
| 43 | 43 |
#define ROW_SHIFT 11 |
| 44 | 44 |
#define COL_SHIFT 20 |
| 45 | 45 |
|
| ... | ... |
@@ -259,12 +259,9 @@ static int decode_frame(AVCodecContext *avctx, |
| 259 | 259 |
int delta; |
| 260 | 260 |
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); |
| 261 | 261 |
|
| 262 |
- if(p->data[0]) |
|
| 263 |
- avctx->release_buffer(avctx, p); |
|
| 264 |
- |
|
| 265 |
- p->reference= 0; |
|
| 266 |
- if(avctx->get_buffer(avctx, p) < 0){
|
|
| 267 |
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 262 |
+ p->reference = 3; |
|
| 263 |
+ if (avctx->reget_buffer(avctx, p) < 0) {
|
|
| 264 |
+ av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); |
|
| 268 | 265 |
return -1; |
| 269 | 266 |
} |
| 270 | 267 |
outdata = a->pic.data[0]; |
| ... | ... |
@@ -360,8 +360,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac |
| 360 | 360 |
|
| 361 | 361 |
if(buf_size <= 769) |
| 362 | 362 |
return 0; |
| 363 |
- if(smk->pic.data[0]) |
|
| 364 |
- avctx->release_buffer(avctx, &smk->pic); |
|
| 365 | 363 |
|
| 366 | 364 |
smk->pic.reference = 1; |
| 367 | 365 |
smk->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; |
| ... | ... |
@@ -224,13 +224,10 @@ static int ulti_decode_frame(AVCodecContext *avctx, |
| 224 | 224 |
int skip; |
| 225 | 225 |
int tmp; |
| 226 | 226 |
|
| 227 |
- if(s->frame.data[0]) |
|
| 228 |
- avctx->release_buffer(avctx, &s->frame); |
|
| 229 |
- |
|
| 230 | 227 |
s->frame.reference = 1; |
| 231 | 228 |
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; |
| 232 |
- if(avctx->get_buffer(avctx, &s->frame) < 0) {
|
|
| 233 |
- av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
|
| 229 |
+ if (avctx->reget_buffer(avctx, &s->frame) < 0) {
|
|
| 230 |
+ av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); |
|
| 234 | 231 |
return -1; |
| 235 | 232 |
} |
| 236 | 233 |
|
| ... | ... |
@@ -555,15 +555,50 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) |
| 555 | 555 |
ret = AVERROR(EINVAL); |
| 556 | 556 |
goto free_and_end; |
| 557 | 557 |
} |
| 558 |
- if (avctx->codec->sample_fmts && avctx->codec->encode) {
|
|
| 558 |
+ if (avctx->codec->encode) {
|
|
| 559 | 559 |
int i; |
| 560 |
- for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) |
|
| 561 |
- if (avctx->sample_fmt == avctx->codec->sample_fmts[i]) |
|
| 562 |
- break; |
|
| 563 |
- if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
|
|
| 564 |
- av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n"); |
|
| 565 |
- ret = AVERROR(EINVAL); |
|
| 566 |
- goto free_and_end; |
|
| 560 |
+ if (avctx->codec->sample_fmts) {
|
|
| 561 |
+ for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++) |
|
| 562 |
+ if (avctx->sample_fmt == avctx->codec->sample_fmts[i]) |
|
| 563 |
+ break; |
|
| 564 |
+ if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
|
|
| 565 |
+ av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n"); |
|
| 566 |
+ ret = AVERROR(EINVAL); |
|
| 567 |
+ goto free_and_end; |
|
| 568 |
+ } |
|
| 569 |
+ } |
|
| 570 |
+ if (avctx->codec->supported_samplerates) {
|
|
| 571 |
+ for (i = 0; avctx->codec->supported_samplerates[i] != 0; i++) |
|
| 572 |
+ if (avctx->sample_rate == avctx->codec->supported_samplerates[i]) |
|
| 573 |
+ break; |
|
| 574 |
+ if (avctx->codec->supported_samplerates[i] == 0) {
|
|
| 575 |
+ av_log(avctx, AV_LOG_ERROR, "Specified sample_rate is not supported\n"); |
|
| 576 |
+ ret = AVERROR(EINVAL); |
|
| 577 |
+ goto free_and_end; |
|
| 578 |
+ } |
|
| 579 |
+ } |
|
| 580 |
+ if (avctx->codec->channel_layouts) {
|
|
| 581 |
+ if (!avctx->channel_layout) {
|
|
| 582 |
+ av_log(avctx, AV_LOG_WARNING, "channel_layout not specified\n"); |
|
| 583 |
+ } else {
|
|
| 584 |
+ for (i = 0; avctx->codec->channel_layouts[i] != 0; i++) |
|
| 585 |
+ if (avctx->channel_layout == avctx->codec->channel_layouts[i]) |
|
| 586 |
+ break; |
|
| 587 |
+ if (avctx->codec->channel_layouts[i] == 0) {
|
|
| 588 |
+ av_log(avctx, AV_LOG_ERROR, "Specified channel_layout is not supported\n"); |
|
| 589 |
+ ret = AVERROR(EINVAL); |
|
| 590 |
+ goto free_and_end; |
|
| 591 |
+ } |
|
| 592 |
+ } |
|
| 593 |
+ } |
|
| 594 |
+ if (avctx->channel_layout && avctx->channels) {
|
|
| 595 |
+ if (av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) {
|
|
| 596 |
+ av_log(avctx, AV_LOG_ERROR, "channel layout does not match number of channels\n"); |
|
| 597 |
+ ret = AVERROR(EINVAL); |
|
| 598 |
+ goto free_and_end; |
|
| 599 |
+ } |
|
| 600 |
+ } else if (avctx->channel_layout) {
|
|
| 601 |
+ avctx->channels = av_get_channel_layout_nb_channels(avctx->channel_layout); |
|
| 567 | 602 |
} |
| 568 | 603 |
} |
| 569 | 604 |
|
| ... | ... |
@@ -1194,11 +1229,9 @@ void av_log_missing_feature(void *avc, const char *feature, int want_sample) |
| 1194 | 1194 |
av_log(avc, AV_LOG_WARNING, "%s not implemented. Update your FFmpeg " |
| 1195 | 1195 |
"version to the newest one from Git. If the problem still " |
| 1196 | 1196 |
"occurs, it means that your file has a feature which has not " |
| 1197 |
- "been implemented.", feature); |
|
| 1197 |
+ "been implemented.\n", feature); |
|
| 1198 | 1198 |
if(want_sample) |
| 1199 | 1199 |
av_log_ask_for_sample(avc, NULL); |
| 1200 |
- else |
|
| 1201 |
- av_log(avc, AV_LOG_WARNING, "\n"); |
|
| 1202 | 1200 |
} |
| 1203 | 1201 |
|
| 1204 | 1202 |
void av_log_ask_for_sample(void *avc, const char *msg, ...) |
| ... | ... |
@@ -1138,7 +1138,7 @@ static int vorbis_floor1_decode(vorbis_context *vc, |
| 1138 | 1138 |
uint_fast16_t floor1_Y[258]; |
| 1139 | 1139 |
uint_fast16_t floor1_Y_final[258]; |
| 1140 | 1140 |
int floor1_flag[258]; |
| 1141 |
- uint_fast8_t class_; |
|
| 1141 |
+ uint_fast8_t class; |
|
| 1142 | 1142 |
uint_fast8_t cdim; |
| 1143 | 1143 |
uint_fast8_t cbits; |
| 1144 | 1144 |
uint_fast8_t csub; |
| ... | ... |
@@ -1162,20 +1162,20 @@ static int vorbis_floor1_decode(vorbis_context *vc, |
| 1162 | 1162 |
|
| 1163 | 1163 |
offset = 2; |
| 1164 | 1164 |
for (i = 0; i < vf->partitions; ++i) {
|
| 1165 |
- class_ = vf->partition_class[i]; |
|
| 1166 |
- cdim = vf->class_dimensions[class_]; |
|
| 1167 |
- cbits = vf->class_subclasses[class_]; |
|
| 1165 |
+ class = vf->partition_class[i]; |
|
| 1166 |
+ cdim = vf->class_dimensions[class]; |
|
| 1167 |
+ cbits = vf->class_subclasses[class]; |
|
| 1168 | 1168 |
csub = (1 << cbits) - 1; |
| 1169 | 1169 |
cval = 0; |
| 1170 | 1170 |
|
| 1171 | 1171 |
AV_DEBUG("Cbits %d \n", cbits);
|
| 1172 | 1172 |
|
| 1173 | 1173 |
if (cbits) // this reads all subclasses for this partition's class |
| 1174 |
- cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[class_]].vlc.table, |
|
| 1175 |
- vc->codebooks[vf->class_masterbook[class_]].nb_bits, 3); |
|
| 1174 |
+ cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[class]].vlc.table, |
|
| 1175 |
+ vc->codebooks[vf->class_masterbook[class]].nb_bits, 3); |
|
| 1176 | 1176 |
|
| 1177 | 1177 |
for (j = 0; j < cdim; ++j) {
|
| 1178 |
- book = vf->subclass_books[class_][cval & csub]; |
|
| 1178 |
+ book = vf->subclass_books[class][cval & csub]; |
|
| 1179 | 1179 |
|
| 1180 | 1180 |
AV_DEBUG("book %d Cbits %d cval %d bits:%d \n", book, cbits, cval, get_bits_count(gb));
|
| 1181 | 1181 |
|