MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / ff_codec_close

Function ff_codec_close

libavcodec/avcodec.c:435–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433}
434
435av_cold void ff_codec_close(AVCodecContext *avctx)
436{
437 int i;
438
439 if (avcodec_is_open(avctx)) {
440 AVCodecInternal *avci = avctx->internal;
441
442#if CONFIG_FRAME_THREAD_ENCODER
443 if (avci->frame_thread_encoder && avctx->thread_count > 1) {
444 ff_frame_thread_encoder_free(avctx);
445 }
446#endif
447 if (HAVE_THREADS && avci->thread_ctx)
448 ff_thread_free(avctx);
449 if (avci->needs_close && ffcodec(avctx->codec)->close)
450 ffcodec(avctx->codec)->close(avctx);
451 avci->byte_buffer_size = 0;
452 av_freep(&avci->byte_buffer);
453 av_frame_free(&avci->buffer_frame);
454 av_packet_free(&avci->buffer_pkt);
455 av_packet_free(&avci->last_pkt_props);
456
457 av_packet_free(&avci->in_pkt);
458 av_frame_free(&avci->in_frame);
459 av_frame_free(&avci->recon_frame);
460
461 av_refstruct_unref(&avci->pool);
462 av_refstruct_pool_uninit(&avci->progress_frame_pool);
463 if (av_codec_is_decoder(avctx->codec))
464 ff_decode_internal_uninit(avctx);
465
466 ff_hwaccel_uninit(avctx);
467
468 av_bsf_free(&avci->bsf);
469
470#if CONFIG_LCMS2
471 ff_icc_context_uninit(&avci->icc);
472#endif
473
474 av_freep(&avctx->internal);
475 }
476
477 for (i = 0; i < avctx->nb_coded_side_data; i++)
478 av_freep(&avctx->coded_side_data[i].data);
479 av_freep(&avctx->coded_side_data);
480 avctx->nb_coded_side_data = 0;
481 av_frame_side_data_free(&avctx->decoded_side_data,
482 &avctx->nb_decoded_side_data);
483
484 av_buffer_unref(&avctx->hw_frames_ctx);
485 av_buffer_unref(&avctx->hw_device_ctx);
486
487 if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)
488 av_opt_free(avctx->priv_data);
489 av_opt_free(avctx);
490 av_freep(&avctx->priv_data);
491 if (av_codec_is_encoder(avctx->codec)) {
492 av_freep(&avctx->extradata);

Callers 2

avcodec_free_contextFunction · 0.85
avcodec_open2Function · 0.85

Calls 15

avcodec_is_openFunction · 0.85
ff_thread_freeFunction · 0.85
ffcodecFunction · 0.85
av_freepFunction · 0.85
av_frame_freeFunction · 0.85
av_packet_freeFunction · 0.85
av_refstruct_unrefFunction · 0.85
av_refstruct_pool_uninitFunction · 0.85
av_codec_is_decoderFunction · 0.85
ff_hwaccel_uninitFunction · 0.85

Tested by

no test coverage detected