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
6libavdevice: 2011-04-186libavdevice: 2011-04-18
7libavfilter: 2012-06-227libavfilter: 2012-06-22
8libavformat: 2012-01-278libavformat: 2012-01-27
9libavresample: 2012-04-249libavresample: 2012-10-05
10libpostproc: 2011-04-1810libpostproc: 2011-04-18
11libswresample: 2011-09-1911libswresample: 2011-09-19
12libswscale: 2011-06-2012libswscale: 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
913 char *bsf = NULL, *next, *codec_tag = NULL;913 char *bsf = NULL, *next, *codec_tag = NULL;
914 AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;914 AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
915 double qscale = -1;915 double qscale = -1;
916 char *buf = NULL, *arg = NULL, *preset = NULL;
917 AVIOContext *s = NULL;
918 916
919 if (!st) {917 if (!st) {
920 av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n");918 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
936 st->codec->codec_type = type;934 st->codec->codec_type = type;
937 choose_encoder(o, oc, ost);935 choose_encoder(o, oc, ost);
938 if (ost->enc) {936 if (ost->enc) {
937 AVIOContext *s = NULL;
938 char *buf = NULL, *arg = NULL, *preset = NULL;
939
939 ost->opts = filter_codec_opts(codec_opts, ost->enc->id, oc, st, ost->enc);940 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 }
940 }966 }
941 967
942 avcodec_get_context_defaults3(st->codec, ost->enc);968 avcodec_get_context_defaults3(st->codec, ost->enc);
943 st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy969 st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy
944 970
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
970 ost->max_frames = INT64_MAX;971 ost->max_frames = INT64_MAX;
971 MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);972 MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st);
972 973
libavcodec/atrac3.c+15−22
@@ -91,7 +91,6 @@ typedef struct ATRAC3Context { · 90 unmodified lines
91 //@{91 //@{
92 /** stream data */92 /** stream data */
93 int coding_mode;93 int coding_mode;
94 int sample_rate;
95 94
96 ChannelUnit *units;95 ChannelUnit *units;
97 //@}96 //@}
@@ -178,19 +177,16 @@ static int decode_bytes(const uint8_t *input, uint8_t *out, int bytes) · 80 unmodified lines
178 177
179static av_cold void init_atrac3_window(void)178static av_cold void init_atrac3_window(void)
180{179{
181 float enc_window[256];180 int i, j;
182 int i;
183 181
184 /* generate the mdct window, for details see182 /* generate the mdct window, for details see
185 * http://wiki.multimedia.cx/index.php?title=RealAudio_atrc#Windows */183 * http://wiki.multimedia.cx/index.php?title=RealAudio_atrc#Windows */
186 for (i = 0; i < 256; i++)184 for (i = 0, j = 255; i < 128; i++, j--) {
187 enc_window[i] = (sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0) * 0.5;185 float wi = sin(((i + 0.5) / 256.0 - 0.5) * M_PI) + 1.0;
188 186 float wj = sin(((j + 0.5) / 256.0 - 0.5) * M_PI) + 1.0;
189 for (i = 0; i < 256; i++) {187 float w = 0.5 * (wi * wi + wj * wj);
190 mdct_window[i] = enc_window[i] /188 mdct_window[i] = mdct_window[511 - i] = wi / w;
191 (enc_window[ i] * enc_window[ i] +189 mdct_window[j] = mdct_window[511 - j] = wj / w;
192 enc_window[255 - i] * enc_window[255 - i]);
193 mdct_window[511 - i] = mdct_window[i];
194 }190 }
195}191}
196 192
@@ -315,13 +311,13 @@ static int decode_spectrum(GetBitContext *gb, float *output) · 118 unmodified lines
315 output[first] = mantissas[j] * scale_factor;311 output[first] = mantissas[j] * scale_factor;
316 } else {312 } else {
317 /* this subband was not coded, so zero the entire subband */313 /* 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));
319 }315 }
320 }316 }
321 317
322 /* clear the subbands that were not coded */318 /* clear the subbands that were not coded */
323 first = subband_tab[i];319 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));
325 return num_subbands;321 return num_subbands;
326}322}
327 323
@@ -498,7 +494,7 @@ static void gain_compensate_and_overlap(float *input, float *prev, · 170 unmodified lines
498 }494 }
499 495
500 /* Delay for the overlapping part. */496 /* Delay for the overlapping part. */
501 memcpy(prev, &input[256], 256 * sizeof(float));497 memcpy(prev, &input[256], 256 * sizeof(*prev));
502}498}
503 499
504/*500/*
@@ -688,7 +684,7 @@ static int decode_channel_sound_unit(ATRAC3Context *q, GetBitContext *gb, · 183 unmodified lines
688 if (band <= num_bands)684 if (band <= num_bands)
689 imlt(q, &snd->spectrum[band * 256], snd->imdct_buf, band & 1);685 imlt(q, &snd->spectrum[band * 256], snd->imdct_buf, band & 1);
690 else686 else
691 memset(snd->imdct_buf, 0, 512 * sizeof(float));687 memset(snd->imdct_buf, 0, 512 * sizeof(*snd->imdct_buf));
692 688
693 /* gain compensation and overlapping */689 /* gain compensation and overlapping */
694 gain_compensate_and_overlap(snd->imdct_buf,690 gain_compensate_and_overlap(snd->imdct_buf,
@@ -746,7 +742,8 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf, · 51 unmodified lines
746 init_get_bits(&q->gb, ptr1, avctx->block_align * 8);742 init_get_bits(&q->gb, ptr1, avctx->block_align * 8);
747 743
748 /* Fill the Weighting coeffs delay buffer */744 /* 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));
750 q->weighting_delay[4] = get_bits1(&q->gb);747 q->weighting_delay[4] = get_bits1(&q->gb);
751 q->weighting_delay[5] = get_bits(&q->gb, 3);748 q->weighting_delay[5] = get_bits(&q->gb, 3);
752 749
@@ -872,9 +869,6 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 119 unmodified lines
872 const uint8_t *edata_ptr = avctx->extradata;869 const uint8_t *edata_ptr = avctx->extradata;
873 ATRAC3Context *q = avctx->priv_data;870 ATRAC3Context *q = avctx->priv_data;
874 871
875 /* Take data from the AVCodecContext (RM container). */
876 q->sample_rate = avctx->sample_rate;
877
878 if (avctx->channels <= 0 || avctx->channels > 2) {872 if (avctx->channels <= 0 || avctx->channels > 2) {
879 av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n");873 av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n");
880 return AVERROR(EINVAL);874 return AVERROR(EINVAL);
@@ -954,8 +948,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 73 unmodified lines
954 if (avctx->block_align >= UINT_MAX / 2)948 if (avctx->block_align >= UINT_MAX / 2)
955 return AVERROR(EINVAL);949 return AVERROR(EINVAL);
956 950
957 q->decoded_bytes_buffer = av_mallocz(avctx->block_align +951 q->decoded_bytes_buffer = av_mallocz(FFALIGN(avctx->block_align, 4) +
958 (4 - avctx->block_align % 4) +
959 FF_INPUT_BUFFER_PADDING_SIZE);952 FF_INPUT_BUFFER_PADDING_SIZE);
960 if (q->decoded_bytes_buffer == NULL)953 if (q->decoded_bytes_buffer == NULL)
961 return AVERROR(ENOMEM);954 return AVERROR(ENOMEM);
@@ -986,7 +979,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 24 unmodified lines
986 avpriv_float_dsp_init(&q->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);979 avpriv_float_dsp_init(&q->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
987 ff_fmt_convert_init(&q->fmt_conv, avctx);980 ff_fmt_convert_init(&q->fmt_conv, avctx);
988 981
989 q->units = av_mallocz(sizeof(ChannelUnit) * avctx->channels);982 q->units = av_mallocz(sizeof(*q->units) * avctx->channels);
990 if (!q->units) {983 if (!q->units) {
991 atrac3_decode_close(avctx);984 atrac3_decode_close(avctx);
992 return AVERROR(ENOMEM);985 return AVERROR(ENOMEM);
libavutil/version.h+4−4
@@ -118,16 +118,16 @@ · 117 unmodified lines
118#define FF_API_OLD_TC_ADJUST_FRAMENUM (LIBAVUTIL_VERSION_MAJOR < 52)118#define FF_API_OLD_TC_ADJUST_FRAMENUM (LIBAVUTIL_VERSION_MAJOR < 52)
119#endif119#endif
120#ifndef FF_API_PIX_FMT120#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)
122#endif122#endif
123#ifndef FF_API_CONTEXT_SIZE123#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)
125#endif125#endif
126#ifndef FF_API_PIX_FMT_DESC126#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)
128#endif128#endif
129#ifndef FF_API_AV_REVERSE129#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)
131#endif131#endif
132 132
133/**133/**

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