History

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

Michael Niedermayer committed 14 years ago

Commit af3fe432 parents 7bc6631 2b8dd374 files · +48 −54Browse files

Unified · Split

4 files
  1. doc/APIchanges +1 −1
  2. ffmpeg_opt.c +28 −27
  3. libavcodec/atrac3.c +15 −22
  4. libavutil/version.h +4 −4
doc/APIchanges+1−1
@@ -6,7 +6,7 @@ libavcodec: 2012-01-27 · 5 unmodified lines
66 libavdevice: 2011-04-18
77 libavfilter: 2012-06-22
88 libavformat: 2012-01-27
9−libavresample: 2012-04-24
9+libavresample: 2012-10-05
1010 libpostproc: 2011-04-18
1111 libswresample: 2011-09-19
1212 libswscale: 2011-06-20
ffmpeg_opt.c+28−27
@@ -913,8 +913,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e · 912 unmodified lines
913913 char *bsf = NULL, *next, *codec_tag = NULL;
914914 AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
915915 double qscale = -1;
916− char *buf = NULL, *arg = NULL, *preset = NULL;
917− AVIOContext *s = NULL;
918916
919917 if (!st) {
920918 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 · 15 unmodified lines
936934 st->codec->codec_type = type;
937935 choose_encoder(o, oc, ost);
938936 if (ost->enc) {
937+ AVIOContext *s = NULL;
938+ char *buf = NULL, *arg = NULL, *preset = NULL;
939+
939940 ost->opts = filter_codec_opts(codec_opts, ost->enc->id, oc, st, ost->enc);
941+
942+ MATCH_PER_STREAM_OPT(presets, str, preset, oc, st);
943+ if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) {
944+ do {
945+ buf = get_line(s);
946+ if (!buf[0] || buf[0] == '#') {
947+ av_free(buf);
948+ continue;
949+ }
950+ if (!(arg = strchr(buf, '='))) {
951+ av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n");
952+ exit(1);
953+ }
954+ *arg++ = 0;
955+ av_dict_set(&ost->opts, buf, arg, AV_DICT_DONT_OVERWRITE);
956+ av_free(buf);
957+ } while (!s->eof_reached);
958+ avio_close(s);
959+ }
960+ if (ret) {
961+ av_log(NULL, AV_LOG_FATAL,
962+ "Preset %s specified for stream %d:%d, but could not be opened.\n",
963+ preset, ost->file_index, ost->index);
964+ exit(1);
965+ }
940966 }
941967
942968 avcodec_get_context_defaults3(st->codec, ost->enc);
943969 st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy
944970
945− MATCH_PER_STREAM_OPT(presets, str, preset, oc, st);
946− if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) {
947− do {
948− buf = get_line(s);
949− if (!buf[0] || buf[0] == '#') {
950− av_free(buf);
951− continue;
952− }
953− if (!(arg = strchr(buf, '='))) {
954− av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n");
955− exit(1);
956− }
957− *arg++ = 0;
958− av_dict_set(&ost->opts, buf, arg, AV_DICT_DONT_OVERWRITE);
959− av_free(buf);
960− } while (!s->eof_reached);
961− avio_close(s);
962− }
963− if (ret) {
964− av_log(NULL, AV_LOG_FATAL,
965− "Preset %s specified for stream %d:%d, but could not be opened.\n",
966− preset, ost->file_index, ost->index);
967− exit(1);
968− }
969−
970971 ost->max_frames = INT64_MAX;
971972 MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);
972973
libavcodec/atrac3.c+15−22
@@ -91,7 +91,6 @@ typedef struct ATRAC3Context { · 90 unmodified lines
9191 //@{
9292 /** stream data */
9393 int coding_mode;
94− int sample_rate;
9594
9695 ChannelUnit *units;
9796 //@}
@@ -178,19 +177,16 @@ static int decode_bytes(const uint8_t *input, uint8_t *out, int bytes) · 80 unmodified lines
178177
179178 static av_cold void init_atrac3_window(void)
180179 {
181− float enc_window[256];
182− int i;
180+ int i, j;
183181
184182 /* generate the mdct window, for details see
185183 * http://wiki.multimedia.cx/index.php?title=RealAudio_atrc#Windows */
186− for (i = 0; i < 256; i++)
187− enc_window[i] = (sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0) * 0.5;
188−
189− for (i = 0; i < 256; i++) {
190− mdct_window[i] = enc_window[i] /
191− (enc_window[ i] * enc_window[ i] +
192− enc_window[255 - i] * enc_window[255 - i]);
193− mdct_window[511 - i] = mdct_window[i];
184+ for (i = 0, j = 255; i < 128; i++, j--) {
185+ float wi = sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0;
186+ float wj = sin(((j + 0.5) / 256.0 - 0.5) * M_PI) + 1.0;
187+ float w = 0.5 * (wi * wi + wj * wj);
188+ mdct_window[i] = mdct_window[511 - i] = wi / w;
189+ mdct_window[j] = mdct_window[511 - j] = wj / w;
194190 }
195191 }
196192
@@ -315,13 +311,13 @@ static int decode_spectrum(GetBitContext *gb, float *output) · 118 unmodified lines
315311 output[first] = mantissas[j] * scale_factor;
316312 } else {
317313 /* this subband was not coded, so zero the entire subband */
318− memset(output + first, 0, subband_size * sizeof(float));
314+ memset(output + first, 0, subband_size * sizeof(*output));
319315 }
320316 }
321317
322318 /* clear the subbands that were not coded */
323319 first = subband_tab[i];
324− memset(output + first, 0, (SAMPLES_PER_FRAME - first) * sizeof(float));
320+ memset(output + first, 0, (SAMPLES_PER_FRAME - first) * sizeof(*output));
325321 return num_subbands;
326322 }
327323
@@ -498,7 +494,7 @@ static void gain_compensate_and_overlap(float *input, float *prev, · 170 unmodified lines
498494 }
499495
500496 /* Delay for the overlapping part. */
501− memcpy(prev, &input[256], 256 * sizeof(float));
497+ memcpy(prev, &input[256], 256 * sizeof(*prev));
502498 }
503499
504500 /*
@@ -688,7 +684,7 @@ static int decode_channel_sound_unit(ATRAC3Context *q, GetBitContext *gb, · 183 unmodified lines
688684 if (band <= num_bands)
689685 imlt(q, &snd->spectrum[band * 256], snd->imdct_buf, band & 1);
690686 else
691− memset(snd->imdct_buf, 0, 512 * sizeof(float));
687+ memset(snd->imdct_buf, 0, 512 * sizeof(*snd->imdct_buf));
692688
693689 /* gain compensation and overlapping */
694690 gain_compensate_and_overlap(snd->imdct_buf,
@@ -746,7 +742,8 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf, · 51 unmodified lines
746742 init_get_bits(&q->gb, ptr1, avctx->block_align * 8);
747743
748744 /* Fill the Weighting coeffs delay buffer */
749− memmove(q->weighting_delay, &q->weighting_delay[2], 4 * sizeof(int));
745+ memmove(q->weighting_delay, &q->weighting_delay[2],
746+ 4 * sizeof(*q->weighting_delay));
750747 q->weighting_delay[4] = get_bits1(&q->gb);
751748 q->weighting_delay[5] = get_bits(&q->gb, 3);
752749
@@ -872,9 +869,6 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 119 unmodified lines
872869 const uint8_t *edata_ptr = avctx->extradata;
873870 ATRAC3Context *q = avctx->priv_data;
874871
875− /* Take data from the AVCodecContext (RM container). */
876− q->sample_rate = avctx->sample_rate;
877−
878872 if (avctx->channels <= 0 || avctx->channels > 2) {
879873 av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n");
880874 return AVERROR(EINVAL);
@@ -954,8 +948,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 73 unmodified lines
954948 if (avctx->block_align >= UINT_MAX / 2)
955949 return AVERROR(EINVAL);
956950
957− q->decoded_bytes_buffer = av_mallocz(avctx->block_align +
958− (4 - avctx->block_align % 4) +
951+ q->decoded_bytes_buffer = av_mallocz(FFALIGN(avctx->block_align, 4) +
959952 FF_INPUT_BUFFER_PADDING_SIZE);
960953 if (q->decoded_bytes_buffer == NULL)
961954 return AVERROR(ENOMEM);
@@ -986,7 +979,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 24 unmodified lines
986979 avpriv_float_dsp_init(&q->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
987980 ff_fmt_convert_init(&q->fmt_conv, avctx);
988981
989− q->units = av_mallocz(sizeof(ChannelUnit) * avctx->channels);
982+ q->units = av_mallocz(sizeof(*q->units) * avctx->channels);
990983 if (!q->units) {
991984 atrac3_decode_close(avctx);
992985 return AVERROR(ENOMEM);
libavutil/version.h+4−4
@@ -118,16 +118,16 @@ · 117 unmodified lines
118118 #define FF_API_OLD_TC_ADJUST_FRAMENUM (LIBAVUTIL_VERSION_MAJOR < 52)
119119 #endif
120120 #ifndef FF_API_PIX_FMT
121−#define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 52)
121+#define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 53)
122122 #endif
123123 #ifndef FF_API_CONTEXT_SIZE
124−#define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 52)
124+#define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 53)
125125 #endif
126126 #ifndef FF_API_PIX_FMT_DESC
127−#define FF_API_PIX_FMT_DESC (LIBAVUTIL_VERSION_MAJOR < 52)
127+#define FF_API_PIX_FMT_DESC (LIBAVUTIL_VERSION_MAJOR < 53)
128128 #endif
129129 #ifndef FF_API_AV_REVERSE
130−#define FF_API_AV_REVERSE (LIBAVUTIL_VERSION_MAJOR < 52)
130+#define FF_API_AV_REVERSE (LIBAVUTIL_VERSION_MAJOR < 53)
131131 #endif
132132
133133 /**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t