mirror of
https://projects.vdr-developer.org/git/vdr-plugin-softhddevice.git
synced 2023-10-10 19:16:51 +02:00
Use ffmpeg new names AVCodecID, AV_CODEC_... .
This commit is contained in:
parent
7615305960
commit
c646007db1
@ -1,6 +1,7 @@
|
|||||||
User johns
|
User johns
|
||||||
Date:
|
Date:
|
||||||
|
|
||||||
|
Use ffmpeg new names AVCodecID, AV_CODEC_... .
|
||||||
Fix bug: video lagging behind after recording stop.
|
Fix bug: video lagging behind after recording stop.
|
||||||
Reduce PES error messages.
|
Reduce PES error messages.
|
||||||
Fix bug #1392: Wrong value for mixing LFE.
|
Fix bug #1392: Wrong value for mixing LFE.
|
||||||
|
30
codec.c
30
codec.c
@ -56,6 +56,13 @@
|
|||||||
|
|
||||||
#include <alsa/iatomic.h>
|
#include <alsa/iatomic.h>
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
|
// support old ffmpeg versions <1.0
|
||||||
|
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,18,102)
|
||||||
|
#define AVCodecID CodecID
|
||||||
|
#define AV_CODEC_ID_AC3 CODEC_ID_AC3
|
||||||
|
#define AV_CODEC_ID_EAC3 CODEC_ID_EAC3
|
||||||
|
#define AV_CODEC_ID_H264 CODEC_ID_H264
|
||||||
|
#endif
|
||||||
#include <libavcodec/vaapi.h>
|
#include <libavcodec/vaapi.h>
|
||||||
#ifdef USE_VDPAU
|
#ifdef USE_VDPAU
|
||||||
#include <libavcodec/vdpau.h>
|
#include <libavcodec/vdpau.h>
|
||||||
@ -434,7 +441,7 @@ void CodecVideoOpen(VideoDecoder * decoder, const char *name, int codec_id)
|
|||||||
decoder->VideoCtx->opaque = decoder; // our structure
|
decoder->VideoCtx->opaque = decoder; // our structure
|
||||||
|
|
||||||
Debug(3, "codec: video '%s'\n", decoder->VideoCtx->codec_name);
|
Debug(3, "codec: video '%s'\n", decoder->VideoCtx->codec_name);
|
||||||
if (codec_id == CODEC_ID_H264) {
|
if (codec_id == AV_CODEC_ID_H264) {
|
||||||
// 2.53 Ghz CPU is too slow for this codec at 1080i
|
// 2.53 Ghz CPU is too slow for this codec at 1080i
|
||||||
//decoder->VideoCtx->skip_loop_filter = AVDISCARD_ALL;
|
//decoder->VideoCtx->skip_loop_filter = AVDISCARD_ALL;
|
||||||
//decoder->VideoCtx->skip_loop_filter = AVDISCARD_BIDIR;
|
//decoder->VideoCtx->skip_loop_filter = AVDISCARD_BIDIR;
|
||||||
@ -990,10 +997,10 @@ static int CodecAudioUpdateHelper(AudioDecoder * audio_decoder,
|
|||||||
audio_decoder->Passthrough = CodecPassthrough;
|
audio_decoder->Passthrough = CodecPassthrough;
|
||||||
|
|
||||||
// SPDIF/HDMI pass-through
|
// SPDIF/HDMI pass-through
|
||||||
if ((CodecPassthrough & CodecAC3 && audio_ctx->codec_id == CODEC_ID_AC3)
|
if ((CodecPassthrough & CodecAC3 && audio_ctx->codec_id == AV_CODEC_ID_AC3)
|
||||||
|| (CodecPassthrough & CodecEAC3
|
|| (CodecPassthrough & CodecEAC3
|
||||||
&& audio_ctx->codec_id == CODEC_ID_EAC3)) {
|
&& audio_ctx->codec_id == AV_CODEC_ID_EAC3)) {
|
||||||
if (audio_ctx->codec_id == CODEC_ID_EAC3) {
|
if (audio_ctx->codec_id == AV_CODEC_ID_EAC3) {
|
||||||
// EAC3 over HDMI some receivers need HBR
|
// EAC3 over HDMI some receivers need HBR
|
||||||
audio_decoder->HwSampleRate *= 4;
|
audio_decoder->HwSampleRate *= 4;
|
||||||
}
|
}
|
||||||
@ -1009,7 +1016,7 @@ static int CodecAudioUpdateHelper(AudioDecoder * audio_decoder,
|
|||||||
|
|
||||||
// try EAC3 none HBR
|
// try EAC3 none HBR
|
||||||
audio_decoder->HwSampleRate /= 4;
|
audio_decoder->HwSampleRate /= 4;
|
||||||
if (audio_ctx->codec_id != CODEC_ID_EAC3
|
if (audio_ctx->codec_id != AV_CODEC_ID_EAC3
|
||||||
|| (err =
|
|| (err =
|
||||||
AudioSetup(&audio_decoder->HwSampleRate,
|
AudioSetup(&audio_decoder->HwSampleRate,
|
||||||
&audio_decoder->HwChannels, *passthrough))) {
|
&audio_decoder->HwChannels, *passthrough))) {
|
||||||
@ -1044,7 +1051,7 @@ static int CodecAudioPassthroughHelper(AudioDecoder * audio_decoder,
|
|||||||
|
|
||||||
audio_ctx = audio_decoder->AudioCtx;
|
audio_ctx = audio_decoder->AudioCtx;
|
||||||
// SPDIF/HDMI passthrough
|
// SPDIF/HDMI passthrough
|
||||||
if (CodecPassthrough & CodecAC3 && audio_ctx->codec_id == CODEC_ID_AC3) {
|
if (CodecPassthrough & CodecAC3 && audio_ctx->codec_id == AV_CODEC_ID_AC3) {
|
||||||
uint16_t *spdif;
|
uint16_t *spdif;
|
||||||
int spdif_sz;
|
int spdif_sz;
|
||||||
|
|
||||||
@ -1094,7 +1101,8 @@ static int CodecAudioPassthroughHelper(AudioDecoder * audio_decoder,
|
|||||||
AudioEnqueue(spdif, spdif_sz);
|
AudioEnqueue(spdif, spdif_sz);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (CodecPassthrough & CodecEAC3 && audio_ctx->codec_id == CODEC_ID_EAC3) {
|
if (CodecPassthrough & CodecEAC3
|
||||||
|
&& audio_ctx->codec_id == AV_CODEC_ID_EAC3) {
|
||||||
uint16_t *spdif;
|
uint16_t *spdif;
|
||||||
int spdif_sz;
|
int spdif_sz;
|
||||||
int repeat;
|
int repeat;
|
||||||
@ -1223,9 +1231,9 @@ static void CodecAudioSetClock(AudioDecoder * audio_decoder, int64_t pts)
|
|||||||
corr = (10 * audio_decoder->HwSampleRate * drift) / (90 * 1000);
|
corr = (10 * audio_decoder->HwSampleRate * drift) / (90 * 1000);
|
||||||
// SPDIF/HDMI passthrough
|
// SPDIF/HDMI passthrough
|
||||||
if ((CodecAudioDrift & CORRECT_AC3) && (!(CodecPassthrough & CodecAC3)
|
if ((CodecAudioDrift & CORRECT_AC3) && (!(CodecPassthrough & CodecAC3)
|
||||||
|| audio_decoder->AudioCtx->codec_id != CODEC_ID_AC3)
|
|| audio_decoder->AudioCtx->codec_id != AV_CODEC_ID_AC3)
|
||||||
&& (!(CodecPassthrough & CodecEAC3)
|
&& (!(CodecPassthrough & CodecEAC3)
|
||||||
|| audio_decoder->AudioCtx->codec_id != CODEC_ID_EAC3)) {
|
|| audio_decoder->AudioCtx->codec_id != AV_CODEC_ID_EAC3)) {
|
||||||
audio_decoder->DriftCorr = -corr;
|
audio_decoder->DriftCorr = -corr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1625,9 +1633,9 @@ static void CodecAudioSetClock(AudioDecoder * audio_decoder, int64_t pts)
|
|||||||
corr = (10 * audio_decoder->HwSampleRate * drift) / (90 * 1000);
|
corr = (10 * audio_decoder->HwSampleRate * drift) / (90 * 1000);
|
||||||
// SPDIF/HDMI passthrough
|
// SPDIF/HDMI passthrough
|
||||||
if ((CodecAudioDrift & CORRECT_AC3) && (!(CodecPassthrough & CodecAC3)
|
if ((CodecAudioDrift & CORRECT_AC3) && (!(CodecPassthrough & CodecAC3)
|
||||||
|| audio_decoder->AudioCtx->codec_id != CODEC_ID_AC3)
|
|| audio_decoder->AudioCtx->codec_id != AV_CODEC_ID_AC3)
|
||||||
&& (!(CodecPassthrough & CodecEAC3)
|
&& (!(CodecPassthrough & CodecEAC3)
|
||||||
|| audio_decoder->AudioCtx->codec_id != CODEC_ID_EAC3)) {
|
|| audio_decoder->AudioCtx->codec_id != AV_CODEC_ID_EAC3)) {
|
||||||
audio_decoder->DriftCorr = -corr;
|
audio_decoder->DriftCorr = -corr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
171
softhddev.c
171
softhddev.c
@ -40,6 +40,19 @@
|
|||||||
#define _N(str) str ///< gettext_noop shortcut
|
#define _N(str) str ///< gettext_noop shortcut
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
|
// support old ffmpeg versions <1.0
|
||||||
|
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,18,102)
|
||||||
|
#define AVCodecID CodecID
|
||||||
|
#define AV_CODEC_ID_AAC CODEC_ID_AAC
|
||||||
|
#define AV_CODEC_ID_AAC_LATM CODEC_ID_AAC_LATM
|
||||||
|
#define AV_CODEC_ID_AC3 CODEC_ID_AC3
|
||||||
|
#define AV_CODEC_ID_EAC3 CODEC_ID_EAC3
|
||||||
|
#define AV_CODEC_ID_H264 CODEC_ID_H264
|
||||||
|
#define AV_CODEC_ID_MP2 CODEC_ID_MP2
|
||||||
|
#define AV_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO
|
||||||
|
#define AV_CODEC_ID_NONE CODEC_ID_NONE
|
||||||
|
#define AV_CODEC_ID_PCM_DVD CODEC_ID_PCM_DVD
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __USE_GNU
|
#ifndef __USE_GNU
|
||||||
#define __USE_GNU
|
#define __USE_GNU
|
||||||
@ -86,7 +99,7 @@ static volatile char StreamFreezed; ///< stream freezed
|
|||||||
static volatile char NewAudioStream; ///< new audio stream
|
static volatile char NewAudioStream; ///< new audio stream
|
||||||
static volatile char SkipAudio; ///< skip audio stream
|
static volatile char SkipAudio; ///< skip audio stream
|
||||||
static AudioDecoder *MyAudioDecoder; ///< audio decoder
|
static AudioDecoder *MyAudioDecoder; ///< audio decoder
|
||||||
static enum CodecID AudioCodecID; ///< current codec id
|
static enum AVCodecID AudioCodecID; ///< current codec id
|
||||||
static int AudioChannelID; ///< current audio channel id
|
static int AudioChannelID; ///< current audio channel id
|
||||||
static VideoStream *AudioSyncStream; ///< video stream for audio/video sync
|
static VideoStream *AudioSyncStream; ///< video stream for audio/video sync
|
||||||
|
|
||||||
@ -617,7 +630,7 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size,
|
|||||||
#if 0
|
#if 0
|
||||||
// Played with PlayAudio
|
// Played with PlayAudio
|
||||||
// FIXME: need 0x80 -- 0xA0 state
|
// FIXME: need 0x80 -- 0xA0 state
|
||||||
if (AudioCodecID == CODEC_ID_NONE) {
|
if (AudioCodecID == AV_CODEC_ID_NONE) {
|
||||||
if ((*p & 0xF0) == 0x80) { // AC-3 & DTS
|
if ((*p & 0xF0) == 0x80) { // AC-3 & DTS
|
||||||
Debug(3, "pesdemux: dvd ac-3\n");
|
Debug(3, "pesdemux: dvd ac-3\n");
|
||||||
} else if ((*p & 0xFF) == 0xA0) { // LPCM
|
} else if ((*p & 0xFF) == 0xA0) { // LPCM
|
||||||
@ -660,22 +673,22 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size,
|
|||||||
r = 0;
|
r = 0;
|
||||||
if (!r && FastMpegCheck(q)) {
|
if (!r && FastMpegCheck(q)) {
|
||||||
r = MpegCheck(q, n);
|
r = MpegCheck(q, n);
|
||||||
codec_id = CODEC_ID_MP2;
|
codec_id = AV_CODEC_ID_MP2;
|
||||||
}
|
}
|
||||||
if (!r && FastAc3Check(q)) {
|
if (!r && FastAc3Check(q)) {
|
||||||
r = Ac3Check(q, n);
|
r = Ac3Check(q, n);
|
||||||
codec_id = CODEC_ID_AC3;
|
codec_id = AV_CODEC_ID_AC3;
|
||||||
if (r > 0 && q[5] > (10 << 3)) {
|
if (r > 0 && q[5] > (10 << 3)) {
|
||||||
codec_id = CODEC_ID_EAC3;
|
codec_id = AV_CODEC_ID_EAC3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!r && FastLatmCheck(q)) {
|
if (!r && FastLatmCheck(q)) {
|
||||||
r = LatmCheck(q, n);
|
r = LatmCheck(q, n);
|
||||||
codec_id = CODEC_ID_AAC_LATM;
|
codec_id = AV_CODEC_ID_AAC_LATM;
|
||||||
}
|
}
|
||||||
if (!r && FastAdtsCheck(q)) {
|
if (!r && FastAdtsCheck(q)) {
|
||||||
r = AdtsCheck(q, n);
|
r = AdtsCheck(q, n);
|
||||||
codec_id = CODEC_ID_AAC;
|
codec_id = AV_CODEC_ID_AAC;
|
||||||
}
|
}
|
||||||
if (r < 0) { // need more bytes
|
if (r < 0) { // need more bytes
|
||||||
break;
|
break;
|
||||||
@ -705,7 +718,7 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size,
|
|||||||
//pesdx->State = PES_MPEG_DECODE;
|
//pesdx->State = PES_MPEG_DECODE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (AudioCodecID != CODEC_ID_NONE) {
|
if (AudioCodecID != AV_CODEC_ID_NONE) {
|
||||||
// shouldn't happen after we have a vaild codec
|
// shouldn't happen after we have a vaild codec
|
||||||
// detected
|
// detected
|
||||||
Debug(4, "pesdemux: skip @%d %02x\n", pesdx->Skip,
|
Debug(4, "pesdemux: skip @%d %02x\n", pesdx->Skip,
|
||||||
@ -831,7 +844,7 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size,
|
|||||||
int bits_per_sample;
|
int bits_per_sample;
|
||||||
const uint8_t *q;
|
const uint8_t *q;
|
||||||
|
|
||||||
if (AudioCodecID != CODEC_ID_PCM_DVD) {
|
if (AudioCodecID != AV_CODEC_ID_PCM_DVD) {
|
||||||
|
|
||||||
q = pesdx->Header;
|
q = pesdx->Header;
|
||||||
Debug(3, "pesdemux: LPCM %d sr:%d bits:%d chan:%d\n",
|
Debug(3, "pesdemux: LPCM %d sr:%d bits:%d chan:%d\n",
|
||||||
@ -861,8 +874,8 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size,
|
|||||||
(q[5] & 0x7) + 1);
|
(q[5] & 0x7) + 1);
|
||||||
// FIXME: support resample
|
// FIXME: support resample
|
||||||
}
|
}
|
||||||
//CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_PCM_DVD);
|
//CodecAudioOpen(MyAudioDecoder, NULL, AV_CODEC_ID_PCM_DVD);
|
||||||
AudioCodecID = CODEC_ID_PCM_DVD;
|
AudioCodecID = AV_CODEC_ID_PCM_DVD;
|
||||||
}
|
}
|
||||||
pesdx->State = PES_LPCM_PAYLOAD;
|
pesdx->State = PES_LPCM_PAYLOAD;
|
||||||
pesdx->Index = 0;
|
pesdx->Index = 0;
|
||||||
@ -1023,7 +1036,7 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
|
|||||||
CodecAudioClose(MyAudioDecoder);
|
CodecAudioClose(MyAudioDecoder);
|
||||||
AudioFlushBuffers();
|
AudioFlushBuffers();
|
||||||
AudioSetBufferTime(ConfigAudioBufferTime);
|
AudioSetBufferTime(ConfigAudioBufferTime);
|
||||||
AudioCodecID = CODEC_ID_NONE;
|
AudioCodecID = AV_CODEC_ID_NONE;
|
||||||
AudioChannelID = -1;
|
AudioChannelID = -1;
|
||||||
NewAudioStream = 0;
|
NewAudioStream = 0;
|
||||||
}
|
}
|
||||||
@ -1081,7 +1094,7 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
|
|||||||
|
|
||||||
if (AudioChannelID != id) { // id changed audio track changed
|
if (AudioChannelID != id) { // id changed audio track changed
|
||||||
AudioChannelID = id;
|
AudioChannelID = id;
|
||||||
AudioCodecID = CODEC_ID_NONE;
|
AudioCodecID = AV_CODEC_ID_NONE;
|
||||||
}
|
}
|
||||||
// Private stream + LPCM ID
|
// Private stream + LPCM ID
|
||||||
if ((id & 0xF0) == 0xA0) {
|
if ((id & 0xF0) == 0xA0) {
|
||||||
@ -1089,7 +1102,7 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
|
|||||||
Error(_("[softhddev] invalid LPCM audio packet %d bytes\n"), size);
|
Error(_("[softhddev] invalid LPCM audio packet %d bytes\n"), size);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
if (AudioCodecID != CODEC_ID_PCM_DVD) {
|
if (AudioCodecID != AV_CODEC_ID_PCM_DVD) {
|
||||||
static int samplerates[] = { 48000, 96000, 44100, 32000 };
|
static int samplerates[] = { 48000, 96000, 44100, 32000 };
|
||||||
int samplerate;
|
int samplerate;
|
||||||
int channels;
|
int channels;
|
||||||
@ -1123,8 +1136,8 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
|
|||||||
(p[5] & 0x7) + 1);
|
(p[5] & 0x7) + 1);
|
||||||
// FIXME: support resample
|
// FIXME: support resample
|
||||||
}
|
}
|
||||||
//CodecAudioOpen(MyAudioDecoder, NULL, CODEC_ID_PCM_DVD);
|
//CodecAudioOpen(MyAudioDecoder, NULL, AV_CODEC_ID_PCM_DVD);
|
||||||
AudioCodecID = CODEC_ID_PCM_DVD;
|
AudioCodecID = AV_CODEC_ID_PCM_DVD;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AudioAvPkt->pts != (int64_t) AV_NOPTS_VALUE) {
|
if (AudioAvPkt->pts != (int64_t) AV_NOPTS_VALUE) {
|
||||||
@ -1140,7 +1153,7 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
|
|||||||
if ((id & 0xF0) == 0x80 && (p[0] & 0xF0) == 0x80) {
|
if ((id & 0xF0) == 0x80 && (p[0] & 0xF0) == 0x80) {
|
||||||
p += 4;
|
p += 4;
|
||||||
n -= 4; // skip track header
|
n -= 4; // skip track header
|
||||||
if (AudioCodecID == CODEC_ID_NONE) {
|
if (AudioCodecID == AV_CODEC_ID_NONE) {
|
||||||
// FIXME: ConfigAudioBufferTime + x
|
// FIXME: ConfigAudioBufferTime + x
|
||||||
AudioSetBufferTime(400);
|
AudioSetBufferTime(400);
|
||||||
}
|
}
|
||||||
@ -1162,20 +1175,20 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
|
|||||||
// 7/9 bytes 0xFFFxxxxxxxxxxx ADTS audio
|
// 7/9 bytes 0xFFFxxxxxxxxxxx ADTS audio
|
||||||
// PCM audio can't be found
|
// PCM audio can't be found
|
||||||
r = 0;
|
r = 0;
|
||||||
codec_id = CODEC_ID_NONE; // keep compiler happy
|
codec_id = AV_CODEC_ID_NONE; // keep compiler happy
|
||||||
if (id != 0xbd && FastMpegCheck(p)) {
|
if (id != 0xbd && FastMpegCheck(p)) {
|
||||||
r = MpegCheck(p, n);
|
r = MpegCheck(p, n);
|
||||||
codec_id = CODEC_ID_MP2;
|
codec_id = AV_CODEC_ID_MP2;
|
||||||
}
|
}
|
||||||
if (id != 0xbd && !r && FastLatmCheck(p)) {
|
if (id != 0xbd && !r && FastLatmCheck(p)) {
|
||||||
r = LatmCheck(p, n);
|
r = LatmCheck(p, n);
|
||||||
codec_id = CODEC_ID_AAC_LATM;
|
codec_id = AV_CODEC_ID_AAC_LATM;
|
||||||
}
|
}
|
||||||
if ((id == 0xbd || (id & 0xF0) == 0x80) && !r && FastAc3Check(p)) {
|
if ((id == 0xbd || (id & 0xF0) == 0x80) && !r && FastAc3Check(p)) {
|
||||||
r = Ac3Check(p, n);
|
r = Ac3Check(p, n);
|
||||||
codec_id = CODEC_ID_AC3;
|
codec_id = AV_CODEC_ID_AC3;
|
||||||
if (r > 0 && p[5] > (10 << 3)) {
|
if (r > 0 && p[5] > (10 << 3)) {
|
||||||
codec_id = CODEC_ID_EAC3;
|
codec_id = AV_CODEC_ID_EAC3;
|
||||||
}
|
}
|
||||||
/* faster ac3 detection at end of pes packet (no improvemnts)
|
/* faster ac3 detection at end of pes packet (no improvemnts)
|
||||||
if (AudioCodecID == codec_id && -r - 2 == n) {
|
if (AudioCodecID == codec_id && -r - 2 == n) {
|
||||||
@ -1185,7 +1198,7 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
|
|||||||
}
|
}
|
||||||
if (id != 0xbd && !r && FastAdtsCheck(p)) {
|
if (id != 0xbd && !r && FastAdtsCheck(p)) {
|
||||||
r = AdtsCheck(p, n);
|
r = AdtsCheck(p, n);
|
||||||
codec_id = CODEC_ID_AAC;
|
codec_id = AV_CODEC_ID_AAC;
|
||||||
}
|
}
|
||||||
if (r < 0) { // need more bytes
|
if (r < 0) { // need more bytes
|
||||||
break;
|
break;
|
||||||
@ -1253,7 +1266,7 @@ int PlayTsAudio(const uint8_t * data, int size)
|
|||||||
AudioFlushBuffers();
|
AudioFlushBuffers();
|
||||||
// max time between audio packets 200ms + 24ms hw buffer
|
// max time between audio packets 200ms + 24ms hw buffer
|
||||||
AudioSetBufferTime(ConfigAudioBufferTime);
|
AudioSetBufferTime(ConfigAudioBufferTime);
|
||||||
AudioCodecID = CODEC_ID_NONE;
|
AudioCodecID = AV_CODEC_ID_NONE;
|
||||||
AudioChannelID = -1;
|
AudioChannelID = -1;
|
||||||
NewAudioStream = 0;
|
NewAudioStream = 0;
|
||||||
PesReset(PesDemuxAudio);
|
PesReset(PesDemuxAudio);
|
||||||
@ -1303,8 +1316,8 @@ struct __video_stream__
|
|||||||
VideoDecoder *Decoder; ///< video decoder
|
VideoDecoder *Decoder; ///< video decoder
|
||||||
pthread_mutex_t DecoderLockMutex; ///< video decoder lock mutex
|
pthread_mutex_t DecoderLockMutex; ///< video decoder lock mutex
|
||||||
|
|
||||||
enum CodecID CodecID; ///< current codec id
|
enum AVCodecID CodecID; ///< current codec id
|
||||||
enum CodecID LastCodecID; ///< last codec id
|
enum AVCodecID LastCodecID; ///< last codec id
|
||||||
|
|
||||||
volatile char NewStream; ///< flag new video stream
|
volatile char NewStream; ///< flag new video stream
|
||||||
volatile char ClosingStream; ///< flag closing video stream
|
volatile char ClosingStream; ///< flag closing video stream
|
||||||
@ -1318,6 +1331,7 @@ struct __video_stream__
|
|||||||
|
|
||||||
int InvalidPesCounter; ///< counter of invalid PES packets
|
int InvalidPesCounter; ///< counter of invalid PES packets
|
||||||
|
|
||||||
|
enum AVCodecID CodecIDRb[VIDEO_PACKET_MAX]; ///< codec ids in ring buffer
|
||||||
AVPacket PacketRb[VIDEO_PACKET_MAX]; ///< PES packet ring buffer
|
AVPacket PacketRb[VIDEO_PACKET_MAX]; ///< PES packet ring buffer
|
||||||
int StartCodeState; ///< last three bytes start code state
|
int StartCodeState; ///< last three bytes start code state
|
||||||
|
|
||||||
@ -1444,9 +1458,9 @@ static void VideoResetPacket(VideoStream * stream)
|
|||||||
|
|
||||||
stream->StartCodeState = 0; // reset start code state
|
stream->StartCodeState = 0; // reset start code state
|
||||||
|
|
||||||
|
stream->CodecIDRb[stream->PacketWrite] = AV_CODEC_ID_NONE;
|
||||||
avpkt = &stream->PacketRb[stream->PacketWrite];
|
avpkt = &stream->PacketRb[stream->PacketWrite];
|
||||||
avpkt->stream_index = 0;
|
avpkt->stream_index = 0;
|
||||||
avpkt->priv = NULL;
|
|
||||||
avpkt->pts = AV_NOPTS_VALUE;
|
avpkt->pts = AV_NOPTS_VALUE;
|
||||||
avpkt->dts = AV_NOPTS_VALUE;
|
avpkt->dts = AV_NOPTS_VALUE;
|
||||||
}
|
}
|
||||||
@ -1463,7 +1477,7 @@ static void VideoNextPacket(VideoStream * stream, int codec_id)
|
|||||||
|
|
||||||
avpkt = &stream->PacketRb[stream->PacketWrite];
|
avpkt = &stream->PacketRb[stream->PacketWrite];
|
||||||
if (!avpkt->stream_index) { // ignore empty packets
|
if (!avpkt->stream_index) { // ignore empty packets
|
||||||
if (codec_id != CODEC_ID_NONE) {
|
if (codec_id != AV_CODEC_ID_NONE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Debug(3, "video: possible stream change loss\n");
|
Debug(3, "video: possible stream change loss\n");
|
||||||
@ -1473,7 +1487,7 @@ static void VideoNextPacket(VideoStream * stream, int codec_id)
|
|||||||
// no free slot available drop last packet
|
// no free slot available drop last packet
|
||||||
Error(_("video: no empty slot in packet ringbuffer\n"));
|
Error(_("video: no empty slot in packet ringbuffer\n"));
|
||||||
avpkt->stream_index = 0;
|
avpkt->stream_index = 0;
|
||||||
if (codec_id == CODEC_ID_NONE) {
|
if (codec_id == AV_CODEC_ID_NONE) {
|
||||||
Debug(3, "video: possible stream change loss\n");
|
Debug(3, "video: possible stream change loss\n");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -1481,7 +1495,7 @@ static void VideoNextPacket(VideoStream * stream, int codec_id)
|
|||||||
// clear area for decoder, always enough space allocated
|
// clear area for decoder, always enough space allocated
|
||||||
memset(avpkt->data + avpkt->stream_index, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
memset(avpkt->data + avpkt->stream_index, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
|
||||||
avpkt->priv = (void *)(size_t) codec_id;
|
stream->CodecIDRb[stream->PacketWrite] = codec_id;
|
||||||
//DumpH264(avpkt->data, avpkt->stream_index);
|
//DumpH264(avpkt->data, avpkt->stream_index);
|
||||||
|
|
||||||
// advance packet write
|
// advance packet write
|
||||||
@ -1541,7 +1555,7 @@ static void VideoMpegEnqueue(VideoStream * stream, int64_t pts,
|
|||||||
fprintf(stderr, "last: %d start\n", stream->StartCodeState);
|
fprintf(stderr, "last: %d start\n", stream->StartCodeState);
|
||||||
#endif
|
#endif
|
||||||
stream->PacketRb[stream->PacketWrite].stream_index -= 3;
|
stream->PacketRb[stream->PacketWrite].stream_index -= 3;
|
||||||
VideoNextPacket(stream, CODEC_ID_MPEG2VIDEO);
|
VideoNextPacket(stream, AV_CODEC_ID_MPEG2VIDEO);
|
||||||
VideoEnqueue(stream, pts, startcode, 3);
|
VideoEnqueue(stream, pts, startcode, 3);
|
||||||
first = p[0] == 0xb3;
|
first = p[0] == 0xb3;
|
||||||
p++;
|
p++;
|
||||||
@ -1558,7 +1572,7 @@ static void VideoMpegEnqueue(VideoStream * stream, int64_t pts,
|
|||||||
fprintf(stderr, "last: %d start\n", stream->StartCodeState);
|
fprintf(stderr, "last: %d start\n", stream->StartCodeState);
|
||||||
#endif
|
#endif
|
||||||
stream->PacketRb[stream->PacketWrite].stream_index -= 2;
|
stream->PacketRb[stream->PacketWrite].stream_index -= 2;
|
||||||
VideoNextPacket(stream, CODEC_ID_MPEG2VIDEO);
|
VideoNextPacket(stream, AV_CODEC_ID_MPEG2VIDEO);
|
||||||
VideoEnqueue(stream, pts, startcode, 2);
|
VideoEnqueue(stream, pts, startcode, 2);
|
||||||
first = p[1] == 0xb3;
|
first = p[1] == 0xb3;
|
||||||
p += 2;
|
p += 2;
|
||||||
@ -1575,7 +1589,7 @@ static void VideoMpegEnqueue(VideoStream * stream, int64_t pts,
|
|||||||
fprintf(stderr, "last: %d start\n", stream->StartCodeState);
|
fprintf(stderr, "last: %d start\n", stream->StartCodeState);
|
||||||
#endif
|
#endif
|
||||||
stream->PacketRb[stream->PacketWrite].stream_index -= 1;
|
stream->PacketRb[stream->PacketWrite].stream_index -= 1;
|
||||||
VideoNextPacket(stream, CODEC_ID_MPEG2VIDEO);
|
VideoNextPacket(stream, AV_CODEC_ID_MPEG2VIDEO);
|
||||||
VideoEnqueue(stream, pts, startcode, 1);
|
VideoEnqueue(stream, pts, startcode, 1);
|
||||||
first = p[2] == 0xb3;
|
first = p[2] == 0xb3;
|
||||||
p += 3;
|
p += 3;
|
||||||
@ -1608,7 +1622,7 @@ static void VideoMpegEnqueue(VideoStream * stream, int64_t pts,
|
|||||||
*/
|
*/
|
||||||
// first packet goes only upto picture header
|
// first packet goes only upto picture header
|
||||||
VideoEnqueue(stream, pts, data, p - data);
|
VideoEnqueue(stream, pts, data, p - data);
|
||||||
VideoNextPacket(stream, CODEC_ID_MPEG2VIDEO);
|
VideoNextPacket(stream, AV_CODEC_ID_MPEG2VIDEO);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "fix\r");
|
fprintf(stderr, "fix\r");
|
||||||
#endif
|
#endif
|
||||||
@ -1856,9 +1870,8 @@ int VideoDecodeInput(VideoStream * stream)
|
|||||||
|
|
||||||
// flush buffers, if close is in the queue
|
// flush buffers, if close is in the queue
|
||||||
for (f = 0; f < filled; ++f) {
|
for (f = 0; f < filled; ++f) {
|
||||||
avpkt =
|
if (stream->CodecIDRb[(stream->PacketRead + f) % VIDEO_PACKET_MAX]
|
||||||
&stream->PacketRb[(stream->PacketRead + f) % VIDEO_PACKET_MAX];
|
== AV_CODEC_ID_NONE) {
|
||||||
if ((int)(size_t) avpkt->priv == CODEC_ID_NONE) {
|
|
||||||
if (f) {
|
if (f) {
|
||||||
Debug(3, "video: cleared upto close\n");
|
Debug(3, "video: cleared upto close\n");
|
||||||
atomic_sub(f, &stream->PacketsFilled);
|
atomic_sub(f, &stream->PacketsFilled);
|
||||||
@ -1877,30 +1890,30 @@ int VideoDecodeInput(VideoStream * stream)
|
|||||||
// handle queued commands
|
// handle queued commands
|
||||||
//
|
//
|
||||||
avpkt = &stream->PacketRb[stream->PacketRead];
|
avpkt = &stream->PacketRb[stream->PacketRead];
|
||||||
switch ((int)(size_t) avpkt->priv) {
|
switch (stream->CodecIDRb[stream->PacketRead]) {
|
||||||
case CODEC_ID_NONE:
|
case AV_CODEC_ID_NONE:
|
||||||
stream->ClosingStream = 0;
|
stream->ClosingStream = 0;
|
||||||
if (stream->LastCodecID != CODEC_ID_NONE) {
|
if (stream->LastCodecID != AV_CODEC_ID_NONE) {
|
||||||
stream->LastCodecID = CODEC_ID_NONE;
|
stream->LastCodecID = AV_CODEC_ID_NONE;
|
||||||
CodecVideoClose(stream->Decoder);
|
CodecVideoClose(stream->Decoder);
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
// FIXME: look if more close are in the queue
|
// FIXME: look if more close are in the queue
|
||||||
// size can be zero
|
// size can be zero
|
||||||
goto skip;
|
goto skip;
|
||||||
case CODEC_ID_MPEG2VIDEO:
|
case AV_CODEC_ID_MPEG2VIDEO:
|
||||||
if (stream->LastCodecID != CODEC_ID_MPEG2VIDEO) {
|
if (stream->LastCodecID != AV_CODEC_ID_MPEG2VIDEO) {
|
||||||
stream->LastCodecID = CODEC_ID_MPEG2VIDEO;
|
stream->LastCodecID = AV_CODEC_ID_MPEG2VIDEO;
|
||||||
CodecVideoOpen(stream->Decoder, VideoHardwareDecoder < 0
|
CodecVideoOpen(stream->Decoder, VideoHardwareDecoder < 0
|
||||||
&& VdpauDecoder ? "mpegvideo_vdpau" : NULL,
|
&& VdpauDecoder ? "mpegvideo_vdpau" : NULL,
|
||||||
CODEC_ID_MPEG2VIDEO);
|
AV_CODEC_ID_MPEG2VIDEO);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CODEC_ID_H264:
|
case AV_CODEC_ID_H264:
|
||||||
if (stream->LastCodecID != CODEC_ID_H264) {
|
if (stream->LastCodecID != AV_CODEC_ID_H264) {
|
||||||
stream->LastCodecID = CODEC_ID_H264;
|
stream->LastCodecID = AV_CODEC_ID_H264;
|
||||||
CodecVideoOpen(stream->Decoder, VideoHardwareDecoder
|
CodecVideoOpen(stream->Decoder, VideoHardwareDecoder
|
||||||
&& VdpauDecoder ? "h264_vdpau" : NULL, CODEC_ID_H264);
|
&& VdpauDecoder ? "h264_vdpau" : NULL, AV_CODEC_ID_H264);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1929,7 +1942,7 @@ int VideoDecodeInput(VideoStream * stream)
|
|||||||
//fprintf(stderr, "]\n");
|
//fprintf(stderr, "]\n");
|
||||||
#else
|
#else
|
||||||
// old version
|
// old version
|
||||||
if (stream->LastCodecID == CODEC_ID_MPEG2VIDEO) {
|
if (stream->LastCodecID == AV_CODEC_ID_MPEG2VIDEO) {
|
||||||
FixPacketForFFMpeg(stream->Decoder, avpkt);
|
FixPacketForFFMpeg(stream->Decoder, avpkt);
|
||||||
} else {
|
} else {
|
||||||
CodecVideoDecode(stream->Decoder, avpkt);
|
CodecVideoDecode(stream->Decoder, avpkt);
|
||||||
@ -1975,8 +1988,8 @@ static void StartVideo(void)
|
|||||||
VideoOsdInit();
|
VideoOsdInit();
|
||||||
if (!MyVideoStream->Decoder) {
|
if (!MyVideoStream->Decoder) {
|
||||||
MyVideoStream->SkipStream = 1;
|
MyVideoStream->SkipStream = 1;
|
||||||
MyVideoStream->CodecID = CODEC_ID_NONE;
|
MyVideoStream->CodecID = AV_CODEC_ID_NONE;
|
||||||
MyVideoStream->LastCodecID = CODEC_ID_NONE;
|
MyVideoStream->LastCodecID = AV_CODEC_ID_NONE;
|
||||||
|
|
||||||
if ((MyVideoStream->HwDecoder = VideoNewHwDecoder(MyVideoStream))) {
|
if ((MyVideoStream->HwDecoder = VideoNewHwDecoder(MyVideoStream))) {
|
||||||
MyVideoStream->Decoder =
|
MyVideoStream->Decoder =
|
||||||
@ -2137,8 +2150,8 @@ int PlayVideo3(VideoStream * stream, const uint8_t * data, int size)
|
|||||||
Debug(3, "video: new video stream lost\n");
|
Debug(3, "video: new video stream lost\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
VideoNextPacket(stream, CODEC_ID_NONE);
|
VideoNextPacket(stream, AV_CODEC_ID_NONE);
|
||||||
stream->CodecID = CODEC_ID_NONE;
|
stream->CodecID = AV_CODEC_ID_NONE;
|
||||||
stream->ClosingStream = 1;
|
stream->ClosingStream = 1;
|
||||||
stream->NewStream = 0;
|
stream->NewStream = 0;
|
||||||
}
|
}
|
||||||
@ -2210,7 +2223,7 @@ int PlayVideo3(VideoStream * stream, const uint8_t * data, int size)
|
|||||||
if ((data[6] & 0xC0) == 0x80 && z >= 2 && check[0] == 0x01
|
if ((data[6] & 0xC0) == 0x80 && z >= 2 && check[0] == 0x01
|
||||||
&& check[1] == 0x09 && !check[3] && !check[4]) {
|
&& check[1] == 0x09 && !check[3] && !check[4]) {
|
||||||
// old PES HDTV recording z == 2 -> stronger check!
|
// old PES HDTV recording z == 2 -> stronger check!
|
||||||
if (stream->CodecID == CODEC_ID_H264) {
|
if (stream->CodecID == AV_CODEC_ID_H264) {
|
||||||
#if 0
|
#if 0
|
||||||
// this should improve ffwd+frew, but produce crash in ffmpeg
|
// this should improve ffwd+frew, but produce crash in ffmpeg
|
||||||
// with some streams
|
// with some streams
|
||||||
@ -2222,16 +2235,16 @@ int PlayVideo3(VideoStream * stream, const uint8_t * data, int size)
|
|||||||
// 1-5=SLICE 6=SEI 7=SPS 8=PPS
|
// 1-5=SLICE 6=SEI 7=SPS 8=PPS
|
||||||
// NAL SPS sequence parameter set
|
// NAL SPS sequence parameter set
|
||||||
if ((check[7] & 0x1F) == 0x07) {
|
if ((check[7] & 0x1F) == 0x07) {
|
||||||
VideoNextPacket(CODEC_ID_H264);
|
VideoNextPacket(AV_CODEC_ID_H264);
|
||||||
VideoEnqueue(AV_NOPTS_VALUE, seq_end_h264,
|
VideoEnqueue(AV_NOPTS_VALUE, seq_end_h264,
|
||||||
sizeof(seq_end_h264));
|
sizeof(seq_end_h264));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
VideoNextPacket(stream, CODEC_ID_H264);
|
VideoNextPacket(stream, AV_CODEC_ID_H264);
|
||||||
} else {
|
} else {
|
||||||
Debug(3, "video: h264 detected\n");
|
Debug(3, "video: h264 detected\n");
|
||||||
stream->CodecID = CODEC_ID_H264;
|
stream->CodecID = AV_CODEC_ID_H264;
|
||||||
}
|
}
|
||||||
// SKIP PES header (ffmpeg supports short start code)
|
// SKIP PES header (ffmpeg supports short start code)
|
||||||
VideoEnqueue(stream, pts, check - 2, l + 2);
|
VideoEnqueue(stream, pts, check - 2, l + 2);
|
||||||
@ -2239,11 +2252,11 @@ int PlayVideo3(VideoStream * stream, const uint8_t * data, int size)
|
|||||||
}
|
}
|
||||||
// PES start code 0x00 0x00 0x01 0x00|0xb3
|
// PES start code 0x00 0x00 0x01 0x00|0xb3
|
||||||
if (z > 1 && check[0] == 0x01 && (!check[1] || check[1] == 0xb3)) {
|
if (z > 1 && check[0] == 0x01 && (!check[1] || check[1] == 0xb3)) {
|
||||||
if (stream->CodecID == CODEC_ID_MPEG2VIDEO) {
|
if (stream->CodecID == AV_CODEC_ID_MPEG2VIDEO) {
|
||||||
VideoNextPacket(stream, CODEC_ID_MPEG2VIDEO);
|
VideoNextPacket(stream, AV_CODEC_ID_MPEG2VIDEO);
|
||||||
} else {
|
} else {
|
||||||
Debug(3, "video: mpeg2 detected ID %02x\n", check[3]);
|
Debug(3, "video: mpeg2 detected ID %02x\n", check[3]);
|
||||||
stream->CodecID = CODEC_ID_MPEG2VIDEO;
|
stream->CodecID = AV_CODEC_ID_MPEG2VIDEO;
|
||||||
}
|
}
|
||||||
#ifdef noDEBUG // pip pes packet has no lenght
|
#ifdef noDEBUG // pip pes packet has no lenght
|
||||||
if (ValidateMpeg(data, size)) {
|
if (ValidateMpeg(data, size)) {
|
||||||
@ -2259,12 +2272,12 @@ int PlayVideo3(VideoStream * stream, const uint8_t * data, int size)
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
// this happens when vdr sends incomplete packets
|
// this happens when vdr sends incomplete packets
|
||||||
if (stream->CodecID == CODEC_ID_NONE) {
|
if (stream->CodecID == AV_CODEC_ID_NONE) {
|
||||||
Debug(3, "video: not detected\n");
|
Debug(3, "video: not detected\n");
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
#ifdef USE_PIP
|
#ifdef USE_PIP
|
||||||
if (stream->CodecID == CODEC_ID_MPEG2VIDEO) {
|
if (stream->CodecID == AV_CODEC_ID_MPEG2VIDEO) {
|
||||||
// SKIP PES header
|
// SKIP PES header
|
||||||
VideoMpegEnqueue(stream, pts, data + 9 + n, size - 9 - n);
|
VideoMpegEnqueue(stream, pts, data + 9 + n, size - 9 - n);
|
||||||
#ifndef USE_MPEG_COMPLETE
|
#ifndef USE_MPEG_COMPLETE
|
||||||
@ -2288,10 +2301,10 @@ int PlayVideo3(VideoStream * stream, const uint8_t * data, int size)
|
|||||||
// incomplete packets produce artefacts after channel switch
|
// incomplete packets produce artefacts after channel switch
|
||||||
// packet < 65526 is the last split packet, detect it here for
|
// packet < 65526 is the last split packet, detect it here for
|
||||||
// better latency
|
// better latency
|
||||||
if (size < 65526 && stream->CodecID == CODEC_ID_MPEG2VIDEO) {
|
if (size < 65526 && stream->CodecID == AV_CODEC_ID_MPEG2VIDEO) {
|
||||||
// mpeg codec supports incomplete packets
|
// mpeg codec supports incomplete packets
|
||||||
// waiting for a full complete packages, increases needed delays
|
// waiting for a full complete packages, increases needed delays
|
||||||
VideoNextPacket(stream, CODEC_ID_MPEG2VIDEO);
|
VideoNextPacket(stream, AV_CODEC_ID_MPEG2VIDEO);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2421,7 +2434,7 @@ int SetPlayMode(int play_mode)
|
|||||||
Clear(); // flush all buffers
|
Clear(); // flush all buffers
|
||||||
MyVideoStream->ClearClose = 0;
|
MyVideoStream->ClearClose = 0;
|
||||||
}
|
}
|
||||||
if (MyVideoStream->CodecID != CODEC_ID_NONE) {
|
if (MyVideoStream->CodecID != AV_CODEC_ID_NONE) {
|
||||||
MyVideoStream->NewStream = 1;
|
MyVideoStream->NewStream = 1;
|
||||||
MyVideoStream->InvalidPesCounter = 0;
|
MyVideoStream->InvalidPesCounter = 0;
|
||||||
// tell hw decoder we are closing stream
|
// tell hw decoder we are closing stream
|
||||||
@ -2433,7 +2446,7 @@ int SetPlayMode(int play_mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (MyAudioDecoder) { // tell audio parser we have new stream
|
if (MyAudioDecoder) { // tell audio parser we have new stream
|
||||||
if (AudioCodecID != CODEC_ID_NONE) {
|
if (AudioCodecID != AV_CODEC_ID_NONE) {
|
||||||
NewAudioStream = 1;
|
NewAudioStream = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2611,10 +2624,10 @@ void StillPicture(const uint8_t * data, int size)
|
|||||||
// enable/disable hardware decoder for still picture
|
// enable/disable hardware decoder for still picture
|
||||||
if (VideoHardwareDecoder != ConfigStillDecoder) {
|
if (VideoHardwareDecoder != ConfigStillDecoder) {
|
||||||
VideoHardwareDecoder = ConfigStillDecoder;
|
VideoHardwareDecoder = ConfigStillDecoder;
|
||||||
VideoNextPacket(MyVideoStream, CODEC_ID_NONE); // close last stream
|
VideoNextPacket(MyVideoStream, AV_CODEC_ID_NONE); // close last stream
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MyVideoStream->CodecID == CODEC_ID_NONE) {
|
if (MyVideoStream->CodecID == AV_CODEC_ID_NONE) {
|
||||||
// FIXME: should detect codec, see PlayVideo
|
// FIXME: should detect codec, see PlayVideo
|
||||||
Error(_("[softhddev] no codec known for still picture\n"));
|
Error(_("[softhddev] no codec known for still picture\n"));
|
||||||
}
|
}
|
||||||
@ -2623,7 +2636,7 @@ void StillPicture(const uint8_t * data, int size)
|
|||||||
#ifdef STILL_DEBUG
|
#ifdef STILL_DEBUG
|
||||||
fprintf(stderr, "still-picture\n");
|
fprintf(stderr, "still-picture\n");
|
||||||
#endif
|
#endif
|
||||||
for (i = 0; i < (MyVideoStream->CodecID == CODEC_ID_MPEG2VIDEO ? 4 : 4);
|
for (i = 0; i < (MyVideoStream->CodecID == AV_CODEC_ID_MPEG2VIDEO ? 4 : 4);
|
||||||
++i) {
|
++i) {
|
||||||
const uint8_t *split;
|
const uint8_t *split;
|
||||||
int n;
|
int n;
|
||||||
@ -2663,13 +2676,13 @@ void StillPicture(const uint8_t * data, int size)
|
|||||||
|
|
||||||
VideoNextPacket(MyVideoStream, MyVideoStream->CodecID); // terminate last packet
|
VideoNextPacket(MyVideoStream, MyVideoStream->CodecID); // terminate last packet
|
||||||
} else { // ES packet
|
} else { // ES packet
|
||||||
if (MyVideoStream->CodecID != CODEC_ID_MPEG2VIDEO) {
|
if (MyVideoStream->CodecID != AV_CODEC_ID_MPEG2VIDEO) {
|
||||||
VideoNextPacket(MyVideoStream, CODEC_ID_NONE); // close last stream
|
VideoNextPacket(MyVideoStream, AV_CODEC_ID_NONE); // close last stream
|
||||||
MyVideoStream->CodecID = CODEC_ID_MPEG2VIDEO;
|
MyVideoStream->CodecID = AV_CODEC_ID_MPEG2VIDEO;
|
||||||
}
|
}
|
||||||
VideoEnqueue(MyVideoStream, AV_NOPTS_VALUE, data, size);
|
VideoEnqueue(MyVideoStream, AV_NOPTS_VALUE, data, size);
|
||||||
}
|
}
|
||||||
if (MyVideoStream->CodecID == CODEC_ID_H264) {
|
if (MyVideoStream->CodecID == AV_CODEC_ID_H264) {
|
||||||
VideoEnqueue(MyVideoStream, AV_NOPTS_VALUE, seq_end_h264,
|
VideoEnqueue(MyVideoStream, AV_NOPTS_VALUE, seq_end_h264,
|
||||||
sizeof(seq_end_h264));
|
sizeof(seq_end_h264));
|
||||||
} else {
|
} else {
|
||||||
@ -2690,7 +2703,7 @@ void StillPicture(const uint8_t * data, int size)
|
|||||||
#endif
|
#endif
|
||||||
if (VideoHardwareDecoder != old_video_hardware_decoder) {
|
if (VideoHardwareDecoder != old_video_hardware_decoder) {
|
||||||
VideoHardwareDecoder = old_video_hardware_decoder;
|
VideoHardwareDecoder = old_video_hardware_decoder;
|
||||||
VideoNextPacket(MyVideoStream, CODEC_ID_NONE); // close last stream
|
VideoNextPacket(MyVideoStream, AV_CODEC_ID_NONE); // close last stream
|
||||||
}
|
}
|
||||||
VideoSetTrickSpeed(MyVideoStream->HwDecoder, 0);
|
VideoSetTrickSpeed(MyVideoStream->HwDecoder, 0);
|
||||||
}
|
}
|
||||||
@ -3140,7 +3153,7 @@ int Start(void)
|
|||||||
AudioInit();
|
AudioInit();
|
||||||
av_new_packet(AudioAvPkt, AUDIO_BUFFER_SIZE);
|
av_new_packet(AudioAvPkt, AUDIO_BUFFER_SIZE);
|
||||||
MyAudioDecoder = CodecAudioNewDecoder();
|
MyAudioDecoder = CodecAudioNewDecoder();
|
||||||
AudioCodecID = CODEC_ID_NONE;
|
AudioCodecID = AV_CODEC_ID_NONE;
|
||||||
AudioChannelID = -1;
|
AudioChannelID = -1;
|
||||||
|
|
||||||
if (!ConfigStartX11Server) {
|
if (!ConfigStartX11Server) {
|
||||||
@ -3293,7 +3306,7 @@ void Resume(void)
|
|||||||
AudioInit();
|
AudioInit();
|
||||||
av_new_packet(AudioAvPkt, AUDIO_BUFFER_SIZE);
|
av_new_packet(AudioAvPkt, AUDIO_BUFFER_SIZE);
|
||||||
MyAudioDecoder = CodecAudioNewDecoder();
|
MyAudioDecoder = CodecAudioNewDecoder();
|
||||||
AudioCodecID = CODEC_ID_NONE;
|
AudioCodecID = AV_CODEC_ID_NONE;
|
||||||
AudioChannelID = -1;
|
AudioChannelID = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3394,8 +3407,8 @@ void PipStart(int x, int y, int width, int height, int pip_x, int pip_y,
|
|||||||
|
|
||||||
if (!PipVideoStream->Decoder) {
|
if (!PipVideoStream->Decoder) {
|
||||||
PipVideoStream->SkipStream = 1;
|
PipVideoStream->SkipStream = 1;
|
||||||
PipVideoStream->CodecID = CODEC_ID_NONE;
|
PipVideoStream->CodecID = AV_CODEC_ID_NONE;
|
||||||
PipVideoStream->LastCodecID = CODEC_ID_NONE;
|
PipVideoStream->LastCodecID = AV_CODEC_ID_NONE;
|
||||||
|
|
||||||
if ((PipVideoStream->HwDecoder = VideoNewHwDecoder(PipVideoStream))) {
|
if ((PipVideoStream->HwDecoder = VideoNewHwDecoder(PipVideoStream))) {
|
||||||
PipVideoStream->Decoder =
|
PipVideoStream->Decoder =
|
||||||
|
41
video.c
41
video.c
@ -151,6 +151,17 @@ typedef enum
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
|
// support old ffmpeg versions <1.0
|
||||||
|
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,18,102)
|
||||||
|
#define AVCodecID CodecID
|
||||||
|
#define AV_CODEC_ID_H263 CODEC_ID_H263
|
||||||
|
#define AV_CODEC_ID_H264 CODEC_ID_H264
|
||||||
|
#define AV_CODEC_ID_MPEG1VIDEO CODEC_ID_MPEG1VIDEO
|
||||||
|
#define AV_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO
|
||||||
|
#define AV_CODEC_ID_MPEG4 CODEC_ID_MPEG4
|
||||||
|
#define AV_CODEC_ID_VC1 CODEC_ID_VC1
|
||||||
|
#define AV_CODEC_ID_WMV3 CODEC_ID_WMV3
|
||||||
|
#endif
|
||||||
#include <libavcodec/vaapi.h>
|
#include <libavcodec/vaapi.h>
|
||||||
#include <libavutil/pixdesc.h>
|
#include <libavutil/pixdesc.h>
|
||||||
|
|
||||||
@ -2687,7 +2698,7 @@ static enum PixelFormat Vaapi_get_format(VaapiDecoder * decoder,
|
|||||||
int e;
|
int e;
|
||||||
VAConfigAttrib attrib;
|
VAConfigAttrib attrib;
|
||||||
|
|
||||||
if (!VideoHardwareDecoder || (video_ctx->codec_id == CODEC_ID_MPEG2VIDEO
|
if (!VideoHardwareDecoder || (video_ctx->codec_id == AV_CODEC_ID_MPEG2VIDEO
|
||||||
&& VideoHardwareDecoder == 1)
|
&& VideoHardwareDecoder == 1)
|
||||||
) { // hardware disabled by config
|
) { // hardware disabled by config
|
||||||
Debug(3, "codec: hardware acceleration disabled\n");
|
Debug(3, "codec: hardware acceleration disabled\n");
|
||||||
@ -2706,19 +2717,19 @@ static enum PixelFormat Vaapi_get_format(VaapiDecoder * decoder,
|
|||||||
|
|
||||||
// check profile
|
// check profile
|
||||||
switch (video_ctx->codec_id) {
|
switch (video_ctx->codec_id) {
|
||||||
case CODEC_ID_MPEG2VIDEO:
|
case AV_CODEC_ID_MPEG2VIDEO:
|
||||||
decoder->SurfacesNeeded =
|
decoder->SurfacesNeeded =
|
||||||
CODEC_SURFACES_MPEG2 + VIDEO_SURFACES_MAX + 2;
|
CODEC_SURFACES_MPEG2 + VIDEO_SURFACES_MAX + 2;
|
||||||
p = VaapiFindProfile(profiles, profile_n, VAProfileMPEG2Main);
|
p = VaapiFindProfile(profiles, profile_n, VAProfileMPEG2Main);
|
||||||
break;
|
break;
|
||||||
case CODEC_ID_MPEG4:
|
case AV_CODEC_ID_MPEG4:
|
||||||
case CODEC_ID_H263:
|
case AV_CODEC_ID_H263:
|
||||||
decoder->SurfacesNeeded =
|
decoder->SurfacesNeeded =
|
||||||
CODEC_SURFACES_MPEG4 + VIDEO_SURFACES_MAX + 2;
|
CODEC_SURFACES_MPEG4 + VIDEO_SURFACES_MAX + 2;
|
||||||
p = VaapiFindProfile(profiles, profile_n,
|
p = VaapiFindProfile(profiles, profile_n,
|
||||||
VAProfileMPEG4AdvancedSimple);
|
VAProfileMPEG4AdvancedSimple);
|
||||||
break;
|
break;
|
||||||
case CODEC_ID_H264:
|
case AV_CODEC_ID_H264:
|
||||||
decoder->SurfacesNeeded =
|
decoder->SurfacesNeeded =
|
||||||
CODEC_SURFACES_H264 + VIDEO_SURFACES_MAX + 2;
|
CODEC_SURFACES_H264 + VIDEO_SURFACES_MAX + 2;
|
||||||
// try more simple formats, fallback to better
|
// try more simple formats, fallback to better
|
||||||
@ -2736,12 +2747,12 @@ static enum PixelFormat Vaapi_get_format(VaapiDecoder * decoder,
|
|||||||
p = VaapiFindProfile(profiles, profile_n, VAProfileH264High);
|
p = VaapiFindProfile(profiles, profile_n, VAProfileH264High);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CODEC_ID_WMV3:
|
case AV_CODEC_ID_WMV3:
|
||||||
decoder->SurfacesNeeded =
|
decoder->SurfacesNeeded =
|
||||||
CODEC_SURFACES_VC1 + VIDEO_SURFACES_MAX + 2;
|
CODEC_SURFACES_VC1 + VIDEO_SURFACES_MAX + 2;
|
||||||
p = VaapiFindProfile(profiles, profile_n, VAProfileVC1Main);
|
p = VaapiFindProfile(profiles, profile_n, VAProfileVC1Main);
|
||||||
break;
|
break;
|
||||||
case CODEC_ID_VC1:
|
case AV_CODEC_ID_VC1:
|
||||||
decoder->SurfacesNeeded =
|
decoder->SurfacesNeeded =
|
||||||
CODEC_SURFACES_VC1 + VIDEO_SURFACES_MAX + 2;
|
CODEC_SURFACES_VC1 + VIDEO_SURFACES_MAX + 2;
|
||||||
p = VaapiFindProfile(profiles, profile_n, VAProfileVC1Advanced);
|
p = VaapiFindProfile(profiles, profile_n, VAProfileVC1Advanced);
|
||||||
@ -7020,7 +7031,7 @@ static enum PixelFormat Vdpau_get_format(VdpauDecoder * decoder,
|
|||||||
VdpDecoderProfile profile;
|
VdpDecoderProfile profile;
|
||||||
int max_refs;
|
int max_refs;
|
||||||
|
|
||||||
if (!VideoHardwareDecoder || (video_ctx->codec_id == CODEC_ID_MPEG2VIDEO
|
if (!VideoHardwareDecoder || (video_ctx->codec_id == AV_CODEC_ID_MPEG2VIDEO
|
||||||
&& VideoHardwareDecoder == 1)
|
&& VideoHardwareDecoder == 1)
|
||||||
) { // hardware disabled by config
|
) { // hardware disabled by config
|
||||||
Debug(3, "codec: hardware acceleration disabled\n");
|
Debug(3, "codec: hardware acceleration disabled\n");
|
||||||
@ -7055,23 +7066,23 @@ static enum PixelFormat Vdpau_get_format(VdpauDecoder * decoder,
|
|||||||
max_refs = CODEC_SURFACES_DEFAULT;
|
max_refs = CODEC_SURFACES_DEFAULT;
|
||||||
// check profile
|
// check profile
|
||||||
switch (video_ctx->codec_id) {
|
switch (video_ctx->codec_id) {
|
||||||
case CODEC_ID_MPEG1VIDEO:
|
case AV_CODEC_ID_MPEG1VIDEO:
|
||||||
max_refs = CODEC_SURFACES_MPEG2;
|
max_refs = CODEC_SURFACES_MPEG2;
|
||||||
profile = VdpauCheckProfile(decoder, VDP_DECODER_PROFILE_MPEG1);
|
profile = VdpauCheckProfile(decoder, VDP_DECODER_PROFILE_MPEG1);
|
||||||
break;
|
break;
|
||||||
case CODEC_ID_MPEG2VIDEO:
|
case AV_CODEC_ID_MPEG2VIDEO:
|
||||||
max_refs = CODEC_SURFACES_MPEG2;
|
max_refs = CODEC_SURFACES_MPEG2;
|
||||||
profile =
|
profile =
|
||||||
VdpauCheckProfile(decoder, VDP_DECODER_PROFILE_MPEG2_MAIN);
|
VdpauCheckProfile(decoder, VDP_DECODER_PROFILE_MPEG2_MAIN);
|
||||||
break;
|
break;
|
||||||
case CODEC_ID_MPEG4:
|
case AV_CODEC_ID_MPEG4:
|
||||||
case CODEC_ID_H263:
|
case AV_CODEC_ID_H263:
|
||||||
/*
|
/*
|
||||||
p = VaapiFindProfile(profiles, profile_n,
|
p = VaapiFindProfile(profiles, profile_n,
|
||||||
VAProfileMPEG4AdvancedSimple);
|
VAProfileMPEG4AdvancedSimple);
|
||||||
*/
|
*/
|
||||||
goto slow_path;
|
goto slow_path;
|
||||||
case CODEC_ID_H264:
|
case AV_CODEC_ID_H264:
|
||||||
// FIXME: can calculate level 4.1 limits
|
// FIXME: can calculate level 4.1 limits
|
||||||
// vdpau supports only 16 references
|
// vdpau supports only 16 references
|
||||||
max_refs = 16;
|
max_refs = 16;
|
||||||
@ -7103,12 +7114,12 @@ static enum PixelFormat Vdpau_get_format(VdpauDecoder * decoder,
|
|||||||
VdpauCheckProfile(decoder, VDP_DECODER_PROFILE_H264_MAIN);
|
VdpauCheckProfile(decoder, VDP_DECODER_PROFILE_H264_MAIN);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CODEC_ID_WMV3:
|
case AV_CODEC_ID_WMV3:
|
||||||
/*
|
/*
|
||||||
p = VaapiFindProfile(profiles, profile_n, VAProfileVC1Main);
|
p = VaapiFindProfile(profiles, profile_n, VAProfileVC1Main);
|
||||||
*/
|
*/
|
||||||
goto slow_path;
|
goto slow_path;
|
||||||
case CODEC_ID_VC1:
|
case AV_CODEC_ID_VC1:
|
||||||
/*
|
/*
|
||||||
p = VaapiFindProfile(profiles, profile_n, VAProfileVC1Advanced);
|
p = VaapiFindProfile(profiles, profile_n, VAProfileVC1Advanced);
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user