FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vidstabutils.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Georg Martius <georg dot martius at web dot de>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "vidstabutils.h"
22 
23 /** convert AV's pixelformat to vid.stab pixelformat */
25 {
26  switch (pf) {
27  case AV_PIX_FMT_YUV420P: return PF_YUV420P;
28  case AV_PIX_FMT_YUV422P: return PF_YUV422P;
29  case AV_PIX_FMT_YUV444P: return PF_YUV444P;
30  case AV_PIX_FMT_YUV410P: return PF_YUV410P;
31  case AV_PIX_FMT_YUV411P: return PF_YUV411P;
32  case AV_PIX_FMT_YUV440P: return PF_YUV440P;
33  case AV_PIX_FMT_YUVA420P: return PF_YUVA420P;
34  case AV_PIX_FMT_GRAY8: return PF_GRAY8;
35  case AV_PIX_FMT_RGB24: return PF_RGB24;
36  case AV_PIX_FMT_BGR24: return PF_BGR24;
37  case AV_PIX_FMT_RGBA: return PF_RGBA;
38  default:
39  av_log(ctx, AV_LOG_ERROR, "cannot deal with pixel format %i\n", pf);
40  return PF_NONE;
41  }
42 }
43 
44 /** struct to hold a valid context for logging from within vid.stab lib */
45 typedef struct VS2AVLogCtx {
46  const AVClass *class;
47 } VS2AVLogCtx;
48 
49 /** wrapper to log vs_log into av_log */
50 static int vs2av_log(int type, const char *tag, const char *format, ...)
51 {
52  va_list ap;
54  AVClass class = {
55  .class_name = tag,
56  .item_name = av_default_item_name,
57  .option = 0,
58  .version = LIBAVUTIL_VERSION_INT,
59  .category = AV_CLASS_CATEGORY_FILTER,
60  };
61  ctx.class = &class;
62  va_start(ap, format);
63  av_vlog(&ctx, type, format, ap);
64  va_end(ap);
65  return VS_OK;
66 }
67 
68 /** sets the memory allocation function and logging constants to av versions */
69 void ff_vs_init(void)
70 {
71  vs_malloc = av_malloc;
72  vs_zalloc = av_mallocz;
73  vs_realloc = av_realloc;
74  vs_free = av_free;
75 
76  VS_ERROR_TYPE = AV_LOG_ERROR;
77  VS_WARN_TYPE = AV_LOG_WARNING;
78  VS_INFO_TYPE = AV_LOG_INFO;
79  VS_MSG_TYPE = AV_LOG_VERBOSE;
80 
81  vs_log = vs2av_log;
82 
83  VS_ERROR = 0;
84  VS_OK = 1;
85 }
const AVClass * class
Definition: vidstabutils.c:46
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
Definition: mem.c:135
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
#define LIBAVUTIL_VERSION_INT
Definition: version.h:86
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:64
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:222
static int vs2av_log(int type, const char *tag, const char *format,...)
wrapper to log vs_log into av_log
Definition: vidstabutils.c:50
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:72
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:102
#define av_malloc(s)
uint32_t tag
Definition: movenc.c:1409
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
#define av_log(a,...)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
av_default_item_name
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:94
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
AVFormatContext * ctx
Definition: movenc.c:48
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:65
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
GLint GLenum type
Definition: opengl_enc.c:105
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:68
static const char * format
Definition: movenc.c:47
Describe the class of an AVClass context structure.
Definition: log.h:67
void av_vlog(void *avcl, int level, const char *fmt, va_list vl)
Send the specified message to the log if the level is less than or equal to the current av_log_level...
Definition: log.c:379
struct to hold a valid context for logging from within vid.stab lib
Definition: vidstabutils.c:45
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
Y , 8bpp.
Definition: pixfmt.h:70
VSPixelFormat ff_av2vs_pixfmt(AVFilterContext *ctx, enum AVPixelFormat pf)
convert AV's pixelformat to vid.stab pixelformat
Definition: vidstabutils.c:24
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:69
#define av_free(p)
An instance of a filter.
Definition: avfilter.h:338
void ff_vs_init(void)
sets the memory allocation function and logging constants to av versions
Definition: vidstabutils.c:69
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:100
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60