Merge commit 'e3db34291f4401a16f6ac92721617a9f33cd4c31'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 13 Feb 2013 10:36:28 +0000 (11:36 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 13 Feb 2013 10:39:05 +0000 (11:39 +0100)
* commit 'e3db34291f4401a16f6ac92721617a9f33cd4c31':
  amrnb: decode directly to the user-provided AVFrame
  als: decode directly to the user-provided AVFrame
  alac: decode directly to the user-provided AVFrame
  adxenc: alloc/free coded_frame instead of keeping it in the ADXContext
  adx: decode directly to the user-provided AVFrame

Conflicts:
libavcodec/alsdec.c
libavcodec/amrnbdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/adx.h
libavcodec/adxdec.c
libavcodec/adxenc.c
libavcodec/alac.c
libavcodec/alsdec.c
libavcodec/amrnbdec.c

Simple merge
Simple merge
Simple merge
@@@ -300,9 -293,9 +299,9 @@@ static int decode_element(AVCodecContex
          return AVERROR_INVALIDDATA;
      }
      alac->nb_samples = output_samples;
 -    if (alac->sample_size > 16) {
 +    if (alac->direct_output) {
          for (ch = 0; ch < channels; ch++)
-             alac->output_samples_buffer[ch] = (int32_t *)alac->frame.extended_data[ch_index + ch];
+             alac->output_samples_buffer[ch] = (int32_t *)frame->extended_data[ch_index + ch];
      }
  
      if (is_compressed) {
          }}
          break;
      }
-             int16_t *outbuffer = ((int16_t *)alac->frame.extended_data[0]) + ch_index;
 +    }else{
 +        switch(alac->sample_size) {
 +        case 16: {
-             int32_t *outbuffer = ((int32_t *)alac->frame.extended_data[0]) + ch_index;
++            int16_t *outbuffer = ((int16_t *)frame->extended_data[0]) + ch_index;
 +            for (i = 0; i < alac->nb_samples; i++) {
 +                for (ch = 0; ch < channels; ch++)
 +                    *outbuffer++ = alac->output_samples_buffer[ch][i];
 +                outbuffer += alac->channels - channels;
 +            }
 +            }
 +            break;
 +        case 24: {
-             int32_t *outbuffer = ((int32_t *)alac->frame.extended_data[0]) + ch_index;
++            int32_t *outbuffer = ((int32_t *)frame->extended_data[0]) + ch_index;
 +            for (i = 0; i < alac->nb_samples; i++) {
 +                for (ch = 0; ch < channels; ch++)
 +                    *outbuffer++ = alac->output_samples_buffer[ch][i] << 8;
 +                outbuffer += alac->channels - channels;
 +            }
 +            }
 +            break;
 +        case 32: {
++            int32_t *outbuffer = ((int32_t *)frame->extended_data[0]) + ch_index;
 +            for (i = 0; i < alac->nb_samples; i++) {
 +                for (ch = 0; ch < channels; ch++)
 +                    *outbuffer++ = alac->output_samples_buffer[ch][i];
 +                outbuffer += alac->channels - channels;
 +            }
 +            }
 +            break;
 +        }
 +    }
  
      return 0;
  }
@@@ -1479,26 -1461,20 +1479,26 @@@ static int decode_frame(AVCodecContext 
      ctx->frame_id++;
  
      /* get output buffer */
-     ctx->frame.nb_samples = ctx->cur_frame_length;
-     if ((ret = ff_get_buffer(avctx, &ctx->frame)) < 0) {
+     frame->nb_samples = ctx->cur_frame_length;
+     if ((ret = ff_get_buffer(avctx, frame)) < 0) {
 -        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
 +        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed.\n");
          return ret;
      }
  
      // transform decoded frame into output format
 -    #define INTERLEAVE_OUTPUT(bps)                                 \
 -    {                                                              \
 -        int##bps##_t *dest = (int##bps##_t*)frame->data[0];        \
 -        shift = bps - ctx->avctx->bits_per_raw_sample;             \
 -        for (sample = 0; sample < ctx->cur_frame_length; sample++) \
 -            for (c = 0; c < avctx->channels; c++)                  \
 -                *dest++ = ctx->raw_samples[c][sample] << shift;    \
 +    #define INTERLEAVE_OUTPUT(bps)                                                   \
 +    {                                                                                \
-         int##bps##_t *dest = (int##bps##_t*)ctx->frame.data[0];                      \
++        int##bps##_t *dest = (int##bps##_t*)frame->data[0];                          \
 +        shift = bps - ctx->avctx->bits_per_raw_sample;                               \
 +        if (!ctx->cs_switch) {                                                       \
 +            for (sample = 0; sample < ctx->cur_frame_length; sample++)               \
 +                for (c = 0; c < avctx->channels; c++)                                \
 +                    *dest++ = ctx->raw_samples[c][sample] << shift;                  \
 +        } else {                                                                     \
 +            for (sample = 0; sample < ctx->cur_frame_length; sample++)               \
 +                for (c = 0; c < avctx->channels; c++)                                \
 +                    *dest++ = ctx->raw_samples[sconf->chan_pos[c]][sample] << shift; \
 +        }                                                                            \
      }
  
      if (ctx->avctx->bits_per_raw_sample <= 16) {
@@@ -185,14 -176,6 +184,11 @@@ static av_cold int amrnb_decode_init(AV
      for (i = 0; i < 4; i++)
          p->prediction_error[i] = MIN_ENERGY;
  
-     avcodec_get_frame_defaults(&p->avframe);
-     avctx->coded_frame = &p->avframe;
 +    ff_acelp_filter_init(&p->acelpf_ctx);
 +    ff_acelp_vectors_init(&p->acelpv_ctx);
 +    ff_celp_filter_init(&p->celpf_ctx);
 +    ff_celp_math_init(&p->celpm_ctx);
 +
      return 0;
  }
  
@@@ -1075,11 -1052,10 +1072,10 @@@ static int amrnb_decode_frame(AVCodecCo
       * for fixed_gain_smooth.
       * The specification has an incorrect formula: the reference decoder uses
       * qbar(n-1) rather than qbar(n) in section 6.1(4) equation 71. */
 -    ff_weighted_vector_sumf(p->lsf_avg, p->lsf_avg, p->lsf_q[3],
 +    p->acelpv_ctx.weighted_vector_sumf(p->lsf_avg, p->lsf_avg, p->lsf_q[3],
                              0.84, 0.16, LP_FILTER_ORDER);
  
-     *got_frame_ptr   = 1;
-     *(AVFrame *)data = p->avframe;
+     *got_frame_ptr = 1;
  
      /* return the amount of bytes consumed if everything was OK */
      return frame_sizes_nb[p->cur_frame_mode] + 1; // +7 for rounding and +8 for TOC