1
0
mirror of https://github.com/jojo61/vdr-plugin-softhdcuvid.git synced 2023-10-10 13:37:41 +02:00

- switch from indent to clang-format, which is supported by Visual Studio Code

- reindent all sources to common code style
- fix include sort errors from clang-format
- update AGPL 3.0 license file
This commit is contained in:
Dirk Nehring 2021-12-27 20:02:45 +01:00
parent 987ff6ba12
commit 177e44de98
29 changed files with 4309 additions and 5337 deletions

6
.clang-format Normal file
View File

@ -0,0 +1,6 @@
---
BasedOnStyle: LLVM
UseTab: Never
IndentWidth: 4
IndentCaseLabels: true
ColumnLimit: 119

37
.indent.pro vendored
View File

@ -1,37 +0,0 @@
--blank-lines-before-block-comments
--blank-lines-after-declarations
--blank-lines-after-procedures
--no-blank-lines-after-commas
--braces-on-if-line
--no-blank-before-sizeof
--comment-indentation41
--declaration-comment-column41
--no-comment-delimiters-on-blank-lines
--swallow-optional-blank-lines
--dont-format-comments
--parameter-indentation4
--indent-level4
--line-comments-indentation0
--cuddle-else
--cuddle-do-while
--brace-indent0
--case-brace-indentation0
//--start-left-side-of-comments
--leave-preprocessor-space
//--continuation-indentation8
--case-indentation4
--else-endif-column0
--no-space-after-casts
--declaration-indentation1
--dont-line-up-parentheses
--no-space-after-function-call-names
--space-special-semicolon
--tab-size4
--no-tabs
--line-length119
--comment-line-length119
--honour-newlines
--dont-break-procedure-type
--break-before-boolean-operator
--continuation-indentation4
--ignore-newlines

View File

@ -22,25 +22,18 @@ CUVID ?= 0
# only valid for VAAPI
DRM ?= 0
# use libplacebo -
# available for all decoders but for DRM you need LIBPLACEBO_GL
LIBPLACEBO ?= 1
LIBPLACEBO_GL ?= 0
# use YADIF deint - only available with cuvid
#YADIF=1
#YADIF = 1
# use gamma correction
#GAMMA ?= 0
CONFIG := -DDEBUG # remove # to enable debug output
CONFIG := -DDEBUG # remove '#' to enable debug output
#--------------------- no more config needed past this point--------------------------------
@ -76,10 +69,10 @@ endif
endif # MAKECMDGOALS!=indent
endif # MAKECMDGOALS!=clean
#--------------------------
PLUGIN = softhdcuvid
# support OPENGLOSD always needed
@ -154,8 +147,6 @@ APIVERSION = $(call PKGCFG,apiversion)
-include $(PLGCFG)
### Parse softhddevice config
ifeq ($(ALSA),1)
@ -180,7 +171,7 @@ endif
ifeq ($(OPENGL),1)
CONFIG += -DUSE_GLX
_CFLAGS += $(shell pkg-config --cflags gl glu glew)
#LIBS += $(shell pkg-config --libs glu glew)
#LIBS += $(shell pkg-config --libs glu glew)
_CFLAGS += $(shell pkg-config --cflags freetype2)
LIBS += $(shell pkg-config --libs freetype2)
endif
@ -212,7 +203,6 @@ _CFLAGS += $(shell pkg-config --cflags libdrm)
LIBS += -lgbm -ldrm -lEGL
endif
ifeq ($(CUVID),1)
#CONFIG += -DUSE_PIP # PIP support
CONFIG += -DCUVID # enable CUVID decoder
@ -223,10 +213,9 @@ endif
endif
ifeq ($(GAMMA),1)
CONFIG += -DGAMMA
CONFIG += -DGAMMA
endif
ARCHIVE = $(PLUGIN)-$(VERSION)
PACKAGE = vdr-$(ARCHIVE)
@ -234,7 +223,6 @@ PACKAGE = vdr-$(ARCHIVE)
SOFILE = libvdr-$(PLUGIN).so
#
# Test that libswresample is available
#
@ -296,8 +284,8 @@ endif
#_CFLAGS += $(shell pkg-config --cflags libavcodec x11 x11-xcb xcb xcb-icccm)
#LIBS += -lrt $(shell pkg-config --libs libavcodec x11 x11-xcb xcb xcb-icccm)
_CFLAGS += $(shell pkg-config --cflags x11 x11-xcb xcb xcb-icccm)
LIBS += -lrt $(shell pkg-config --libs x11 x11-xcb xcb xcb-icccm)
_CFLAGS += $(shell pkg-config --cflags x11 x11-xcb xcb xcb-icccm)
LIBS += -lrt $(shell pkg-config --libs x11 x11-xcb xcb xcb-icccm)
_CFLAGS += -I./opengl -I./
@ -305,10 +293,11 @@ LIBS += -L/usr/lib64
ifeq ($(CUVID),1)
LIBS += -lcuda -lnvcuvid
LIBS += -lcuda -lnvcuvid
endif
LIBS += -lGLEW -lGLU -ldl -lglut
### Includes and Defines (add further entries here):
INCLUDES +=
@ -319,10 +308,9 @@ DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -D_GNU_SOURCE $(CONFIG) \
### Make it standard
override CXXFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \
-g -W -Wextra -Winit-self -Werror=overloaded-virtual -Wno-unused-parameter
-g -W -Wextra -Werror=overloaded-virtual -Wno-unused-parameter
override CFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \
-g -W -Wextra -Winit-self -std=gnu99
-g -W -Wextra
### The object files (add further files here):
@ -383,9 +371,8 @@ install-i18n: $(I18Nmsgs)
$(OBJS): Makefile
$(SOFILE): $(OBJS) shaders.h
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@
install-lib: $(SOFILE)
install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION)
@ -404,17 +391,14 @@ clean:
@-rm -f $(PODIR)/*.mo $(PODIR)/*.pot
@-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~
## Private Targets:
HDRS= $(wildcard *.h)
HDRS = $(wildcard *.h)
indent:
for i in $(SRCS) $(HDRS); do \
indent $$i; \
unexpand -a $$i | sed -e s/constconst/const/ > $$i.up; \
mv $$i.up $$i; \
clang-format -i $$i; \
done
## Private Targets:
video_test: video.c Makefile
$(CC) -DVIDEO_TEST -DVERSION='"$(VERSION)"' $(CFLAGS) $(LDFLAGS) $< \
$(LIBS) -o $@

View File

@ -1,21 +1,21 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license
for software and other kinds of works, specifically designed to ensure
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are
designed to take away your freedom to share and change the works. By
contrast, our General Public Licenses are intended to guarantee your
freedom to share and change all versions of a program--to make sure it
remains free software for all its users.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
@ -60,11 +60,10 @@ modification follow.
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public
License.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds
of works, such as semiconductor masks.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
@ -377,12 +376,12 @@ that material) supplement the terms of this License with terms:
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further restriction,
you may remove that term. If a license document contains a further
restriction but permits relicensing or conveying under this License, you
may add to a covered work material governed by the terms of that license
document, provided that the further restriction does not survive such
relicensing or conveying.
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
@ -551,34 +550,34 @@ shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have permission
to link or combine any covered work with a work licensed under version 3
of the GNU General Public License into a single combined work, and to
convey the resulting work. The terms of this License will continue to
apply to the part which is the covered work, but the work with which it is
combined will remain governed by version 3 of the GNU General Public
License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may differ
in detail to address new problems or concerns.
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero
General Public License "or any later version" applies to it, you have
the option of following the terms and conditions either of that
numbered version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number
of the GNU Affero General Public License, you may choose any version
ever published by the Free Software Foundation.
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that
proxy's public statement of acceptance of a version permanently
authorizes you to choose that version for the Program.
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
@ -617,9 +616,9 @@ an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
@ -634,9 +633,9 @@ the "copyright" line and a pointer to where the full notice is found.
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@ -644,7 +643,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
@ -659,4 +658,4 @@ specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.

934
audio.c

File diff suppressed because it is too large Load Diff

54
audio.h
View File

@ -1,7 +1,7 @@
///
/// @file audio.h @brief Audio module headerfile
///
/// Copyright (c) 2009 - 2014 by Johns. All Rights Reserved.
/// Copyright (c) 2009 - 2014 by Johns. All Rights Reserved.
///
/// Contributor(s):
///
@ -27,41 +27,41 @@
// Prototypes
//----------------------------------------------------------------------------
extern void AudioEnqueue(const void *, int); ///< buffer audio samples
extern void AudioFlushBuffers(void); ///< flush audio buffers
extern void AudioPoller(void); ///< poll audio events/handling
extern int AudioFreeBytes(void); ///< free bytes in audio output
extern int AudioUsedBytes(void); ///< used bytes in audio output
extern int64_t AudioGetDelay(void); ///< get current audio delay
extern void AudioSetClock(int64_t); ///< set audio clock base
extern int64_t AudioGetClock(); ///< get current audio clock
extern void AudioSetVolume(int); ///< set volume
extern int AudioSetup(int *, int *, int); ///< setup audio output
extern void AudioEnqueue(const void *, int); ///< buffer audio samples
extern void AudioFlushBuffers(void); ///< flush audio buffers
extern void AudioPoller(void); ///< poll audio events/handling
extern int AudioFreeBytes(void); ///< free bytes in audio output
extern int AudioUsedBytes(void); ///< used bytes in audio output
extern int64_t AudioGetDelay(void); ///< get current audio delay
extern void AudioSetClock(int64_t); ///< set audio clock base
extern int64_t AudioGetClock(); ///< get current audio clock
extern void AudioSetVolume(int); ///< set volume
extern int AudioSetup(int *, int *, int); ///< setup audio output
extern void AudioPlay(void); ///< play audio
extern void AudioPause(void); ///< pause audio
extern void AudioPlay(void); ///< play audio
extern void AudioPause(void); ///< pause audio
extern void AudioSetBufferTime(int); ///< set audio buffer time
extern void AudioSetSoftvol(int); ///< enable/disable softvol
extern void AudioSetNormalize(int, int); ///< set normalize parameters
extern void AudioSetCompression(int, int); ///< set compression parameters
extern void AudioSetStereoDescent(int); ///< set stereo loudness descent
extern void AudioSetBufferTime(int); ///< set audio buffer time
extern void AudioSetSoftvol(int); ///< enable/disable softvol
extern void AudioSetNormalize(int, int); ///< set normalize parameters
extern void AudioSetCompression(int, int); ///< set compression parameters
extern void AudioSetStereoDescent(int); ///< set stereo loudness descent
extern void AudioSetDevice(const char *); ///< set PCM audio device
extern void AudioSetDevice(const char *); ///< set PCM audio device
/// set pass-through device
/// set pass-through device
extern void AudioSetPassthroughDevice(const char *);
extern void AudioSetChannel(const char *); ///< set mixer channel
extern void AudioSetAutoAES(int); ///< set automatic AES flag handling
extern void AudioInit(void); ///< setup audio module
extern void AudioExit(void); ///< cleanup and exit audio module
extern void AudioSetChannel(const char *); ///< set mixer channel
extern void AudioSetAutoAES(int); ///< set automatic AES flag handling
extern void AudioInit(void); ///< setup audio module
extern void AudioExit(void); ///< cleanup and exit audio module
//----------------------------------------------------------------------------
// Variables
//----------------------------------------------------------------------------
extern char AudioAlsaDriverBroken; ///< disable broken driver message
extern char AudioAlsaNoCloseOpen; ///< disable alsa close/open fix
extern char AudioAlsaCloseOpenDelay; ///< enable alsa close/open delay fix
extern char AudioAlsaDriverBroken; ///< disable broken driver message
extern char AudioAlsaNoCloseOpen; ///< disable alsa close/open fix
extern char AudioAlsaCloseOpenDelay; ///< enable alsa close/open delay fix
/// @}

405
codec.c
View File

@ -1,7 +1,7 @@
///
/// @file codec.c @brief Codec functions
///
/// Copyright (c) 2009 - 2015 by Johns. All Rights Reserved.
/// Copyright (c) 2009 - 2015 by Johns. All Rights Reserved.
///
/// Contributor(s):
///
@ -27,7 +27,7 @@
/// It is uses ffmpeg (http://ffmpeg.org) as backend.
///
/// It may work with libav (http://libav.org), but the tests show
/// many bugs and incompatiblity in it. Don't use this shit.
/// many bugs and incompatiblity in it. Don't use this shit.
///
/// compile with pass-through support (stable, AC-3, E-AC-3 only)
@ -51,16 +51,16 @@
#include <endian.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <libintl.h>
#define _(str) gettext(str) ///< gettext shortcut
#define _N(str) str ///< gettext_noop shortcut
#include <sys/stat.h>
#include <sys/types.h>
#define _(str) gettext(str) ///< gettext shortcut
#define _N(str) str ///< gettext_noop shortcut
#include <libavcodec/avcodec.h>
#include <libavutil/opt.h>
#include <libavutil/mem.h>
#include <libavutil/opt.h>
#ifdef USE_SWRESAMPLE
#include <libswresample/swresample.h>
@ -75,11 +75,13 @@
#endif
#include <pthread.h>
// clang-format off
#include "iatomic.h"
#include "misc.h"
#include "video.h"
#include "audio.h"
#include "codec.h"
// clang-format on
//----------------------------------------------------------------------------
// Global
@ -113,12 +115,12 @@ AVBufferRef *hw_device_ctx;
///
struct _video_decoder_
{
VideoHwDecoder *HwDecoder; ///< video hardware decoder
VideoHwDecoder *HwDecoder; ///< video hardware decoder
int GetFormatDone; ///< flag get format called!
AVCodec *VideoCodec; ///< video codec
AVCodecContext *VideoCtx; ///< video codec context
AVFrame *Frame; ///< decoded video frame
int GetFormatDone; ///< flag get format called!
AVCodec *VideoCodec; ///< video codec
AVCodecContext *VideoCtx; ///< video codec context
AVFrame *Frame; ///< decoded video frame
};
#endif
//----------------------------------------------------------------------------
@ -128,14 +130,13 @@ struct _video_decoder_
/**
** Callback to negotiate the PixelFormat.
**
** @param video_ctx codec context
** @param fmt is the list of formats which are supported by
** the codec, it is terminated by -1 as 0 is a
** valid format, the formats are ordered by
** quality.
** @param video_ctx codec context
** @param fmt is the list of formats which are supported by
** the codec, it is terminated by -1 as 0 is a
** valid format, the formats are ordered by
** quality.
*/
static enum AVPixelFormat Codec_get_format(AVCodecContext * video_ctx, const enum AVPixelFormat *fmt)
{
static enum AVPixelFormat Codec_get_format(AVCodecContext *video_ctx, const enum AVPixelFormat *fmt) {
VideoDecoder *decoder;
enum AVPixelFormat fmt1;
@ -145,9 +146,8 @@ static enum AVPixelFormat Codec_get_format(AVCodecContext * video_ctx, const enu
Error("codec/video: ffmpeg/libav buggy: width or height zero\n");
}
// decoder->GetFormatDone = 1;
// decoder->GetFormatDone = 1;
return Video_get_format(decoder->HwDecoder, video_ctx, fmt);
}
// static void Codec_free_buffer(void *opaque, uint8_t *data);
@ -157,16 +157,15 @@ static enum AVPixelFormat Codec_get_format(AVCodecContext * video_ctx, const enu
**
** Called at the beginning of each frame to get a buffer for it.
**
** @param video_ctx Codec context
** @param frame Get buffer for this frame
** @param video_ctx Codec context
** @param frame Get buffer for this frame
*/
static int Codec_get_buffer2(AVCodecContext * video_ctx, AVFrame * frame, int flags)
{
static int Codec_get_buffer2(AVCodecContext *video_ctx, AVFrame *frame, int flags) {
VideoDecoder *decoder;
decoder = video_ctx->opaque;
if (!decoder->GetFormatDone) { // get_format missing
if (!decoder->GetFormatDone) { // get_format missing
enum AVPixelFormat fmts[2];
// fprintf(stderr, "codec: buggy libav, use ffmpeg\n");
@ -177,9 +176,9 @@ static int Codec_get_buffer2(AVCodecContext * video_ctx, AVFrame * frame, int fl
}
#if 0
if (decoder->hwaccel_get_buffer && (AV_PIX_FMT_VDPAU == decoder->hwaccel_pix_fmt
|| AV_PIX_FMT_CUDA == decoder->hwaccel_pix_fmt || AV_PIX_FMT_VAAPI == decoder->hwaccel_pix_fmt)) {
// Debug(3,"hwaccel get_buffer\n");
return decoder->hwaccel_get_buffer(video_ctx, frame, flags);
|| AV_PIX_FMT_CUDA == decoder->hwaccel_pix_fmt || AV_PIX_FMT_VAAPI == decoder->hwaccel_pix_fmt)) {
// Debug(3,"hwaccel get_buffer\n");
return decoder->hwaccel_get_buffer(video_ctx, frame, flags);
}
#endif
// Debug(3, "codec: fallback to default get_buffer\n");
@ -193,12 +192,11 @@ static int Codec_get_buffer2(AVCodecContext * video_ctx, AVFrame * frame, int fl
/**
** Allocate a new video decoder context.
**
** @param hw_decoder video hardware decoder
** @param hw_decoder video hardware decoder
**
** @returns private decoder pointer for video decoder.
*/
VideoDecoder *CodecVideoNewDecoder(VideoHwDecoder * hw_decoder)
{
VideoDecoder *CodecVideoNewDecoder(VideoHwDecoder *hw_decoder) {
VideoDecoder *decoder;
if (!(decoder = calloc(1, sizeof(*decoder)))) {
@ -214,10 +212,7 @@ VideoDecoder *CodecVideoNewDecoder(VideoHwDecoder * hw_decoder)
**
** @param decoder private video decoder
*/
void CodecVideoDelDecoder(VideoDecoder * decoder)
{
free(decoder);
}
void CodecVideoDelDecoder(VideoDecoder *decoder) { free(decoder); }
/**
** Open video decoder.
@ -225,14 +220,13 @@ void CodecVideoDelDecoder(VideoDecoder * decoder)
** @param decoder private video decoder
** @param codec_id video codec id
*/
void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
{
void CodecVideoOpen(VideoDecoder *decoder, int codec_id) {
AVCodec *video_codec;
const char *name;
int ret, deint = 2;
Debug(3, "***************codec: Video Open using video codec ID %#06x (%s)\n", codec_id,
avcodec_get_name(codec_id));
avcodec_get_name(codec_id));
if (decoder->VideoCtx) {
Error(_("codec: missing close\n"));
@ -261,7 +255,7 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
break;
case AV_CODEC_ID_H264:
name = "h264_v4l2m2m";
// name = "h264_mmal";
// name = "h264_mmal";
break;
case AV_CODEC_ID_HEVC:
name = "hevc_v4l2m2m";
@ -289,8 +283,9 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
}
decoder->VideoCtx->hw_device_ctx = av_buffer_ref(HwDeviceContext);
#else
decoder->VideoCtx->pix_fmt = AV_PIX_FMT_DRM_PRIME; /* request a DRM frame */
// decoder->VideoCtx->pix_fmt = AV_PIX_FMT_MMAL; /* request a DRM frame */
decoder->VideoCtx->pix_fmt = AV_PIX_FMT_DRM_PRIME; /* request a DRM frame */
// decoder->VideoCtx->pix_fmt = AV_PIX_FMT_MMAL; /* request a DRM frame
//*/
#endif
// FIXME: for software decoder use all cpus, otherwise 1
@ -310,12 +305,12 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
// decoder->VideoCtx->extra_hw_frames = 8; // VIDEO_SURFACES_MAX +1
if (video_codec->capabilities & (AV_CODEC_CAP_AUTO_THREADS)) {
Debug(3, "codec: auto threads enabled");
// decoder->VideoCtx->thread_count = 0;
// decoder->VideoCtx->thread_count = 0;
}
if (video_codec->capabilities & AV_CODEC_CAP_TRUNCATED) {
Debug(3, "codec: supports truncated packets");
//decoder->VideoCtx->flags |= CODEC_FLAG_TRUNCATED;
// decoder->VideoCtx->flags |= CODEC_FLAG_TRUNCATED;
}
// FIXME: own memory management for video frames.
if (video_codec->capabilities & AV_CODEC_CAP_DR1) {
@ -323,16 +318,16 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
}
if (video_codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) {
Debug(3, "codec: supports frame threads");
// decoder->VideoCtx->thread_count = 0;
// decoder->VideoCtx->thread_count = 0;
// decoder->VideoCtx->thread_type |= FF_THREAD_FRAME;
}
if (video_codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) {
Debug(3, "codec: supports slice threads");
// decoder->VideoCtx->thread_count = 0;
// decoder->VideoCtx->thread_count = 0;
// decoder->VideoCtx->thread_type |= FF_THREAD_SLICE;
}
// if (av_opt_set_int(decoder->VideoCtx, "refcounted_frames", 1, 0) < 0)
// Fatal(_("VAAPI Refcounts invalid\n"));
// if (av_opt_set_int(decoder->VideoCtx, "refcounted_frames", 1, 0) < 0)
// Fatal(_("VAAPI Refcounts invalid\n"));
decoder->VideoCtx->thread_safe_callbacks = 0;
#endif
@ -352,8 +347,9 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
#endif
#ifdef CUVID
if (strcmp(decoder->VideoCodec->long_name, "Nvidia CUVID MPEG2VIDEO decoder") == 0) { // deinterlace for mpeg2 is somehow broken
if (av_opt_set_int(decoder->VideoCtx->priv_data, "deint", deint, 0) < 0) { // adaptive
if (strcmp(decoder->VideoCodec->long_name,
"Nvidia CUVID MPEG2VIDEO decoder") == 0) { // deinterlace for mpeg2 is somehow broken
if (av_opt_set_int(decoder->VideoCtx->priv_data, "deint", deint, 0) < 0) { // adaptive
pthread_mutex_unlock(&CodecLockMutex);
Fatal(_("codec: can't set option deint to video codec!\n"));
}
@ -368,7 +364,7 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
Fatal(_("codec: can't set option drop 2.field to video codec!\n"));
}
} else if (strstr(decoder->VideoCodec->long_name, "Nvidia CUVID") != NULL) {
if (av_opt_set_int(decoder->VideoCtx->priv_data, "deint", deint, 0) < 0) { // adaptive
if (av_opt_set_int(decoder->VideoCtx->priv_data, "deint", deint, 0) < 0) { // adaptive
pthread_mutex_unlock(&CodecLockMutex);
Fatal(_("codec: can't set option deint to video codec!\n"));
}
@ -393,12 +389,12 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
pthread_mutex_unlock(&CodecLockMutex);
decoder->VideoCtx->opaque = decoder; // our structure
decoder->VideoCtx->opaque = decoder; // our structure
//decoder->VideoCtx->debug = FF_DEBUG_STARTCODE;
//decoder->VideoCtx->err_recognition |= AV_EF_EXPLODE;
// decoder->VideoCtx->debug = FF_DEBUG_STARTCODE;
// decoder->VideoCtx->err_recognition |= AV_EF_EXPLODE;
//av_log_set_level(AV_LOG_DEBUG);
// av_log_set_level(AV_LOG_DEBUG);
av_log_set_level(0);
decoder->VideoCtx->get_format = Codec_get_format;
@ -408,17 +404,17 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
decoder->VideoCtx->hwaccel_context = VideoGetHwAccelContext(decoder->HwDecoder);
//
// Prepare frame buffer for decoder
// Prepare frame buffer for decoder
//
#if 0
if (!(decoder->Frame = av_frame_alloc())) {
Fatal(_("codec: can't allocate video decoder frame buffer\n"));
Fatal(_("codec: can't allocate video decoder frame buffer\n"));
}
#endif
// reset buggy ffmpeg/libav flag
decoder->GetFormatDone = 0;
#if defined (YADIF) || defined (RASPI)
#if defined(YADIF) || defined(RASPI)
decoder->filter = 0;
#endif
}
@ -428,8 +424,7 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
**
** @param video_decoder private video decoder
*/
void CodecVideoClose(VideoDecoder * video_decoder)
{
void CodecVideoClose(VideoDecoder *video_decoder) {
AVFrame *frame;
// FIXME: play buffered data
@ -441,14 +436,14 @@ void CodecVideoClose(VideoDecoder * video_decoder)
#if 1
frame = av_frame_alloc();
avcodec_send_packet(video_decoder->VideoCtx, NULL);
while (avcodec_receive_frame(video_decoder->VideoCtx, frame) >= 0) ;
while (avcodec_receive_frame(video_decoder->VideoCtx, frame) >= 0)
;
av_frame_free(&frame);
#endif
avcodec_close(video_decoder->VideoCtx);
av_freep(&video_decoder->VideoCtx);
pthread_mutex_unlock(&CodecLockMutex);
}
}
#if 0
@ -472,16 +467,16 @@ void DisplayPts(AVCodecContext * video_ctx, AVFrame * frame)
pts = frame->pkt_pts;
if (pts == (int64_t) AV_NOPTS_VALUE) {
printf("*");
printf("*");
}
ms_delay = (1000 * video_ctx->time_base.num) / video_ctx->time_base.den;
ms_delay += frame->repeat_pict * ms_delay / 2;
printf("codec: PTS %s%s %" PRId64 " %d %d/%d %d/%d %dms\n", frame->repeat_pict ? "r" : " ",
frame->interlaced_frame ? "I" : " ", pts, (int)(pts - last_pts) / 90, video_ctx->time_base.num,
video_ctx->time_base.den, video_ctx->framerate.num, video_ctx->framerate.den, ms_delay);
printf("codec: PTS %s%s %" PRId64 " %d %d/%d %d/%d %dms\n", frame->repeat_pict ? "r" : " ",
frame->interlaced_frame ? "I" : " ", pts, (int)(pts - last_pts) / 90, video_ctx->time_base.num,
video_ctx->time_base.den, video_ctx->framerate.num, video_ctx->framerate.den, ms_delay);
if (pts != (int64_t) AV_NOPTS_VALUE) {
last_pts = pts;
last_pts = pts;
}
}
@ -495,14 +490,13 @@ void DisplayPts(AVCodecContext * video_ctx, AVFrame * frame)
*/
extern int CuvidTestSurfaces();
#if defined YADIF || defined (VAAPI)
extern int init_filters(AVCodecContext * dec_ctx, void *decoder, AVFrame * frame);
extern int push_filters(AVCodecContext * dec_ctx, void *decoder, AVFrame * frame);
#if defined YADIF || defined(VAAPI)
extern int init_filters(AVCodecContext *dec_ctx, void *decoder, AVFrame *frame);
extern int push_filters(AVCodecContext *dec_ctx, void *decoder, AVFrame *frame);
#endif
#ifdef VAAPI
void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
{
void CodecVideoDecode(VideoDecoder *decoder, const AVPacket *avpkt) {
AVCodecContext *video_ctx = decoder->VideoCtx;
if (video_ctx->codec_type == AVMEDIA_TYPE_VIDEO && CuvidTestSurfaces()) {
@ -510,7 +504,7 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
AVPacket pkt[1];
AVFrame *frame;
*pkt = *avpkt; // use copy
*pkt = *avpkt; // use copy
ret = avcodec_send_packet(video_ctx, pkt);
if (ret < 0) {
return;
@ -540,7 +534,8 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
decoder->filter = 2;
}
}
if (frame->interlaced_frame && decoder->filter == 2 && (frame->height != 720)) { // broken ZDF sends Interlaced flag
if (frame->interlaced_frame && decoder->filter == 2 &&
(frame->height != 720)) { // broken ZDF sends Interlaced flag
push_filters(video_ctx, decoder->HwDecoder, frame);
continue;
}
@ -557,8 +552,7 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
#ifdef CUVID
void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
{
void CodecVideoDecode(VideoDecoder *decoder, const AVPacket *avpkt) {
AVCodecContext *video_ctx;
AVFrame *frame;
int ret, ret1;
@ -567,10 +561,10 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
static uint64_t first_time = 0;
const AVPacket *pkt;
next_part:
next_part:
video_ctx = decoder->VideoCtx;
pkt = avpkt; // use copy
pkt = avpkt; // use copy
got_frame = 0;
// printf("decode packet %d\n",(GetusTicks()-first_time)/1000000);
@ -585,21 +579,23 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
if (!CuvidTestSurfaces())
usleep(1000);
// printf("send packet to decode %s %04x\n",consumed?"ok":"Full",ret1);
// printf("send packet to decode %s %04x\n",consumed?"ok":"Full",ret1);
if ((ret1 == AVERROR(EAGAIN) || ret1 == AVERROR_EOF || ret1 >= 0) && CuvidTestSurfaces()) {
ret = 0;
while ((ret >= 0) && CuvidTestSurfaces()) { // get frames until empty snd Surfaces avail.
frame = av_frame_alloc();
ret = avcodec_receive_frame(video_ctx, frame); // get new frame
if (ret >= 0) { // one is avail.
ret = avcodec_receive_frame(video_ctx, frame); // get new frame
if (ret >= 0) { // one is avail.
got_frame = 1;
} else {
got_frame = 0;
}
// printf("got %s packet from decoder\n",got_frame?"1":"no");
if (got_frame) { // frame completed
// printf("video frame pts %#012" PRIx64 " %dms\n",frame->pts,(int)(apts - frame->pts) / 90);
// printf("got %s packet from
// decoder\n",got_frame?"1":"no");
if (got_frame) { // frame completed
// printf("video frame pts %#012" PRIx64 "
//%dms\n",frame->pts,(int)(apts - frame->pts) / 90);
#ifdef YADIF
if (decoder->filter) {
if (decoder->filter == 1) {
@ -611,7 +607,8 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
decoder->filter = 2;
}
}
if (frame->interlaced_frame && decoder->filter == 2 && (frame->height != 720)) { // broken ZDF sends Interlaced flag
if (frame->interlaced_frame && decoder->filter == 2 &&
(frame->height != 720)) { // broken ZDF sends Interlaced flag
ret = push_filters(video_ctx, decoder->HwDecoder, frame);
// av_frame_unref(frame);
continue;
@ -634,9 +631,8 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
}
if (!consumed) {
goto next_part; // try again to stuff decoder
goto next_part; // try again to stuff decoder
}
}
#endif
@ -645,8 +641,7 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
**
** @param decoder video decoder data
*/
void CodecVideoFlushBuffers(VideoDecoder * decoder)
{
void CodecVideoFlushBuffers(VideoDecoder *decoder) {
if (decoder->VideoCtx) {
avcodec_flush_buffers(decoder->VideoCtx);
}
@ -666,58 +661,56 @@ typedef struct _audio_decoder_ AudioDecoder;
///
/// Audio decoder structure.
///
struct _audio_decoder_
{
AVCodec *AudioCodec; ///< audio codec
AVCodecContext *AudioCtx; ///< audio codec context
struct _audio_decoder_ {
AVCodec *AudioCodec; ///< audio codec
AVCodecContext *AudioCtx; ///< audio codec context
char Passthrough; ///< current pass-through flags
int SampleRate; ///< current stream sample rate
int Channels; ///< current stream channels
char Passthrough; ///< current pass-through flags
int SampleRate; ///< current stream sample rate
int Channels; ///< current stream channels
int HwSampleRate; ///< hw sample rate
int HwChannels; ///< hw channels
int HwSampleRate; ///< hw sample rate
int HwChannels; ///< hw channels
AVFrame *Frame; ///< decoded audio frame buffer
AVFrame *Frame; ///< decoded audio frame buffer
#ifdef USE_SWRESAMPLE
#if LIBSWRESAMPLE_VERSION_INT < AV_VERSION_INT(0, 15, 100)
struct SwrContext *Resample; ///< ffmpeg software resample context
struct SwrContext *Resample; ///< ffmpeg software resample context
#else
SwrContext *Resample; ///< ffmpeg software resample context
SwrContext *Resample; ///< ffmpeg software resample context
#endif
#endif
#ifdef USE_AVRESAMPLE
AVAudioResampleContext *Resample; ///< libav software resample context
AVAudioResampleContext *Resample; ///< libav software resample context
#endif
uint16_t Spdif[24576 / 2]; ///< SPDIF output buffer
int SpdifIndex; ///< index into SPDIF output buffer
int SpdifCount; ///< SPDIF repeat counter
uint16_t Spdif[24576 / 2]; ///< SPDIF output buffer
int SpdifIndex; ///< index into SPDIF output buffer
int SpdifCount; ///< SPDIF repeat counter
int64_t LastDelay; ///< last delay
struct timespec LastTime; ///< last time
int64_t LastPTS; ///< last PTS
int64_t LastDelay; ///< last delay
struct timespec LastTime; ///< last time
int64_t LastPTS; ///< last PTS
int Drift; ///< accumulated audio drift
int DriftCorr; ///< audio drift correction value
int DriftFrac; ///< audio drift fraction for ac3
int Drift; ///< accumulated audio drift
int DriftCorr; ///< audio drift correction value
int DriftFrac; ///< audio drift fraction for ac3
};
///
/// IEC Data type enumeration.
///
enum IEC61937
{
IEC61937_AC3 = 0x01, ///< AC-3 data
enum IEC61937 {
IEC61937_AC3 = 0x01, ///< AC-3 data
// FIXME: more data types
IEC61937_EAC3 = 0x15, ///< E-AC-3 data
IEC61937_EAC3 = 0x15, ///< E-AC-3 data
};
#ifdef USE_AUDIO_DRIFT_CORRECTION
#define CORRECT_PCM 1 ///< do PCM audio-drift correction
#define CORRECT_AC3 2 ///< do AC-3 audio-drift correction
static char CodecAudioDrift; ///< flag: enable audio-drift correction
#define CORRECT_PCM 1 ///< do PCM audio-drift correction
#define CORRECT_AC3 2 ///< do AC-3 audio-drift correction
static char CodecAudioDrift; ///< flag: enable audio-drift correction
#else
static const int CodecAudioDrift = 0;
#endif
@ -729,15 +722,14 @@ static char CodecPassthrough;
#else
static const int CodecPassthrough = 0;
#endif
static char CodecDownmix; ///< enable AC-3 decoder downmix
static char CodecDownmix; ///< enable AC-3 decoder downmix
/**
** Allocate a new audio decoder context.
**
** @returns private decoder pointer for audio decoder.
*/
AudioDecoder *CodecAudioNewDecoder(void)
{
AudioDecoder *CodecAudioNewDecoder(void) {
AudioDecoder *audio_decoder;
if (!(audio_decoder = calloc(1, sizeof(*audio_decoder)))) {
@ -755,9 +747,8 @@ AudioDecoder *CodecAudioNewDecoder(void)
**
** @param decoder private audio decoder
*/
void CodecAudioDelDecoder(AudioDecoder * decoder)
{
av_frame_free(&decoder->Frame); // callee does checks
void CodecAudioDelDecoder(AudioDecoder *decoder) {
av_frame_free(&decoder->Frame); // callee does checks
free(decoder);
}
@ -767,8 +758,7 @@ void CodecAudioDelDecoder(AudioDecoder * decoder)
** @param audio_decoder private audio decoder
** @param codec_id audio codec id
*/
void CodecAudioOpen(AudioDecoder * audio_decoder, int codec_id)
{
void CodecAudioOpen(AudioDecoder *audio_decoder, int codec_id) {
AVCodec *audio_codec;
Debug(3, "codec: using audio codec ID %#06x (%s)\n", codec_id, avcodec_get_name(codec_id));
@ -817,8 +807,7 @@ void CodecAudioOpen(AudioDecoder * audio_decoder, int codec_id)
**
** @param audio_decoder private audio decoder
*/
void CodecAudioClose(AudioDecoder * audio_decoder)
{
void CodecAudioClose(AudioDecoder *audio_decoder) {
// FIXME: output any buffered data
#ifdef USE_SWRESAMPLE
@ -844,8 +833,7 @@ void CodecAudioClose(AudioDecoder * audio_decoder)
**
** @param mask enable mask (PCM, AC-3)
*/
void CodecSetAudioDrift(int mask)
{
void CodecSetAudioDrift(int mask) {
#ifdef USE_AUDIO_DRIFT_CORRECTION
CodecAudioDrift = mask & (CORRECT_PCM | CORRECT_AC3);
#endif
@ -857,8 +845,7 @@ void CodecSetAudioDrift(int mask)
**
** @param mask enable mask (PCM, AC-3, E-AC-3)
*/
void CodecSetAudioPassthrough(int mask)
{
void CodecSetAudioPassthrough(int mask) {
#ifdef USE_PASSTHROUGH
CodecPassthrough = mask & (CodecPCM | CodecAC3 | CodecEAC3);
#endif
@ -870,8 +857,7 @@ void CodecSetAudioPassthrough(int mask)
**
** @param onoff enable/disable downmix.
*/
void CodecSetAudioDownmix(int onoff)
{
void CodecSetAudioDownmix(int onoff) {
if (onoff == -1) {
CodecDownmix ^= 1;
return;
@ -882,16 +868,15 @@ void CodecSetAudioDownmix(int onoff)
/**
** Reorder audio frame.
**
** ffmpeg L R C Ls Rs -> alsa L R Ls Rs C
** ffmpeg L R C LFE Ls Rs -> alsa L R Ls Rs C LFE
** ffmpeg L R C LFE Ls Rs Rl Rr -> alsa L R Ls Rs C LFE Rl Rr
** ffmpeg L R C Ls Rs -> alsa L R Ls Rs C
** ffmpeg L R C LFE Ls Rs -> alsa L R Ls Rs C LFE
** ffmpeg L R C LFE Ls Rs Rl Rr -> alsa L R Ls Rs C LFE Rl Rr
**
** @param buf[IN,OUT] sample buffer
** @param size size of sample buffer in bytes
** @param channels number of channels interleaved in sample buffer
** @param buf[IN,OUT] sample buffer
** @param size size of sample buffer in bytes
** @param channels number of channels interleaved in sample buffer
*/
static void CodecReorderAudioFrame(int16_t * buf, int size, int channels)
{
static void CodecReorderAudioFrame(int16_t *buf, int size, int channels) {
int i;
int c;
int ls;
@ -945,17 +930,16 @@ static void CodecReorderAudioFrame(int16_t * buf, int size, int channels)
** @param audio_decoder audio decoder data
** @param[out] passthrough pass-through output
*/
static int CodecAudioUpdateHelper(AudioDecoder * audio_decoder, int *passthrough)
{
static int CodecAudioUpdateHelper(AudioDecoder *audio_decoder, int *passthrough) {
const AVCodecContext *audio_ctx;
int err;
audio_ctx = audio_decoder->AudioCtx;
Debug(3, "codec/audio: format change %s %dHz *%d channels%s%s%s%s%s\n",
av_get_sample_fmt_name(audio_ctx->sample_fmt), audio_ctx->sample_rate, audio_ctx->channels,
CodecPassthrough & CodecPCM ? " PCM" : "", CodecPassthrough & CodecMPA ? " MPA" : "",
CodecPassthrough & CodecAC3 ? " AC-3" : "", CodecPassthrough & CodecEAC3 ? " E-AC-3" : "",
CodecPassthrough ? " pass-through" : "");
av_get_sample_fmt_name(audio_ctx->sample_fmt), audio_ctx->sample_rate, audio_ctx->channels,
CodecPassthrough & CodecPCM ? " PCM" : "", CodecPassthrough & CodecMPA ? " MPA" : "",
CodecPassthrough & CodecAC3 ? " AC-3" : "", CodecPassthrough & CodecEAC3 ? " E-AC-3" : "",
CodecPassthrough ? " pass-through" : "");
*passthrough = 0;
audio_decoder->SampleRate = audio_ctx->sample_rate;
@ -965,14 +949,14 @@ static int CodecAudioUpdateHelper(AudioDecoder * audio_decoder, int *passthrough
audio_decoder->Passthrough = CodecPassthrough;
// SPDIF/HDMI pass-through
if ((CodecPassthrough & CodecAC3 && audio_ctx->codec_id == AV_CODEC_ID_AC3)
|| (CodecPassthrough & CodecEAC3 && audio_ctx->codec_id == AV_CODEC_ID_EAC3)) {
if ((CodecPassthrough & CodecAC3 && audio_ctx->codec_id == AV_CODEC_ID_AC3) ||
(CodecPassthrough & CodecEAC3 && audio_ctx->codec_id == AV_CODEC_ID_EAC3)) {
if (audio_ctx->codec_id == AV_CODEC_ID_EAC3) {
// E-AC-3 over HDMI some receivers need HBR
audio_decoder->HwSampleRate *= 4;
}
audio_decoder->HwChannels = 2;
audio_decoder->SpdifIndex = 0; // reset buffer
audio_decoder->SpdifIndex = 0; // reset buffer
audio_decoder->SpdifCount = 0;
*passthrough = 1;
}
@ -981,8 +965,8 @@ static int CodecAudioUpdateHelper(AudioDecoder * audio_decoder, int *passthrough
// try E-AC-3 none HBR
audio_decoder->HwSampleRate /= 4;
if (audio_ctx->codec_id != AV_CODEC_ID_EAC3
|| (err = AudioSetup(&audio_decoder->HwSampleRate, &audio_decoder->HwChannels, *passthrough))) {
if (audio_ctx->codec_id != AV_CODEC_ID_EAC3 ||
(err = AudioSetup(&audio_decoder->HwSampleRate, &audio_decoder->HwChannels, *passthrough))) {
Debug(3, "codec/audio: audio setup error\n");
// FIXME: handle errors
@ -993,8 +977,8 @@ static int CodecAudioUpdateHelper(AudioDecoder * audio_decoder, int *passthrough
}
Debug(3, "codec/audio: resample %s %dHz *%d -> %s %dHz *%d\n", av_get_sample_fmt_name(audio_ctx->sample_fmt),
audio_ctx->sample_rate, audio_ctx->channels, av_get_sample_fmt_name(AV_SAMPLE_FMT_S16),
audio_decoder->HwSampleRate, audio_decoder->HwChannels);
audio_ctx->sample_rate, audio_ctx->channels, av_get_sample_fmt_name(AV_SAMPLE_FMT_S16),
audio_decoder->HwSampleRate, audio_decoder->HwChannels);
return 0;
}
@ -1003,10 +987,9 @@ static int CodecAudioUpdateHelper(AudioDecoder * audio_decoder, int *passthrough
** Audio pass-through decoder helper.
**
** @param audio_decoder audio decoder data
** @param avpkt undecoded audio packet
** @param avpkt undecoded audio packet
*/
static int CodecAudioPassthroughHelper(AudioDecoder * audio_decoder, const AVPacket * avpkt)
{
static int CodecAudioPassthroughHelper(AudioDecoder *audio_decoder, const AVPacket *avpkt) {
#ifdef USE_PASSTHROUGH
const AVCodecContext *audio_ctx;
@ -1025,14 +1008,13 @@ static int CodecAudioPassthroughHelper(AudioDecoder * audio_decoder, const AVPac
if (CodecAudioDrift & CORRECT_AC3) {
int x;
x = (audio_decoder->DriftFrac +
(audio_decoder->DriftCorr * spdif_sz)) / (10 * audio_decoder->HwSampleRate * 100);
audio_decoder->DriftFrac =
(audio_decoder->DriftFrac +
(audio_decoder->DriftCorr * spdif_sz)) % (10 * audio_decoder->HwSampleRate * 100);
x = (audio_decoder->DriftFrac + (audio_decoder->DriftCorr * spdif_sz)) /
(10 * audio_decoder->HwSampleRate * 100);
audio_decoder->DriftFrac = (audio_decoder->DriftFrac + (audio_decoder->DriftCorr * spdif_sz)) %
(10 * audio_decoder->HwSampleRate * 100);
// round to word border
x *= audio_decoder->HwChannels * 4;
if (x < -64) { // limit correction
if (x < -64) { // limit correction
x = -64;
} else if (x > 64) {
x = 64;
@ -1047,7 +1029,7 @@ static int CodecAudioPassthroughHelper(AudioDecoder * audio_decoder, const AVPac
Error(_("codec/audio: decoded data smaller than encoded\n"));
return -1;
}
spdif[0] = htole16(0xF872); // iec 61937 sync word
spdif[0] = htole16(0xF872); // iec 61937 sync word
spdif[1] = htole16(0x4E1F);
spdif[2] = htole16(IEC61937_AC3 | (avpkt->data[5] & 0x07) << 8);
spdif[3] = htole16(avpkt->size * 8);
@ -1068,7 +1050,7 @@ static int CodecAudioPassthroughHelper(AudioDecoder * audio_decoder, const AVPac
// build SPDIF header and append A52 audio to it
// avpkt is the original data
spdif = audio_decoder->Spdif;
spdif_sz = 24576; // 4 * 6144
spdif_sz = 24576; // 4 * 6144
if (audio_decoder->HwSampleRate == 48000) {
spdif_sz = 6144;
}
@ -1078,8 +1060,8 @@ static int CodecAudioPassthroughHelper(AudioDecoder * audio_decoder, const AVPac
}
// check if we must pack multiple packets
repeat = 1;
if ((avpkt->data[4] & 0xc0) != 0xc0) { // fscod
static const uint8_t eac3_repeat[4] = { 6, 3, 2, 1 };
if ((avpkt->data[4] & 0xc0) != 0xc0) { // fscod
static const uint8_t eac3_repeat[4] = {6, 3, 2, 1};
// fscod2
repeat = eac3_repeat[(avpkt->data[4] & 0x30) >> 4];
@ -1095,7 +1077,7 @@ static int CodecAudioPassthroughHelper(AudioDecoder * audio_decoder, const AVPac
return 1;
}
spdif[0] = htole16(0xF872); // iec 61937 sync word
spdif[0] = htole16(0xF872); // iec 61937 sync word
spdif[1] = htole16(0x4E1F);
spdif[2] = htole16(IEC61937_EAC3);
spdif[3] = htole16(audio_decoder->SpdifIndex * 8);
@ -1118,10 +1100,9 @@ static int CodecAudioPassthroughHelper(AudioDecoder * audio_decoder, const AVPac
** Set/update audio pts clock.
**
** @param audio_decoder audio decoder data
** @param pts presentation timestamp
** @param pts presentation timestamp
*/
static void CodecAudioSetClock(AudioDecoder * audio_decoder, int64_t pts)
{
static void CodecAudioSetClock(AudioDecoder *audio_decoder, int64_t pts) {
#ifdef USE_AUDIO_DRIFT_CORRECTION
struct timespec nowtime;
int64_t delay;
@ -1152,8 +1133,8 @@ static void CodecAudioSetClock(AudioDecoder * audio_decoder, int64_t pts)
return;
}
tim_diff = (nowtime.tv_sec - audio_decoder->LastTime.tv_sec)
* 1000 * 1000 * 1000 + (nowtime.tv_nsec - audio_decoder->LastTime.tv_nsec);
tim_diff = (nowtime.tv_sec - audio_decoder->LastTime.tv_sec) * 1000 * 1000 * 1000 +
(nowtime.tv_nsec - audio_decoder->LastTime.tv_nsec);
drift = (tim_diff * 90) / (1000 * 1000) - pts_diff + delay - audio_decoder->LastDelay;
@ -1165,7 +1146,7 @@ static void CodecAudioSetClock(AudioDecoder * audio_decoder, int64_t pts)
if (0) {
Debug(3, "codec/audio: interval P:%5" PRId64 "ms T:%5" PRId64 "ms D:%4" PRId64 "ms %f %d\n", pts_diff / 90,
tim_diff / (1000 * 1000), delay / 90, drift / 90.0, audio_decoder->DriftCorr);
tim_diff / (1000 * 1000), delay / 90, drift / 90.0, audio_decoder->DriftCorr);
}
// underruns and av_resample have the same time :(((
if (abs(drift) > 10 * 90) {
@ -1173,7 +1154,7 @@ static void CodecAudioSetClock(AudioDecoder * audio_decoder, int64_t pts)
Debug(3, "codec/audio: drift(%6d) %3dms reset\n", audio_decoder->DriftCorr, drift / 90);
audio_decoder->LastDelay = 0;
#ifdef DEBUG
corr = 0; // keep gcc happy
corr = 0; // keep gcc happy
#endif
} else {
@ -1181,14 +1162,13 @@ static void CodecAudioSetClock(AudioDecoder * audio_decoder, int64_t pts)
audio_decoder->Drift = drift;
corr = (10 * audio_decoder->HwSampleRate * drift) / (90 * 1000);
// SPDIF/HDMI passthrough
if ((CodecAudioDrift & CORRECT_AC3) && (!(CodecPassthrough & CodecAC3)
|| audio_decoder->AudioCtx->codec_id != AV_CODEC_ID_AC3)
&& (!(CodecPassthrough & CodecEAC3)
|| audio_decoder->AudioCtx->codec_id != AV_CODEC_ID_EAC3)) {
if ((CodecAudioDrift & CORRECT_AC3) &&
(!(CodecPassthrough & CodecAC3) || audio_decoder->AudioCtx->codec_id != AV_CODEC_ID_AC3) &&
(!(CodecPassthrough & CodecEAC3) || audio_decoder->AudioCtx->codec_id != AV_CODEC_ID_EAC3)) {
audio_decoder->DriftCorr = -corr;
}
if (audio_decoder->DriftCorr < -20000) { // limit correction
if (audio_decoder->DriftCorr < -20000) { // limit correction
audio_decoder->DriftCorr = -20000;
} else if (audio_decoder->DriftCorr > 20000) {
audio_decoder->DriftCorr = 20000;
@ -1237,8 +1217,7 @@ static void CodecAudioSetClock(AudioDecoder * audio_decoder, int64_t pts)
**
** @param audio_decoder audio decoder data
*/
static void CodecAudioUpdateFormat(AudioDecoder * audio_decoder)
{
static void CodecAudioUpdateFormat(AudioDecoder *audio_decoder) {
int passthrough;
const AVCodecContext *audio_ctx;
@ -1246,25 +1225,24 @@ static void CodecAudioUpdateFormat(AudioDecoder * audio_decoder)
// FIXME: handle swresample format conversions.
return;
}
if (passthrough) { // pass-through no conversion allowed
if (passthrough) { // pass-through no conversion allowed
return;
}
audio_ctx = audio_decoder->AudioCtx;
#ifdef DEBUG
if (audio_ctx->sample_fmt == AV_SAMPLE_FMT_S16 && audio_ctx->sample_rate == audio_decoder->HwSampleRate
&& !CodecAudioDrift) {
if (audio_ctx->sample_fmt == AV_SAMPLE_FMT_S16 && audio_ctx->sample_rate == audio_decoder->HwSampleRate &&
!CodecAudioDrift) {
// FIXME: use Resample only, when it is needed!
fprintf(stderr, "no resample needed\n");
}
#endif
#ifdef USE_SWRESAMPLE
audio_decoder->Resample =
swr_alloc_set_opts(audio_decoder->Resample, audio_ctx->channel_layout, AV_SAMPLE_FMT_S16,
audio_decoder->HwSampleRate, audio_ctx->channel_layout, audio_ctx->sample_fmt, audio_ctx->sample_rate, 0,
NULL);
audio_decoder->Resample = swr_alloc_set_opts(audio_decoder->Resample, audio_ctx->channel_layout, AV_SAMPLE_FMT_S16,
audio_decoder->HwSampleRate, audio_ctx->channel_layout,
audio_ctx->sample_fmt, audio_ctx->sample_rate, 0, NULL);
if (audio_decoder->Resample) {
swr_init(audio_decoder->Resample);
} else {
@ -1301,11 +1279,10 @@ static void CodecAudioUpdateFormat(AudioDecoder * audio_decoder)
** @note the caller has not aligned avpkt and not cleared the end.
**
** @param audio_decoder audio decoder data
** @param avpkt audio packet
** @param avpkt audio packet
*/
void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
{
void CodecAudioDecode(AudioDecoder *audio_decoder, const AVPacket *avpkt) {
AVCodecContext *audio_ctx = audio_decoder->AudioCtx;
if (audio_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
@ -1314,7 +1291,7 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
AVFrame *frame = audio_decoder->Frame;
av_frame_unref(frame);
*pkt = *avpkt; // use copy
*pkt = *avpkt; // use copy
ret = avcodec_send_packet(audio_ctx, pkt);
if (ret < 0) {
Debug(3, "codec: sending audio packet failed");
@ -1328,16 +1305,17 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
if (ret >= 0) {
// update audio clock
if (avpkt->pts != (int64_t) AV_NOPTS_VALUE) {
if (avpkt->pts != (int64_t)AV_NOPTS_VALUE) {
CodecAudioSetClock(audio_decoder, avpkt->pts);
}
// format change
if (audio_decoder->Passthrough != CodecPassthrough || audio_decoder->SampleRate != audio_ctx->sample_rate
|| audio_decoder->Channels != audio_ctx->channels) {
if (audio_decoder->Passthrough != CodecPassthrough ||
audio_decoder->SampleRate != audio_ctx->sample_rate ||
audio_decoder->Channels != audio_ctx->channels) {
CodecAudioUpdateFormat(audio_decoder);
}
if (!audio_decoder->HwSampleRate || !audio_decoder->HwChannels) {
return; // unsupported sample format
return; // unsupported sample format
}
if (CodecAudioPassthroughHelper(audio_decoder, avpkt)) {
return;
@ -1347,13 +1325,12 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
uint8_t *out[1];
out[0] = outbuf;
ret =
swr_convert(audio_decoder->Resample, out, sizeof(outbuf) / (2 * audio_decoder->HwChannels),
(const uint8_t **)frame->extended_data, frame->nb_samples);
ret = swr_convert(audio_decoder->Resample, out, sizeof(outbuf) / (2 * audio_decoder->HwChannels),
(const uint8_t **)frame->extended_data, frame->nb_samples);
if (ret > 0) {
if (!(audio_decoder->Passthrough & CodecPCM)) {
CodecReorderAudioFrame((int16_t *) outbuf, ret * 2 * audio_decoder->HwChannels,
audio_decoder->HwChannels);
CodecReorderAudioFrame((int16_t *)outbuf, ret * 2 * audio_decoder->HwChannels,
audio_decoder->HwChannels);
}
AudioEnqueue(outbuf, ret * 2 * audio_decoder->HwChannels);
}
@ -1370,11 +1347,7 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
**
** @param decoder audio decoder data
*/
void CodecAudioFlushBuffers(AudioDecoder * decoder)
{
avcodec_flush_buffers(decoder->AudioCtx);
}
void CodecAudioFlushBuffers(AudioDecoder *decoder) { avcodec_flush_buffers(decoder->AudioCtx); }
//----------------------------------------------------------------------------
// Codec
@ -1383,18 +1356,13 @@ void CodecAudioFlushBuffers(AudioDecoder * decoder)
/**
** Empty log callback
*/
static void CodecNoopCallback( __attribute__((unused))
void *ptr, __attribute__((unused))
int level, __attribute__((unused))
const char *fmt, __attribute__((unused)) va_list vl)
{
}
static void CodecNoopCallback(__attribute__((unused)) void *ptr, __attribute__((unused)) int level,
__attribute__((unused)) const char *fmt, __attribute__((unused)) va_list vl) {}
/**
** Codec init
*/
void CodecInit(void)
{
void CodecInit(void) {
pthread_mutex_init(&CodecLockMutex, NULL);
#ifndef DEBUG
// disable display ffmpeg error messages
@ -1407,7 +1375,4 @@ void CodecInit(void)
/**
** Codec exit.
*/
void CodecExit(void)
{
pthread_mutex_destroy(&CodecLockMutex);
}
void CodecExit(void) { pthread_mutex_destroy(&CodecLockMutex); }

37
codec.h
View File

@ -27,16 +27,15 @@
// Defines
//----------------------------------------------------------------------------
#define CodecPCM 0x01 ///< PCM bit mask
#define CodecMPA 0x02 ///< MPA bit mask (planned)
#define CodecAC3 0x04 ///< AC-3 bit mask
#define CodecEAC3 0x08 ///< E-AC-3 bit mask
#define CodecDTS 0x10 ///< DTS bit mask (planned)
#define CodecPCM 0x01 ///< PCM bit mask
#define CodecMPA 0x02 ///< MPA bit mask (planned)
#define CodecAC3 0x04 ///< AC-3 bit mask
#define CodecEAC3 0x08 ///< E-AC-3 bit mask
#define CodecDTS 0x10 ///< DTS bit mask (planned)
#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000
enum HWAccelID
{
enum HWAccelID {
HWACCEL_NONE = 0,
HWACCEL_AUTO,
HWACCEL_VDPAU,
@ -53,19 +52,18 @@ extern AVBufferRef *hw_device_ctx;
///
/// Video decoder structure.
///
struct _video_decoder_
{
VideoHwDecoder *HwDecoder; ///< video hardware decoder
struct _video_decoder_ {
VideoHwDecoder *HwDecoder; ///< video hardware decoder
int GetFormatDone; ///< flag get format called!
AVCodec *VideoCodec; ///< video codec
AVCodecContext *VideoCtx; ///< video codec context
int GetFormatDone; ///< flag get format called!
AVCodec *VideoCodec; ///< video codec
AVCodecContext *VideoCtx; ///< video codec context
// #ifdef FFMPEG_WORKAROUND_ARTIFACTS
int FirstKeyFrame; ///< flag first frame
int FirstKeyFrame; ///< flag first frame
// #endif
// AVFrame *Frame; ///< decoded video frame
// AVFrame *Frame; ///< decoded video frame
int filter; // flag for deint filter
int filter; // flag for deint filter
/* hwaccel options */
enum HWAccelID hwaccel_id;
@ -75,9 +73,9 @@ struct _video_decoder_
/* hwaccel context */
enum HWAccelID active_hwaccel_id;
void *hwaccel_ctx;
void (*hwaccel_uninit)(AVCodecContext * s);
int (*hwaccel_get_buffer)(AVCodecContext * s, AVFrame * frame, int flags);
int (*hwaccel_retrieve_data)(AVCodecContext * s, AVFrame * frame);
void (*hwaccel_uninit)(AVCodecContext *s);
int (*hwaccel_get_buffer)(AVCodecContext *s, AVFrame *frame, int flags);
int (*hwaccel_retrieve_data)(AVCodecContext *s, AVFrame *frame);
enum AVPixelFormat hwaccel_pix_fmt;
enum AVPixelFormat hwaccel_retrieved_pix_fmt;
AVBufferRef *hw_frames_ctx;
@ -87,7 +85,6 @@ struct _video_decoder_
double cached_hdr_peak;
// From VO
struct mp_hwdec_devices *hwdec_devs;
};
//----------------------------------------------------------------------------

260
common.h
View File

@ -19,17 +19,17 @@
#ifndef MPLAYER_GL_COMMON_H
#define MPLAYER_GL_COMMON_H
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#if 0
#include "config.h"
#include "common/msg.h"
#include "config.h"
#include "misc/bstr.h"
#include "video/out/vo.h"
#include "video/csputils.h"
#include "video/mp_image.h"
#include "video/out/vo.h"
#endif
#if HAVE_GL_COCOA
@ -53,9 +53,8 @@
struct GL;
typedef struct GL GL;
enum
{
MPGL_CAP_ROW_LENGTH = (1 << 4), // GL_[UN]PACK_ROW_LENGTH
enum {
MPGL_CAP_ROW_LENGTH = (1 << 4), // GL_[UN]PACK_ROW_LENGTH
MPGL_CAP_FB = (1 << 5),
MPGL_CAP_VAO = (1 << 6),
MPGL_CAP_TEX_RG = (1 << 10), // GL_ARB_texture_rg / GL 3.x
@ -69,157 +68,158 @@ enum
MPGL_CAP_ARB_FLOAT = (1 << 19), // GL_ARB_texture_float
MPGL_CAP_EXT_CR_HFLOAT = (1 << 20), // GL_EXT_color_buffer_half_float
MPGL_CAP_SW = (1 << 30), // indirect or sw renderer
MPGL_CAP_SW = (1 << 30), // indirect or sw renderer
};
// E.g. 310 means 3.1
// Code doesn't have to use the macros; they are for convenience only.
#define MPGL_VER(major, minor) (((major) * 100) + (minor) * 10)
#define MPGL_VER(major, minor) (((major)*100) + (minor)*10)
#define MPGL_VER_GET_MAJOR(ver) ((unsigned)(ver) / 100)
#define MPGL_VER_GET_MINOR(ver) ((unsigned)(ver) % 100 / 10)
#define MPGL_VER_P(ver) MPGL_VER_GET_MAJOR(ver), MPGL_VER_GET_MINOR(ver)
void mpgl_load_functions(GL * gl, void *(*getProcAddress)(const GLubyte *), const char *ext2, struct mp_log *log);
void mpgl_load_functions2(GL * gl, void *(*get_fn)(void *ctx, const char *n), void *fn_ctx, const char *ext2,
struct mp_log *log);
void mpgl_load_functions(GL *gl, void *(*getProcAddress)(const GLubyte *), const char *ext2, struct mp_log *log);
void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n), void *fn_ctx, const char *ext2,
struct mp_log *log);
typedef void (GLAPIENTRY * MP_GLDEBUGPROC) (GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void *);
typedef void(GLAPIENTRY *MP_GLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *, const void *);
// function pointers loaded from the OpenGL library
struct GL
{
int version; // MPGL_VER() mangled (e.g. 210 for 2.1)
int es; // es version (e.g. 300), 0 for desktop GL
int glsl_version; // e.g. 130 for GLSL 1.30
char *extensions; // Equivalent to GL_EXTENSIONS
int mpgl_caps; // Bitfield of MPGL_CAP_* constants
bool debug_context; // use of e.g. GLX_CONTEXT_DEBUG_BIT_ARB
GLuint main_fb; // framebuffer to render to (normally 0)
struct GL {
int version; // MPGL_VER() mangled (e.g. 210 for 2.1)
int es; // es version (e.g. 300), 0 for desktop GL
int glsl_version; // e.g. 130 for GLSL 1.30
char *extensions; // Equivalent to GL_EXTENSIONS
int mpgl_caps; // Bitfield of MPGL_CAP_* constants
bool debug_context; // use of e.g. GLX_CONTEXT_DEBUG_BIT_ARB
GLuint main_fb; // framebuffer to render to (normally 0)
void (GLAPIENTRY * Viewport) (GLint, GLint, GLsizei, GLsizei);
void (GLAPIENTRY * Clear) (GLbitfield);
void (GLAPIENTRY * GenTextures) (GLsizei, GLuint *);
void (GLAPIENTRY * DeleteTextures) (GLsizei, const GLuint *);
void (GLAPIENTRY * ClearColor) (GLclampf, GLclampf, GLclampf, GLclampf);
void (GLAPIENTRY * Enable) (GLenum);
void (GLAPIENTRY * Disable) (GLenum);
const GLubyte *(GLAPIENTRY * GetString) (GLenum);
void (GLAPIENTRY * BlendFuncSeparate) (GLenum, GLenum, GLenum, GLenum);
void (GLAPIENTRY * Flush) (void);
void (GLAPIENTRY * Finish) (void);
void (GLAPIENTRY * PixelStorei) (GLenum, GLint);
void (GLAPIENTRY * TexImage1D) (GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
void (GLAPIENTRY * TexImage2D) (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
void (GLAPIENTRY * TexSubImage2D) (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
void (GLAPIENTRY * TexParameteri) (GLenum, GLenum, GLint);
void (GLAPIENTRY * GetIntegerv) (GLenum, GLint *);
void (GLAPIENTRY * ReadPixels) (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *);
void (GLAPIENTRY * ReadBuffer) (GLenum);
void (GLAPIENTRY * DrawArrays) (GLenum, GLint, GLsizei);
GLenum(GLAPIENTRY * GetError) (void);
void (GLAPIENTRY * GetTexLevelParameteriv) (GLenum, GLint, GLenum, GLint *);
void (GLAPIENTRY * Scissor) (GLint, GLint, GLsizei, GLsizei);
void(GLAPIENTRY *Viewport)(GLint, GLint, GLsizei, GLsizei);
void(GLAPIENTRY *Clear)(GLbitfield);
void(GLAPIENTRY *GenTextures)(GLsizei, GLuint *);
void(GLAPIENTRY *DeleteTextures)(GLsizei, const GLuint *);
void(GLAPIENTRY *ClearColor)(GLclampf, GLclampf, GLclampf, GLclampf);
void(GLAPIENTRY *Enable)(GLenum);
void(GLAPIENTRY *Disable)(GLenum);
const GLubyte *(GLAPIENTRY *GetString)(GLenum);
void(GLAPIENTRY *BlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum);
void(GLAPIENTRY *Flush)(void);
void(GLAPIENTRY *Finish)(void);
void(GLAPIENTRY *PixelStorei)(GLenum, GLint);
void(GLAPIENTRY *TexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
void(GLAPIENTRY *TexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
void(GLAPIENTRY *TexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
void(GLAPIENTRY *TexParameteri)(GLenum, GLenum, GLint);
void(GLAPIENTRY *GetIntegerv)(GLenum, GLint *);
void(GLAPIENTRY *ReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *);
void(GLAPIENTRY *ReadBuffer)(GLenum);
void(GLAPIENTRY *DrawArrays)(GLenum, GLint, GLsizei);
GLenum(GLAPIENTRY *GetError)(void);
void(GLAPIENTRY *GetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *);
void(GLAPIENTRY *Scissor)(GLint, GLint, GLsizei, GLsizei);
void (GLAPIENTRY * GenBuffers) (GLsizei, GLuint *);
void (GLAPIENTRY * DeleteBuffers) (GLsizei, const GLuint *);
void (GLAPIENTRY * BindBuffer) (GLenum, GLuint);
void (GLAPIENTRY * BindBufferBase) (GLenum, GLuint, GLuint);
GLvoid *(GLAPIENTRY * MapBufferRange) (GLenum, GLintptr, GLsizeiptr, GLbitfield);
GLboolean(GLAPIENTRY * UnmapBuffer) (GLenum);
void (GLAPIENTRY * BufferData) (GLenum, intptr_t, const GLvoid *, GLenum);
void (GLAPIENTRY * ActiveTexture) (GLenum);
void (GLAPIENTRY * BindTexture) (GLenum, GLuint);
int (GLAPIENTRY * SwapInterval) (int);
void (GLAPIENTRY * TexImage3D) (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum,
const GLvoid *);
void(GLAPIENTRY *GenBuffers)(GLsizei, GLuint *);
void(GLAPIENTRY *DeleteBuffers)(GLsizei, const GLuint *);
void(GLAPIENTRY *BindBuffer)(GLenum, GLuint);
void(GLAPIENTRY *BindBufferBase)(GLenum, GLuint, GLuint);
GLvoid *(GLAPIENTRY *MapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield);
GLboolean(GLAPIENTRY *UnmapBuffer)(GLenum);
void(GLAPIENTRY *BufferData)(GLenum, intptr_t, const GLvoid *, GLenum);
void(GLAPIENTRY *ActiveTexture)(GLenum);
void(GLAPIENTRY *BindTexture)(GLenum, GLuint);
int(GLAPIENTRY *SwapInterval)(int);
void(GLAPIENTRY *TexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum,
const GLvoid *);
void (GLAPIENTRY * GenVertexArrays) (GLsizei, GLuint *);
void (GLAPIENTRY * BindVertexArray) (GLuint);
GLint(GLAPIENTRY * GetAttribLocation) (GLuint, const GLchar *);
void (GLAPIENTRY * EnableVertexAttribArray) (GLuint);
void (GLAPIENTRY * DisableVertexAttribArray) (GLuint);
void (GLAPIENTRY * VertexAttribPointer) (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);
void (GLAPIENTRY * DeleteVertexArrays) (GLsizei, const GLuint *);
void (GLAPIENTRY * UseProgram) (GLuint);
GLint(GLAPIENTRY * GetUniformLocation) (GLuint, const GLchar *);
void (GLAPIENTRY * CompileShader) (GLuint);
GLuint(GLAPIENTRY * CreateProgram) (void);
GLuint(GLAPIENTRY * CreateShader) (GLenum);
void (GLAPIENTRY * ShaderSource) (GLuint, GLsizei, const GLchar **, const GLint *);
void (GLAPIENTRY * LinkProgram) (GLuint);
void (GLAPIENTRY * AttachShader) (GLuint, GLuint);
void (GLAPIENTRY * DeleteShader) (GLuint);
void (GLAPIENTRY * DeleteProgram) (GLuint);
void (GLAPIENTRY * GetShaderInfoLog) (GLuint, GLsizei, GLsizei *, GLchar *);
void (GLAPIENTRY * GetShaderiv) (GLuint, GLenum, GLint *);
void (GLAPIENTRY * GetProgramInfoLog) (GLuint, GLsizei, GLsizei *, GLchar *);
void (GLAPIENTRY * GetProgramiv) (GLenum, GLenum, GLint *);
const GLubyte *(GLAPIENTRY * GetStringi) (GLenum, GLuint);
void (GLAPIENTRY * BindAttribLocation) (GLuint, GLuint, const GLchar *);
void (GLAPIENTRY * BindFramebuffer) (GLenum, GLuint);
void (GLAPIENTRY * GenFramebuffers) (GLsizei, GLuint *);
void (GLAPIENTRY * DeleteFramebuffers) (GLsizei, const GLuint *);
GLenum(GLAPIENTRY * CheckFramebufferStatus) (GLenum);
void (GLAPIENTRY * FramebufferTexture2D) (GLenum, GLenum, GLenum, GLuint, GLint);
void (GLAPIENTRY * BlitFramebuffer) (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);
void (GLAPIENTRY * GetFramebufferAttachmentParameteriv) (GLenum, GLenum, GLenum, GLint *);
void(GLAPIENTRY *GenVertexArrays)(GLsizei, GLuint *);
void(GLAPIENTRY *BindVertexArray)(GLuint);
GLint(GLAPIENTRY *GetAttribLocation)(GLuint, const GLchar *);
void(GLAPIENTRY *EnableVertexAttribArray)(GLuint);
void(GLAPIENTRY *DisableVertexAttribArray)(GLuint);
void(GLAPIENTRY *VertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);
void(GLAPIENTRY *DeleteVertexArrays)(GLsizei, const GLuint *);
void(GLAPIENTRY *UseProgram)(GLuint);
GLint(GLAPIENTRY *GetUniformLocation)(GLuint, const GLchar *);
void(GLAPIENTRY *CompileShader)(GLuint);
GLuint(GLAPIENTRY *CreateProgram)(void);
GLuint(GLAPIENTRY *CreateShader)(GLenum);
void(GLAPIENTRY *ShaderSource)(GLuint, GLsizei, const GLchar **, const GLint *);
void(GLAPIENTRY *LinkProgram)(GLuint);
void(GLAPIENTRY *AttachShader)(GLuint, GLuint);
void(GLAPIENTRY *DeleteShader)(GLuint);
void(GLAPIENTRY *DeleteProgram)(GLuint);
void(GLAPIENTRY *GetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *);
void(GLAPIENTRY *GetShaderiv)(GLuint, GLenum, GLint *);
void(GLAPIENTRY *GetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *);
void(GLAPIENTRY *GetProgramiv)(GLenum, GLenum, GLint *);
const GLubyte *(GLAPIENTRY *GetStringi)(GLenum, GLuint);
void(GLAPIENTRY *BindAttribLocation)(GLuint, GLuint, const GLchar *);
void(GLAPIENTRY *BindFramebuffer)(GLenum, GLuint);
void(GLAPIENTRY *GenFramebuffers)(GLsizei, GLuint *);
void(GLAPIENTRY *DeleteFramebuffers)(GLsizei, const GLuint *);
GLenum(GLAPIENTRY *CheckFramebufferStatus)(GLenum);
void(GLAPIENTRY *FramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint);
void(GLAPIENTRY *BlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);
void(GLAPIENTRY *GetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint *);
void (GLAPIENTRY * Uniform1f) (GLint, GLfloat);
void (GLAPIENTRY * Uniform2f) (GLint, GLfloat, GLfloat);
void (GLAPIENTRY * Uniform3f) (GLint, GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * Uniform4f) (GLint, GLfloat, GLfloat, GLfloat, GLfloat);
void (GLAPIENTRY * Uniform1i) (GLint, GLint);
void (GLAPIENTRY * UniformMatrix2fv) (GLint, GLsizei, GLboolean, const GLfloat *);
void (GLAPIENTRY * UniformMatrix3fv) (GLint, GLsizei, GLboolean, const GLfloat *);
void(GLAPIENTRY *Uniform1f)(GLint, GLfloat);
void(GLAPIENTRY *Uniform2f)(GLint, GLfloat, GLfloat);
void(GLAPIENTRY *Uniform3f)(GLint, GLfloat, GLfloat, GLfloat);
void(GLAPIENTRY *Uniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat);
void(GLAPIENTRY *Uniform1i)(GLint, GLint);
void(GLAPIENTRY *UniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat *);
void(GLAPIENTRY *UniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *);
void (GLAPIENTRY * InvalidateFramebuffer) (GLenum, GLsizei, const GLenum *);
void(GLAPIENTRY *InvalidateFramebuffer)(GLenum, GLsizei, const GLenum *);
GLsync(GLAPIENTRY * FenceSync) (GLenum, GLbitfield);
GLenum(GLAPIENTRY * ClientWaitSync) (GLsync, GLbitfield, GLuint64);
void (GLAPIENTRY * DeleteSync) (GLsync sync);
GLsync(GLAPIENTRY *FenceSync)(GLenum, GLbitfield);
GLenum(GLAPIENTRY *ClientWaitSync)(GLsync, GLbitfield, GLuint64);
void(GLAPIENTRY *DeleteSync)(GLsync sync);
void (GLAPIENTRY * GenQueries) (GLsizei, GLuint *);
void (GLAPIENTRY * DeleteQueries) (GLsizei, const GLuint *);
void (GLAPIENTRY * BeginQuery) (GLenum, GLuint);
void (GLAPIENTRY * EndQuery) (GLenum);
void (GLAPIENTRY * QueryCounter) (GLuint, GLenum);
GLboolean(GLAPIENTRY * IsQuery) (GLuint);
void (GLAPIENTRY * GetQueryObjectiv) (GLuint, GLenum, GLint *);
void (GLAPIENTRY * GetQueryObjecti64v) (GLuint, GLenum, GLint64 *);
void (GLAPIENTRY * GetQueryObjectuiv) (GLuint, GLenum, GLuint *);
void (GLAPIENTRY * GetQueryObjectui64v) (GLuint, GLenum, GLuint64 *);
void(GLAPIENTRY *GenQueries)(GLsizei, GLuint *);
void(GLAPIENTRY *DeleteQueries)(GLsizei, const GLuint *);
void(GLAPIENTRY *BeginQuery)(GLenum, GLuint);
void(GLAPIENTRY *EndQuery)(GLenum);
void(GLAPIENTRY *QueryCounter)(GLuint, GLenum);
GLboolean(GLAPIENTRY *IsQuery)(GLuint);
void(GLAPIENTRY *GetQueryObjectiv)(GLuint, GLenum, GLint *);
void(GLAPIENTRY *GetQueryObjecti64v)(GLuint, GLenum, GLint64 *);
void(GLAPIENTRY *GetQueryObjectuiv)(GLuint, GLenum, GLuint *);
void(GLAPIENTRY *GetQueryObjectui64v)(GLuint, GLenum, GLuint64 *);
void (GLAPIENTRY * VDPAUInitNV) (const GLvoid *, const GLvoid *);
void (GLAPIENTRY * VDPAUFiniNV) (void);
GLvdpauSurfaceNV(GLAPIENTRY * VDPAURegisterOutputSurfaceNV)
(GLvoid *, GLenum, GLsizei, const GLuint *);
GLvdpauSurfaceNV(GLAPIENTRY * VDPAURegisterVideoSurfaceNV)
(GLvoid *, GLenum, GLsizei, const GLuint *);
void (GLAPIENTRY * VDPAUUnregisterSurfaceNV) (GLvdpauSurfaceNV);
void (GLAPIENTRY * VDPAUSurfaceAccessNV) (GLvdpauSurfaceNV, GLenum);
void (GLAPIENTRY * VDPAUMapSurfacesNV) (GLsizei, const GLvdpauSurfaceNV *);
void (GLAPIENTRY * VDPAUUnmapSurfacesNV) (GLsizei, const GLvdpauSurfaceNV *);
void(GLAPIENTRY *VDPAUInitNV)(const GLvoid *, const GLvoid *);
void(GLAPIENTRY *VDPAUFiniNV)(void);
GLvdpauSurfaceNV(GLAPIENTRY *VDPAURegisterOutputSurfaceNV)(GLvoid *, GLenum, GLsizei, const GLuint *);
GLvdpauSurfaceNV(GLAPIENTRY *VDPAURegisterVideoSurfaceNV)(GLvoid *, GLenum, GLsizei, const GLuint *);
void(GLAPIENTRY *VDPAUUnregisterSurfaceNV)(GLvdpauSurfaceNV);
void(GLAPIENTRY *VDPAUSurfaceAccessNV)(GLvdpauSurfaceNV, GLenum);
void(GLAPIENTRY *VDPAUMapSurfacesNV)(GLsizei, const GLvdpauSurfaceNV *);
void(GLAPIENTRY *VDPAUUnmapSurfacesNV)(GLsizei, const GLvdpauSurfaceNV *);
#if HAVE_GL_WIN32
// The HANDLE type might not be present on non-Win32
BOOL(GLAPIENTRY * DXSetResourceShareHandleNV) (void *dxObject, HANDLE shareHandle);
HANDLE(GLAPIENTRY * DXOpenDeviceNV) (void *dxDevice);
BOOL(GLAPIENTRY * DXCloseDeviceNV) (HANDLE hDevice);
HANDLE(GLAPIENTRY * DXRegisterObjectNV) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
BOOL(GLAPIENTRY * DXUnregisterObjectNV) (HANDLE hDevice, HANDLE hObject);
BOOL(GLAPIENTRY * DXLockObjectsNV) (HANDLE hDevice, GLint count, HANDLE * hObjects);
BOOL(GLAPIENTRY * DXUnlockObjectsNV) (HANDLE hDevice, GLint count, HANDLE * hObjects);
BOOL(GLAPIENTRY *DXSetResourceShareHandleNV)
(void *dxObject, HANDLE shareHandle);
HANDLE(GLAPIENTRY *DXOpenDeviceNV)(void *dxDevice);
BOOL(GLAPIENTRY *DXCloseDeviceNV)(HANDLE hDevice);
HANDLE(GLAPIENTRY *DXRegisterObjectNV)
(HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access);
BOOL(GLAPIENTRY *DXUnregisterObjectNV)(HANDLE hDevice, HANDLE hObject);
BOOL(GLAPIENTRY *DXLockObjectsNV)
(HANDLE hDevice, GLint count, HANDLE *hObjects);
BOOL(GLAPIENTRY *DXUnlockObjectsNV)
(HANDLE hDevice, GLint count, HANDLE *hObjects);
#endif
GLint(GLAPIENTRY * GetVideoSync) (GLuint *);
GLint(GLAPIENTRY * WaitVideoSync) (GLint, GLint, unsigned int *);
GLint(GLAPIENTRY *GetVideoSync)(GLuint *);
GLint(GLAPIENTRY *WaitVideoSync)(GLint, GLint, unsigned int *);
void (GLAPIENTRY * GetTranslatedShaderSourceANGLE) (GLuint, GLsizei, GLsizei *, GLchar * source);
void(GLAPIENTRY *GetTranslatedShaderSourceANGLE)(GLuint, GLsizei, GLsizei *, GLchar *source);
void (GLAPIENTRY * DebugMessageCallback) (MP_GLDEBUGPROC callback, const void *userParam);
void(GLAPIENTRY *DebugMessageCallback)(MP_GLDEBUGPROC callback, const void *userParam);
void *(GLAPIENTRY * MPGetNativeDisplay) (const char *name);
void *(GLAPIENTRY *MPGetNativeDisplay)(const char *name);
};
#endif /* MPLAYER_GL_COMMON_H */

View File

@ -14,12 +14,11 @@
#define _DRVAPI_ERROR_STRING_H_
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
// Error Code string definitions here
typedef struct
{
typedef struct {
char const *error_string;
unsigned int error_id;
} s_CudaErrorStr;
@ -62,30 +61,30 @@ s_CudaErrorStr sCudaDrvErrorString[] = {
/**
* This indicates profiling APIs are called while application is running
* in visual profiler mode.
*/
*/
{"CUDA_ERROR_PROFILER_DISABLED", 5},
/**
* This indicates profiling has not been initialized for this context.
* Call cuProfilerInitialize() to resolve this.
*/
*/
{"CUDA_ERROR_PROFILER_NOT_INITIALIZED", 6},
/**
* This indicates profiler has already been started and probably
* cuProfilerStart() is incorrectly called.
*/
*/
{"CUDA_ERROR_PROFILER_ALREADY_STARTED", 7},
/**
* This indicates profiler has already been stopped and probably
* cuProfilerStop() is incorrectly called.
*/
*/
{"CUDA_ERROR_PROFILER_ALREADY_STOPPED", 8},
/**
* This indicates that no CUDA-capable devices were detected by the installed
* CUDA driver.
* This indicates that no CUDA-capable devices were detected by the
* installed CUDA driver.
*/
{"CUDA_ERROR_NO_DEVICE (no CUDA-capable devices were detected)", 100},
@ -207,9 +206,9 @@ s_CudaErrorStr sCudaDrvErrorString[] = {
{"CUDA_ERROR_INVALID_GRAPHICS_CONTEXT", 219},
/**
* This indicates that an uncorrectable NVLink error was detected during the
* execution.
*/
* This indicates that an uncorrectable NVLink error was detected during the
* execution.
*/
{"CUDA_ERROR_NVLINK_UNCORRECTABLE", 220},
/**
@ -256,18 +255,19 @@ s_CudaErrorStr sCudaDrvErrorString[] = {
/**
* This indicates that asynchronous operations issued previously have not
* completed yet. This result is not actually an error, but must be indicated
* differently than ::CUDA_SUCCESS (which indicates completion). Calls that
* may return this value include ::cuEventQuery() and ::cuStreamQuery().
* completed yet. This result is not actually an error, but must be
* indicated differently than ::CUDA_SUCCESS (which indicates completion).
* Calls that may return this value include ::cuEventQuery() and
* ::cuStreamQuery().
*/
{"CUDA_ERROR_NOT_READY", 600},
/**
* While executing a kernel, the device encountered a
* load or store instruction on an invalid memory address.
* This leaves the process in an inconsistent state and any further CUDA work
* will return the same error. To continue using CUDA, the process must be terminated
* and relaunched.
* This leaves the process in an inconsistent state and any further CUDA
* work will return the same error. To continue using CUDA, the process must
* be terminated and relaunched.
*/
{"CUDA_ERROR_ILLEGAL_ADDRESS", 700},
@ -342,8 +342,8 @@ s_CudaErrorStr sCudaDrvErrorString[] = {
{"CUDA_ERROR_TOO_MANY_PEERS", 711},
/**
* This error indicates that the memory range passed to ::cuMemHostRegister()
* has already been registered.
* This error indicates that the memory range passed to
* ::cuMemHostRegister() has already been registered.
*/
{"CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED", 712},
@ -356,25 +356,25 @@ s_CudaErrorStr sCudaDrvErrorString[] = {
/**
* While executing a kernel, the device encountered a stack error.
* This can be due to stack corruption or exceeding the stack size limit.
* This leaves the process in an inconsistent state and any further CUDA work
* will return the same error. To continue using CUDA, the process must be terminated
* and relaunched.
* This leaves the process in an inconsistent state and any further CUDA
* work will return the same error. To continue using CUDA, the process must
* be terminated and relaunched.
*/
{"CUDA_ERROR_HARDWARE_STACK_ERROR", 714},
/**
* While executing a kernel, the device encountered an illegal instruction.
* This leaves the process in an inconsistent state and any further CUDA work
* will return the same error. To continue using CUDA, the process must be terminated
* and relaunched.
* This leaves the process in an inconsistent state and any further CUDA
* work will return the same error. To continue using CUDA, the process must
* be terminated and relaunched.
*/
{"CUDA_ERROR_ILLEGAL_INSTRUCTION", 715},
/**
* While executing a kernel, the device encountered a load or store instruction
* on a memory address which is not aligned.
* This leaves the process in an inconsistent state and any further CUDA work
* will return the same error. To continue using CUDA, the process must be terminated
* While executing a kernel, the device encountered a load or store
* instruction on a memory address which is not aligned. This leaves the
* process in an inconsistent state and any further CUDA work will return
* the same error. To continue using CUDA, the process must be terminated
* and relaunched.
*/
{"CUDA_ERROR_MISALIGNED_ADDRESS", 716},
@ -384,17 +384,17 @@ s_CudaErrorStr sCudaDrvErrorString[] = {
* which can only operate on memory locations in certain address spaces
* (global, shared, or local), but was supplied a memory address not
* belonging to an allowed address space.
* This leaves the process in an inconsistent state and any further CUDA work
* will return the same error. To continue using CUDA, the process must be terminated
* and relaunched.
* This leaves the process in an inconsistent state and any further CUDA
* work will return the same error. To continue using CUDA, the process must
* be terminated and relaunched.
*/
{"CUDA_ERROR_INVALID_ADDRESS_SPACE", 717},
/**
* While executing a kernel, the device program counter wrapped its address space.
* This leaves the process in an inconsistent state and any further CUDA work
* will return the same error. To continue using CUDA, the process must be terminated
* and relaunched.
* While executing a kernel, the device program counter wrapped its address
* space. This leaves the process in an inconsistent state and any further
* CUDA work will return the same error. To continue using CUDA, the process
* must be terminated and relaunched.
*/
{"CUDA_ERROR_INVALID_PC", 718},
@ -409,11 +409,13 @@ s_CudaErrorStr sCudaDrvErrorString[] = {
{"CUDA_ERROR_LAUNCH_FAILED", 719},
/**
* This error indicates that the number of blocks launched per grid for a kernel that was
* launched via either ::cuLaunchCooperativeKernel or ::cuLaunchCooperativeKernelMultiDevice
* exceeds the maximum number of blocks as allowed by ::cuOccupancyMaxActiveBlocksPerMultiprocessor
* or ::cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags times the number of multiprocessors
* as specified by the device attribute ::CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT.
* This error indicates that the number of blocks launched per grid for a
* kernel that was launched via either ::cuLaunchCooperativeKernel or
* ::cuLaunchCooperativeKernelMultiDevice exceeds the maximum number of
* blocks as allowed by ::cuOccupancyMaxActiveBlocksPerMultiprocessor or
* ::cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags times the number
* of multiprocessors as specified by the device attribute
* ::CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT.
*/
{"CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE", 720},
@ -432,13 +434,11 @@ s_CudaErrorStr sCudaDrvErrorString[] = {
* This indicates that an unknown internal error has occurred.
*/
{"CUDA_ERROR_UNKNOWN", 999},
{NULL, -1}
};
{NULL, -1}};
// This is just a linear search through the array, since the error_id's are not
// always ocurring consecutively
static inline const char *getCudaDrvErrorString(CUresult error_id)
{
static inline const char *getCudaDrvErrorString(CUresult error_id) {
int index = 0;
while (sCudaDrvErrorString[index].error_id != error_id && (int)sCudaDrvErrorString[index].error_id != -1) {

View File

@ -23,9 +23,7 @@
/// @addtogroup iatomic
/// @{
#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
// gcc before 4.7 didn't support atomic builtins,
// use alsa atomic functions.
@ -59,38 +57,32 @@ typedef volatile int atomic_t;
///
/// Set atomic value.
///
#define atomic_set(ptr, val) \
__atomic_store_n(ptr, val, __ATOMIC_SEQ_CST)
#define atomic_set(ptr, val) __atomic_store_n(ptr, val, __ATOMIC_SEQ_CST)
///
/// Read atomic value.
///
#define atomic_read(ptr) \
__atomic_load_n(ptr, __ATOMIC_SEQ_CST)
#define atomic_read(ptr) __atomic_load_n(ptr, __ATOMIC_SEQ_CST)
///
/// Increment atomic value.
///
#define atomic_inc(ptr) \
__atomic_add_fetch(ptr, 1, __ATOMIC_SEQ_CST)
#define atomic_inc(ptr) __atomic_add_fetch(ptr, 1, __ATOMIC_SEQ_CST)
///
/// Decrement atomic value.
///
#define atomic_dec(ptr) \
__atomic_sub_fetch(ptr, 1, __ATOMIC_SEQ_CST)
#define atomic_dec(ptr) __atomic_sub_fetch(ptr, 1, __ATOMIC_SEQ_CST)
///
/// Add to atomic value.
///
#define atomic_add(val, ptr) \
__atomic_add_fetch(ptr, val, __ATOMIC_SEQ_CST)
#define atomic_add(val, ptr) __atomic_add_fetch(ptr, val, __ATOMIC_SEQ_CST)
///
/// Subtract from atomic value.
///
#define atomic_sub(val, ptr) \
__atomic_sub_fetch(ptr, val, __ATOMIC_SEQ_CST)
#define atomic_sub(val, ptr) __atomic_sub_fetch(ptr, val, __ATOMIC_SEQ_CST)
#endif

47
misc.h
View File

@ -24,9 +24,9 @@
/// @addtogroup misc
/// @{
#include <syslog.h>
#include <stdarg.h>
#include <time.h> // clock_gettime
#include <syslog.h>
#include <time.h> // clock_gettime
//////////////////////////////////////////////////////////////////////////////
// Defines
@ -40,23 +40,22 @@
// Variables
//////////////////////////////////////////////////////////////////////////////
extern int SysLogLevel; ///< how much information wanted
extern int SysLogLevel; ///< how much information wanted
//////////////////////////////////////////////////////////////////////////////
// Prototypes
//////////////////////////////////////////////////////////////////////////////
static inline void Syslog(const int, const char *format, ...)
__attribute__((format(printf, 2, 3)));
static inline void Syslog(const int, const char *format, ...) __attribute__((format(printf, 2, 3)));
//////////////////////////////////////////////////////////////////////////////
// Inlines
//////////////////////////////////////////////////////////////////////////////
#ifdef DEBUG
#define DebugLevel 4 /// private debug level
#define DebugLevel 4 /// private debug level
#else
#define DebugLevel 0 /// private debug level
#define DebugLevel 0 /// private debug level
#endif
/**
@ -67,8 +66,7 @@ static inline void Syslog(const int, const char *format, ...)
** - 2 info
** - 3 important debug and fixme's
*/
static inline void Syslog(const int level, const char *format, ...)
{
static inline void Syslog(const int level, const char *format, ...) {
if (SysLogLevel > level || DebugLevel > level) {
va_list ap;
@ -81,30 +79,34 @@ static inline void Syslog(const int level, const char *format, ...)
/**
** Show error.
*/
#define Error(fmt...) Syslog(LOG_ERR, fmt)
#define Error(fmt...) Syslog(LOG_ERR, fmt)
/**
** Show fatal error.
*/
#define Fatal(fmt...) do { Error(fmt); abort(); } while (0)
#define Fatal(fmt...) \
do { \
Error(fmt); \
abort(); \
} while (0)
/**
** Show warning.
*/
#define Warning(fmt...) Syslog(LOG_WARNING, fmt)
#define Warning(fmt...) Syslog(LOG_WARNING, fmt)
/**
** Show info.
*/
#define Info(fmt...) Syslog(LOG_INFO, fmt)
#define Info(fmt...) Syslog(LOG_INFO, fmt)
/**
** Show debug.
*/
#ifdef DEBUG
#define Debug(level, fmt...) Syslog(level, fmt)
#define Debug(level, fmt...) Syslog(level, fmt)
#else
#define Debug(level, fmt...) /* disabled */
#define Debug(level, fmt...) /* disabled */
#endif
#ifndef AV_NOPTS_VALUE
@ -116,17 +118,16 @@ static inline void Syslog(const int level, const char *format, ...)
**
** @param ts dvb time stamp
*/
static inline const char *Timestamp2String(int64_t ts)
{
static inline const char *Timestamp2String(int64_t ts) {
static char buf[4][16];
static int idx;
if (ts == (int64_t) AV_NOPTS_VALUE) {
if (ts == (int64_t)AV_NOPTS_VALUE) {
return "--:--:--.---";
}
idx = (idx + 1) % 3;
snprintf(buf[idx], sizeof(buf[idx]), "%2d:%02d:%02d.%03d", (int)(ts / (90 * 3600000)),
(int)((ts / (90 * 60000)) % 60), (int)((ts / (90 * 1000)) % 60), (int)((ts / 90) % 1000));
(int)((ts / (90 * 60000)) % 60), (int)((ts / (90 * 1000)) % 60), (int)((ts / 90) % 1000));
return buf[idx];
}
@ -136,8 +137,7 @@ static inline const char *Timestamp2String(int64_t ts)
**
** @returns ticks in ms,
*/
static inline uint32_t GetMsTicks(void)
{
static inline uint32_t GetMsTicks(void) {
#ifdef CLOCK_MONOTONIC
struct timespec tspec;
@ -153,14 +153,13 @@ static inline uint32_t GetMsTicks(void)
#endif
}
static inline uint64_t GetusTicks(void)
{
static inline uint64_t GetusTicks(void) {
#ifdef CLOCK_MONOTONIC
struct timespec tspec;
clock_gettime(CLOCK_MONOTONIC, &tspec);
return (uint64_t) (tspec.tv_sec * 1000000) + (tspec.tv_nsec);
return (uint64_t)(tspec.tv_sec * 1000000) + (tspec.tv_nsec);
#else
struct timeval tval;

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
#ifndef __SOFTHDDEVICE_OPENGLOSD_H
#define __SOFTHDDEVICE_OPENGLOSD_H
// clang-format off
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <GL/gl.h>
@ -17,9 +18,9 @@
#include FT_STROKER_H
#undef __FTERRORS_H__
#define FT_ERRORDEF( e, v, s ) { e, s },
#define FT_ERROR_START_LIST {
#define FT_ERROR_END_LIST { 0, 0 } };
#define FT_ERRORDEF( e, v, s ) { e, s },
#define FT_ERROR_START_LIST {
#define FT_ERROR_END_LIST { 0, 0 } };
const struct
{
int code;
@ -36,17 +37,15 @@ extern "C"
{
#include <stdint.h>
#include <libavcodec/avcodec.h>
#include "audio.h"
#include "video.h"
#include "codec.h"
}
// clang-format on
extern "C" pthread_mutex_t OSDMutex;
struct sOglImage
{
struct sOglImage {
GLuint texture;
GLint width;
GLint height;
@ -54,54 +53,42 @@ struct sOglImage
};
/****************************************************************************************
* Helpers
****************************************************************************************/
* Helpers
****************************************************************************************/
void ConvertColor(const GLint & colARGB, glm::vec4 & col);
void ConvertColor(const GLint &colARGB, glm::vec4 &col);
/****************************************************************************************
* cShader
****************************************************************************************/
enum eShaderType
{
stRect,
stTexture,
stText,
stCount
};
* cShader
****************************************************************************************/
enum eShaderType { stRect, stTexture, stText, stCount };
class cShader
{
class cShader {
private:
eShaderType type;
GLuint id;
bool Compile(const char *vertexCode, const char *fragmentCode);
bool CheckCompileErrors(GLuint object, bool program = false);
public:
cShader(void)
{
};
virtual ~ cShader(void)
{
};
cShader(void){};
virtual ~cShader(void){};
bool Load(eShaderType type);
void Use(void);
void SetFloat(const GLchar * name, GLfloat value);
void SetInteger(const GLchar * name, GLint value);
void SetVector2f(const GLchar * name, GLfloat x, GLfloat y);
void SetVector3f(const GLchar * name, GLfloat x, GLfloat y, GLfloat z);
void SetVector4f(const GLchar * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void SetMatrix4(const GLchar * name, const glm::mat4 & matrix);
void SetFloat(const GLchar *name, GLfloat value);
void SetInteger(const GLchar *name, GLint value);
void SetVector2f(const GLchar *name, GLfloat x, GLfloat y);
void SetVector3f(const GLchar *name, GLfloat x, GLfloat y, GLfloat z);
void SetVector4f(const GLchar *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void SetMatrix4(const GLchar *name, const glm::mat4 &matrix);
};
/****************************************************************************************
* cOglGlyph
****************************************************************************************/
class cOglGlyph:public cListObject
{
* cOglGlyph
****************************************************************************************/
class cOglGlyph : public cListObject {
private:
struct tKerning
{
struct tKerning {
public:
tKerning(FT_ULong prevSym, GLfloat kerning = 0.0f) {
this->prevSym = prevSym;
@ -117,47 +104,28 @@ class cOglGlyph:public cListObject
int height;
int advanceX;
cVector < tKerning > kerningCache;
cVector<tKerning> kerningCache;
GLuint texture;
void LoadTexture(FT_BitmapGlyph ftGlyph);
public:
cOglGlyph(FT_ULong charCode, FT_BitmapGlyph ftGlyph);
virtual ~ cOglGlyph();
FT_ULong CharCode(void)
{
return charCode;
}
int AdvanceX(void)
{
return advanceX;
}
int BearingLeft(void) const
{
return bearingLeft;
}
int BearingTop(void) const
{
return bearingTop;
}
int Width(void) const
{
return width;
}
int Height(void) const
{
return height;
}
virtual ~cOglGlyph();
FT_ULong CharCode(void) { return charCode; }
int AdvanceX(void) { return advanceX; }
int BearingLeft(void) const { return bearingLeft; }
int BearingTop(void) const { return bearingTop; }
int Width(void) const { return width; }
int Height(void) const { return height; }
int GetKerningCache(FT_ULong prevSym);
void SetKerningCache(FT_ULong prevSym, int kerning);
void BindTexture(void);
};
/****************************************************************************************
* cOglFont
****************************************************************************************/
class cOglFont:public cListObject
{
* cOglFont
****************************************************************************************/
class cOglFont : public cListObject {
private:
static bool initiated;
cString name;
@ -166,40 +134,28 @@ class cOglFont:public cListObject
int bottom;
static FT_Library ftLib;
FT_Face face;
static cList < cOglFont > *fonts;
mutable cList < cOglGlyph > glyphCache;
cOglFont(const char *fontName, int charHeight);
static cList<cOglFont> *fonts;
mutable cList<cOglGlyph> glyphCache;
cOglFont(const char *fontName, int charHeight);
static void Init(void);
public:
virtual ~ cOglFont(void);
virtual ~cOglFont(void);
static cOglFont *Get(const char *name, int charHeight);
static void Cleanup(void);
const char *Name(void)
{
return *name;
};
int Size(void)
{
return size;
};
int Bottom(void)
{
return bottom;
};
int Height(void)
{
return height;
};
const char *Name(void) { return *name; };
int Size(void) { return size; };
int Bottom(void) { return bottom; };
int Height(void) { return height; };
cOglGlyph *Glyph(FT_ULong charCode) const;
int Kerning(cOglGlyph * glyph, FT_ULong prevSym) const;
int Kerning(cOglGlyph *glyph, FT_ULong prevSym) const;
};
/****************************************************************************************
* cOglFb
* Framebuffer Object - OpenGL part of a Pixmap
****************************************************************************************/
class cOglFb
{
* cOglFb
* Framebuffer Object - OpenGL part of a Pixmap
****************************************************************************************/
class cOglFb {
protected:
bool initiated;
// GLuint fb;
@ -207,16 +163,14 @@ class cOglFb
GLint width, height;
GLint viewPortWidth, viewPortHeight;
bool scrollable;
public:
GLuint fb;
GLuint fb;
GLuint texture;
cOglFb(GLint width, GLint height, GLint viewPortWidth, GLint viewPortHeight);
virtual ~ cOglFb(void);
bool Initiated(void)
{
return initiated;
}
cOglFb(GLint width, GLint height, GLint viewPortWidth, GLint viewPortHeight);
virtual ~cOglFb(void);
bool Initiated(void) { return initiated; }
virtual bool Init(void);
void Bind(void);
void BindRead(void);
@ -224,64 +178,42 @@ class cOglFb
virtual void Unbind(void);
bool BindTexture(void);
void Blit(GLint destX1, GLint destY1, GLint destX2, GLint destY2);
GLint Width(void)
{
return width;
};
GLint Height(void)
{
return height;
};
bool Scrollable(void)
{
return scrollable;
};
GLint ViewportWidth(void)
{
return viewPortWidth;
};
GLint ViewportHeight(void)
{
return viewPortHeight;
};
GLint Width(void) { return width; };
GLint Height(void) { return height; };
bool Scrollable(void) { return scrollable; };
GLint ViewportWidth(void) { return viewPortWidth; };
GLint ViewportHeight(void) { return viewPortHeight; };
};
/****************************************************************************************
* cOglOutputFb
* Output Framebuffer Object - holds Vdpau Output Surface which is our "output framebuffer"
****************************************************************************************/
class cOglOutputFb:public cOglFb
{
* cOglOutputFb
* Output Framebuffer Object - holds Vdpau Output Surface which is our "output
*framebuffer"
****************************************************************************************/
class cOglOutputFb : public cOglFb {
protected:
bool initiated;
private:
GLvdpauSurfaceNV surface;
GLvdpauSurfaceNV surface;
public:
GLuint fb;
GLuint fb;
GLuint texture;
cOglOutputFb(GLint width, GLint height);
virtual ~ cOglOutputFb(void);
cOglOutputFb(GLint width, GLint height);
virtual ~cOglOutputFb(void);
virtual bool Init(void);
virtual void BindWrite(void);
virtual void Unbind(void);
};
/****************************************************************************************
* cOglVb
* Vertex Buffer - OpenGl Vertices for the different drawing commands
****************************************************************************************/
enum eVertexBufferType
{
vbRect,
vbEllipse,
vbSlope,
vbTexture,
vbText,
vbCount
};
* cOglVb
* Vertex Buffer - OpenGl Vertices for the different drawing commands
****************************************************************************************/
enum eVertexBufferType { vbRect, vbEllipse, vbSlope, vbTexture, vbText, vbCount };
class cOglVb
{
class cOglVb {
private:
eVertexBufferType type;
eShaderType shader;
@ -291,9 +223,10 @@ class cOglVb
int sizeVertex2;
int numVertices;
GLuint drawMode;
public:
cOglVb(int type);
virtual ~ cOglVb(void);
cOglVb(int type);
virtual ~cOglVb(void);
bool Init(void);
void Bind(void);
void Unbind(void);
@ -303,148 +236,106 @@ class cOglVb
void SetShaderColor(GLint color);
void SetShaderAlpha(GLint alpha);
void SetShaderProjectionMatrix(GLint width, GLint height);
void SetVertexData(GLfloat * vertices, int count = 0);
void SetVertexData(GLfloat *vertices, int count = 0);
void DrawArrays(int count = 0);
};
/****************************************************************************************
* cOpenGLCmd
****************************************************************************************/
class cOglCmd
{
* cOpenGLCmd
****************************************************************************************/
class cOglCmd {
protected:
cOglFb * fb;
cOglFb *fb;
public:
cOglCmd(cOglFb * fb)
{
this->fb = fb;
};
virtual ~ cOglCmd(void)
{
};
cOglCmd(cOglFb *fb) { this->fb = fb; };
virtual ~cOglCmd(void){};
virtual const char *Description(void) = 0;
virtual bool Execute(void) = 0;
};
class cOglCmdInitOutputFb:public cOglCmd
{
class cOglCmdInitOutputFb : public cOglCmd {
private:
cOglOutputFb * oFb;
cOglOutputFb *oFb;
public:
cOglCmdInitOutputFb(cOglOutputFb * oFb);
virtual ~ cOglCmdInitOutputFb(void)
{
};
virtual const char *Description(void)
{
return "InitOutputFramebuffer";
}
cOglCmdInitOutputFb(cOglOutputFb *oFb);
virtual ~cOglCmdInitOutputFb(void){};
virtual const char *Description(void) { return "InitOutputFramebuffer"; }
virtual bool Execute(void);
};
class cOglCmdInitFb:public cOglCmd
{
class cOglCmdInitFb : public cOglCmd {
private:
cCondWait * wait;
cCondWait *wait;
public:
cOglCmdInitFb(cOglFb * fb, cCondWait * wait = NULL);
virtual ~ cOglCmdInitFb(void)
{
};
virtual const char *Description(void)
{
return "InitFramebuffer";
}
cOglCmdInitFb(cOglFb *fb, cCondWait *wait = NULL);
virtual ~cOglCmdInitFb(void){};
virtual const char *Description(void) { return "InitFramebuffer"; }
virtual bool Execute(void);
};
class cOglCmdDeleteFb:public cOglCmd
{
class cOglCmdDeleteFb : public cOglCmd {
public:
cOglCmdDeleteFb(cOglFb * fb);
virtual ~ cOglCmdDeleteFb(void)
{
};
virtual const char *Description(void)
{
return "DeleteFramebuffer";
}
cOglCmdDeleteFb(cOglFb *fb);
virtual ~cOglCmdDeleteFb(void){};
virtual const char *Description(void) { return "DeleteFramebuffer"; }
virtual bool Execute(void);
};
class cOglCmdRenderFbToBufferFb:public cOglCmd
{
class cOglCmdRenderFbToBufferFb : public cOglCmd {
private:
cOglFb * buffer;
cOglFb *buffer;
GLfloat x, y;
GLfloat drawPortX, drawPortY;
GLint transparency;
public:
cOglCmdRenderFbToBufferFb(cOglFb * fb, cOglFb * buffer, GLint x, GLint y, GLint transparency, GLint drawPortX,
GLint drawPortY);
virtual ~ cOglCmdRenderFbToBufferFb(void)
{
};
virtual const char *Description(void)
{
return "Render Framebuffer to Buffer";
}
cOglCmdRenderFbToBufferFb(cOglFb *fb, cOglFb *buffer, GLint x, GLint y, GLint transparency, GLint drawPortX,
GLint drawPortY);
virtual ~cOglCmdRenderFbToBufferFb(void){};
virtual const char *Description(void) { return "Render Framebuffer to Buffer"; }
virtual bool Execute(void);
};
class cOglCmdCopyBufferToOutputFb:public cOglCmd
{
class cOglCmdCopyBufferToOutputFb : public cOglCmd {
private:
cOglOutputFb * oFb;
cOglOutputFb *oFb;
GLint x, y;
public:
cOglCmdCopyBufferToOutputFb(cOglFb * fb, cOglOutputFb * oFb, GLint x, GLint y);
virtual ~ cOglCmdCopyBufferToOutputFb(void)
{
};
virtual const char *Description(void)
{
return "Copy buffer to OutputFramebuffer";
}
cOglCmdCopyBufferToOutputFb(cOglFb *fb, cOglOutputFb *oFb, GLint x, GLint y);
virtual ~cOglCmdCopyBufferToOutputFb(void){};
virtual const char *Description(void) { return "Copy buffer to OutputFramebuffer"; }
virtual bool Execute(void);
};
class cOglCmdFill:public cOglCmd
{
class cOglCmdFill : public cOglCmd {
private:
GLint color;
public:
cOglCmdFill(cOglFb * fb, GLint color);
virtual ~ cOglCmdFill(void)
{
};
virtual const char *Description(void)
{
return "Fill";
}
cOglCmdFill(cOglFb *fb, GLint color);
virtual ~cOglCmdFill(void){};
virtual const char *Description(void) { return "Fill"; }
virtual bool Execute(void);
};
class cOglCmdDrawRectangle:public cOglCmd
{
class cOglCmdDrawRectangle : public cOglCmd {
private:
GLint x, y;
GLint width, height;
GLint color;
public:
cOglCmdDrawRectangle(cOglFb * fb, GLint x, GLint y, GLint width, GLint height, GLint color);
virtual ~ cOglCmdDrawRectangle(void)
{
};
virtual const char *Description(void)
{
return "DrawRectangle";
}
cOglCmdDrawRectangle(cOglFb *fb, GLint x, GLint y, GLint width, GLint height, GLint color);
virtual ~cOglCmdDrawRectangle(void){};
virtual const char *Description(void) { return "DrawRectangle"; }
virtual bool Execute(void);
};
class cOglCmdDrawEllipse:public cOglCmd
{
class cOglCmdDrawEllipse : public cOglCmd {
private:
GLint x, y;
GLint width, height;
@ -453,39 +344,29 @@ class cOglCmdDrawEllipse:public cOglCmd
GLfloat *CreateVerticesFull(int &numVertices);
GLfloat *CreateVerticesQuadrant(int &numVertices);
GLfloat *CreateVerticesHalf(int &numVertices);
public:
cOglCmdDrawEllipse(cOglFb * fb, GLint x, GLint y, GLint width, GLint height, GLint color, GLint quadrants);
virtual ~ cOglCmdDrawEllipse(void)
{
};
virtual const char *Description(void)
{
return "DrawEllipse";
}
cOglCmdDrawEllipse(cOglFb *fb, GLint x, GLint y, GLint width, GLint height, GLint color, GLint quadrants);
virtual ~cOglCmdDrawEllipse(void){};
virtual const char *Description(void) { return "DrawEllipse"; }
virtual bool Execute(void);
};
class cOglCmdDrawSlope:public cOglCmd
{
class cOglCmdDrawSlope : public cOglCmd {
private:
GLint x, y;
GLint width, height;
GLint color;
GLint type;
public:
cOglCmdDrawSlope(cOglFb * fb, GLint x, GLint y, GLint width, GLint height, GLint color, GLint type);
virtual ~ cOglCmdDrawSlope(void)
{
};
virtual const char *Description(void)
{
return "DrawSlope";
}
cOglCmdDrawSlope(cOglFb *fb, GLint x, GLint y, GLint width, GLint height, GLint color, GLint type);
virtual ~cOglCmdDrawSlope(void){};
virtual const char *Description(void) { return "DrawSlope"; }
virtual bool Execute(void);
};
class cOglCmdDrawText:public cOglCmd
{
class cOglCmdDrawText : public cOglCmd {
private:
GLint x, y;
GLint limitX;
@ -493,97 +374,78 @@ class cOglCmdDrawText:public cOglCmd
cString fontName;
int fontSize;
unsigned int *symbols;
public:
cOglCmdDrawText(cOglFb * fb, GLint x, GLint y, unsigned int *symbols, GLint limitX, const char *name,
int fontSize, tColor colorText);
virtual ~ cOglCmdDrawText(void);
virtual const char *Description(void)
{
return "DrawText";
}
cOglCmdDrawText(cOglFb *fb, GLint x, GLint y, unsigned int *symbols, GLint limitX, const char *name, int fontSize,
tColor colorText);
virtual ~cOglCmdDrawText(void);
virtual const char *Description(void) { return "DrawText"; }
virtual bool Execute(void);
};
class cOglCmdDrawImage:public cOglCmd
{
class cOglCmdDrawImage : public cOglCmd {
private:
tColor * argb;
tColor *argb;
GLint x, y, width, height;
bool overlay;
GLfloat scaleX, scaleY;
public:
cOglCmdDrawImage(cOglFb * fb, tColor * argb, GLint width, GLint height, GLint x, GLint y, bool overlay =
true, double scaleX = 1.0f, double scaleY = 1.0f);
virtual ~ cOglCmdDrawImage(void);
virtual const char *Description(void)
{
return "Draw Image";
}
cOglCmdDrawImage(cOglFb *fb, tColor *argb, GLint width, GLint height, GLint x, GLint y, bool overlay = true,
double scaleX = 1.0f, double scaleY = 1.0f);
virtual ~cOglCmdDrawImage(void);
virtual const char *Description(void) { return "Draw Image"; }
virtual bool Execute(void);
};
class cOglCmdDrawTexture:public cOglCmd
{
class cOglCmdDrawTexture : public cOglCmd {
private:
sOglImage * imageRef;
sOglImage *imageRef;
GLint x, y;
public:
cOglCmdDrawTexture(cOglFb * fb, sOglImage * imageRef, GLint x, GLint y);
virtual ~ cOglCmdDrawTexture(void)
{
};
virtual const char *Description(void)
{
return "Draw Texture";
}
cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y);
virtual ~cOglCmdDrawTexture(void){};
virtual const char *Description(void) { return "Draw Texture"; }
virtual bool Execute(void);
};
class cOglCmdStoreImage:public cOglCmd
{
class cOglCmdStoreImage : public cOglCmd {
private:
sOglImage * imageRef;
sOglImage *imageRef;
tColor *data;
public:
cOglCmdStoreImage(sOglImage * imageRef, tColor * argb);
virtual ~ cOglCmdStoreImage(void);
virtual const char *Description(void)
{
return "Store Image";
}
cOglCmdStoreImage(sOglImage *imageRef, tColor *argb);
virtual ~cOglCmdStoreImage(void);
virtual const char *Description(void) { return "Store Image"; }
virtual bool Execute(void);
};
class cOglCmdDropImage:public cOglCmd
{
class cOglCmdDropImage : public cOglCmd {
private:
sOglImage * imageRef;
sOglImage *imageRef;
cCondWait *wait;
public:
cOglCmdDropImage(sOglImage * imageRef, cCondWait * wait);
virtual ~ cOglCmdDropImage(void)
{
};
virtual const char *Description(void)
{
return "Drop Image";
}
cOglCmdDropImage(sOglImage *imageRef, cCondWait *wait);
virtual ~cOglCmdDropImage(void){};
virtual const char *Description(void) { return "Drop Image"; }
virtual bool Execute(void);
};
/******************************************************************************
* cOglThread
******************************************************************************/
* cOglThread
******************************************************************************/
#define OGL_MAX_OSDIMAGES 256
#define OGL_CMDQUEUE_SIZE 100
class cOglThread:public cThread
{
class cOglThread : public cThread {
private:
cCondWait * startWait;
cCondWait *startWait;
cCondWait *wait;
bool stalled;
std::queue < cOglCmd * >commands;
std::queue<cOglCmd *> commands;
GLint maxTextureSize;
sOglImage imageCache[OGL_MAX_OSDIMAGES];
long memCached;
@ -597,96 +459,81 @@ class cOglThread:public cThread
void Cleanup(void);
int GetFreeSlot(void);
void ClearSlot(int slot);
protected:
virtual void Action(void);
virtual void Action(void);
public:
cOglThread(cCondWait * startWait, int maxCacheSize);
virtual ~ cOglThread();
cOglThread(cCondWait *startWait, int maxCacheSize);
virtual ~cOglThread();
void Stop(void);
void DoCmd(cOglCmd * cmd);
int StoreImage(const cImage & image);
void DoCmd(cOglCmd *cmd);
int StoreImage(const cImage &image);
void DropImageData(int imageHandle);
sOglImage *GetImageRef(int slot);
int MaxTextureSize(void)
{
return maxTextureSize;
};
int MaxTextureSize(void) { return maxTextureSize; };
};
/****************************************************************************************
* cOglPixmap
****************************************************************************************/
class cOglPixmap:public cPixmap
{
* cOglPixmap
****************************************************************************************/
class cOglPixmap : public cPixmap {
private:
cOglFb * fb;
std::shared_ptr < cOglThread > oglThread;
cOglFb *fb;
std::shared_ptr<cOglThread> oglThread;
bool dirty;
public:
cOglPixmap(std::shared_ptr < cOglThread > oglThread, int Layer, const cRect & ViewPort, const cRect & DrawPort =
cRect::Null);
virtual ~ cOglPixmap(void);
cOglFb *Fb(void)
{
return fb;
};
int X(void)
{
return ViewPort().X();
};
int Y(void)
{
return ViewPort().Y();
};
virtual bool IsDirty(void)
{
return dirty;
}
virtual void SetDirty(bool dirty = true) {
this->dirty = dirty;
}
cOglPixmap(std::shared_ptr<cOglThread> oglThread, int Layer, const cRect &ViewPort,
const cRect &DrawPort = cRect::Null);
virtual ~cOglPixmap(void);
cOglFb *Fb(void) { return fb; };
int X(void) { return ViewPort().X(); };
int Y(void) { return ViewPort().Y(); };
virtual bool IsDirty(void) { return dirty; }
virtual void SetDirty(bool dirty = true) { this->dirty = dirty; }
virtual void SetAlpha(int Alpha);
virtual void SetTile(bool Tile);
virtual void SetViewPort(const cRect & Rect);
virtual void SetDrawPortPoint(const cPoint & Point, bool Dirty = true);
virtual void SetViewPort(const cRect &Rect);
virtual void SetDrawPortPoint(const cPoint &Point, bool Dirty = true);
virtual void Clear(void);
virtual void Fill(tColor Color);
virtual void DrawImage(const cPoint & Point, const cImage & Image);
virtual void DrawImage(const cPoint & Point, int ImageHandle);
virtual void DrawPixel(const cPoint & Point, tColor Color);
virtual void DrawBitmap(const cPoint & Point, const cBitmap & Bitmap, tColor ColorFg = 0, tColor ColorBg =
0, bool Overlay = false);
virtual void DrawText(const cPoint & Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont * Font,
int Width = 0, int Height = 0, int Alignment = taDefault);
virtual void DrawRectangle(const cRect & Rect, tColor Color);
virtual void DrawEllipse(const cRect & Rect, tColor Color, int Quadrants = 0);
virtual void DrawSlope(const cRect & Rect, tColor Color, int Type);
virtual void Render(const cPixmap * Pixmap, const cRect & Source, const cPoint & Dest);
virtual void Copy(const cPixmap * Pixmap, const cRect & Source, const cPoint & Dest);
virtual void Scroll(const cPoint & Dest, const cRect & Source = cRect::Null);
virtual void Pan(const cPoint & Dest, const cRect & Source = cRect::Null);
virtual void DrawImage(const cPoint &Point, const cImage &Image);
virtual void DrawImage(const cPoint &Point, int ImageHandle);
virtual void DrawPixel(const cPoint &Point, tColor Color);
virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0,
bool Overlay = false);
virtual void DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font,
int Width = 0, int Height = 0, int Alignment = taDefault);
virtual void DrawRectangle(const cRect &Rect, tColor Color);
virtual void DrawEllipse(const cRect &Rect, tColor Color, int Quadrants = 0);
virtual void DrawSlope(const cRect &Rect, tColor Color, int Type);
virtual void Render(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest);
virtual void Copy(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest);
virtual void Scroll(const cPoint &Dest, const cRect &Source = cRect::Null);
virtual void Pan(const cPoint &Dest, const cRect &Source = cRect::Null);
};
/******************************************************************************
* cOglOsd
******************************************************************************/
class cOglOsd:public cOsd
{
* cOglOsd
******************************************************************************/
class cOglOsd : public cOsd {
private:
cOglFb * bFb;
std::shared_ptr < cOglThread > oglThread;
cVector < cOglPixmap * >oglPixmaps;
cOglFb *bFb;
std::shared_ptr<cOglThread> oglThread;
cVector<cOglPixmap *> oglPixmaps;
bool isSubtitleOsd;
protected:
public:
cOglOsd(int Left, int Top, uint Level, std::shared_ptr < cOglThread > oglThread);
virtual ~ cOglOsd();
virtual eOsdError SetAreas(const tArea * Areas, int NumAreas);
virtual cPixmap *CreatePixmap(int Layer, const cRect & ViewPort, const cRect & DrawPort = cRect::Null);
virtual void DestroyPixmap(cPixmap * Pixmap);
cOglOsd(int Left, int Top, uint Level, std::shared_ptr<cOglThread> oglThread);
virtual ~cOglOsd();
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas);
virtual cPixmap *CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null);
virtual void DestroyPixmap(cPixmap *Pixmap);
virtual void Flush(void);
virtual void DrawScaledBitmap(int x, int y, const cBitmap & Bitmap, double FactorX, double FactorY,
bool AntiAlias = false);
virtual void DrawScaledBitmap(int x, int y, const cBitmap &Bitmap, double FactorX, double FactorY,
bool AntiAlias = false);
static cOglOutputFb *oFb;
};

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: VDR \n"
"Report-Msgid-Bugs-To: <see README>\n"
"POT-Creation-Date: 2020-04-15 18:57+0200\n"
"POT-Creation-Date: 2021-12-27 13:13+0100\n"
"PO-Revision-Date: blabla\n"
"Last-Translator: blabla\n"
"Language-Team: blabla\n"
@ -408,7 +408,7 @@ msgstr ""
msgid "Hue (-314..314) "
msgstr ""
msgid "Monitor Colorspace"
msgid "Temperature 6500K + x * 100K"
msgstr ""
msgid "Color Blindness"
@ -417,6 +417,9 @@ msgstr ""
msgid "Color Correction (-100..100) "
msgstr ""
msgid "Monitor Type"
msgstr ""
msgid "Scaling"
msgstr "Skalierung"
@ -574,15 +577,15 @@ msgstr ""
msgid "Suspend SoftHdDevice"
msgstr "Unterbreche SoftHdDevice"
msgid "Toggle LUT on/off"
msgstr ""
msgid "PIP toggle on/off: off"
msgstr "PIP deaktivieren"
msgid "PIP toggle on/off: on"
msgstr "PIP aktivieren"
msgid "PIP zapmode (not working)"
msgstr ""
msgid "PIP channel +"
msgstr "PIP Kanal +"
@ -715,6 +718,10 @@ msgstr ""
msgid "[softhddev] no codec known for still picture\n"
msgstr ""
#, c-format
msgid "Too much shaders definded\n"
msgstr ""
#, c-format
msgid "Bad formated geometry please use: [=][<width>{xX}<height>][{+-}<xoffset>{+-}<yoffset>]\n"
msgstr ""
@ -884,6 +891,9 @@ msgstr ""
msgid "Failed initializing libplacebo\n"
msgstr ""
msgid "Failed to create placebo opengl \n"
msgstr ""
msgid "Failed to create XCB Surface\n"
msgstr ""
@ -893,6 +903,9 @@ msgstr ""
msgid "Failed creating vulkan swapchain!"
msgstr ""
msgid "libplacebo: failed initializing swapchain\n"
msgstr ""
msgid "Failed initializing libplacebo renderer\n"
msgstr ""

View File

@ -1,5 +1,5 @@
///
/// @file ringbuffer.c @brief Ringbuffer module
/// @file ringbuffer.c @brief Ringbuffer module
///
/// Copyright (c) 2009, 2011, 2014 by Johns. All Rights Reserved.
///
@ -34,17 +34,16 @@
#include "ringbuffer.h"
/// ring buffer structure
struct _ring_buffer_
{
char *Buffer; ///< ring buffer data
const char *BufferEnd; ///< end of buffer
size_t Size; ///< bytes in buffer (for faster calc)
struct _ring_buffer_ {
char *Buffer; ///< ring buffer data
const char *BufferEnd; ///< end of buffer
size_t Size; ///< bytes in buffer (for faster calc)
const char *ReadPointer; ///< only used by reader
char *WritePointer; ///< only used by writer
const char *ReadPointer; ///< only used by reader
char *WritePointer; ///< only used by writer
/// The only thing modified by both
atomic_t Filled; ///< how many of the buffer is used
atomic_t Filled; ///< how many of the buffer is used
};
/**
@ -52,8 +51,7 @@ struct _ring_buffer_
**
** @param rb Ring buffer to reset read/write pointers.
*/
void RingBufferReset(RingBuffer * rb)
{
void RingBufferReset(RingBuffer *rb) {
rb->ReadPointer = rb->Buffer;
rb->WritePointer = rb->Buffer;
atomic_set(&rb->Filled, 0);
@ -67,11 +65,10 @@ void RingBufferReset(RingBuffer * rb)
** @returns Allocated ring buffer, must be freed with
** RingBufferDel(), NULL for out of memory.
*/
RingBuffer *RingBufferNew(size_t size)
{
RingBuffer *RingBufferNew(size_t size) {
RingBuffer *rb;
if (!(rb = malloc(sizeof(*rb)))) { // allocate structure
if (!(rb = malloc(sizeof(*rb)))) { // allocate structure
return rb;
}
if (!(rb->Buffer = malloc(size))) { // allocate buffer
@ -89,8 +86,7 @@ RingBuffer *RingBufferNew(size_t size)
/**
** Free an allocated ring buffer.
*/
void RingBufferDel(RingBuffer * rb)
{
void RingBufferDel(RingBuffer *rb) {
free(rb->Buffer);
free(rb);
}
@ -103,21 +99,20 @@ void RingBufferDel(RingBuffer * rb)
**
** @returns Number of bytes that could be advanced in ring buffer.
*/
size_t RingBufferWriteAdvance(RingBuffer * rb, size_t cnt)
{
size_t RingBufferWriteAdvance(RingBuffer *rb, size_t cnt) {
size_t n;
n = rb->Size - atomic_read(&rb->Filled);
if (cnt > n) { // not enough space
if (cnt > n) { // not enough space
cnt = n;
}
//
// Hitting end of buffer?
// Hitting end of buffer?
//
n = rb->BufferEnd - rb->WritePointer;
if (n > cnt) { // don't cross the end
if (n > cnt) { // don't cross the end
rb->WritePointer += cnt;
} else { // reached or cross the end
} else { // reached or cross the end
rb->WritePointer = rb->Buffer;
if (n < cnt) {
n = cnt - n;
@ -126,7 +121,7 @@ size_t RingBufferWriteAdvance(RingBuffer * rb, size_t cnt)
}
//
// Only atomic modification!
// Only atomic modification!
//
atomic_add(cnt, &rb->Filled);
return cnt;
@ -142,22 +137,21 @@ size_t RingBufferWriteAdvance(RingBuffer * rb, size_t cnt)
** @returns The number of bytes that could be placed in the ring
** buffer.
*/
size_t RingBufferWrite(RingBuffer * rb, const void *buf, size_t cnt)
{
size_t RingBufferWrite(RingBuffer *rb, const void *buf, size_t cnt) {
size_t n;
n = rb->Size - atomic_read(&rb->Filled);
if (cnt > n) { // not enough space
if (cnt > n) { // not enough space
cnt = n;
}
//
// Hitting end of buffer?
// Hitting end of buffer?
//
n = rb->BufferEnd - rb->WritePointer;
if (n > cnt) { // don't cross the end
if (n > cnt) { // don't cross the end
memcpy(rb->WritePointer, buf, cnt);
rb->WritePointer += cnt;
} else { // reached or cross the end
} else { // reached or cross the end
memcpy(rb->WritePointer, buf, n);
rb->WritePointer = rb->Buffer;
if (n < cnt) {
@ -169,7 +163,7 @@ size_t RingBufferWrite(RingBuffer * rb, const void *buf, size_t cnt)
}
//
// Only atomic modification!
// Only atomic modification!
//
atomic_add(cnt, &rb->Filled);
return cnt;
@ -184,21 +178,20 @@ size_t RingBufferWrite(RingBuffer * rb, const void *buf, size_t cnt)
** @returns The number of bytes that could be placed in the ring
** buffer at the write pointer.
*/
size_t RingBufferGetWritePointer(RingBuffer * rb, void **wp)
{
size_t RingBufferGetWritePointer(RingBuffer *rb, void **wp) {
size_t n;
size_t cnt;
// Total free bytes available in ring buffer
// Total free bytes available in ring buffer
cnt = rb->Size - atomic_read(&rb->Filled);
*wp = rb->WritePointer;
//
// Hitting end of buffer?
// Hitting end of buffer?
//
n = rb->BufferEnd - rb->WritePointer;
if (n <= cnt) { // reached or cross the end
if (n <= cnt) { // reached or cross the end
return n;
}
return cnt;
@ -212,21 +205,20 @@ size_t RingBufferGetWritePointer(RingBuffer * rb, void **wp)
**
** @returns Number of bytes that could be advanced in ring buffer.
*/
size_t RingBufferReadAdvance(RingBuffer * rb, size_t cnt)
{
size_t RingBufferReadAdvance(RingBuffer *rb, size_t cnt) {
size_t n;
n = atomic_read(&rb->Filled);
if (cnt > n) { // not enough filled
if (cnt > n) { // not enough filled
cnt = n;
}
//
// Hitting end of buffer?
// Hitting end of buffer?
//
n = rb->BufferEnd - rb->ReadPointer;
if (n > cnt) { // don't cross the end
if (n > cnt) { // don't cross the end
rb->ReadPointer += cnt;
} else { // reached or cross the end
} else { // reached or cross the end
rb->ReadPointer = rb->Buffer;
if (n < cnt) {
n = cnt - n;
@ -235,7 +227,7 @@ size_t RingBufferReadAdvance(RingBuffer * rb, size_t cnt)
}
//
// Only atomic modification!
// Only atomic modification!
//
atomic_sub(cnt, &rb->Filled);
return cnt;
@ -250,22 +242,21 @@ size_t RingBufferReadAdvance(RingBuffer * rb, size_t cnt)
**
** @returns Number of bytes that could be read from ring buffer.
*/
size_t RingBufferRead(RingBuffer * rb, void *buf, size_t cnt)
{
size_t RingBufferRead(RingBuffer *rb, void *buf, size_t cnt) {
size_t n;
n = atomic_read(&rb->Filled);
if (cnt > n) { // not enough filled
if (cnt > n) { // not enough filled
cnt = n;
}
//
// Hitting end of buffer?
// Hitting end of buffer?
//
n = rb->BufferEnd - rb->ReadPointer;
if (n > cnt) { // don't cross the end
if (n > cnt) { // don't cross the end
memcpy(buf, rb->ReadPointer, cnt);
rb->ReadPointer += cnt;
} else { // reached or cross the end
} else { // reached or cross the end
memcpy(buf, rb->ReadPointer, n);
rb->ReadPointer = rb->Buffer;
if (n < cnt) {
@ -277,7 +268,7 @@ size_t RingBufferRead(RingBuffer * rb, void *buf, size_t cnt)
}
//
// Only atomic modification!
// Only atomic modification!
//
atomic_sub(cnt, &rb->Filled);
return cnt;
@ -292,21 +283,20 @@ size_t RingBufferRead(RingBuffer * rb, void *buf, size_t cnt)
** @returns The number of bytes that could be read from the ring
** buffer at the read pointer.
*/
size_t RingBufferGetReadPointer(RingBuffer * rb, const void **rp)
{
size_t RingBufferGetReadPointer(RingBuffer *rb, const void **rp) {
size_t n;
size_t cnt;
// Total used bytes in ring buffer
// Total used bytes in ring buffer
cnt = atomic_read(&rb->Filled);
*rp = rb->ReadPointer;
//
// Hitting end of buffer?
// Hitting end of buffer?
//
n = rb->BufferEnd - rb->ReadPointer;
if (n <= cnt) { // reached or cross the end
if (n <= cnt) { // reached or cross the end
return n;
}
return cnt;
@ -319,10 +309,7 @@ size_t RingBufferGetReadPointer(RingBuffer * rb, const void **rp)
**
** @returns Number of bytes free in buffer.
*/
size_t RingBufferFreeBytes(RingBuffer * rb)
{
return rb->Size - atomic_read(&rb->Filled);
}
size_t RingBufferFreeBytes(RingBuffer *rb) { return rb->Size - atomic_read(&rb->Filled); }
/**
** Get used bytes in ring buffer.
@ -331,7 +318,4 @@ size_t RingBufferFreeBytes(RingBuffer * rb)
**
** @returns Number of bytes used in buffer.
*/
size_t RingBufferUsedBytes(RingBuffer * rb)
{
return atomic_read(&rb->Filled);
}
size_t RingBufferUsedBytes(RingBuffer *rb) { return atomic_read(&rb->Filled); }

View File

@ -1,7 +1,7 @@
///
/// @file ringbuffer.h @brief Ringbuffer module header file
/// @file ringbuffer.h @brief Ringbuffer module header file
///
/// Copyright (c) 2009, 2011 by Johns. All Rights Reserved.
/// Copyright (c) 2009, 2011 by Johns. All Rights Reserved.
///
/// Contributor(s):
///

251
shaders.h
View File

@ -13,9 +13,9 @@ const char *gl_version = "#version 300 es ";
/* Color conversion matrix: RGB = m * YUV + c
* m is in row-major matrix, with m[row][col], e.g.:
* [ a11 a12 a13 ] float m[3][3] = { { a11, a12, a13 },
* [ a21 a22 a23 ] { a21, a22, a23 },
* [ a31 a32 a33 ] { a31, a32, a33 } };
* [ a11 a12 a13 ] float m[3][3] = { { a11, a12, a13 },
* [ a21 a22 a23 ] { a21, a22, a23 },
* [ a31 a32 a33 ] { a31, a32, a33 } };
* This is accessed as e.g.: m[2-1][1-1] = a21
* In particular, each row contains all the coefficients for one of R, G, B,
* while each column contains all the coefficients for one of Y, U, V:
@ -24,88 +24,67 @@ const char *gl_version = "#version 300 es ";
* is the Y vector (1, 1, 1), the 2nd is the U vector, the 3rd the V vector.
* The matrix might also be used for other conversions and colorspaces.
*/
struct mp_cmat
{
GLfloat m[3][3]; // colormatrix
GLfloat c[3]; //colormatrix_c
struct mp_cmat {
GLfloat m[3][3]; // colormatrix
GLfloat c[3]; // colormatrix_c
};
struct mp_mat
{
struct mp_mat {
GLfloat m[3][3];
};
// YUV input limited range (16-235 for luma, 16-240 for chroma)
// ITU-R BT.601 (SD)
struct mp_cmat yuv_bt601 = { {{1.164384, 1.164384, 1.164384},
{0.00000, -0.391762, 2.017232},
{1.596027, -0.812968, 0.000000}},
{-0.874202, 0.531668, -1.085631}
};
struct mp_cmat yuv_bt601 = {
{{1.164384, 1.164384, 1.164384}, {0.00000, -0.391762, 2.017232}, {1.596027, -0.812968, 0.000000}},
{-0.874202, 0.531668, -1.085631}};
// ITU-R BT.709 (HD)
struct mp_cmat yuv_bt709 = { {{1.164384, 1.164384, 1.164384},
{0.00000, -0.213249, 2.112402},
{1.792741, -0.532909, 0.000000}},
{-0.972945, 0.301483, -1.133402}
};
struct mp_cmat yuv_bt709 = {
{{1.164384, 1.164384, 1.164384}, {0.00000, -0.213249, 2.112402}, {1.792741, -0.532909, 0.000000}},
{-0.972945, 0.301483, -1.133402}};
// ITU-R BT.2020 non-constant luminance system
struct mp_cmat yuv_bt2020ncl = { {{1.164384, 1.164384, 1.164384},
{0.00000, -0.187326, 2.141772},
{1.678674, -0.650424, 0.000000}},
{-0.915688, 0.347459, -1.148145}
};
struct mp_cmat yuv_bt2020ncl = {
{{1.164384, 1.164384, 1.164384}, {0.00000, -0.187326, 2.141772}, {1.678674, -0.650424, 0.000000}},
{-0.915688, 0.347459, -1.148145}};
// ITU-R BT.2020 constant luminance system
struct mp_cmat yuv_bt2020cl = { {{0.0000, 1.164384, 0.000000},
{0.00000, 0.000000, 1.138393},
{1.138393, 0.000000, 0.000000}},
{-0.571429, -0.073059, -0.571429}
};
struct mp_cmat yuv_bt2020cl = {
{{0.0000, 1.164384, 0.000000}, {0.00000, 0.000000, 1.138393}, {1.138393, 0.000000, 0.000000}},
{-0.571429, -0.073059, -0.571429}};
float cms_matrix[3][3] = { {1.660497, -0.124547, -0.018154},
{-0.587657, 1.132895, -0.100597},
{-0.072840, -0.008348, 1.118751}
};
float cms_matrix[3][3] = {
{1.660497, -0.124547, -0.018154}, {-0.587657, 1.132895, -0.100597}, {-0.072840, -0.008348, 1.118751}};
// Common constants for SMPTE ST.2084 (PQ)
static const float PQ_M1 = 2610. / 4096 * 1. / 4,
PQ_M2 = 2523. / 4096 * 128,
PQ_C1 = 3424. / 4096,
PQ_C2 = 2413. / 4096 * 32,
PQ_C3 = 2392. / 4096 * 32;
static const float PQ_M1 = 2610. / 4096 * 1. / 4, PQ_M2 = 2523. / 4096 * 128, PQ_C1 = 3424. / 4096,
PQ_C2 = 2413. / 4096 * 32, PQ_C3 = 2392. / 4096 * 32;
// Common constants for ARIB STD-B67 (HLG)
static const float HLG_A = 0.17883277,
HLG_B = 0.28466892,
HLG_C = 0.55991073;
static const float HLG_A = 0.17883277, HLG_B = 0.28466892, HLG_C = 0.55991073;
struct gl_vao_entry
{
struct gl_vao_entry {
// used for shader / glBindAttribLocation
const char *name;
// glVertexAttribPointer() arguments
int num_elems; // size (number of elements)
int num_elems; // size (number of elements)
GLenum type;
bool normalized;
int offset;
};
struct vertex_pt
{
struct vertex_pt {
float x, y;
};
struct vertex_pi
{
struct vertex_pi {
GLint x, y;
};
#define TEXUNIT_VIDEO_NUM 6
struct vertex
{
struct vertex {
struct vertex_pt position;
struct vertex_pt texcoord[TEXUNIT_VIDEO_NUM];
};
@ -114,27 +93,19 @@ static const struct gl_vao_entry vertex_vao[] = {
{"position", 2, GL_FLOAT, false, offsetof(struct vertex, position)},
{"texcoord0", 2, GL_FLOAT, false, offsetof(struct vertex, texcoord[0])},
{"texcoord1", 2, GL_FLOAT, false, offsetof(struct vertex, texcoord[1])},
{0}
};
{0}};
#define GLSL(...) pl_shader_append(__VA_ARGS__)
#define GLSLV(...) pl_shader_append_v(__VA_ARGS__)
#define GLSL(...) pl_shader_append(__VA_ARGS__)
#define GLSLV(...) pl_shader_append_v(__VA_ARGS__)
char sh[SHADER_LENGTH];
char shv[SHADER_LENGTH];
void GL_init()
{
sh[0] = 0;
}
void GL_init() { sh[0] = 0; }
void GLV_init()
{
shv[0] = 0;
}
void GLV_init() { shv[0] = 0; }
void pl_shader_append(const char *fmt, ...)
{
void pl_shader_append(const char *fmt, ...) {
char temp[1000];
va_list ap;
@ -145,11 +116,9 @@ void pl_shader_append(const char *fmt, ...)
if (strlen(sh) + strlen(temp) > SHADER_LENGTH)
Fatal(_("Shaderlenght fault\n"));
strcat(sh, temp);
}
void pl_shader_append_v(const char *fmt, ...)
{
void pl_shader_append_v(const char *fmt, ...) {
char temp[1000];
va_list ap;
@ -160,18 +129,16 @@ void pl_shader_append_v(const char *fmt, ...)
if (strlen(shv) + strlen(temp) > SHADER_LENGTH)
Fatal(_("Shaderlenght fault\n"));
strcat(shv, temp);
}
static void compile_attach_shader(GLuint program, GLenum type, const char *source)
{
static void compile_attach_shader(GLuint program, GLenum type, const char *source) {
GLuint shader;
GLint status = 1234, log_length;
char log[4000];
GLsizei len;
shader = glCreateShader(type);
glShaderSource(shader, 1, (const GLchar **)&source, NULL); // &buffer, NULL);
glShaderSource(shader, 1, (const GLchar **)&source, NULL); // &buffer, NULL);
glCompileShader(shader);
status = 0;
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
@ -183,11 +150,9 @@ static void compile_attach_shader(GLuint program, GLenum type, const char *sourc
glAttachShader(program, shader);
glDeleteShader(shader);
}
static void link_shader(GLuint program)
{
static void link_shader(GLuint program) {
GLint status, log_length;
glLinkProgram(program);
@ -198,8 +163,7 @@ static void link_shader(GLuint program)
Debug(3, "Link Status %d loglen %d\n", status, log_length);
}
static GLuint sc_generate_osd(GLuint gl_prog)
{
static GLuint sc_generate_osd(GLuint gl_prog) {
Debug(3, "vor create osd\n");
gl_prog = glCreateProgram();
@ -215,7 +179,7 @@ static GLuint sc_generate_osd(GLuint gl_prog)
GLSL("}\n");
Debug(3, "vor compile vertex osd\n");
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, sh); // vertex_osd);
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, sh); // vertex_osd);
GL_init();
GLSL("%s\n", gl_version);
GLSL("#define texture1D texture\n");
@ -227,14 +191,14 @@ static GLuint sc_generate_osd(GLuint gl_prog)
GLSL("vec4 color; \n");
GLSL("color = vec4(texture(texture0, texcoord0));\n");
#ifdef GAMMA
GLSL("// delinearize gamma \n");
GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n"); // delinearize gamma
GLSL("// delinearize gamma \n");
GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n"); // delinearize gamma
GLSL("color.rgb = pow(color.rgb, vec3(2.4)); \n");
#endif
GLSL("out_color = color;\n");
GLSL("}\n");
Debug(3, "vor compile fragment osd \n");
compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, sh); //fragment_osd);
compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, sh); // fragment_osd);
glBindAttribLocation(gl_prog, 0, "vertex_position");
glBindAttribLocation(gl_prog, 1, "vertex_texcoord0");
@ -243,8 +207,7 @@ static GLuint sc_generate_osd(GLuint gl_prog)
return gl_prog;
}
static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace)
{
static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace) {
char vname[80];
int n;
@ -254,39 +217,39 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace)
GL_init();
GLSL("%s\n", gl_version);
GLSL("in vec2 vertex_position; \n");
GLSL("in vec2 vertex_texcoord0; \n");
GLSL("out vec2 texcoord0; \n");
GLSL("in vec2 vertex_texcoord1; \n");
GLSL("out vec2 texcoord1; \n");
GLSL("in vec2 vertex_position; \n");
GLSL("in vec2 vertex_texcoord0; \n");
GLSL("out vec2 texcoord0; \n");
GLSL("in vec2 vertex_texcoord1; \n");
GLSL("out vec2 texcoord1; \n");
if (Planes == 3) {
GLSL("in vec2 vertex_texcoord2; \n");
GLSL("out vec2 texcoord2; \n");
GLSL("out vec2 texcoord2; \n");
}
GLSL("void main() { \n");
GLSL("void main() { \n");
GLSL("gl_Position = vec4(vertex_position, 1.0, 1.0);\n");
GLSL("texcoord0 = vertex_texcoord0; \n");
GLSL("texcoord1 = vertex_texcoord1; \n");
if (Planes == 3) {
GLSL("texcoord2 = vertex_texcoord1; \n"); // texcoord1 ist hier richtig
GLSL("texcoord2 = vertex_texcoord1; \n"); // texcoord1 ist hier richtig
}
GLSL("} \n");
GLSL("} \n");
Debug(3, "vor create\n");
gl_prog = glCreateProgram();
Debug(3, "vor compile vertex\n");
// printf("%s",sh);
// printf("%s",sh);
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, sh);
switch (colorspace) {
case AVCOL_SPC_RGB:
case AVCOL_SPC_BT470BG:
case AVCOL_SPC_BT470BG:
m = &yuv_bt601.m[0][0];
c = &yuv_bt601.c[0];
Debug(3, "BT601 Colorspace used\n");
break;
case AVCOL_SPC_BT709:
case AVCOL_SPC_UNSPECIFIED: // comes with UHD
case AVCOL_SPC_UNSPECIFIED: // comes with UHD
m = &yuv_bt709.m[0][0];
c = &yuv_bt709.c[0];
Debug(3, "BT709 Colorspace used\n");
@ -297,7 +260,7 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace)
cms = &cms_matrix[0][0];
Debug(3, "BT2020NCL Colorspace used\n");
break;
default: // fallback
default: // fallback
m = &yuv_bt709.m[0][0];
c = &yuv_bt709.c[0];
Debug(3, "default BT709 Colorspace used %d\n", colorspace);
@ -309,8 +272,8 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace)
GLSL("%s\n", gl_version);
GLSL("precision mediump float; \n");
GLSL("layout(location = 0) out vec4 out_color;\n");
GLSL("in vec2 texcoord0; \n");
GLSL("in vec2 texcoord1; \n");
GLSL("in vec2 texcoord0; \n");
GLSL("in vec2 texcoord1; \n");
if (Planes == 3)
GLSL("in vec2 texcoord2; \n");
GLSL("uniform mat3 colormatrix; \n");
@ -321,8 +284,8 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace)
GLSL("uniform sampler2D texture1; \n");
if (Planes == 3)
GLSL("uniform sampler2D texture2; \n");
GLSL("void main() { \n");
GLSL("vec4 color; \n");
GLSL("void main() { \n");
GLSL("vec4 color; \n");
if (colorspace == AVCOL_SPC_BT2020_NCL) {
GLSL("color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r; \n");
@ -333,55 +296,64 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace)
GLSL("color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;\n");
}
GLSL("// color conversion\n");
GLSL("color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c; \n");
GLSL("color.a = 1.0; \n");
GLSL("color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c; "
"\n");
GLSL("color.a = 1.0; \n");
GLSL("// pl_shader_linearize \n");
GLSL("color.rgb = max(color.rgb, 0.0); \n");
// GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n");
// GLSL("color.rgb = pow(color.rgb, vec3(2.4)); \n");
// GLSL("color.rgb = mix(vec3(4.0) * color.rgb * color.rgb,exp((color.rgb - vec3(%f)) * vec3(1.0/%f)) + vec3(%f) , bvec3(lessThan(vec3(0.5), color.rgb)));\n",HLG_C, HLG_A, HLG_B);
GLSL("color.rgb = mix(vec3(4.0) * color.rgb * color.rgb,exp((color.rgb - vec3(0.55991073)) * vec3(1.0/0.17883277)) + vec3(0.28466892), bvec3(lessThan(vec3(0.5), color.rgb)));\n");
GLSL("color.rgb *= vec3(1.0/3.17955); \n"); // PL_COLOR_SDR_WHITE_HLG
GLSL("// color mapping \n");
GLSL("color.rgb = cms_matrix * color.rgb; \n");
GLSL("// pl_shader_linearize \n");
GLSL("color.rgb = max(color.rgb, 0.0); \n");
// GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n");
// GLSL("color.rgb = pow(color.rgb, vec3(2.4)); \n");
// GLSL("color.rgb = mix(vec3(4.0) * color.rgb * color.rgb,exp((color.rgb -
// vec3(%f)) * vec3(1.0/%f)) + vec3(%f) ,
// bvec3(lessThan(vec3(0.5), color.rgb)));\n",HLG_C, HLG_A, HLG_B);
GLSL("color.rgb = mix(vec3(4.0) * color.rgb * color.rgb,exp((color.rgb - "
"vec3(0.55991073)) * vec3(1.0/0.17883277)) + vec3(0.28466892), "
"bvec3(lessThan(vec3(0.5), color.rgb)));\n");
GLSL("color.rgb *= vec3(1.0/3.17955); \n"); // PL_COLOR_SDR_WHITE_HLG
GLSL("// color mapping \n");
GLSL("color.rgb = cms_matrix * color.rgb; \n");
#ifndef GAMMA
GLSL("// pl_shader_delinearize \n");
GLSL("color.rgb = max(color.rgb, 0.0); \n");
// GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n");
// GLSL("color.rgb = pow(color.rgb, vec3(1.0/2.4)); \n");
GLSL("color.rgb *= vec3(3.17955); \n"); // PL_COLOR_SDR_WHITE_HLG
GLSL("color.rgb = mix(vec3(0.5) * sqrt(color.rgb), vec3(0.17883277) * log(color.rgb - vec3(0.28466892)) + vec3(0.55991073), bvec3(lessThan(vec3(1.0), color.rgb))); \n");
GLSL("// pl_shader_delinearize \n");
GLSL("color.rgb = max(color.rgb, 0.0); \n");
// GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n");
// GLSL("color.rgb = pow(color.rgb, vec3(1.0/2.4)); \n");
GLSL("color.rgb *= vec3(3.17955); \n"); // PL_COLOR_SDR_WHITE_HLG
GLSL("color.rgb = mix(vec3(0.5) * sqrt(color.rgb), vec3(0.17883277) * "
"log(color.rgb - vec3(0.28466892)) + vec3(0.55991073), "
"bvec3(lessThan(vec3(1.0), color.rgb))); \n");
#endif
GLSL("out_color = color; \n");
GLSL("out_color = color; \n");
GLSL("} \n");
} else {
GLSL("color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r; \n");
GLSL("color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r; \n");
if (Planes == 3) {
GLSL("color.g = 1.000000 * vec4(texture(texture1, texcoord1)).r;\n");
GLSL("color.b = 1.000000 * vec4(texture(texture2, texcoord2)).r;\n");
} else {
GLSL("color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg; \n");
}
GLSL("// color conversion \n");
GLSL("color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c; \n");
GLSL("color.a = 1.0; \n");
GLSL("// color conversion \n");
GLSL("color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c; \n");
GLSL("color.a = 1.0; \n");
GLSL("// linearize gamma \n");
GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n"); // linearize gamma
GLSL("// linearize gamma \n");
GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n"); // linearize gamma
GLSL("color.rgb = pow(color.rgb, vec3(2.4)); \n");
#ifndef GAMMA
GLSL("// delinearize gamma to sRGB \n");
GLSL("color.rgb = max(color.rgb, 0.0); \n");
GLSL("color.rgb = mix(color.rgb * vec3(12.92), vec3(1.055) * pow(color.rgb, vec3(1.0/2.4)) - vec3(0.055), bvec3(lessThanEqual(vec3(0.0031308), color.rgb))); \n");
GLSL("// delinearize gamma to sRGB \n");
GLSL("color.rgb = max(color.rgb, 0.0); \n");
GLSL("color.rgb = mix(color.rgb * vec3(12.92), vec3(1.055) * "
"pow(color.rgb, vec3(1.0/2.4)) - vec3(0.055), "
"bvec3(lessThanEqual(vec3(0.0031308), color.rgb))); \n");
#endif
GLSL("// color mapping \n");
GLSL("out_color = color; \n");
GLSL("// color mapping \n");
GLSL("out_color = color; \n");
GLSL("} \n");
}
//printf(">%s<",sh);
// printf(">%s<",sh);
Debug(3, "vor compile fragment\n");
compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, sh);
glBindAttribLocation(gl_prog, 0, "vertex_position");
@ -416,8 +388,7 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace)
return gl_prog;
}
static void render_pass_quad(int flip, float xcrop, float ycrop)
{
static void render_pass_quad(int flip, float xcrop, float ycrop) {
struct vertex va[4];
int n;
const struct gl_vao_entry *e;
@ -444,21 +415,21 @@ static void render_pass_quad(int flip, float xcrop, float ycrop)
}
va[0].texcoord[0].x = (float)0.0 + xcrop;
va[0].texcoord[0].y = (float)0.0 + ycrop; // abgeschnitten von links oben
va[0].texcoord[0].y = (float)0.0 + ycrop; // abgeschnitten von links oben
va[0].texcoord[1].x = (float)0.0 + xcrop;
va[0].texcoord[1].y = (float)0.0 + ycrop; // abgeschnitten von links oben
va[0].texcoord[1].y = (float)0.0 + ycrop; // abgeschnitten von links oben
va[1].texcoord[0].x = (float)0.0 + xcrop;
va[1].texcoord[0].y = (float)1.0 - ycrop; // abgeschnitten links unten 1.0 - Wert
va[1].texcoord[0].y = (float)1.0 - ycrop; // abgeschnitten links unten 1.0 - Wert
va[1].texcoord[1].x = (float)0.0 + xcrop;
va[1].texcoord[1].y = (float)1.0 - ycrop; // abgeschnitten links unten 1.0 - Wert
va[1].texcoord[1].y = (float)1.0 - ycrop; // abgeschnitten links unten 1.0 - Wert
va[2].texcoord[0].x = (float)1.0 - xcrop;
va[2].texcoord[0].y = (float)0.0 + ycrop; // abgeschnitten von rechts oben
va[2].texcoord[0].y = (float)0.0 + ycrop; // abgeschnitten von rechts oben
va[2].texcoord[1].x = (float)1.0 - xcrop;
va[2].texcoord[1].y = (float)0.0 + ycrop; // abgeschnitten von rechts oben
va[2].texcoord[1].y = (float)0.0 + ycrop; // abgeschnitten von rechts oben
va[3].texcoord[0].x = (float)1.0 - xcrop;
va[3].texcoord[0].y = (float)1.0 - ycrop; // abgeschnitten von rechts unten 1.0 - wert
va[3].texcoord[0].y = (float)1.0 - ycrop; // abgeschnitten von rechts unten 1.0 - wert
va[3].texcoord[1].x = (float)1.0 - xcrop;
va[3].texcoord[1].y = (float)1.0 - ycrop; // abgeschnitten von rechts unten 1.0 - wert
va[3].texcoord[1].y = (float)1.0 - ycrop; // abgeschnitten von rechts unten 1.0 - wert
glBindBuffer(GL_ARRAY_BUFFER, vao_buffer);
glBufferData(GL_ARRAY_BUFFER, 4 * sizeof(struct vertex), va, GL_DYNAMIC_DRAW);
@ -470,7 +441,7 @@ static void render_pass_quad(int flip, float xcrop, float ycrop)
e = &vertex_vao[n];
glEnableVertexAttribArray(n);
glVertexAttribPointer(n, e->num_elems, e->type, e->normalized, sizeof(struct vertex),
(void *)(intptr_t) e->offset);
(void *)(intptr_t)e->offset);
}
glBindBuffer(GL_ARRAY_BUFFER, 0);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
///
/// @file softhddev.h @brief software HD device plugin header file.
/// @file softhddev.h @brief software HD device plugin header file.
///
/// Copyright (c) 2011 - 2015 by Johns. All Rights Reserved.
/// Copyright (c) 2011 - 2015 by Johns. All Rights Reserved.
///
/// Contributor(s):
///
@ -21,95 +21,94 @@
//////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
/// C callback feed key press
extern void FeedKeyPress(const char *, const char *, int, int, const char *);
/// C callback feed key press
extern void FeedKeyPress(const char *, const char *, int, int, const char *);
/// C plugin get osd size and ascpect
extern void GetOsdSize(int *, int *, double *);
/// C plugin get osd size and ascpect
extern void GetOsdSize(int *, int *, double *);
/// C plugin close osd
extern void OsdClose(void);
/// C plugin draw osd pixmap
extern void OsdDrawARGB(int, int, int, int, int, const uint8_t *, int, int);
/// C plugin close osd
extern void OsdClose(void);
/// C plugin draw osd pixmap
extern void OsdDrawARGB(int, int, int, int, int, const uint8_t *, int, int);
/// C plugin play audio packet
extern int PlayAudio(const uint8_t *, int, uint8_t);
/// C plugin play TS audio packet
extern int PlayTsAudio(const uint8_t *, int);
/// C plugin set audio volume
extern void SetVolumeDevice(int);
/// C plugin reset channel id (restarts audio)
extern void ResetChannelId(void);
/// C plugin play audio packet
extern int PlayAudio(const uint8_t *, int, uint8_t);
/// C plugin play TS audio packet
extern int PlayTsAudio(const uint8_t *, int);
/// C plugin set audio volume
extern void SetVolumeDevice(int);
/// C plugin reset channel id (restarts audio)
extern void ResetChannelId(void);
/// C plugin play video packet
extern int PlayVideo(const uint8_t *, int);
/// C plugin play TS video packet
extern void PlayTsVideo(const uint8_t *, int);
/// C plugin grab an image
extern uint8_t *GrabImage(int *, int, int, int, int);
/// C plugin play video packet
extern int PlayVideo(const uint8_t *, int);
/// C plugin play TS video packet
extern void PlayTsVideo(const uint8_t *, int);
/// C plugin grab an image
extern uint8_t *GrabImage(int *, int, int, int, int);
/// C plugin set play mode
extern int SetPlayMode(int);
/// C plugin get current system time counter
extern int64_t GetSTC(void);
/// C plugin get video stream size and aspect
extern void GetVideoSize(int *, int *, double *);
/// C plugin set trick speed
extern void TrickSpeed(int);
/// C plugin clears all video and audio data from the device
extern void Clear(void);
/// C plugin sets the device into play mode
extern void Play(void);
/// C plugin sets the device into "freeze frame" mode
extern void Freeze(void);
/// C plugin mute audio
extern void Mute(void);
/// C plugin display I-frame as a still picture.
extern void StillPicture(const uint8_t *, int);
/// C plugin poll if ready
extern int Poll(int);
/// C plugin flush output buffers
extern int Flush(int);
/// C plugin set play mode
extern int SetPlayMode(int);
/// C plugin get current system time counter
extern int64_t GetSTC(void);
/// C plugin get video stream size and aspect
extern void GetVideoSize(int *, int *, double *);
/// C plugin set trick speed
extern void TrickSpeed(int);
/// C plugin clears all video and audio data from the device
extern void Clear(void);
/// C plugin sets the device into play mode
extern void Play(void);
/// C plugin sets the device into "freeze frame" mode
extern void Freeze(void);
/// C plugin mute audio
extern void Mute(void);
/// C plugin display I-frame as a still picture.
extern void StillPicture(const uint8_t *, int);
/// C plugin poll if ready
extern int Poll(int);
/// C plugin flush output buffers
extern int Flush(int);
/// C plugin command line help
extern const char *CommandLineHelp(void);
/// C plugin process the command line arguments
extern int ProcessArgs(int, char *const[]);
/// C plugin command line help
extern const char *CommandLineHelp(void);
/// C plugin process the command line arguments
extern int ProcessArgs(int, char *const[]);
/// C plugin exit + cleanup
extern void SoftHdDeviceExit(void);
/// C plugin start code
extern int Start(void);
/// C plugin stop code
extern void Stop(void);
/// C plugin house keeping
extern void Housekeeping(void);
/// C plugin main thread hook
extern void MainThreadHook(void);
/// C plugin exit + cleanup
extern void SoftHdDeviceExit(void);
/// C plugin start code
extern int Start(void);
/// C plugin stop code
extern void Stop(void);
/// C plugin house keeping
extern void Housekeeping(void);
/// C plugin main thread hook
extern void MainThreadHook(void);
/// Suspend plugin
extern void Suspend(int, int, int);
/// Resume plugin
extern void Resume(void);
/// Suspend plugin
extern void Suspend(int, int, int);
/// Resume plugin
extern void Resume(void);
/// Get decoder statistics
extern void GetStats(int *, int *, int *, int *, float *, int *, int *, int *, int *);
/// C plugin scale video
extern void ScaleVideo(int, int, int, int);
/// Get decoder statistics
extern void GetStats(int *, int *, int *, int *, float *, int *, int *, int *, int *);
/// C plugin scale video
extern void ScaleVideo(int, int, int, int);
/// Set Pip position
extern void PipSetPosition(int, int, int, int, int, int, int, int);
/// Pip start
extern void PipStart(int, int, int, int, int, int, int, int);
/// Pip stop
extern void PipStop(void);
/// Pip play video packet
extern int PipPlayVideo(const uint8_t *, int);
/// Set Pip position
extern void PipSetPosition(int, int, int, int, int, int, int, int);
/// Pip start
extern void PipStart(int, int, int, int, int, int, int, int);
/// Pip stop
extern void PipStop(void);
/// Pip play video packet
extern int PipPlayVideo(const uint8_t *, int);
extern const char *X11DisplayName; ///< x11 display name
extern const char *X11DisplayName; ///< x11 display name
#ifdef __cplusplus
}
#endif

View File

@ -1,7 +1,7 @@
///
/// @file softhddevice.h @brief software HD device plugin header file.
///
/// Copyright (c) 2011, 2014 by Johns. All Rights Reserved.
/// Copyright (c) 2011, 2014 by Johns. All Rights Reserved.
///
/// Contributor(s):
///

View File

@ -1,7 +1,7 @@
///
/// @file softhddev_service.h @brief software HD device service header file.
///
/// Copyright (c) 2012 by durchflieger. All Rights Reserved.
/// Copyright (c) 2012 by durchflieger. All Rights Reserved.
///
/// Contributor(s):
///
@ -22,15 +22,13 @@
#pragma once
#define ATMO_GRAB_SERVICE "SoftHDDevice-AtmoGrabService-v1.0"
#define ATMO1_GRAB_SERVICE "SoftHDDevice-AtmoGrabService-v1.1"
#define OSD_3DMODE_SERVICE "SoftHDDevice-Osd3DModeService-v1.0"
#define ATMO_GRAB_SERVICE "SoftHDDevice-AtmoGrabService-v1.0"
#define ATMO1_GRAB_SERVICE "SoftHDDevice-AtmoGrabService-v1.1"
#define OSD_3DMODE_SERVICE "SoftHDDevice-Osd3DModeService-v1.0"
enum
{ GRAB_IMG_RGBA_FORMAT_B8G8R8A8 };
enum { GRAB_IMG_RGBA_FORMAT_B8G8R8A8 };
typedef struct
{
typedef struct {
int structSize;
// request data
@ -45,13 +43,11 @@ typedef struct
void *img;
} SoftHDDevice_AtmoGrabService_v1_0_t;
typedef struct
{
typedef struct {
int Mode;
} SoftHDDevice_Osd3DModeService_v1_0_t;
typedef struct
{
typedef struct {
// request/reply data
int width;

2751
video.c

File diff suppressed because it is too large Load Diff

19
video.h
View File

@ -1,7 +1,7 @@
///
/// @file video.h @brief Video module header file
///
/// Copyright (c) 2009 - 2015 by Johns. All Rights Reserved.
/// Copyright (c) 2009 - 2015 by Johns. All Rights Reserved.
///
/// Contributor(s):
///
@ -40,11 +40,12 @@ typedef struct __video_stream__ VideoStream;
// Variables
//----------------------------------------------------------------------------
extern signed char VideoHardwareDecoder; ///< flag use hardware decoder
extern char VideoIgnoreRepeatPict; ///< disable repeat pict warning
extern int VideoAudioDelay; ///< audio/video delay
extern char ConfigStartX11Server; ///< flag start the x11 server
extern signed char VideoHardwareDecoder; ///< flag use hardware decoder
extern char VideoIgnoreRepeatPict; ///< disable repeat pict warning
extern int VideoAudioDelay; ///< audio/video delay
extern char ConfigStartX11Server; ///< flag start the x11 server
extern char MyConfigDir[];
//----------------------------------------------------------------------------
// Prototypes
//----------------------------------------------------------------------------
@ -224,11 +225,11 @@ extern void VideoGetStats(VideoHwDecoder *, int *, int *, int *, int *, float *,
/// Get video stream size
extern void VideoGetVideoSize(VideoHwDecoder *, int *, int *, int *, int *);
extern void VideoOsdInit(void); ///< Setup osd.
extern void VideoOsdExit(void); ///< Cleanup osd.
extern void VideoOsdInit(void); ///< Setup osd.
extern void VideoOsdExit(void); ///< Cleanup osd.
extern void VideoInit(const char *); ///< Setup video module.
extern void VideoExit(void); ///< Cleanup and exit video module.
extern void VideoInit(const char *); ///< Setup video module.
extern void VideoExit(void); ///< Cleanup and exit video module.
/// Poll video input buffers.
extern int VideoPollInput(VideoStream *);