diff mbox series

[FFmpeg-devel,1/3] avcodec/adpcmenc: Add FF_CODEC_CAP_INIT_CLEANUP

Message ID 1589800269-30359-1-git-send-email-lance.lmwang@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/3] avcodec/adpcmenc: Add FF_CODEC_CAP_INIT_CLEANUP
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Limin Wang May 18, 2020, 11:11 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

then we can remove adpcm_encode_close() in adpcm_encode_init() if have failed.
so the goto error lable wlll be unnecessary and can be removed later. 

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/adpcmenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Limin Wang May 24, 2020, 2:09 p.m. UTC | #1
On Mon, May 18, 2020 at 07:11:07PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> then we can remove adpcm_encode_close() in adpcm_encode_init() if have failed.
> so the goto error lable wlll be unnecessary and can be removed later. 
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/adpcmenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
> index 668939c..1c84561 100644
> --- a/libavcodec/adpcmenc.c
> +++ b/libavcodec/adpcmenc.c
> @@ -146,7 +146,6 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
>  
>      return 0;
>  error:
> -    adpcm_encode_close(avctx);
>      return ret;
>  }
>  
> @@ -717,6 +716,7 @@ AVCodec ff_ ## name_ ## _encoder = {                        \
>      .encode2        = adpcm_encode_frame,                   \
>      .close          = adpcm_encode_close,                   \
>      .sample_fmts    = sample_fmts_,                         \
> +    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,            \
>  }
>  
>  ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_QT,  adpcm_ima_qt,  sample_fmts_p, "ADPCM IMA QuickTime");
> -- 
> 2.6.4
> 

ping, I'll remove the use of FF_ALLOC_OR_GOTO macro if it's return error
directly if the change is OK.
Limin Wang May 27, 2020, 1:26 a.m. UTC | #2
On Mon, May 18, 2020 at 07:11:07PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> then we can remove adpcm_encode_close() in adpcm_encode_init() if have failed.
> so the goto error lable wlll be unnecessary and can be removed later. 
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/adpcmenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
> index 668939c..1c84561 100644
> --- a/libavcodec/adpcmenc.c
> +++ b/libavcodec/adpcmenc.c
> @@ -146,7 +146,6 @@ static av_cold int adpcm_encode_init(AVCodecContext *avctx)
>  
>      return 0;
>  error:
> -    adpcm_encode_close(avctx);
>      return ret;
>  }
>  
> @@ -717,6 +716,7 @@ AVCodec ff_ ## name_ ## _encoder = {                        \
>      .encode2        = adpcm_encode_frame,                   \
>      .close          = adpcm_encode_close,                   \
>      .sample_fmts    = sample_fmts_,                         \
> +    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,            \
>  }
>  
>  ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_QT,  adpcm_ima_qt,  sample_fmts_p, "ADPCM IMA QuickTime");
> -- 
> 2.6.4
> 

will apply tomorrow it if no comments.
diff mbox series

Patch

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 668939c..1c84561 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -146,7 +146,6 @@  static av_cold int adpcm_encode_init(AVCodecContext *avctx)
 
     return 0;
 error:
-    adpcm_encode_close(avctx);
     return ret;
 }
 
@@ -717,6 +716,7 @@  AVCodec ff_ ## name_ ## _encoder = {                        \
     .encode2        = adpcm_encode_frame,                   \
     .close          = adpcm_encode_close,                   \
     .sample_fmts    = sample_fmts_,                         \
+    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,            \
 }
 
 ADPCM_ENCODER(AV_CODEC_ID_ADPCM_IMA_QT,  adpcm_ima_qt,  sample_fmts_p, "ADPCM IMA QuickTime");