libaribb24_close() does the same as the fail path in libaribb24_init().
Unified · Split
| @@ -147,12 +147,12 @@ static int libaribb24_init(AVCodecContext *avctx) · 146 unmodified lines | ||
| 147 | 147 | { |
| 148 | 148 | Libaribb24Context *b24 = avctx->priv_data; |
| 149 | 149 | void(* arib_dec_init)(arib_decoder_t* decoder) = NULL; |
| 150 | − int ret_code = AVERROR_EXTERNAL; | |
| 150 | + int ret; | |
| 151 | 151 | int profile = avctx->profile; |
| 152 | 152 | |
| 153 | 153 | if (!(b24->lib_instance = arib_instance_new(avctx))) { |
| 154 | 154 | av_log(avctx, AV_LOG_ERROR, "Failed to initialize libaribb24!\n"); |
| 155 | − goto init_fail; | |
| 155 | + return AVERROR_EXTERNAL; | |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | if (b24->aribb24_base_path) { |
| @@ -165,11 +165,11 @@ static int libaribb24_init(AVCodecContext *avctx) · 6 unmodified lines | ||
| 165 | 165 | |
| 166 | 166 | if (!(b24->parser = arib_get_parser(b24->lib_instance))) { |
| 167 | 167 | av_log(avctx, AV_LOG_ERROR, "Failed to initialize libaribb24 PES parser!\n"); |
| 168 | − goto init_fail; | |
| 168 | + return AVERROR_EXTERNAL; | |
| 169 | 169 | } |
| 170 | 170 | if (!(b24->decoder = arib_get_decoder(b24->lib_instance))) { |
| 171 | 171 | av_log(avctx, AV_LOG_ERROR, "Failed to initialize libaribb24 decoder!\n"); |
| 172 | − goto init_fail; | |
| 172 | + return AVERROR_EXTERNAL; | |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | if (profile == AV_PROFILE_UNKNOWN) |
| @@ -184,27 +184,16 @@ static int libaribb24_init(AVCodecContext *avctx) · 8 unmodified lines | ||
| 184 | 184 | break; |
| 185 | 185 | default: |
| 186 | 186 | av_log(avctx, AV_LOG_ERROR, "Unknown or unsupported profile set!\n"); |
| 187 | − ret_code = AVERROR(EINVAL); | |
| 188 | − goto init_fail; | |
| 187 | + return AVERROR(EINVAL); | |
| 189 | 188 | } |
| 190 | 189 | |
| 191 | 190 | arib_dec_init(b24->decoder); |
| 192 | 191 | |
| 193 | − if (libaribb24_generate_ass_header(avctx) < 0) { | |
| 194 | − ret_code = AVERROR(ENOMEM); | |
| 195 | − goto init_fail; | |
| 196 | − } | |
| 192 | + ret = libaribb24_generate_ass_header(avctx); | |
| 193 | + if (ret < 0) | |
| 194 | + return ret; | |
| 197 | 195 | |
| 198 | 196 | return 0; |
| 199 | − | |
| 200 | −init_fail: | |
| 201 | − if (b24->decoder) | |
| 202 | − arib_finalize_decoder(b24->decoder); | |
| 203 | − | |
| 204 | − if (b24->lib_instance) | |
| 205 | − arib_instance_destroy(b24->lib_instance); | |
| 206 | − | |
| 207 | − return ret_code; | |
| 208 | 197 | } |
| 209 | 198 | |
| 210 | 199 | static int libaribb24_close(AVCodecContext *avctx) |
| @@ -410,7 +399,7 @@ const FFCodec ff_libaribb24_decoder = { · 199 unmodified lines | ||
| 410 | 399 | .p.id = AV_CODEC_ID_ARIB_CAPTION, |
| 411 | 400 | .p.priv_class = &aribb24_class, |
| 412 | 401 | .p.wrapper_name = "libaribb24", |
| 413 | − .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE, | |
| 402 | + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_NOT_INIT_THREADSAFE, | |
| 414 | 403 | .priv_data_size = sizeof(Libaribb24Context), |
| 415 | 404 | .init = libaribb24_init, |
| 416 | 405 | .close = libaribb24_close, |