diff --git a/src/zm_ffmpeg.h b/src/zm_ffmpeg.h index 59f4c2416..c1a3c26ca 100644 --- a/src/zm_ffmpeg.h +++ b/src/zm_ffmpeg.h @@ -250,8 +250,6 @@ void zm_dump_codecpar(const AVCodecParameters *par); #define zm_av_packet_unref(packet) av_packet_unref(packet) #define zm_av_packet_ref(dst, src) av_packet_ref(dst, src) -#define zm_av_frame_alloc() av_frame_alloc() - int check_sample_fmt(const AVCodec *codec, enum AVSampleFormat sample_fmt); enum AVPixelFormat fix_deprecated_pix_fmt(enum AVPixelFormat ); diff --git a/src/zm_ffmpeg_input.cpp b/src/zm_ffmpeg_input.cpp index bf68114d9..e19e6ebf9 100644 --- a/src/zm_ffmpeg_input.cpp +++ b/src/zm_ffmpeg_input.cpp @@ -174,7 +174,7 @@ AVFrame *FFmpeg_Input::get_frame(int stream_id) { AVCodecContext *context = streams[packet->stream_index].context; - frame = av_frame_ptr{zm_av_frame_alloc()}; + frame = av_frame_ptr{av_frame_alloc()}; if (!frame) { Error("Unable to allocate frame."); return nullptr; diff --git a/src/zm_ffmpeg_output.cpp b/src/zm_ffmpeg_output.cpp index d0a242e68..e7390ad82 100644 --- a/src/zm_ffmpeg_output.cpp +++ b/src/zm_ffmpeg_output.cpp @@ -92,7 +92,7 @@ AVFrame *FFmpeg_Output::get_frame( int stream_id ) { return nullptr; } - frame = av_frame_ptr{zm_av_frame_alloc()}; + frame = av_frame_ptr{av_frame_alloc()}; if (!frame) { Error("Unable to allocate frame."); return nullptr; diff --git a/src/zm_image.cpp b/src/zm_image.cpp index f347faf36..bfaf0b8d6 100644 --- a/src/zm_image.cpp +++ b/src/zm_image.cpp @@ -301,7 +301,7 @@ bool Image::Assign(const AVFrame *frame) { // Desired format AVPixelFormat format = (AVPixelFormat)AVPixFormat(); - av_frame_ptr dest_frame{zm_av_frame_alloc()}; + av_frame_ptr dest_frame{av_frame_alloc()}; if (!dest_frame) { Error("Unable to allocate destination frame"); return false; diff --git a/src/zm_local_camera.cpp b/src/zm_local_camera.cpp index 008d824da..a37d1e752 100644 --- a/src/zm_local_camera.cpp +++ b/src/zm_local_camera.cpp @@ -434,7 +434,7 @@ LocalCamera::LocalCamera( /* Initialize swscale stuff */ if (capture and (conversion_type == 1)) { - tmpPicture = av_frame_ptr{zm_av_frame_alloc()}; + tmpPicture = av_frame_ptr{av_frame_alloc()}; if (!tmpPicture) Fatal("Could not allocate temporary picture"); @@ -676,7 +676,7 @@ void LocalCamera::Initialise() { Fatal("Can't map video buffer %u (%u bytes) to memory: %s(%d)", i, vid_buf.length, strerror(errno), errno); - capturePictures[i] = av_frame_ptr{zm_av_frame_alloc()}; + capturePictures[i] = av_frame_ptr{av_frame_alloc()}; if (!capturePictures[i]) Fatal("Could not allocate picture"); diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index d95894560..f471ad46f 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -3399,7 +3399,7 @@ int Monitor::PrimeCapture() { } if (decoding != DECODING_NONE) { - if (!dest_frame) dest_frame = av_frame_ptr{zm_av_frame_alloc()}; + if (!dest_frame) dest_frame = av_frame_ptr{av_frame_alloc()}; if (!decoder_it) decoder_it = packetqueue.get_video_it(false); if (!decoder) { Debug(1, "Creating decoder thread"); diff --git a/src/zm_mpeg.cpp b/src/zm_mpeg.cpp index a83766571..28c1fe068 100644 --- a/src/zm_mpeg.cpp +++ b/src/zm_mpeg.cpp @@ -213,7 +213,7 @@ bool VideoStream::OpenStream( ) { Debug( 1, "Opened codec" ); /* allocate the encoded raw picture */ - opicture = av_frame_ptr{zm_av_frame_alloc()}; + opicture = av_frame_ptr{av_frame_alloc()}; if (!opicture) { Error("Could not allocate opicture"); return false; diff --git a/src/zm_packet.cpp b/src/zm_packet.cpp index fcebb0b89..dd3f1297e 100644 --- a/src/zm_packet.cpp +++ b/src/zm_packet.cpp @@ -71,7 +71,7 @@ ZMPacket::ZMPacket(ZMPacket &p) : decoded(false) { packet = av_packet_ptr{av_packet_alloc()}; - if (zm_av_packet_ref(packet.get(), p.packet.get()) < 0) { + if (av_packet_ref(packet.get(), p.packet.get()) < 0) { Error("error refing packet"); } } @@ -101,7 +101,7 @@ int ZMPacket::decode(AVCodecContext *ctx) { if (in_frame) { Error("Already have a frame?"); } else { - in_frame = av_frame_ptr{zm_av_frame_alloc()}; + in_frame = av_frame_ptr{av_frame_alloc()}; } // packets are always stored in AV_TIME_BASE_Q so need to convert to codec time base @@ -157,13 +157,13 @@ int ZMPacket::decode(AVCodecContext *ctx) { } // end if target_format not set #endif - av_frame_ptr new_frame{zm_av_frame_alloc()}; + av_frame_ptr new_frame{av_frame_alloc()}; #if 0 if ( target_format == AV_PIX_FMT_RGB0 ) { if ( image ) { if ( 0 > image->PopulateFrame(new_frame) ) { delete new_frame; - new_frame = zm_av_frame_alloc(); + new_frame = av_frame_alloc(); delete image; image = nullptr; new_frame->format = target_format; @@ -243,7 +243,7 @@ AVPacket *ZMPacket::set_packet(AVPacket *p) { AVFrame *ZMPacket::get_out_frame(int width, int height, AVPixelFormat format) { if (!out_frame) { - out_frame = av_frame_ptr{zm_av_frame_alloc()}; + out_frame = av_frame_ptr{av_frame_alloc()}; if (!out_frame) { Error("Unable to allocate a frame"); return nullptr; diff --git a/src/zm_swscale.cpp b/src/zm_swscale.cpp index f61b7e3bc..2235fb71b 100644 --- a/src/zm_swscale.cpp +++ b/src/zm_swscale.cpp @@ -31,13 +31,13 @@ SWScale::SWScale() : } bool SWScale::init() { - input_avframe = av_frame_ptr{zm_av_frame_alloc()}; + input_avframe = av_frame_ptr{av_frame_alloc()}; if (!input_avframe) { Error("Failed allocating AVFrame for the input"); return false; } - output_avframe = av_frame_ptr{zm_av_frame_alloc()}; + output_avframe = av_frame_ptr{av_frame_alloc()}; if (!output_avframe) { Error("Failed allocating AVFrame for the output"); return false; diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index 53357160d..14f8702e2 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -938,14 +938,14 @@ bool VideoStore::setup_resampler() { /** Create a new frame to store the audio samples. */ if (!in_frame) { - if (!(in_frame = av_frame_ptr{zm_av_frame_alloc()})) { + if (!(in_frame = av_frame_ptr{av_frame_alloc()})) { Error("Could not allocate in frame"); return false; } } /** Create a new frame to store the audio samples. */ - if (!(out_frame = av_frame_ptr{zm_av_frame_alloc()})) { + if (!(out_frame = av_frame_ptr{av_frame_alloc()})) { Error("Could not allocate out frame"); return false; } @@ -1137,7 +1137,9 @@ int VideoStore::writeVideoFramePacket(const std::shared_ptr zm_packet) zm_packet->image->AVPixFormat() == chosen_codec_data->sw_pix_fmt ) { zm_packet->image->PopulateFrame(frame.get()); + Debug(2, "populating"); } else { + Debug(2, "converting"); zm_packet->get_out_frame(video_out_ctx->width, video_out_ctx->height, chosen_codec_data->sw_pix_fmt); av_frame_ref(frame.get(), zm_packet->out_frame.get()); @@ -1176,7 +1178,7 @@ int VideoStore::writeVideoFramePacket(const std::shared_ptr zm_packet) #if HAVE_LIBAVUTIL_HWCONTEXT_H if (video_out_ctx->hw_frames_ctx) { int ret; - hw_frame = av_frame_ptr{zm_av_frame_alloc()}; + hw_frame = av_frame_ptr{av_frame_alloc()}; if (!hw_frame) { return AVERROR(ENOMEM); } @@ -1197,7 +1199,7 @@ int VideoStore::writeVideoFramePacket(const std::shared_ptr zm_packet) } // end if hwaccel #endif - if (monitor->WallClockTimestamps() or !(zm_packet->in_frame || zm_packet->packet)) { + if (1 or (monitor->WallClockTimestamps() or !(zm_packet->in_frame || zm_packet->packet))) { if (video_first_pts == AV_NOPTS_VALUE) { video_first_pts = static_cast(std::chrono::duration_cast(zm_packet->timestamp.time_since_epoch()).count()); Debug(2, "No video_first_pts, set to (%" PRId64 ") secs(%.2f)",