mirror of
https://github.com/jojo61/vdr-plugin-softhdcuvid.git
synced 2023-10-10 13:37:41 +02:00
Vaapi changed to egl
This commit is contained in:
parent
cdac2bcc3d
commit
4d2735a971
48
Makefile
48
Makefile
@ -7,9 +7,9 @@
|
||||
# This name will be used in the '-P...' option of VDR to load the plugin.
|
||||
# By default the main source file also carries this name.
|
||||
|
||||
PLUGIN = softhdcuvid
|
||||
|
||||
### Configuration (edit this for your needs)
|
||||
# comment out if not needed
|
||||
|
||||
# what kind of driver do we make -
|
||||
# if VAAPI is enabled the drivername is softhdvaapi
|
||||
@ -17,18 +17,30 @@ PLUGIN = softhdcuvid
|
||||
#VAAPI=1
|
||||
CUVID=1
|
||||
|
||||
# use libplacebo - available for both drivers
|
||||
#LIBPLACEBO=1
|
||||
|
||||
# use YADIF deint - only available with cuvid
|
||||
#YADIF=1
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# support OPENGLOSD - only configurable with cuvid
|
||||
OPENGLOSD=1
|
||||
|
||||
# use Libplacebo - only configurable with cuvid
|
||||
LIBPLACEBO=1
|
||||
|
||||
# use YADIF deint - only configurable with cuvid
|
||||
YADIF=0
|
||||
|
||||
#--------------------- no more config needed past this point--------------------------------
|
||||
# support alsa audio output module
|
||||
PLUGIN = softhdcuvid
|
||||
|
||||
# support OPENGLOSD always needed
|
||||
OPENGLOSD=1
|
||||
|
||||
# support alsa audio output module
|
||||
ALSA ?= $(shell pkg-config --exists alsa && echo 1)
|
||||
# support OSS audio output module
|
||||
OSS ?= 1
|
||||
@ -48,7 +60,7 @@ SWRESAMPLE = 1
|
||||
#AVRESAMPLE = 1
|
||||
#endif
|
||||
|
||||
CONFIG := -DDEBUG #-DOSD_DEBUG # enable debug output+functions
|
||||
CONFIG := #-DDEBUG #-DOSD_DEBUG # enable debug output+functions
|
||||
CONFIG += -DHAVE_GL # needed for mpv libs
|
||||
#CONFIG += -DSTILL_DEBUG=2 # still picture debug verbose level
|
||||
CONFIG += -DAV_INFO -DAV_INFO_TIME=3000 # info/debug a/v sync
|
||||
@ -114,8 +126,8 @@ CONFIG += -DUSE_OSS
|
||||
endif
|
||||
|
||||
ifeq ($(OPENGL),1)
|
||||
_CFLAGS += $(shell pkg-config --cflags libva-glx)
|
||||
LIBS += $(shell pkg-config --libs libva-glx)
|
||||
#_CFLAGS += $(shell pkg-config --cflags libva-glx)
|
||||
#LIBS += $(shell pkg-config --libs libva-glx)
|
||||
endif
|
||||
|
||||
ifeq ($(OPENGLOSD),1)
|
||||
@ -125,17 +137,16 @@ endif
|
||||
ifeq ($(OPENGL),1)
|
||||
CONFIG += -DUSE_GLX
|
||||
_CFLAGS += $(shell pkg-config --cflags gl glu glew)
|
||||
LIBS += $(shell pkg-config --libs gl glu glew)
|
||||
_CFLAGS += $(shell pkg-config --cflags glew)
|
||||
LIBS += $(shell pkg-config --libs glew)
|
||||
#LIBS += $(shell pkg-config --libs glu glew)
|
||||
_CFLAGS += $(shell pkg-config --cflags freetype2)
|
||||
LIBS += $(shell pkg-config --libs freetype2)
|
||||
endif
|
||||
|
||||
ifeq ($(VAAPI),1)
|
||||
CONFIG += -DVAAPI -DUSE_OPENGLOSD
|
||||
LIBPLACEBO=1
|
||||
CONFIG += -DVAAPI
|
||||
#LIBPLACEBO=1
|
||||
PLUGIN = softhdvaapi
|
||||
LIBS += -lEGL -lEGL_mesa
|
||||
endif
|
||||
|
||||
ifeq ($(LIBPLACEBO),1)
|
||||
@ -144,6 +155,7 @@ endif
|
||||
|
||||
ifeq ($(CUVID),1)
|
||||
CONFIG += -DCUVID # enable CUVID decoder
|
||||
LIBS += -lEGL -lGL
|
||||
ifeq ($(YADIF),1)
|
||||
CONFIG += -DYADIF # Yadif only with CUVID
|
||||
endif
|
||||
@ -235,10 +247,10 @@ LIBS += -lplacebo -lglut
|
||||
endif
|
||||
|
||||
ifeq ($(CUVID),1)
|
||||
LIBS += -lcuda -L/usr/local/cuda/targets/x86_64-linux/lib -lcudart -lnvcuvid
|
||||
LIBS += -lcuda -L/usr/local/cuda/targets/x86_64-linux/lib -lcudart -lnvcuvid
|
||||
endif
|
||||
|
||||
LIBS += -lGLEW -lGLX -ldl
|
||||
LIBS += -lGLEW -lGLU -ldl
|
||||
### Includes and Defines (add further entries here):
|
||||
|
||||
INCLUDES +=
|
||||
|
290
codec.c
290
codec.c
@ -315,7 +315,7 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
|
||||
decoder->VideoCtx->pkt_timebase.den = 90000;
|
||||
decoder->VideoCtx->framerate.num = 50;
|
||||
decoder->VideoCtx->framerate.den = 1;
|
||||
decoder->VideoCtx->extra_hw_frames = 8; // VIDEO_SURFACES_MAX +1
|
||||
|
||||
|
||||
pthread_mutex_lock(&CodecLockMutex);
|
||||
// open codec
|
||||
@ -323,6 +323,7 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
|
||||
deint = 2;
|
||||
#endif
|
||||
#ifdef VAAPI
|
||||
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;
|
||||
@ -1220,23 +1221,23 @@ static void CodecAudioSetClock(AudioDecoder * audio_decoder, int64_t pts)
|
||||
|
||||
delay = AudioGetDelay();
|
||||
if (!delay) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
clock_gettime(CLOCK_MONOTONIC, &nowtime);
|
||||
if (!audio_decoder->LastDelay) {
|
||||
audio_decoder->LastTime = nowtime;
|
||||
audio_decoder->LastPTS = pts;
|
||||
audio_decoder->LastDelay = delay;
|
||||
audio_decoder->Drift = 0;
|
||||
audio_decoder->DriftFrac = 0;
|
||||
Debug(3, "codec/audio: inital drift delay %" PRId64 "ms\n",
|
||||
delay / 90);
|
||||
return;
|
||||
audio_decoder->LastTime = nowtime;
|
||||
audio_decoder->LastPTS = pts;
|
||||
audio_decoder->LastDelay = delay;
|
||||
audio_decoder->Drift = 0;
|
||||
audio_decoder->DriftFrac = 0;
|
||||
Debug(3, "codec/audio: inital drift delay %" PRId64 "ms\n",
|
||||
delay / 90);
|
||||
return;
|
||||
}
|
||||
// collect over some time
|
||||
pts_diff = pts - audio_decoder->LastPTS;
|
||||
if (pts_diff < 10 * 1000 * 90) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
tim_diff = (nowtime.tv_sec - audio_decoder->LastTime.tv_sec)
|
||||
@ -1262,51 +1263,51 @@ static void CodecAudioSetClock(AudioDecoder * audio_decoder, int64_t pts)
|
||||
// underruns and av_resample have the same time :(((
|
||||
if (abs(drift) > 10 * 90) {
|
||||
// drift too big, pts changed?
|
||||
Debug(3, "codec/audio: drift(%6d) %3dms reset\n",
|
||||
audio_decoder->DriftCorr, drift / 90);
|
||||
audio_decoder->LastDelay = 0;
|
||||
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 {
|
||||
|
||||
drift += audio_decoder->Drift;
|
||||
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)) {
|
||||
audio_decoder->DriftCorr = -corr;
|
||||
}
|
||||
drift += audio_decoder->Drift;
|
||||
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)) {
|
||||
audio_decoder->DriftCorr = -corr;
|
||||
}
|
||||
|
||||
if (audio_decoder->DriftCorr < -20000) { // limit correction
|
||||
audio_decoder->DriftCorr = -20000;
|
||||
} else if (audio_decoder->DriftCorr > 20000) {
|
||||
audio_decoder->DriftCorr = 20000;
|
||||
}
|
||||
if (audio_decoder->DriftCorr < -20000) { // limit correction
|
||||
audio_decoder->DriftCorr = -20000;
|
||||
} else if (audio_decoder->DriftCorr > 20000) {
|
||||
audio_decoder->DriftCorr = 20000;
|
||||
}
|
||||
}
|
||||
// FIXME: this works with libav 0.8, and only with >10ms with ffmpeg 0.10
|
||||
if (audio_decoder->AvResample && audio_decoder->DriftCorr) {
|
||||
int distance;
|
||||
int distance;
|
||||
|
||||
// try workaround for buggy ffmpeg 0.10
|
||||
if (abs(audio_decoder->DriftCorr) < 2000) {
|
||||
distance = (pts_diff * audio_decoder->HwSampleRate) / (900 * 1000);
|
||||
} else {
|
||||
distance = (pts_diff * audio_decoder->HwSampleRate) / (90 * 1000);
|
||||
}
|
||||
av_resample_compensate(audio_decoder->AvResample,
|
||||
audio_decoder->DriftCorr / 10, distance);
|
||||
// try workaround for buggy ffmpeg 0.10
|
||||
if (abs(audio_decoder->DriftCorr) < 2000) {
|
||||
distance = (pts_diff * audio_decoder->HwSampleRate) / (900 * 1000);
|
||||
} else {
|
||||
distance = (pts_diff * audio_decoder->HwSampleRate) / (90 * 1000);
|
||||
}
|
||||
av_resample_compensate(audio_decoder->AvResample,
|
||||
audio_decoder->DriftCorr / 10, distance);
|
||||
}
|
||||
if (1) {
|
||||
static int c;
|
||||
static int c;
|
||||
|
||||
if (!(c++ % 10)) {
|
||||
Debug(3, "codec/audio: drift(%6d) %8dus %5d\n",
|
||||
audio_decoder->DriftCorr, drift * 1000 / 90, corr);
|
||||
}
|
||||
if (!(c++ % 10)) {
|
||||
Debug(3, "codec/audio: drift(%6d) %8dus %5d\n",
|
||||
audio_decoder->DriftCorr, drift * 1000 / 90, corr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1324,64 +1325,64 @@ static void CodecAudioUpdateFormat(AudioDecoder * audio_decoder)
|
||||
int err;
|
||||
|
||||
if (audio_decoder->ReSample) {
|
||||
audio_resample_close(audio_decoder->ReSample);
|
||||
audio_decoder->ReSample = NULL;
|
||||
audio_resample_close(audio_decoder->ReSample);
|
||||
audio_decoder->ReSample = NULL;
|
||||
}
|
||||
if (audio_decoder->AvResample) {
|
||||
av_resample_close(audio_decoder->AvResample);
|
||||
audio_decoder->AvResample = NULL;
|
||||
audio_decoder->RemainCount = 0;
|
||||
av_resample_close(audio_decoder->AvResample);
|
||||
audio_decoder->AvResample = NULL;
|
||||
audio_decoder->RemainCount = 0;
|
||||
}
|
||||
|
||||
audio_ctx = audio_decoder->AudioCtx;
|
||||
if ((err = CodecAudioUpdateHelper(audio_decoder, &passthrough))) {
|
||||
|
||||
Debug(3, "codec/audio: resample %dHz *%d -> %dHz *%d err %d\n",
|
||||
audio_ctx->sample_rate, audio_ctx->channels,
|
||||
audio_decoder->HwSampleRate, audio_decoder->HwChannels,err);
|
||||
Debug(3, "codec/audio: resample %dHz *%d -> %dHz *%d err %d\n",
|
||||
audio_ctx->sample_rate, audio_ctx->channels,
|
||||
audio_decoder->HwSampleRate, audio_decoder->HwChannels,err);
|
||||
|
||||
if (err == 1) {
|
||||
audio_decoder->ReSample =
|
||||
av_audio_resample_init(audio_decoder->HwChannels,
|
||||
audio_ctx->channels, audio_decoder->HwSampleRate,
|
||||
audio_ctx->sample_rate, audio_ctx->sample_fmt,
|
||||
audio_ctx->sample_fmt, 16, 10, 0, 0.8);
|
||||
// libav-0.8_pre didn't support 6 -> 2 channels
|
||||
if (!audio_decoder->ReSample) {
|
||||
Error(_("codec/audio: resample setup error\n"));
|
||||
if (err == 1) {
|
||||
audio_decoder->ReSample =
|
||||
av_audio_resample_init(audio_decoder->HwChannels,
|
||||
audio_ctx->channels, audio_decoder->HwSampleRate,
|
||||
audio_ctx->sample_rate, audio_ctx->sample_fmt,
|
||||
audio_ctx->sample_fmt, 16, 10, 0, 0.8);
|
||||
// libav-0.8_pre didn't support 6 -> 2 channels
|
||||
if (!audio_decoder->ReSample) {
|
||||
Error(_("codec/audio: resample setup error\n"));
|
||||
audio_decoder->HwChannels = 0;
|
||||
audio_decoder->HwSampleRate = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
Debug(3, "codec/audio: audio setup error\n");
|
||||
// FIXME: handle errors
|
||||
audio_decoder->HwChannels = 0;
|
||||
audio_decoder->HwSampleRate = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
Debug(3, "codec/audio: audio setup error\n");
|
||||
// FIXME: handle errors
|
||||
audio_decoder->HwChannels = 0;
|
||||
audio_decoder->HwSampleRate = 0;
|
||||
return;
|
||||
return;
|
||||
}
|
||||
if (passthrough) { // pass-through no conversion allowed
|
||||
return;
|
||||
return;
|
||||
}
|
||||
// prepare audio drift resample
|
||||
#ifdef USE_AUDIO_DRIFT_CORRECTION
|
||||
if (CodecAudioDrift & CORRECT_PCM) {
|
||||
if (audio_decoder->AvResample) {
|
||||
Error(_("codec/audio: overwrite resample\n"));
|
||||
}
|
||||
audio_decoder->AvResample =
|
||||
av_resample_init(audio_decoder->HwSampleRate,
|
||||
audio_decoder->HwSampleRate, 16, 10, 0, 0.8);
|
||||
if (!audio_decoder->AvResample) {
|
||||
Error(_("codec/audio: AvResample setup error\n"));
|
||||
} else {
|
||||
// reset drift to some default value
|
||||
audio_decoder->DriftCorr /= 2;
|
||||
audio_decoder->DriftFrac = 0;
|
||||
av_resample_compensate(audio_decoder->AvResample,
|
||||
audio_decoder->DriftCorr / 10,
|
||||
10 * audio_decoder->HwSampleRate);
|
||||
}
|
||||
if (audio_decoder->AvResample) {
|
||||
Error(_("codec/audio: overwrite resample\n"));
|
||||
}
|
||||
audio_decoder->AvResample =
|
||||
av_resample_init(audio_decoder->HwSampleRate,
|
||||
audio_decoder->HwSampleRate, 16, 10, 0, 0.8);
|
||||
if (!audio_decoder->AvResample) {
|
||||
Error(_("codec/audio: AvResample setup error\n"));
|
||||
} else {
|
||||
// reset drift to some default value
|
||||
audio_decoder->DriftCorr /= 2;
|
||||
audio_decoder->DriftFrac = 0;
|
||||
av_resample_compensate(audio_decoder->AvResample,
|
||||
audio_decoder->DriftCorr / 10,
|
||||
10 * audio_decoder->HwSampleRate);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -1718,22 +1719,22 @@ static void CodecAudioSetClock(AudioDecoder * audio_decoder, int64_t pts)
|
||||
#endif
|
||||
#ifdef USE_AVRESAMPLE
|
||||
if (audio_decoder->Resample && audio_decoder->DriftCorr) {
|
||||
int distance;
|
||||
int distance;
|
||||
|
||||
distance = (pts_diff * audio_decoder->HwSampleRate) / (900 * 1000);
|
||||
if (avresample_set_compensation(audio_decoder->Resample,
|
||||
audio_decoder->DriftCorr / 10, distance)) {
|
||||
Debug(3, "codec/audio: swr_set_compensation failed\n");
|
||||
}
|
||||
distance = (pts_diff * audio_decoder->HwSampleRate) / (900 * 1000);
|
||||
if (avresample_set_compensation(audio_decoder->Resample,
|
||||
audio_decoder->DriftCorr / 10, distance)) {
|
||||
Debug(3, "codec/audio: swr_set_compensation failed\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (1) {
|
||||
static int c;
|
||||
static int c;
|
||||
|
||||
if (!(c++ % 10)) {
|
||||
Debug(3, "codec/audio: drift(%6d) %8dus %5d\n",
|
||||
audio_decoder->DriftCorr, drift * 1000 / 90, corr);
|
||||
}
|
||||
if (!(c++ % 10)) {
|
||||
Debug(3, "codec/audio: drift(%6d) %8dus %5d\n",
|
||||
audio_decoder->DriftCorr, drift * 1000 / 90, corr);
|
||||
}
|
||||
}
|
||||
#else
|
||||
AudioSetClock(pts);
|
||||
@ -1825,55 +1826,56 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
|
||||
AVCodecContext *audio_ctx = audio_decoder->AudioCtx;
|
||||
|
||||
if (audio_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
int ret;
|
||||
AVPacket pkt[1];
|
||||
AVFrame *frame = audio_decoder->Frame;
|
||||
int ret;
|
||||
AVPacket pkt[1];
|
||||
AVFrame *frame = audio_decoder->Frame;
|
||||
|
||||
av_frame_unref(frame);
|
||||
*pkt = *avpkt; // use copy
|
||||
ret = avcodec_send_packet(audio_ctx, pkt);
|
||||
if (ret < 0) {
|
||||
Debug(3, "codec: sending audio packet failed");
|
||||
return;
|
||||
}
|
||||
ret = avcodec_receive_frame(audio_ctx, frame);
|
||||
if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
|
||||
Debug(3, "codec: receiving audio frame failed");
|
||||
return;
|
||||
}
|
||||
if (ret >= 0) {
|
||||
// update audio clock
|
||||
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) {
|
||||
CodecAudioUpdateFormat(audio_decoder);
|
||||
}
|
||||
if (!audio_decoder->HwSampleRate || !audio_decoder->HwChannels) {
|
||||
return; // unsupported sample format
|
||||
}
|
||||
if (CodecAudioPassthroughHelper(audio_decoder, avpkt)) {
|
||||
return;
|
||||
}
|
||||
if (audio_decoder->Resample) {
|
||||
uint8_t outbuf[8192 * 2 * 8];
|
||||
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);
|
||||
if (ret > 0) {
|
||||
if (!(audio_decoder->Passthrough & CodecPCM)) {
|
||||
CodecReorderAudioFrame((int16_t *) outbuf, ret * 2 * audio_decoder->HwChannels,
|
||||
audio_decoder->HwChannels);
|
||||
}
|
||||
AudioEnqueue(outbuf, ret * 2 * audio_decoder->HwChannels);
|
||||
av_frame_unref(frame);
|
||||
*pkt = *avpkt; // use copy
|
||||
ret = avcodec_send_packet(audio_ctx, pkt);
|
||||
if (ret < 0) {
|
||||
Debug(3, "codec: sending audio packet failed");
|
||||
return;
|
||||
}
|
||||
ret = avcodec_receive_frame(audio_ctx, frame);
|
||||
if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
|
||||
Debug(3, "codec: receiving audio frame failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ret >= 0) {
|
||||
// update audio clock
|
||||
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) {
|
||||
CodecAudioUpdateFormat(audio_decoder);
|
||||
}
|
||||
if (!audio_decoder->HwSampleRate || !audio_decoder->HwChannels) {
|
||||
return; // unsupported sample format
|
||||
}
|
||||
if (CodecAudioPassthroughHelper(audio_decoder, avpkt)) {
|
||||
return;
|
||||
}
|
||||
if (audio_decoder->Resample) {
|
||||
uint8_t outbuf[8192 * 2 * 8];
|
||||
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);
|
||||
if (ret > 0) {
|
||||
if (!(audio_decoder->Passthrough & CodecPCM)) {
|
||||
CodecReorderAudioFrame((int16_t *) outbuf, ret * 2 * audio_decoder->HwChannels,
|
||||
audio_decoder->HwChannels);
|
||||
}
|
||||
AudioEnqueue(outbuf, ret * 2 * audio_decoder->HwChannels);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,10 @@ void ConvertColor(const GLint &colARGB, glm::vec4 &col) {
|
||||
col.b = ((colARGB & 0x000000FF) ) / 255.0;
|
||||
}
|
||||
|
||||
extern "C" void OSD_get_context();
|
||||
extern "C" void OSD_get_shared_context();
|
||||
extern "C" void OSD_release_context();
|
||||
|
||||
/****************************************************************************************
|
||||
* cShader
|
||||
****************************************************************************************/
|
||||
@ -119,7 +123,7 @@ void main() \
|
||||
#else
|
||||
|
||||
const char *rectVertexShader =
|
||||
"\n\
|
||||
"\n \
|
||||
\
|
||||
layout (location = 0) in vec2 position; \
|
||||
out vec4 rectCol; \
|
||||
@ -134,8 +138,9 @@ void main() \
|
||||
";
|
||||
|
||||
const char *rectFragmentShader =
|
||||
"\n\
|
||||
"\n \
|
||||
\
|
||||
precision mediump float; \
|
||||
in vec4 rectCol; \
|
||||
out vec4 color; \
|
||||
\
|
||||
@ -146,7 +151,7 @@ void main() \
|
||||
";
|
||||
|
||||
const char *textureVertexShader =
|
||||
"\n\
|
||||
"\n \
|
||||
\
|
||||
layout (location = 0) in vec2 position; \
|
||||
layout (location = 1) in vec2 texCoords; \
|
||||
@ -166,7 +171,8 @@ void main() \
|
||||
";
|
||||
|
||||
const char *textureFragmentShader =
|
||||
"\n\
|
||||
"\n \
|
||||
precision mediump float; \
|
||||
in vec2 TexCoords; \
|
||||
in vec4 alphaValue; \
|
||||
out vec4 color; \
|
||||
@ -180,7 +186,7 @@ void main() \
|
||||
";
|
||||
|
||||
const char *textVertexShader =
|
||||
"\n\
|
||||
"\n \
|
||||
\
|
||||
layout (location = 0) in vec2 position; \
|
||||
layout (location = 1) in vec2 texCoords; \
|
||||
@ -200,7 +206,8 @@ void main() \
|
||||
";
|
||||
|
||||
const char *textFragmentShader =
|
||||
"\n\
|
||||
"\n \
|
||||
precision mediump float; \
|
||||
in vec2 TexCoords; \
|
||||
in vec4 textColor; \
|
||||
\
|
||||
@ -287,12 +294,14 @@ bool cShader::Compile(const char *vertexCode, const char *fragmentCode) {
|
||||
sVertex = glCreateShader(GL_VERTEX_SHADER);
|
||||
glShaderSource(sVertex, 1, &vertexCode, NULL);
|
||||
glCompileShader(sVertex);
|
||||
// esyslog("[softhddev]:SHADER:VERTEX %s\n",vertexCode);
|
||||
if (!CheckCompileErrors(sVertex))
|
||||
return false;
|
||||
// Fragment Shader
|
||||
sFragment = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
glShaderSource(sFragment, 1, &fragmentCode, NULL);
|
||||
glCompileShader(sFragment);
|
||||
// esyslog("[softhddev]:SHADER:FRAGMENT %s\n",fragmentCode);
|
||||
if (!CheckCompileErrors(sFragment))
|
||||
return false;
|
||||
// link Program
|
||||
@ -315,14 +324,14 @@ bool cShader::CheckCompileErrors(GLuint object, bool program) {
|
||||
glGetShaderiv(object, GL_COMPILE_STATUS, &success);
|
||||
if (!success) {
|
||||
glGetShaderInfoLog(object, 1024, NULL, infoLog);
|
||||
esyslog("[softhddev]:SHADER: Compile-time error: Type: %d - %s", type, infoLog);
|
||||
esyslog("[softhddev]:SHADER: Compile-time error: Type: %d - \n%s\n", type, infoLog);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
glGetProgramiv(object, GL_LINK_STATUS, &success);
|
||||
if (!success) {
|
||||
glGetProgramInfoLog(object, 1024, NULL, infoLog);
|
||||
esyslog("[softhddev]:SHADER: Link-time error: Type: %d", type);
|
||||
esyslog("[softhddev]:SHADER: Link-time error: Type: %d - \n%s\n", type, infoLog);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -365,6 +374,10 @@ void cOglGlyph::BindTexture(void) {
|
||||
|
||||
void cOglGlyph::LoadTexture(FT_BitmapGlyph ftGlyph) {
|
||||
// Disable byte-alignment restriction
|
||||
#ifdef VAAPI
|
||||
OSD_release_context();
|
||||
OSD_get_shared_context();
|
||||
#endif
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
@ -386,6 +399,11 @@ void cOglGlyph::LoadTexture(FT_BitmapGlyph ftGlyph) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
#ifdef VAAPI
|
||||
OSD_release_context();
|
||||
OSD_get_context();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -550,6 +568,10 @@ cOglFb::~cOglFb(void) {
|
||||
|
||||
bool cOglFb::Init(void) {
|
||||
initiated = true;
|
||||
#ifdef VAAPI
|
||||
OSD_release_context();
|
||||
OSD_get_shared_context();
|
||||
#endif
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
@ -562,10 +584,19 @@ bool cOglFb::Init(void) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fb);
|
||||
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
|
||||
|
||||
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||
esyslog("[softhddev]ERROR: Framebuffer is not complete!\n");
|
||||
esyslog("[softhddev]ERROR: %d Framebuffer is not complete!\n",__LINE__);
|
||||
#ifdef VAAPI
|
||||
OSD_release_context();
|
||||
OSD_get_context();
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
#ifdef VAAPI
|
||||
OSD_release_context();
|
||||
OSD_get_context();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -619,6 +650,7 @@ cOglOutputFb::~cOglOutputFb(void) {
|
||||
|
||||
bool cOglOutputFb::Init(void) {
|
||||
initiated = true;
|
||||
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
@ -634,19 +666,16 @@ bool cOglOutputFb::Init(void) {
|
||||
esyslog("[softhddev]ERROR::cOglOutputFb: Framebuffer is not complete!");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void cOglOutputFb::BindWrite(void) {
|
||||
// glVDPAUMapSurfacesNV(1, &surface);
|
||||
if (!initiated)
|
||||
Init();
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fb);
|
||||
}
|
||||
|
||||
void cOglOutputFb::Unbind(void) {
|
||||
// glVDPAUUnmapSurfacesNV(1, &surface);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
@ -882,6 +911,8 @@ extern unsigned char *posd;
|
||||
//}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
bool cOglCmdCopyBufferToOutputFb::Execute(void) {
|
||||
int i;
|
||||
pthread_mutex_lock(&OSDMutex);
|
||||
@ -896,6 +927,7 @@ bool cOglCmdCopyBufferToOutputFb::Execute(void) {
|
||||
glReadPixels(0, 0 ,fb->Width(), fb->Height(),GL_BGRA,GL_UNSIGNED_BYTE,posd);
|
||||
#else
|
||||
fb->Blit(x, y + fb->Height(), x + fb->Width(), y);
|
||||
glFlush();
|
||||
#endif
|
||||
ActivateOsd(oFb->texture,x, y, fb->Width() ,fb->Height());
|
||||
|
||||
@ -1323,6 +1355,10 @@ cOglCmdDrawImage::~cOglCmdDrawImage(void) {
|
||||
|
||||
bool cOglCmdDrawImage::Execute(void) {
|
||||
GLuint texture;
|
||||
#ifdef VAAPI
|
||||
OSD_release_context();
|
||||
OSD_get_shared_context();
|
||||
#endif
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexImage2D(
|
||||
@ -1341,7 +1377,11 @@ bool cOglCmdDrawImage::Execute(void) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
#ifdef VAAPI
|
||||
OSD_release_context();
|
||||
OSD_get_context();
|
||||
#endif
|
||||
|
||||
GLfloat x1 = x; //left
|
||||
GLfloat y1 = y; //top
|
||||
GLfloat x2 = x + width; //right
|
||||
@ -1430,6 +1470,10 @@ cOglCmdStoreImage::~cOglCmdStoreImage(void) {
|
||||
}
|
||||
|
||||
bool cOglCmdStoreImage::Execute(void) {
|
||||
#ifdef VAAPI
|
||||
OSD_release_context();
|
||||
OSD_get_shared_context();
|
||||
#endif
|
||||
glGenTextures(1, &imageRef->texture);
|
||||
glBindTexture(GL_TEXTURE_2D, imageRef->texture);
|
||||
glTexImage2D(
|
||||
@ -1448,6 +1492,10 @@ bool cOglCmdStoreImage::Execute(void) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
#ifdef VAAPI
|
||||
OSD_release_context();
|
||||
OSD_get_context();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2041,11 +2089,17 @@ cOglOsd::cOglOsd(int Left, int Top, uint Level, std::shared_ptr<cOglThread> oglT
|
||||
posd = MALLOC(unsigned char, osdWidth * osdHeight * 4);
|
||||
#endif
|
||||
//create output framebuffer
|
||||
#ifdef VAAPI
|
||||
OSD_release_context();
|
||||
OSD_get_shared_context();
|
||||
#endif
|
||||
if (!oFb) {
|
||||
oFb = new cOglOutputFb(osdWidth, osdHeight);
|
||||
oglThread->DoCmd(new cOglCmdInitOutputFb(oFb));
|
||||
}
|
||||
|
||||
#ifdef VAAPI
|
||||
OSD_release_context();
|
||||
#endif
|
||||
}
|
||||
|
||||
cOglOsd::~cOglOsd() {
|
||||
|
196
shaders.h
196
shaders.h
@ -1,54 +1,54 @@
|
||||
|
||||
// shader
|
||||
#ifdef CUVID
|
||||
char vertex_osd[] = {"\
|
||||
#version 330\n\
|
||||
in vec2 vertex_position;\n\
|
||||
in vec2 vertex_texcoord0;\n\
|
||||
out vec2 texcoord0;\n\
|
||||
void main() {\n\
|
||||
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
|
||||
texcoord0 = vertex_texcoord0;\n\
|
||||
}\n"};
|
||||
|
||||
char fragment_osd[] = {"\
|
||||
#version 330\n\
|
||||
#define texture1D texture\n\
|
||||
precision mediump float; \
|
||||
layout(location = 0) out vec4 out_color;\n\
|
||||
in vec2 texcoord0;\n\
|
||||
uniform sampler2D texture0;\n\
|
||||
void main() {\n\
|
||||
vec4 color; \n\
|
||||
color = vec4(texture(texture0, texcoord0));\n\
|
||||
out_color = color;\n\
|
||||
}\n"};
|
||||
|
||||
char vertex[] = {"\
|
||||
#version 330\n\
|
||||
#version 310 es\n\
|
||||
in vec2 vertex_position;\n\
|
||||
in vec2 vertex_texcoord0;\n\
|
||||
out vec2 texcoord0;\n\
|
||||
in vec2 vertex_texcoord1;\n\
|
||||
out vec2 texcoord1;\n\
|
||||
in vec2 vertex_texcoord2;\n\
|
||||
out vec2 texcoord2;\n\
|
||||
in vec2 vertex_texcoord3;\n\
|
||||
out vec2 texcoord3;\n\
|
||||
in vec2 vertex_texcoord4;\n\
|
||||
out vec2 texcoord4;\n\
|
||||
in vec2 vertex_texcoord5;\n\
|
||||
out vec2 texcoord5;\n\
|
||||
void main() {\n\
|
||||
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
|
||||
texcoord0 = vertex_texcoord0;\n\
|
||||
texcoord1 = vertex_texcoord1;\n\
|
||||
texcoord2 = vertex_texcoord2;\n\
|
||||
texcoord3 = vertex_texcoord3;\n\
|
||||
texcoord4 = vertex_texcoord4;\n\
|
||||
texcoord5 = vertex_texcoord5;\n\
|
||||
}\n"};
|
||||
|
||||
|
||||
char fragment[] = {"\
|
||||
#version 330\n\
|
||||
#version 310 es\n\
|
||||
#define texture1D texture\n\
|
||||
#define texture3D texture\n\
|
||||
precision mediump float; \
|
||||
layout(location = 0) out vec4 out_color;\n\
|
||||
in vec2 texcoord0;\n\
|
||||
in vec2 texcoord1;\n\
|
||||
in vec2 texcoord2;\n\
|
||||
in vec2 texcoord3;\n\
|
||||
in vec2 texcoord4;\n\
|
||||
in vec2 texcoord5;\n\
|
||||
uniform mat3 colormatrix;\n\
|
||||
uniform vec3 colormatrix_c;\n\
|
||||
uniform sampler2D texture0;\n\
|
||||
//uniform vec2 texture_size0;\n\
|
||||
//uniform mat2 texture_rot0;\n\
|
||||
//uniform vec2 pixel_size0;\n\
|
||||
uniform sampler2D texture1;\n\
|
||||
//uniform vec2 texture_size1;\n\
|
||||
//uniform mat2 texture_rot1;\n\
|
||||
//uniform vec2 pixel_size1;\n\
|
||||
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
|
||||
void main() {\n\
|
||||
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
|
||||
color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;\n\
|
||||
@ -61,27 +61,18 @@ out_color = color;\n\
|
||||
}\n"};
|
||||
|
||||
char fragment_bt2100[] = {"\
|
||||
#version 330\n\
|
||||
#version 310 es\n \
|
||||
#define texture1D texture\n\
|
||||
#define texture3D texture\n\
|
||||
precision mediump float; \
|
||||
layout(location = 0) out vec4 out_color;\n\
|
||||
in vec2 texcoord0;\n\
|
||||
in vec2 texcoord1;\n\
|
||||
in vec2 texcoord2;\n\
|
||||
in vec2 texcoord3;\n\
|
||||
in vec2 texcoord4;\n\
|
||||
in vec2 texcoord5;\n\
|
||||
uniform mat3 colormatrix;\n\
|
||||
uniform vec3 colormatrix_c;\n\
|
||||
uniform mat3 cms_matrix;\n\
|
||||
uniform sampler2D texture0;\n\
|
||||
//uniform vec2 texture_size0;\n\
|
||||
//uniform mat2 texture_rot0;\n\
|
||||
//uniform vec2 pixel_size0;\n\
|
||||
uniform sampler2D texture1;\n\
|
||||
//uniform vec2 texture_size1;\n\
|
||||
//uniform mat2 texture_rot1;\n\
|
||||
//uniform vec2 pixel_size1;\n\
|
||||
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
|
||||
void main() {\n\
|
||||
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
|
||||
@ -99,6 +90,98 @@ color.rgb = pow(color.rgb, vec3(1.0/2.4));\n\
|
||||
out_color = color;\n\
|
||||
}\n"};
|
||||
|
||||
|
||||
#else
|
||||
char vertex_osd[] = {"\
|
||||
\n\
|
||||
in vec2 vertex_position;\n\
|
||||
in vec2 vertex_texcoord0;\n\
|
||||
out vec2 texcoord0;\n\
|
||||
void main() {\n\
|
||||
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
|
||||
texcoord0 = vertex_texcoord0;\n\
|
||||
}\n"};
|
||||
|
||||
char fragment_osd[] = {"\
|
||||
\n\
|
||||
#define texture1D texture\n\
|
||||
precision mediump float; \
|
||||
layout(location = 0) out vec4 out_color;\n\
|
||||
in vec2 texcoord0;\n\
|
||||
uniform sampler2D texture0;\n\
|
||||
void main() {\n\
|
||||
vec4 color; \n\
|
||||
color = vec4(texture(texture0, texcoord0));\n\
|
||||
out_color = color;\n\
|
||||
}\n"};
|
||||
|
||||
char vertex[] = {"\
|
||||
\n\
|
||||
in vec2 vertex_position;\n\
|
||||
in vec2 vertex_texcoord0;\n\
|
||||
out vec2 texcoord0;\n\
|
||||
in vec2 vertex_texcoord1;\n\
|
||||
out vec2 texcoord1;\n\
|
||||
void main() {\n\
|
||||
gl_Position = vec4(vertex_position, 1.0, 1.0);\n\
|
||||
texcoord0 = vertex_texcoord0;\n\
|
||||
texcoord1 = vertex_texcoord1;\n\
|
||||
}\n"};
|
||||
|
||||
char fragment[] = {"\
|
||||
\n\
|
||||
#define texture1D texture\n\
|
||||
#define texture3D texture\n\
|
||||
precision mediump float; \
|
||||
layout(location = 0) out vec4 out_color;\n\
|
||||
in vec2 texcoord0;\n\
|
||||
in vec2 texcoord1;\n\
|
||||
uniform mat3 colormatrix;\n\
|
||||
uniform vec3 colormatrix_c;\n\
|
||||
uniform sampler2D texture0;\n\
|
||||
uniform sampler2D texture1;\n\
|
||||
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
|
||||
void main() {\n\
|
||||
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
|
||||
color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r;\n\
|
||||
color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg;\n\
|
||||
// color conversion\n\
|
||||
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
|
||||
color.a = 1.0;\n\
|
||||
// color mapping\n\
|
||||
out_color = color;\n\
|
||||
}\n"};
|
||||
|
||||
char fragment_bt2100[] = {"\
|
||||
\n \
|
||||
#define texture1D texture\n\
|
||||
#define texture3D texture\n\
|
||||
precision mediump float; \
|
||||
layout(location = 0) out vec4 out_color;\n\
|
||||
in vec2 texcoord0;\n\
|
||||
in vec2 texcoord1;\n\
|
||||
uniform mat3 colormatrix;\n\
|
||||
uniform vec3 colormatrix_c;\n\
|
||||
uniform mat3 cms_matrix;\n\
|
||||
uniform sampler2D texture0;\n\
|
||||
uniform sampler2D texture1;\n\
|
||||
//#define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x))\n\
|
||||
void main() {\n\
|
||||
vec4 color; // = vec4(0.0, 0.0, 0.0, 1.0);\n\
|
||||
color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r;\n\
|
||||
color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;\n\
|
||||
// color conversion\n\
|
||||
color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c;\n\
|
||||
color.a = 1.0;\n\
|
||||
// color mapping\n\
|
||||
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
|
||||
color.rgb = pow(color.rgb, vec3(2.4));\n\
|
||||
color.rgb = cms_matrix * color.rgb;\n\
|
||||
color.rgb = clamp(color.rgb, 0.0, 1.0);\n\
|
||||
color.rgb = pow(color.rgb, vec3(1.0/2.4));\n\
|
||||
out_color = color;\n\
|
||||
}\n"};
|
||||
#endif
|
||||
/* 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 },
|
||||
@ -113,12 +196,12 @@ out_color = color;\n\
|
||||
* The matrix might also be used for other conversions and colorspaces.
|
||||
*/
|
||||
struct mp_cmat {
|
||||
float m[3][3]; // colormatrix
|
||||
float c[3]; //colormatrix_c
|
||||
GLfloat m[3][3]; // colormatrix
|
||||
GLfloat c[3]; //colormatrix_c
|
||||
};
|
||||
|
||||
struct mp_mat {
|
||||
float m[3][3];
|
||||
GLfloat m[3][3];
|
||||
};
|
||||
|
||||
// YUV input limited range (16-235 for luma, 16-240 for chroma)
|
||||
@ -185,10 +268,6 @@ 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])},
|
||||
{"texcoord2", 2, GL_FLOAT, false, offsetof(struct vertex, texcoord[2])},
|
||||
{"texcoord3", 2, GL_FLOAT, false, offsetof(struct vertex, texcoord[3])},
|
||||
{"texcoord4", 2, GL_FLOAT, false, offsetof(struct vertex, texcoord[4])},
|
||||
{"texcoord5", 2, GL_FLOAT, false, offsetof(struct vertex, texcoord[5])},
|
||||
{0}
|
||||
};
|
||||
|
||||
@ -198,7 +277,8 @@ static void compile_attach_shader(GLuint program,
|
||||
{
|
||||
GLuint shader;
|
||||
GLint status, log_length;
|
||||
|
||||
char log[4000];
|
||||
GLsizei len;
|
||||
shader = glCreateShader(type);
|
||||
glShaderSource(shader, 1, &source, NULL);
|
||||
glCompileShader(shader);
|
||||
@ -206,9 +286,10 @@ static void compile_attach_shader(GLuint program,
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
|
||||
log_length = 0;
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &log_length);
|
||||
Debug(3,"compile Status %d loglen %d\n",status,log_length);
|
||||
glGetShaderInfoLog(shader,4000,&len,log);
|
||||
GlxCheck();
|
||||
Debug(3,"compile Status %d loglen %d >%s<\n",status,log_length,log);
|
||||
|
||||
GlxCheck();
|
||||
glAttachShader(program, shader);
|
||||
glDeleteShader(shader);
|
||||
}
|
||||
@ -223,10 +304,24 @@ static void link_shader(GLuint program)
|
||||
log_length = 0;
|
||||
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &log_length);
|
||||
Debug(3,"Link Status %d loglen %d\n",status,log_length);
|
||||
|
||||
|
||||
}
|
||||
|
||||
static GLuint sc_generate_osd(GLuint gl_prog) {
|
||||
|
||||
Debug(3,"vor create osd\n");
|
||||
gl_prog = glCreateProgram();
|
||||
Debug(3,"vor compile vertex osd\n");
|
||||
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, vertex_osd);
|
||||
Debug(3,"vor compile fragment osd \n");
|
||||
compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, fragment_osd);
|
||||
glBindAttribLocation(gl_prog,0,"vertex_position");
|
||||
glBindAttribLocation(gl_prog,1,"vertex_texcoord0");
|
||||
|
||||
link_shader(gl_prog);
|
||||
return gl_prog;
|
||||
}
|
||||
|
||||
|
||||
static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace) {
|
||||
|
||||
char vname[80];
|
||||
@ -284,7 +379,8 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace) {
|
||||
if (gl_colormatrix != -1)
|
||||
glProgramUniformMatrix3fv(gl_prog,gl_colormatrix,1,0,m);
|
||||
GlxCheck();
|
||||
//glProgramUniform3fv(gl_prog,gl_colormatrix,3,&yuv_bt709.m[0][0]);
|
||||
Debug(3,"nach set colormatrix\n");
|
||||
|
||||
gl_colormatrix_c = glGetUniformLocation(gl_prog,"colormatrix_c");
|
||||
Debug(3,"get uniform colormatrix_c %d %f\n",gl_colormatrix_c,*c);
|
||||
if (gl_colormatrix_c != -1)
|
||||
|
135
softhddev.c
135
softhddev.c
@ -107,6 +107,7 @@ static VideoStream *AudioSyncStream; ///< video stream for audio/video sync
|
||||
#define AUDIO_MIN_BUFFER_FREE (3072 * 8 * 8)
|
||||
#define AUDIO_BUFFER_SIZE (512 * 1024) ///< audio PES buffer default size
|
||||
static AVPacket AudioAvPkt[1]; ///< audio a/v packet
|
||||
int AudioDelay = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Audio codec parser
|
||||
@ -579,7 +580,7 @@ static void PesInit(PesDemux * pesdx)
|
||||
pesdx->Size = PES_MAX_PAYLOAD;
|
||||
pesdx->Buffer = av_malloc(PES_MAX_PAYLOAD + AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
if (!pesdx->Buffer) {
|
||||
Fatal(_("pesdemux: out of memory\n"));
|
||||
Fatal(_("pesdemux: out of memory\n"));
|
||||
}
|
||||
PesReset(pesdx);
|
||||
}
|
||||
@ -672,57 +673,56 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size,
|
||||
// FIXME: simple+faster detection, if codec already known
|
||||
r = 0;
|
||||
if (!r && FastMpegCheck(q)) {
|
||||
r = MpegCheck(q, n);
|
||||
codec_id = AV_CODEC_ID_MP2;
|
||||
r = MpegCheck(q, n);
|
||||
codec_id = AV_CODEC_ID_MP2;
|
||||
}
|
||||
if (!r && FastAc3Check(q)) {
|
||||
r = Ac3Check(q, n);
|
||||
codec_id = AV_CODEC_ID_AC3;
|
||||
if (r > 0 && q[5] > (10 << 3)) {
|
||||
codec_id = AV_CODEC_ID_EAC3;
|
||||
}
|
||||
r = Ac3Check(q, n);
|
||||
codec_id = AV_CODEC_ID_AC3;
|
||||
if (r > 0 && q[5] > (10 << 3)) {
|
||||
codec_id = AV_CODEC_ID_EAC3;
|
||||
}
|
||||
}
|
||||
if (!r && FastLatmCheck(q)) {
|
||||
r = LatmCheck(q, n);
|
||||
codec_id = AV_CODEC_ID_AAC_LATM;
|
||||
r = LatmCheck(q, n);
|
||||
codec_id = AV_CODEC_ID_AAC_LATM;
|
||||
}
|
||||
if (!r && FastAdtsCheck(q)) {
|
||||
r = AdtsCheck(q, n);
|
||||
codec_id = AV_CODEC_ID_AAC;
|
||||
r = AdtsCheck(q, n);
|
||||
codec_id = AV_CODEC_ID_AAC;
|
||||
}
|
||||
if (r < 0) { // need more bytes
|
||||
break;
|
||||
break;
|
||||
}
|
||||
if (r > 0) {
|
||||
AVPacket avpkt[1];
|
||||
AVPacket avpkt[1];
|
||||
|
||||
// new codec id, close and open new
|
||||
if (AudioCodecID != codec_id) {
|
||||
Debug(3, "pesdemux: new codec %#06x -> %#06x\n",
|
||||
AudioCodecID, codec_id);
|
||||
CodecAudioClose(MyAudioDecoder);
|
||||
CodecAudioOpen(MyAudioDecoder, codec_id);
|
||||
AudioCodecID = codec_id;
|
||||
}
|
||||
av_init_packet(avpkt);
|
||||
avpkt->data = (void *)q;
|
||||
avpkt->size = r;
|
||||
avpkt->pts = pesdx->PTS;
|
||||
avpkt->dts = pesdx->DTS;
|
||||
// FIXME: not aligned for ffmpeg
|
||||
CodecAudioDecode(MyAudioDecoder, avpkt);
|
||||
pesdx->PTS = AV_NOPTS_VALUE;
|
||||
pesdx->DTS = AV_NOPTS_VALUE;
|
||||
pesdx->Skip += r;
|
||||
// FIXME: switch to decoder state
|
||||
//pesdx->State = PES_MPEG_DECODE;
|
||||
break;
|
||||
// new codec id, close and open new
|
||||
if (AudioCodecID != codec_id) {
|
||||
Debug(3, "pesdemux: new codec %#06x -> %#06x\n",
|
||||
AudioCodecID, codec_id);
|
||||
CodecAudioClose(MyAudioDecoder);
|
||||
CodecAudioOpen(MyAudioDecoder, codec_id);
|
||||
AudioCodecID = codec_id;
|
||||
}
|
||||
av_init_packet(avpkt);
|
||||
avpkt->data = (void *)q;
|
||||
avpkt->size = r;
|
||||
avpkt->pts = pesdx->PTS;
|
||||
avpkt->dts = pesdx->DTS;
|
||||
// FIXME: not aligned for ffmpeg
|
||||
CodecAudioDecode(MyAudioDecoder, avpkt);
|
||||
pesdx->PTS = AV_NOPTS_VALUE;
|
||||
pesdx->DTS = AV_NOPTS_VALUE;
|
||||
pesdx->Skip += r;
|
||||
// FIXME: switch to decoder state
|
||||
//pesdx->State = PES_MPEG_DECODE;
|
||||
break;
|
||||
}
|
||||
if (AudioCodecID != AV_CODEC_ID_NONE) {
|
||||
// shouldn't happen after we have a vaild codec
|
||||
// detected
|
||||
Debug(4, "pesdemux: skip @%d %02x\n", pesdx->Skip,
|
||||
q[0]);
|
||||
// shouldn't happen after we have a vaild codec
|
||||
// detected
|
||||
Debug(4, "pesdemux: skip @%d %02x\n", pesdx->Skip,q[0]);
|
||||
}
|
||||
// try next byte
|
||||
++pesdx->Skip;
|
||||
@ -1024,9 +1024,15 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
|
||||
if (SkipAudio || !MyAudioDecoder) { // skip audio
|
||||
return size;
|
||||
}
|
||||
if (StreamFreezed) { // stream freezed
|
||||
if (StreamFreezed ) { // stream freezed
|
||||
return 0;
|
||||
}
|
||||
if (AudioDelay) {
|
||||
Debug(3,"AudioDelay %dms\n",AudioDelay);
|
||||
usleep(AudioDelay/90);
|
||||
AudioDelay = 0;
|
||||
return 0;
|
||||
}
|
||||
if (NewAudioStream) {
|
||||
// this clears the audio ringbuffer indirect, open and setup does it
|
||||
CodecAudioClose(MyAudioDecoder);
|
||||
@ -1205,9 +1211,9 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
|
||||
|
||||
// new codec id, close and open new
|
||||
if (AudioCodecID != codec_id) {
|
||||
CodecAudioClose(MyAudioDecoder);
|
||||
CodecAudioOpen(MyAudioDecoder, codec_id);
|
||||
AudioCodecID = codec_id;
|
||||
CodecAudioClose(MyAudioDecoder);
|
||||
CodecAudioOpen(MyAudioDecoder, codec_id);
|
||||
AudioCodecID = codec_id;
|
||||
}
|
||||
av_init_packet(avpkt);
|
||||
avpkt->data = (void *)p;
|
||||
@ -1257,6 +1263,7 @@ int PlayTsAudio(const uint8_t * data, int size)
|
||||
if (StreamFreezed) { // stream freezed
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (NewAudioStream) {
|
||||
// this clears the audio ringbuffer indirect, open and setup does it
|
||||
CodecAudioClose(MyAudioDecoder);
|
||||
@ -1279,7 +1286,13 @@ int PlayTsAudio(const uint8_t * data, int size)
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (AudioDelay) {
|
||||
Debug(3,"AudioDelay %dms\n",AudioDelay);
|
||||
usleep(AudioDelay*1000);
|
||||
AudioDelay = 0;
|
||||
// TsDemuxer(tsdx, data, size); // insert dummy audio
|
||||
|
||||
}
|
||||
return TsDemuxer(tsdx, data, size);
|
||||
}
|
||||
|
||||
@ -2498,27 +2511,27 @@ int SetPlayMode(int play_mode)
|
||||
case 0: // audio/video from decoder
|
||||
// tell video parser we get new stream
|
||||
if (MyVideoStream->Decoder && !MyVideoStream->SkipStream) {
|
||||
// clear buffers on close configured always or replay only
|
||||
if (ConfigVideoClearOnSwitch || MyVideoStream->ClearClose) {
|
||||
Clear(); // flush all buffers
|
||||
MyVideoStream->ClearClose = 0;
|
||||
}
|
||||
if (MyVideoStream->CodecID != AV_CODEC_ID_NONE) {
|
||||
MyVideoStream->NewStream = 1;
|
||||
MyVideoStream->InvalidPesCounter = 0;
|
||||
// tell hw decoder we are closing stream
|
||||
VideoSetClosing(MyVideoStream->HwDecoder);
|
||||
VideoResetStart(MyVideoStream->HwDecoder);
|
||||
// clear buffers on close configured always or replay only
|
||||
if (ConfigVideoClearOnSwitch || MyVideoStream->ClearClose) {
|
||||
Clear(); // flush all buffers
|
||||
MyVideoStream->ClearClose = 0;
|
||||
}
|
||||
if (MyVideoStream->CodecID != AV_CODEC_ID_NONE) {
|
||||
MyVideoStream->NewStream = 1;
|
||||
MyVideoStream->InvalidPesCounter = 0;
|
||||
// tell hw decoder we are closing stream
|
||||
VideoSetClosing(MyVideoStream->HwDecoder);
|
||||
VideoResetStart(MyVideoStream->HwDecoder);
|
||||
#ifdef DEBUG
|
||||
VideoSwitch = GetMsTicks();
|
||||
Debug(3, "video: new stream start\n");
|
||||
VideoSwitch = GetMsTicks();
|
||||
Debug(3, "video: new stream start\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
if (MyAudioDecoder) { // tell audio parser we have new stream
|
||||
if (AudioCodecID != AV_CODEC_ID_NONE) {
|
||||
NewAudioStream = 1;
|
||||
}
|
||||
if (AudioCodecID != AV_CODEC_ID_NONE) {
|
||||
NewAudioStream = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1: // audio/video from player
|
||||
|
Loading…
Reference in New Issue
Block a user