]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit 'f34b152eb7b7e8d2aee57c710a072cf74173fbe1'
authorHendrik Leppkes <h.leppkes@gmail.com>
Tue, 18 Aug 2015 07:09:55 +0000 (09:09 +0200)
committerHendrik Leppkes <h.leppkes@gmail.com>
Tue, 18 Aug 2015 07:09:55 +0000 (09:09 +0200)
* commit 'f34b152eb7b7e8d2aee57c710a072cf74173fbe1':
  libfdk-aacdec: Clean up properly if the init fails

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
1  2 
libavcodec/libfdk-aacdec.c

index c25bd5e737cabf79581f5779cf8e20140655de36,5ac8fb7cb71c33a8b385f2afa92471a29032ecef..420d91f222ac15180569f59e0d130c94c400124c
@@@ -2,7 -2,7 +2,7 @@@
   * AAC decoder wrapper
   * Copyright (c) 2012 Martin Storsjo
   *
 - * This file is part of Libav.
 + * This file is part of FFmpeg.
   *
   * Permission to use, copy, modify, and/or distribute this software for any
   * purpose with or without fee is hereby granted, provided that the above
@@@ -44,7 -44,7 +44,7 @@@ typedef struct FDKAACDecContext 
      uint8_t *decoder_buffer;
      int decoder_buffer_size;
      uint8_t *anc_buffer;
 -    enum ConcealMethod conceal_method;
 +    int conceal_method;
      int drc_level;
      int drc_boost;
      int drc_heavy;
@@@ -199,8 -199,8 +199,8 @@@ static av_cold int fdk_aac_decode_close
  
      if (s->handle)
          aacDecoder_Close(s->handle);
 -    av_free(s->decoder_buffer);
 -    av_free(s->anc_buffer);
 +    av_freep(&s->decoder_buffer);
 +    av_freep(&s->anc_buffer);
  
      return 0;
  }
@@@ -256,13 -256,11 +256,11 @@@ static av_cold int fdk_aac_decode_init(
                 s->anc_buffer = av_malloc(DMX_ANC_BUFFSIZE);
                 if (!s->anc_buffer) {
                     av_log(avctx, AV_LOG_ERROR, "Unable to allocate ancillary buffer for the decoder\n");
-                    ret = AVERROR(ENOMEM);
-                    goto fail;
+                    return AVERROR(ENOMEM);
                 }
                 if (aacDecoder_AncDataInit(s->handle, s->anc_buffer, DMX_ANC_BUFFSIZE)) {
                     av_log(avctx, AV_LOG_ERROR, "Unable to register downmix ancillary buffer in the decoder\n");
-                    ret = AVERROR_UNKNOWN;
-                    goto fail;
+                    return AVERROR_UNKNOWN;
                 }
              }
          }
  
      s->decoder_buffer_size = DECODER_BUFFSIZE * DECODER_MAX_CHANNELS;
      s->decoder_buffer = av_malloc(s->decoder_buffer_size);
-     if (!s->decoder_buffer) {
-         ret = AVERROR(ENOMEM);
-         goto fail;
-     }
+     if (!s->decoder_buffer)
+         return AVERROR(ENOMEM);
  
      return 0;
- fail:
-     fdk_aac_decode_close(avctx);
-     return ret;
  }
  
  static int fdk_aac_decode_frame(AVCodecContext *avctx, void *data,
          goto end;
      frame->nb_samples = avctx->frame_size;
  
 -    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
 -        av_log(avctx, AV_LOG_ERROR, "ff_get_buffer() failed\n");
 +    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
          goto end;
 -    }
 +
      memcpy(frame->extended_data[0], s->decoder_buffer,
             avctx->channels * avctx->frame_size *
             av_get_bytes_per_sample(avctx->sample_fmt));
@@@ -388,4 -382,6 +381,6 @@@ AVCodec ff_libfdk_aac_decoder = 
      .flush          = fdk_aac_decode_flush,
      .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF,
      .priv_class     = &fdk_aac_dec_class,
+     .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
+                       FF_CODEC_CAP_INIT_CLEANUP,
  };