Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing avcodec_close, avcodec_free_context is replacement and been … #4131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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