UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
lavc_common.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2013-2023 CESNET, z. s. p. o.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, is permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * 3. Neither the name of CESNET nor the names of its contributors may be
21 * used to endorse or promote products derived from this software without
22 * specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
26 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
28 * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37#ifndef LAVC_COMMON_H_C9D57362_067F_45AD_A491_A8084A39E675
38#define LAVC_COMMON_H_C9D57362_067F_45AD_A491_A8084A39E675
39
40#include "audio/types.h"
41#include "types.h"
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47#include <libavcodec/avcodec.h>
48#include <libavutil/imgutils.h>
49#include <libavutil/mem.h>
50#include <libavutil/opt.h>
51#include <libavutil/pixfmt.h>
52#include <libavutil/samplefmt.h>
53#include <libavutil/version.h>
54
55#ifdef __cplusplus
56}
57#endif
58
59#include "libavcodec/utils.h"
60
61#ifdef _MSC_VER
62#define __attribute__(a)
63#endif
64
65// component indices to rgb_shift[] (@ref av_to_uv_convert)
66enum {
70};
71
72#define LIBAV_ERRBUF_LEN 1024
73
77#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 26, 0)
78#define AV_CODEC_ID_AV1 AV_CODEC_ID_NONE
79#endif
80
81#define Y210_PRESENT LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(56, 42, 100) // FFMPEG commit 1c37cad0
82#define X2RGB10LE_PRESENT LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(56, 55, 100) // FFMPEG commit b09fb030
83#define P210_PRESENT LIBAVUTIL_VERSION_INT > AV_VERSION_INT(57, 9, 101) // FFMPEG commit b2cd1fb2ec6
84#define VUYX_PRESENT LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 34, 100) // FFMPEG commit cc5a5c98604
85#define XV3X_PRESENT LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 36, 100) // FFMPEG commit d75c4693fef adds P012, Y212, XV30 and XV36
86
87#if defined FF_API_OLD_CHANNEL_LAYOUT || (LIBAVUTIL_VERSION_MAJOR >= 58)
88#define AVCODECCTX_CHANNELS(context) (context)->ch_layout.nb_channels
89#define FF_API_NEW_CHANNEL_LAYOUT 1
90#else
91#define AVCODECCTX_CHANNELS(context) (context)->channels
92#endif
93
94#ifndef AV_CODEC_CAP_OTHER_THREADS
95#define AV_CODEC_CAP_OTHER_THREADS AV_CODEC_CAP_AUTO_THREADS
96#endif
97
98
99#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(56, 39, 100)
100#define AV_PIX_FMT_VULKAN AV_PIX_FMT_NONE
101#endif
102
103#ifdef __cplusplus
104extern "C" {
105#endif
106
107void print_decoder_error(const char *mod_name, int rc);
108
109void print_libav_error(int verbosity, const char *msg, int rc);
110void printf_libav_error(int verbosity, int rc, const char *msg, ...) __attribute__((format (printf, 3, 4)));
112
113codec_t get_av_to_ug_codec(enum AVCodecID av_codec);
114enum AVCodecID get_ug_to_av_codec(codec_t ug_codec);
115
116void ug_set_av_logging(void);
117int av_pixfmt_get_subsampling(enum AVPixelFormat fmt) __attribute__((const));
118struct pixfmt_desc av_pixfmt_get_desc(enum AVPixelFormat pixfmt);
119void lavd_flush(AVCodecContext *codec_ctx);
120const char *lavc_thread_type_to_str(int thread_type);
121struct audio_desc audio_desc_from_av_frame(const AVFrame *frm);
122enum AVSampleFormat audio_bps_to_av_sample_fmt(int bps, bool planar);
123const char *get_avpixfmts_names(const enum AVPixelFormat *pixfmts);
124
125#ifdef __cplusplus
126}
127#endif
128
129#endif // defined LAVC_COMMON_H_C9D57362_067F_45AD_A491_A8084A39E675
130
const char * fmt
This file contains definition of some common audio types.
void printf_libav_error(int verbosity, int rc, const char *msg,...) __attribute__((format(printf
codec_t get_av_to_ug_codec(enum AVCodecID av_codec)
Definition lavc_common.c:79
enum AVSampleFormat audio_bps_to_av_sample_fmt(int bps, bool planar)
const char * lavc_thread_type_to_str(int thread_type)
void ug_set_av_logging(void)
Sets specified log level either given explicitly or from UG-wide log_level.
@ B_SHIFT_IDX
Definition lavc_common.h:69
@ G_SHIFT_IDX
Definition lavc_common.h:68
@ R_SHIFT_IDX
Definition lavc_common.h:67
int av_pixfmt_get_subsampling(enum AVPixelFormat fmt) __attribute__((const))
struct audio_desc audio_desc_from_av_frame(const AVFrame *frm)
void print_decoder_error(const char *mod_name, int rc)
struct pixfmt_desc av_pixfmt_get_desc(enum AVPixelFormat pixfmt)
enum AVCodecID get_ug_to_av_codec(codec_t ug_codec)
Definition lavc_common.c:89
void lavd_flush(AVCodecContext *codec_ctx)
const char * get_avpixfmts_names(const enum AVPixelFormat *pixfmts)
void bool libav_codec_has_extradata(codec_t codec)
void print_libav_error(int verbosity, const char *msg, int rc)
This file contains some common data types.
codec_t
Definition types.h:65
codec_t ug_codec
Definition v4l2_common.h:68