Merge commit '2b8dd371e4d276ca0d342e82b8b4cc281be0630a'

* commit '2b8dd371e4d276ca0d342e82b8b4cc281be0630a':
  lavu: postpone recent deprecations until the next major bump
  APIchanges: update lavr bump date
  avconv: only apply presets when we have an encoder.
  atrac3: replace a calculation with FFALIGN()
  atrac3: remove unused ATRAC3Context field, sample_rate
  atrac3: use sizeof(variable) instead of sizeof(type)
  atrac3: simplify MDCT window calculation

Conflicts:
	doc/APIchanges

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-10-23 13:05:52 +02:00
commit af3fe43d84
4 changed files with 48 additions and 54 deletions

View File

@ -6,7 +6,7 @@ libavcodec: 2012-01-27
libavdevice: 2011-04-18 libavdevice: 2011-04-18
libavfilter: 2012-06-22 libavfilter: 2012-06-22
libavformat: 2012-01-27 libavformat: 2012-01-27
libavresample: 2012-04-24 libavresample: 2012-10-05
libpostproc: 2011-04-18 libpostproc: 2011-04-18
libswresample: 2011-09-19 libswresample: 2011-09-19
libswscale: 2011-06-20 libswscale: 2011-06-20

View File

@ -913,8 +913,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
char *bsf = NULL, *next, *codec_tag = NULL; char *bsf = NULL, *next, *codec_tag = NULL;
AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL; AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
double qscale = -1; double qscale = -1;
char *buf = NULL, *arg = NULL, *preset = NULL;
AVIOContext *s = NULL;
if (!st) { if (!st) {
av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n"); av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n");
@ -936,37 +934,40 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
st->codec->codec_type = type; st->codec->codec_type = type;
choose_encoder(o, oc, ost); choose_encoder(o, oc, ost);
if (ost->enc) { if (ost->enc) {
AVIOContext *s = NULL;
char *buf = NULL, *arg = NULL, *preset = NULL;
ost->opts = filter_codec_opts(codec_opts, ost->enc->id, oc, st, ost->enc); ost->opts = filter_codec_opts(codec_opts, ost->enc->id, oc, st, ost->enc);
MATCH_PER_STREAM_OPT(presets, str, preset, oc, st);
if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) {
do {
buf = get_line(s);
if (!buf[0] || buf[0] == '#') {
av_free(buf);
continue;
}
if (!(arg = strchr(buf, '='))) {
av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n");
exit(1);
}
*arg++ = 0;
av_dict_set(&ost->opts, buf, arg, AV_DICT_DONT_OVERWRITE);
av_free(buf);
} while (!s->eof_reached);
avio_close(s);
}
if (ret) {
av_log(NULL, AV_LOG_FATAL,
"Preset %s specified for stream %d:%d, but could not be opened.\n",
preset, ost->file_index, ost->index);
exit(1);
}
} }
avcodec_get_context_defaults3(st->codec, ost->enc); avcodec_get_context_defaults3(st->codec, ost->enc);
st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy
MATCH_PER_STREAM_OPT(presets, str, preset, oc, st);
if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) {
do {
buf = get_line(s);
if (!buf[0] || buf[0] == '#') {
av_free(buf);
continue;
}
if (!(arg = strchr(buf, '='))) {
av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n");
exit(1);
}
*arg++ = 0;
av_dict_set(&ost->opts, buf, arg, AV_DICT_DONT_OVERWRITE);
av_free(buf);
} while (!s->eof_reached);
avio_close(s);
}
if (ret) {
av_log(NULL, AV_LOG_FATAL,
"Preset %s specified for stream %d:%d, but could not be opened.\n",
preset, ost->file_index, ost->index);
exit(1);
}
ost->max_frames = INT64_MAX; ost->max_frames = INT64_MAX;
MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st); MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);

View File

@ -91,7 +91,6 @@ typedef struct ATRAC3Context {
//@{ //@{
/** stream data */ /** stream data */
int coding_mode; int coding_mode;
int sample_rate;
ChannelUnit *units; ChannelUnit *units;
//@} //@}
@ -178,19 +177,16 @@ static int decode_bytes(const uint8_t *input, uint8_t *out, int bytes)
static av_cold void init_atrac3_window(void) static av_cold void init_atrac3_window(void)
{ {
float enc_window[256]; int i, j;
int i;
/* generate the mdct window, for details see /* generate the mdct window, for details see
* http://wiki.multimedia.cx/index.php?title=RealAudio_atrc#Windows */ * http://wiki.multimedia.cx/index.php?title=RealAudio_atrc#Windows */
for (i = 0; i < 256; i++) for (i = 0, j = 255; i < 128; i++, j--) {
enc_window[i] = (sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0) * 0.5; float wi = sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0;
float wj = sin(((j + 0.5) / 256.0 - 0.5) * M_PI) + 1.0;
for (i = 0; i < 256; i++) { float w = 0.5 * (wi * wi + wj * wj);
mdct_window[i] = enc_window[i] / mdct_window[i] = mdct_window[511 - i] = wi / w;
(enc_window[ i] * enc_window[ i] + mdct_window[j] = mdct_window[511 - j] = wj / w;
enc_window[255 - i] * enc_window[255 - i]);
mdct_window[511 - i] = mdct_window[i];
} }
} }
@ -315,13 +311,13 @@ static int decode_spectrum(GetBitContext *gb, float *output)
output[first] = mantissas[j] * scale_factor; output[first] = mantissas[j] * scale_factor;
} else { } else {
/* this subband was not coded, so zero the entire subband */ /* this subband was not coded, so zero the entire subband */
memset(output + first, 0, subband_size * sizeof(float)); memset(output + first, 0, subband_size * sizeof(*output));
} }
} }
/* clear the subbands that were not coded */ /* clear the subbands that were not coded */
first = subband_tab[i]; first = subband_tab[i];
memset(output + first, 0, (SAMPLES_PER_FRAME - first) * sizeof(float)); memset(output + first, 0, (SAMPLES_PER_FRAME - first) * sizeof(*output));
return num_subbands; return num_subbands;
} }
@ -498,7 +494,7 @@ static void gain_compensate_and_overlap(float *input, float *prev,
} }
/* Delay for the overlapping part. */ /* Delay for the overlapping part. */
memcpy(prev, &input[256], 256 * sizeof(float)); memcpy(prev, &input[256], 256 * sizeof(*prev));
} }
/* /*
@ -688,7 +684,7 @@ static int decode_channel_sound_unit(ATRAC3Context *q, GetBitContext *gb,
if (band <= num_bands) if (band <= num_bands)
imlt(q, &snd->spectrum[band * 256], snd->imdct_buf, band & 1); imlt(q, &snd->spectrum[band * 256], snd->imdct_buf, band & 1);
else else
memset(snd->imdct_buf, 0, 512 * sizeof(float)); memset(snd->imdct_buf, 0, 512 * sizeof(*snd->imdct_buf));
/* gain compensation and overlapping */ /* gain compensation and overlapping */
gain_compensate_and_overlap(snd->imdct_buf, gain_compensate_and_overlap(snd->imdct_buf,
@ -746,7 +742,8 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf,
init_get_bits(&q->gb, ptr1, avctx->block_align * 8); init_get_bits(&q->gb, ptr1, avctx->block_align * 8);
/* Fill the Weighting coeffs delay buffer */ /* Fill the Weighting coeffs delay buffer */
memmove(q->weighting_delay, &q->weighting_delay[2], 4 * sizeof(int)); memmove(q->weighting_delay, &q->weighting_delay[2],
4 * sizeof(*q->weighting_delay));
q->weighting_delay[4] = get_bits1(&q->gb); q->weighting_delay[4] = get_bits1(&q->gb);
q->weighting_delay[5] = get_bits(&q->gb, 3); q->weighting_delay[5] = get_bits(&q->gb, 3);
@ -872,9 +869,6 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
const uint8_t *edata_ptr = avctx->extradata; const uint8_t *edata_ptr = avctx->extradata;
ATRAC3Context *q = avctx->priv_data; ATRAC3Context *q = avctx->priv_data;
/* Take data from the AVCodecContext (RM container). */
q->sample_rate = avctx->sample_rate;
if (avctx->channels <= 0 || avctx->channels > 2) { if (avctx->channels <= 0 || avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n"); av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);
@ -954,8 +948,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
if (avctx->block_align >= UINT_MAX / 2) if (avctx->block_align >= UINT_MAX / 2)
return AVERROR(EINVAL); return AVERROR(EINVAL);
q->decoded_bytes_buffer = av_mallocz(avctx->block_align + q->decoded_bytes_buffer = av_mallocz(FFALIGN(avctx->block_align, 4) +
(4 - avctx->block_align % 4) +
FF_INPUT_BUFFER_PADDING_SIZE); FF_INPUT_BUFFER_PADDING_SIZE);
if (q->decoded_bytes_buffer == NULL) if (q->decoded_bytes_buffer == NULL)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
@ -986,7 +979,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
avpriv_float_dsp_init(&q->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); avpriv_float_dsp_init(&q->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
ff_fmt_convert_init(&q->fmt_conv, avctx); ff_fmt_convert_init(&q->fmt_conv, avctx);
q->units = av_mallocz(sizeof(ChannelUnit) * avctx->channels); q->units = av_mallocz(sizeof(*q->units) * avctx->channels);
if (!q->units) { if (!q->units) {
atrac3_decode_close(avctx); atrac3_decode_close(avctx);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);

View File

@ -118,16 +118,16 @@
#define FF_API_OLD_TC_ADJUST_FRAMENUM (LIBAVUTIL_VERSION_MAJOR < 52) #define FF_API_OLD_TC_ADJUST_FRAMENUM (LIBAVUTIL_VERSION_MAJOR < 52)
#endif #endif
#ifndef FF_API_PIX_FMT #ifndef FF_API_PIX_FMT
#define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 52) #define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 53)
#endif #endif
#ifndef FF_API_CONTEXT_SIZE #ifndef FF_API_CONTEXT_SIZE
#define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 52) #define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 53)
#endif #endif
#ifndef FF_API_PIX_FMT_DESC #ifndef FF_API_PIX_FMT_DESC
#define FF_API_PIX_FMT_DESC (LIBAVUTIL_VERSION_MAJOR < 52) #define FF_API_PIX_FMT_DESC (LIBAVUTIL_VERSION_MAJOR < 53)
#endif #endif
#ifndef FF_API_AV_REVERSE #ifndef FF_API_AV_REVERSE
#define FF_API_AV_REVERSE (LIBAVUTIL_VERSION_MAJOR < 52) #define FF_API_AV_REVERSE (LIBAVUTIL_VERSION_MAJOR < 53)
#endif #endif
/** /**