mirror of
https://github.com/Motion-Project/motion.git
synced 2026-06-11 23:34:36 -04:00
Remove unused MY declares for old ffmpeg versions
This commit is contained in:
@@ -113,8 +113,6 @@ class cls_webu_post;
|
||||
class cls_webu_common;
|
||||
class cls_webu_stream;
|
||||
|
||||
#define MYFFVER (LIBAVFORMAT_VERSION_MAJOR * 1000)+LIBAVFORMAT_VERSION_MINOR
|
||||
|
||||
enum MOTPLS_SIGNAL {
|
||||
MOTPLS_SIGNAL_NONE,
|
||||
MOTPLS_SIGNAL_ALARM,
|
||||
|
||||
@@ -123,7 +123,7 @@ int cls_movie::get_oformat()
|
||||
{
|
||||
if (tlapse == TIMELAPSE_APPEND) {
|
||||
oc->oformat = av_guess_format("mpeg2video", nullptr, nullptr);
|
||||
oc->video_codec_id = MY_CODEC_ID_MPEG2VIDEO;
|
||||
oc->video_codec_id = AV_CODEC_ID_MPEG2VIDEO;
|
||||
full_nm += ".mpg";
|
||||
movie_nm += ".mpg";
|
||||
if (oc->oformat == nullptr) {
|
||||
@@ -140,50 +140,50 @@ int cls_movie::get_oformat()
|
||||
oc->oformat = av_guess_format("mov", nullptr, nullptr);
|
||||
full_nm += ".mov";
|
||||
movie_nm += ".mov";
|
||||
oc->video_codec_id = MY_CODEC_ID_H264;
|
||||
oc->video_codec_id = AV_CODEC_ID_H264;
|
||||
}
|
||||
|
||||
if (container == "flv") {
|
||||
oc->oformat = av_guess_format("flv", nullptr, nullptr);
|
||||
full_nm += ".flv";
|
||||
movie_nm += ".flv";
|
||||
oc->video_codec_id = MY_CODEC_ID_FLV1;
|
||||
oc->video_codec_id = AV_CODEC_ID_FLV1;
|
||||
}
|
||||
|
||||
if (container == "ogg") {
|
||||
oc->oformat = av_guess_format("ogg", nullptr, nullptr);
|
||||
full_nm += ".ogg";
|
||||
movie_nm += ".ogg";
|
||||
oc->video_codec_id = MY_CODEC_ID_THEORA;
|
||||
oc->video_codec_id = AV_CODEC_ID_THEORA;
|
||||
}
|
||||
|
||||
if (container == "webm") {
|
||||
oc->oformat = av_guess_format("webm", nullptr, nullptr);
|
||||
full_nm += ".webm";
|
||||
movie_nm += ".webm";
|
||||
oc->video_codec_id = MY_CODEC_ID_VP8;
|
||||
oc->video_codec_id = AV_CODEC_ID_VP8;
|
||||
}
|
||||
|
||||
if (container == "mp4") {
|
||||
oc->oformat = av_guess_format("mp4", nullptr, nullptr);
|
||||
full_nm += ".mp4";
|
||||
movie_nm += ".mp4";
|
||||
oc->video_codec_id = MY_CODEC_ID_H264;
|
||||
oc->video_codec_id = AV_CODEC_ID_H264;
|
||||
}
|
||||
|
||||
if (container == "mkv") {
|
||||
oc->oformat = av_guess_format("matroska", nullptr, nullptr);
|
||||
full_nm += ".mkv";
|
||||
movie_nm += ".mkv";
|
||||
oc->video_codec_id = MY_CODEC_ID_H264;
|
||||
oc->video_codec_id = AV_CODEC_ID_H264;
|
||||
}
|
||||
|
||||
if (container == "hevc") {
|
||||
oc->video_codec_id = MY_CODEC_ID_HEVC;
|
||||
oc->video_codec_id = AV_CODEC_ID_HEVC;
|
||||
oc->oformat = av_guess_format("mp4", nullptr, nullptr);
|
||||
full_nm += ".mp4";
|
||||
movie_nm += ".mp4";
|
||||
oc->video_codec_id = MY_CODEC_ID_HEVC;
|
||||
oc->video_codec_id = AV_CODEC_ID_HEVC;
|
||||
}
|
||||
|
||||
if (oc->oformat == nullptr) {
|
||||
@@ -194,7 +194,7 @@ int cls_movie::get_oformat()
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (oc->oformat->video_codec == MY_CODEC_ID_NONE) {
|
||||
if (oc->oformat->video_codec == AV_CODEC_ID_NONE) {
|
||||
MOTPLS_LOG(ERR, TYPE_ENCODER, NO_ERRNO, _("Could not get the container"));
|
||||
free_context();
|
||||
return -1;
|
||||
@@ -287,8 +287,8 @@ int cls_movie::set_quality()
|
||||
if (quality > 100) {
|
||||
quality = 100;
|
||||
}
|
||||
if (ctx_codec->codec_id == MY_CODEC_ID_H264 ||
|
||||
ctx_codec->codec_id == MY_CODEC_ID_HEVC) {
|
||||
if (ctx_codec->codec_id == AV_CODEC_ID_H264 ||
|
||||
ctx_codec->codec_id == AV_CODEC_ID_HEVC) {
|
||||
if (quality <= 0) {
|
||||
quality = 45; // default to 45%
|
||||
}
|
||||
@@ -317,7 +317,7 @@ int cls_movie::set_quality()
|
||||
char crf[10];
|
||||
quality = (int)(( (100-quality) * 51)/100);
|
||||
snprintf(crf, 10, "%d", quality);
|
||||
if (ctx_codec->codec_id == MY_CODEC_ID_H264) {
|
||||
if (ctx_codec->codec_id == AV_CODEC_ID_H264) {
|
||||
av_opt_set(ctx_codec->priv_data, "profile", "high", 0);
|
||||
}
|
||||
av_opt_set(ctx_codec->priv_data, "crf", crf, 0);
|
||||
@@ -328,7 +328,7 @@ int cls_movie::set_quality()
|
||||
/* The selection of 8000 is a subjective number based upon viewing output files */
|
||||
if (quality > 0) {
|
||||
quality =(int)(((100-quality)*(100-quality)*(100-quality) * 8000) / 1000000) + 1;
|
||||
ctx_codec->flags |= MY_CODEC_FLAG_QSCALE;
|
||||
ctx_codec->flags |= AV_CODEC_FLAG_QSCALE;
|
||||
ctx_codec->global_quality=quality;
|
||||
}
|
||||
}
|
||||
@@ -423,9 +423,9 @@ int cls_movie::set_codec()
|
||||
ctx_codec->height = height;
|
||||
ctx_codec->time_base.num = 1;
|
||||
ctx_codec->time_base.den = fps;
|
||||
ctx_codec->pix_fmt = MY_PIX_FMT_YUV420P;
|
||||
ctx_codec->pix_fmt = AV_PIX_FMT_YUV420P;
|
||||
ctx_codec->max_b_frames = 0;
|
||||
ctx_codec->flags |= MY_CODEC_FLAG_GLOBAL_HEADER;
|
||||
ctx_codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
|
||||
if (set_quality() < 0) {
|
||||
MOTPLS_LOG(ERR, TYPE_ENCODER, NO_ERRNO, _("Unable to set quality"));
|
||||
@@ -597,7 +597,7 @@ int cls_movie::set_outputfile()
|
||||
if ((timelapse_exists(full_nm.c_str()) == 0) || (tlapse != TIMELAPSE_APPEND)) {
|
||||
clock_gettime(CLOCK_MONOTONIC, &cb_st_ts);
|
||||
retcd = avio_open(&oc->pb, full_nm.c_str()
|
||||
, MY_FLAG_WRITE|AVIO_FLAG_NONBLOCK);
|
||||
, AVIO_FLAG_WRITE|AVIO_FLAG_NONBLOCK);
|
||||
if (retcd < 0) {
|
||||
av_strerror(retcd, errstr, sizeof(errstr));
|
||||
MOTPLS_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO
|
||||
@@ -610,7 +610,7 @@ int cls_movie::set_outputfile()
|
||||
return -1;
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &cb_st_ts);
|
||||
retcd = avio_open(&oc->pb, full_nm.c_str(), MY_FLAG_WRITE| AVIO_FLAG_NONBLOCK);
|
||||
retcd = avio_open(&oc->pb, full_nm.c_str(), AVIO_FLAG_WRITE| AVIO_FLAG_NONBLOCK);
|
||||
if (retcd < 0) {
|
||||
av_strerror(retcd, errstr, sizeof(errstr));
|
||||
MOTPLS_LOG(ERR, TYPE_ENCODER, SHOW_ERRNO
|
||||
|
||||
@@ -348,8 +348,8 @@ void cls_netcam::free_pkt()
|
||||
int cls_netcam::check_pixfmt()
|
||||
{
|
||||
int retcd = -1;
|
||||
if (((enum AVPixelFormat)frame->format == MY_PIX_FMT_YUV420P) ||
|
||||
((enum AVPixelFormat)frame->format == MY_PIX_FMT_YUVJ420P)) {
|
||||
if (((enum AVPixelFormat)frame->format == AV_PIX_FMT_YUV420P) ||
|
||||
((enum AVPixelFormat)frame->format == AV_PIX_FMT_YUVJ420P)) {
|
||||
retcd = 0;
|
||||
}
|
||||
return retcd;
|
||||
@@ -1201,7 +1201,7 @@ int cls_netcam::open_sws()
|
||||
,(enum AVPixelFormat)frame->format
|
||||
,imgsize.width
|
||||
,imgsize.height
|
||||
,MY_PIX_FMT_YUV420P
|
||||
,AV_PIX_FMT_YUV420P
|
||||
,SWS_BICUBIC,nullptr,nullptr,nullptr);
|
||||
if (swsctx == nullptr) {
|
||||
if (status == NETCAM_NOTCONNECTED) {
|
||||
@@ -1214,7 +1214,7 @@ int cls_netcam::open_sws()
|
||||
}
|
||||
|
||||
swsframe_size = av_image_get_buffer_size(
|
||||
MY_PIX_FMT_YUV420P, imgsize.width, imgsize.height, 1);
|
||||
AV_PIX_FMT_YUV420P, imgsize.width, imgsize.height, 1);
|
||||
if (swsframe_size <= 0) {
|
||||
if (status == NETCAM_NOTCONNECTED) {
|
||||
MOTPLS_LOG(ERR, TYPE_NETCAM, NO_ERRNO
|
||||
@@ -1269,7 +1269,7 @@ int cls_netcam::resize()
|
||||
retcd = av_image_fill_arrays(
|
||||
swsframe_out->data
|
||||
, swsframe_out->linesize
|
||||
, buffer_out, MY_PIX_FMT_YUV420P
|
||||
, buffer_out, AV_PIX_FMT_YUV420P
|
||||
, imgsize.width, imgsize.height, 1);
|
||||
if (retcd < 0) {
|
||||
if (status == NETCAM_NOTCONNECTED) {
|
||||
@@ -1306,7 +1306,7 @@ int cls_netcam::resize()
|
||||
, swsframe_size
|
||||
, (const uint8_t * const*)swsframe_out
|
||||
, swsframe_out->linesize
|
||||
, MY_PIX_FMT_YUV420P
|
||||
, AV_PIX_FMT_YUV420P
|
||||
, imgsize.width, imgsize.height, 1);
|
||||
if (retcd < 0) {
|
||||
if (status == NETCAM_NOTCONNECTED) {
|
||||
|
||||
35
src/util.hpp
35
src/util.hpp
@@ -20,27 +20,7 @@
|
||||
#ifndef _INCLUDE_UTIL_HPP_
|
||||
#define _INCLUDE_UTIL_HPP_
|
||||
|
||||
#define MY_PIX_FMT_YUV420P AV_PIX_FMT_YUV420P
|
||||
#define MY_PIX_FMT_YUVJ420P AV_PIX_FMT_YUVJ420P
|
||||
#define MyPixelFormat AVPixelFormat
|
||||
|
||||
#define MY_FLAG_READ AVIO_FLAG_READ
|
||||
#define MY_FLAG_WRITE AVIO_FLAG_WRITE
|
||||
#define MY_FLAG_READ_WRITE AVIO_FLAG_READ_WRITE
|
||||
|
||||
#define MY_CODEC_ID_MSMPEG4V2 AV_CODEC_ID_MSMPEG4V2
|
||||
#define MY_CODEC_ID_FLV1 AV_CODEC_ID_FLV1
|
||||
#define MY_CODEC_ID_FFV1 AV_CODEC_ID_FFV1
|
||||
#define MY_CODEC_ID_NONE AV_CODEC_ID_NONE
|
||||
#define MY_CODEC_ID_MPEG2VIDEO AV_CODEC_ID_MPEG2VIDEO
|
||||
#define MY_CODEC_ID_H264 AV_CODEC_ID_H264
|
||||
#define MY_CODEC_ID_HEVC AV_CODEC_ID_HEVC
|
||||
#define MY_CODEC_ID_THEORA AV_CODEC_ID_THEORA
|
||||
#define MY_CODEC_ID_VP8 AV_CODEC_ID_VP8
|
||||
#define MY_CODEC_ID_VP9 AV_CODEC_ID_VP9
|
||||
|
||||
#define MY_CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER
|
||||
#define MY_CODEC_FLAG_QSCALE AV_CODEC_FLAG_QSCALE
|
||||
#define MYFFVER (LIBAVFORMAT_VERSION_MAJOR * 1000)+LIBAVFORMAT_VERSION_MINOR
|
||||
|
||||
#if (LIBAVCODEC_VERSION_MAJOR >= 59)
|
||||
typedef const AVCodec myAVCodec; /* Version independent definition for AVCodec*/
|
||||
@@ -48,6 +28,13 @@
|
||||
typedef AVCodec myAVCodec; /* Version independent definition for AVCodec*/
|
||||
#endif
|
||||
|
||||
#if (MYFFVER <= 60016)
|
||||
typedef uint8_t myuint; /* Version independent uint */
|
||||
#else
|
||||
typedef const uint8_t myuint; /* Version independent uint */
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_GETTEXT
|
||||
#include <libintl.h>
|
||||
extern int _nl_msg_cat_cntr; /* Required for changing the locale dynamically */
|
||||
@@ -69,12 +56,6 @@
|
||||
#else
|
||||
typedef int mhdrslt; /* Version independent return result from MHD */
|
||||
#endif
|
||||
/* Version independent uint */
|
||||
#if (MYFFVER <= 60016)
|
||||
typedef uint8_t myuint;
|
||||
#else
|
||||
typedef const uint8_t myuint;
|
||||
#endif
|
||||
|
||||
struct ctx_params_item {
|
||||
std::string param_name; /* The name or description of the ID as requested by user*/
|
||||
|
||||
@@ -157,7 +157,7 @@ void cls_webu_common::img_resize(cls_camera *p_cam
|
||||
|
||||
retcd = av_image_fill_arrays(
|
||||
frm_in->data, frm_in->linesize
|
||||
, src, MY_PIX_FMT_YUV420P
|
||||
, src, AV_PIX_FMT_YUV420P
|
||||
, src_w, src_h, 1);
|
||||
if (retcd < 0) {
|
||||
av_strerror(retcd, errstr, sizeof(errstr));
|
||||
@@ -172,7 +172,7 @@ void cls_webu_common::img_resize(cls_camera *p_cam
|
||||
|
||||
retcd = av_image_fill_arrays(
|
||||
frm_out->data, frm_out->linesize
|
||||
, buf, MY_PIX_FMT_YUV420P
|
||||
, buf, AV_PIX_FMT_YUV420P
|
||||
, dst_w, dst_h, 1);
|
||||
if (retcd < 0) {
|
||||
av_strerror(retcd, errstr, sizeof(errstr));
|
||||
@@ -185,8 +185,8 @@ void cls_webu_common::img_resize(cls_camera *p_cam
|
||||
}
|
||||
|
||||
swsctx = sws_getContext(
|
||||
src_w, src_h, MY_PIX_FMT_YUV420P
|
||||
,dst_w, dst_h, MY_PIX_FMT_YUV420P
|
||||
src_w, src_h, AV_PIX_FMT_YUV420P
|
||||
,dst_w, dst_h, AV_PIX_FMT_YUV420P
|
||||
,SWS_BICUBIC, NULL, NULL, NULL);
|
||||
if (swsctx == NULL) {
|
||||
MOTPLS_LOG(ERR, TYPE_NETCAM, NO_ERRNO
|
||||
@@ -215,7 +215,7 @@ void cls_webu_common::img_resize(cls_camera *p_cam
|
||||
(uint8_t *)dst, img_sz
|
||||
, (const uint8_t * const*)frm_out
|
||||
, frm_out->linesize
|
||||
, MY_PIX_FMT_YUV420P, dst_w, dst_h, 1);
|
||||
, AV_PIX_FMT_YUV420P, dst_w, dst_h, 1);
|
||||
|
||||
if (retcd < 0) {
|
||||
av_strerror(retcd, errstr, sizeof(errstr));
|
||||
|
||||
@@ -277,9 +277,9 @@ int cls_webu_mpegts::open_mpegts()
|
||||
|
||||
fmtctx = avformat_alloc_context();
|
||||
fmtctx->oformat = av_guess_format("mpegts", NULL, NULL);
|
||||
fmtctx->video_codec_id = MY_CODEC_ID_H264;
|
||||
fmtctx->video_codec_id = AV_CODEC_ID_H264;
|
||||
|
||||
codec = avcodec_find_encoder(MY_CODEC_ID_H264);
|
||||
codec = avcodec_find_encoder(AV_CODEC_ID_H264);
|
||||
strm = avformat_new_stream(fmtctx, codec);
|
||||
|
||||
if (webua->device_id > 0) {
|
||||
@@ -300,16 +300,16 @@ int cls_webu_mpegts::open_mpegts()
|
||||
|
||||
ctx_codec = avcodec_alloc_context3(codec);
|
||||
ctx_codec->gop_size = 15;
|
||||
ctx_codec->codec_id = MY_CODEC_ID_H264;
|
||||
ctx_codec->codec_id = AV_CODEC_ID_H264;
|
||||
ctx_codec->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||
ctx_codec->bit_rate = 400000;
|
||||
ctx_codec->width = img_w;
|
||||
ctx_codec->height = img_h;
|
||||
ctx_codec->time_base.num = 1;
|
||||
ctx_codec->time_base.den = 90000;
|
||||
ctx_codec->pix_fmt = MY_PIX_FMT_YUV420P;
|
||||
ctx_codec->pix_fmt = AV_PIX_FMT_YUV420P;
|
||||
ctx_codec->max_b_frames = 1;
|
||||
ctx_codec->flags |= MY_CODEC_FLAG_GLOBAL_HEADER;
|
||||
ctx_codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
|
||||
ctx_codec->framerate.num = 1;
|
||||
ctx_codec->framerate.den = 1;
|
||||
av_opt_set(ctx_codec->priv_data, "profile", "main", 0);
|
||||
|
||||
Reference in New Issue
Block a user