Skip to content

Commit

Permalink
Removing avcodec_close, avcodec_free_context is replacement and been …
Browse files Browse the repository at this point in the history
…around since 2014, so should be no reason to version test.
  • Loading branch information
SteveGilvarry committed Sep 14, 2024
1 parent 528b155 commit 8822710
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/zm_ffmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ int zm_send_frame_receive_packet(AVCodecContext *ctx, AVFrame *frame, AVPacket &

void zm_free_codec(AVCodecContext **ctx) {
if (*ctx) {
avcodec_close(*ctx);
//avcodec_close(*ctx);
// We allocate and copy in newer ffmpeg, so need to free it
avcodec_free_context(ctx);
*ctx = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions src/zm_ffmpeg_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,14 +607,14 @@ int FfmpegCamera::Close() {
mLastAudioPTS = 0;

if (mVideoCodecContext) {
avcodec_close(mVideoCodecContext);
//avcodec_close(mVideoCodecContext);
avcodec_free_context(&mVideoCodecContext);
mVideoCodecContext = nullptr;
}

if (mAudioCodecContext and !mSecondInput) {
// If second input, then these will get freed in FFmpeg_Input's destructor
avcodec_close(mAudioCodecContext);
//avcodec_close(mAudioCodecContext);
avcodec_free_context(&mAudioCodecContext);
mAudioCodecContext = nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion src/zm_ffmpeg_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ int FFmpeg_Input::Open(const char *filepath) {
int FFmpeg_Input::Close( ) {
if (streams) {
for (unsigned int i = 0; i < input_format_context->nb_streams; i += 1) {
avcodec_close(streams[i].context);
//avcodec_close(streams[i].context);
avcodec_free_context(&streams[i].context);
streams[i].context = nullptr;
}
Expand Down
3 changes: 2 additions & 1 deletion src/zm_mpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ VideoStream::~VideoStream( ) {

/* close each codec */
if ( ost ) {
avcodec_close( codec_context );
//avcodec_close( codec_context );
avcodec_free_context(&codec_context);
av_free( video_outbuf );
}

Expand Down
3 changes: 2 additions & 1 deletion src/zm_remote_camera_rtsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ RemoteCameraRtsp::RemoteCameraRtsp(
RemoteCameraRtsp::~RemoteCameraRtsp() {

if ( mVideoCodecContext ) {
avcodec_close(mVideoCodecContext);
//avcodec_close(mVideoCodecContext);
avcodec_free_context(&mVideoCodecContext);
mVideoCodecContext = nullptr; // Freed by avformat_free_context in the destructor of RtspThread class
}
// Is allocated in RTSPThread and is free there as well
Expand Down
6 changes: 3 additions & 3 deletions src/zm_videostore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ VideoStore::~VideoStore() {
video_in_ctx = nullptr;

if (video_out_ctx) {
avcodec_close(video_out_ctx);
//avcodec_close(video_out_ctx);
Debug(3, "Freeing video_out_ctx");
avcodec_free_context(&video_out_ctx);
if (hw_device_ctx) {
Expand All @@ -758,13 +758,13 @@ VideoStore::~VideoStore() {
if (audio_out_stream) {
audio_in_codec = nullptr;
if (audio_in_ctx) {
avcodec_close(audio_in_ctx);
//avcodec_close(audio_in_ctx);
avcodec_free_context(&audio_in_ctx);
}

if (audio_out_ctx) {
Debug(4, "Success closing audio_out_ctx");
avcodec_close(audio_out_ctx);
//avcodec_close(audio_out_ctx);
avcodec_free_context(&audio_out_ctx);
}

Expand Down

0 comments on commit 8822710

Please sign in to comment.