2013-04-18 23:49:27 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 Georg Martius <georg dot martius at web dot de>
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "vidstabutils.h"
|
|
|
|
|
2021-09-27 15:22:25 +00:00
|
|
|
const enum AVPixelFormat ff_vidstab_pix_fmts[] = {
|
|
|
|
AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P,
|
|
|
|
AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUVA420P,
|
|
|
|
AV_PIX_FMT_YUV440P, AV_PIX_FMT_GRAY8,
|
|
|
|
AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24, AV_PIX_FMT_RGBA,
|
|
|
|
AV_PIX_FMT_NONE
|
|
|
|
};
|
|
|
|
|
2013-04-18 23:49:27 +00:00
|
|
|
/** convert AV's pixelformat to vid.stab pixelformat */
|
2014-08-22 02:12:09 +00:00
|
|
|
VSPixelFormat ff_av2vs_pixfmt(AVFilterContext *ctx, enum AVPixelFormat pf)
|
2013-04-24 15:01:26 +00:00
|
|
|
{
|
|
|
|
switch (pf) {
|
2013-04-18 23:49:27 +00:00
|
|
|
case AV_PIX_FMT_YUV420P: return PF_YUV420P;
|
|
|
|
case AV_PIX_FMT_YUV422P: return PF_YUV422P;
|
|
|
|
case AV_PIX_FMT_YUV444P: return PF_YUV444P;
|
|
|
|
case AV_PIX_FMT_YUV410P: return PF_YUV410P;
|
|
|
|
case AV_PIX_FMT_YUV411P: return PF_YUV411P;
|
|
|
|
case AV_PIX_FMT_YUV440P: return PF_YUV440P;
|
|
|
|
case AV_PIX_FMT_YUVA420P: return PF_YUVA420P;
|
|
|
|
case AV_PIX_FMT_GRAY8: return PF_GRAY8;
|
|
|
|
case AV_PIX_FMT_RGB24: return PF_RGB24;
|
|
|
|
case AV_PIX_FMT_BGR24: return PF_BGR24;
|
|
|
|
case AV_PIX_FMT_RGBA: return PF_RGBA;
|
|
|
|
default:
|
|
|
|
av_log(ctx, AV_LOG_ERROR, "cannot deal with pixel format %i\n", pf);
|
|
|
|
return PF_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** struct to hold a valid context for logging from within vid.stab lib */
|
2017-05-12 18:00:49 +00:00
|
|
|
typedef struct VS2AVLogCtx {
|
2013-04-24 15:01:26 +00:00
|
|
|
const AVClass *class;
|
2013-04-18 23:49:27 +00:00
|
|
|
} VS2AVLogCtx;
|
|
|
|
|
|
|
|
/** wrapper to log vs_log into av_log */
|
2014-08-22 02:12:09 +00:00
|
|
|
static int vs2av_log(int type, const char *tag, const char *format, ...)
|
2013-04-24 15:01:26 +00:00
|
|
|
{
|
2013-04-18 23:49:27 +00:00
|
|
|
va_list ap;
|
|
|
|
VS2AVLogCtx ctx;
|
|
|
|
AVClass class = {
|
2014-08-17 00:47:14 +00:00
|
|
|
.class_name = tag,
|
|
|
|
.item_name = av_default_item_name,
|
|
|
|
.option = 0,
|
|
|
|
.version = LIBAVUTIL_VERSION_INT,
|
|
|
|
.category = AV_CLASS_CATEGORY_FILTER,
|
2013-04-18 23:49:27 +00:00
|
|
|
};
|
|
|
|
ctx.class = &class;
|
2013-04-24 15:01:26 +00:00
|
|
|
va_start(ap, format);
|
2013-04-18 23:49:27 +00:00
|
|
|
av_vlog(&ctx, type, format, ap);
|
2013-04-24 15:01:26 +00:00
|
|
|
va_end(ap);
|
2013-04-18 23:49:27 +00:00
|
|
|
return VS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** sets the memory allocation function and logging constants to av versions */
|
2014-08-22 02:12:09 +00:00
|
|
|
void ff_vs_init(void)
|
2013-04-24 15:01:26 +00:00
|
|
|
{
|
2013-04-18 23:49:27 +00:00
|
|
|
vs_malloc = av_malloc;
|
|
|
|
vs_zalloc = av_mallocz;
|
|
|
|
vs_realloc = av_realloc;
|
|
|
|
vs_free = av_free;
|
|
|
|
|
|
|
|
VS_ERROR_TYPE = AV_LOG_ERROR;
|
|
|
|
VS_WARN_TYPE = AV_LOG_WARNING;
|
|
|
|
VS_INFO_TYPE = AV_LOG_INFO;
|
|
|
|
VS_MSG_TYPE = AV_LOG_VERBOSE;
|
|
|
|
|
2014-08-22 02:12:09 +00:00
|
|
|
vs_log = vs2av_log;
|
2013-04-18 23:49:27 +00:00
|
|
|
|
|
|
|
VS_ERROR = 0;
|
|
|
|
VS_OK = 1;
|
|
|
|
}
|