diff mbox series

[FFmpeg-devel,07/13] avcodec/roqvideoenc: Cleanup generically after init failure

Message ID 20200829175626.11682-7-andreas.rheinhardt@gmail.com
State Accepted
Commit 7c8cf40adcee516caaa16e7da364c87b204d31a6
Headers show
Series [FFmpeg-devel,01/13] avcodec/cinepakenc: Cleanup generically after init failure
Related show

Checks

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

Commit Message

Andreas Rheinhardt Aug. 29, 2020, 5:56 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/roqvideoenc.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Paul B Mahol Aug. 29, 2020, 8:38 p.m. UTC | #1
On 8/29/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavcodec/roqvideoenc.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>


LGTM

> diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
> index ac05123dc6..dc6a63099d 100644
> --- a/libavcodec/roqvideoenc.c
> +++ b/libavcodec/roqvideoenc.c
> @@ -1004,10 +1004,8 @@ static av_cold int roq_encode_init(AVCodecContext
> *avctx)
>
>      enc->last_frame    = av_frame_alloc();
>      enc->current_frame = av_frame_alloc();
> -    if (!enc->last_frame || !enc->current_frame) {
> -        roq_encode_end(avctx);
> +    if (!enc->last_frame || !enc->current_frame)
>          return AVERROR(ENOMEM);
> -    }
>
>      enc->tmpData      = av_malloc(sizeof(RoqTempdata));
>
> @@ -1024,10 +1022,8 @@ static av_cold int roq_encode_init(AVCodecContext
> *avctx)
>          av_malloc_array ((enc->width*enc->height/64), sizeof(motion_vect));
>
>      if (!enc->tmpData || !enc->this_motion4 || !enc->last_motion4 ||
> -        !enc->this_motion8 || !enc->last_motion8) {
> -        roq_encode_end(avctx);
> +        !enc->this_motion8 || !enc->last_motion8)
>          return AVERROR(ENOMEM);
> -    }
>
>      return 0;
>  }
> @@ -1135,4 +1131,5 @@ AVCodec ff_roq_encoder = {
>      .pix_fmts             = (const enum AVPixelFormat[]){
> AV_PIX_FMT_YUVJ444P,
>                                                          AV_PIX_FMT_NONE },
>      .priv_class     = &roq_class,
> +    .caps_internal        = FF_CODEC_CAP_INIT_CLEANUP,
>  };
> --
> 2.20.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index ac05123dc6..dc6a63099d 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -1004,10 +1004,8 @@  static av_cold int roq_encode_init(AVCodecContext *avctx)
 
     enc->last_frame    = av_frame_alloc();
     enc->current_frame = av_frame_alloc();
-    if (!enc->last_frame || !enc->current_frame) {
-        roq_encode_end(avctx);
+    if (!enc->last_frame || !enc->current_frame)
         return AVERROR(ENOMEM);
-    }
 
     enc->tmpData      = av_malloc(sizeof(RoqTempdata));
 
@@ -1024,10 +1022,8 @@  static av_cold int roq_encode_init(AVCodecContext *avctx)
         av_malloc_array ((enc->width*enc->height/64), sizeof(motion_vect));
 
     if (!enc->tmpData || !enc->this_motion4 || !enc->last_motion4 ||
-        !enc->this_motion8 || !enc->last_motion8) {
-        roq_encode_end(avctx);
+        !enc->this_motion8 || !enc->last_motion8)
         return AVERROR(ENOMEM);
-    }
 
     return 0;
 }
@@ -1135,4 +1131,5 @@  AVCodec ff_roq_encoder = {
     .pix_fmts             = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUVJ444P,
                                                         AV_PIX_FMT_NONE },
     .priv_class     = &roq_class,
+    .caps_internal        = FF_CODEC_CAP_INIT_CLEANUP,
 };