diff options
author | Johns <johns98@gmx.net> | 2015-11-03 11:39:41 +0100 |
---|---|---|
committer | Johns <johns98@gmx.net> | 2015-11-03 11:39:41 +0100 |
commit | 6dfa88aecf1b5a4c5932ba278209d9f22676547f (patch) | |
tree | 9eac4ed3a9ba7ded4dbabb7d1339fa627a399ef9 | |
parent | ee2311d25237b9828c1423505e5d4055a836414d (diff) | |
download | vdr-plugin-softhddevice-6dfa88aecf1b5a4c5932ba278209d9f22676547f.tar.gz vdr-plugin-softhddevice-6dfa88aecf1b5a4c5932ba278209d9f22676547f.tar.bz2 |
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | codec.c | 65 | ||||
-rw-r--r-- | codec.h | 4 | ||||
-rw-r--r-- | po/de_DE.po | 4 | ||||
-rw-r--r-- | softhddev.c | 24 |
5 files changed, 59 insertions, 39 deletions
@@ -1,6 +1,7 @@ User johns Date: + Preparations for new ffmpeg VDPAU API. Added VDPAU multi decoder loop changes to VA-API code. Reenabled VA-API auto detection. Check and enforce USE_PIP is defined, for new code. @@ -65,6 +65,7 @@ #define AVCodecID CodecID #define AV_CODEC_ID_AC3 CODEC_ID_AC3 #define AV_CODEC_ID_EAC3 CODEC_ID_EAC3 +#define AV_CODEC_ID_MPEG2VIDEO CODEC_ID_MPEG2VIDEO #define AV_CODEC_ID_H264 CODEC_ID_H264 #endif #include <libavcodec/vaapi.h> @@ -419,22 +420,39 @@ void CodecVideoDelDecoder(VideoDecoder * decoder) ** Open video decoder. ** ** @param decoder private video decoder -** @param name video codec name -** @param codec_id video codec id, used if name == NULL +** @param codec_id video codec id */ -void CodecVideoOpen(VideoDecoder * decoder, const char *name, int codec_id) +void CodecVideoOpen(VideoDecoder * decoder, int codec_id) { AVCodec *video_codec; + const char *name; - Debug(3, "codec: using video codec %s or ID %#06x\n", name, codec_id); + Debug(3, "codec: using video codec ID %#06x (%s)\n", codec_id, + avcodec_get_name(codec_id)); if (decoder->VideoCtx) { Error(_("codec: missing close\n")); } +#if 1 + // FIXME: old vdpau API: should be updated to new API + name = NULL; + if (!strcasecmp(VideoGetDriverName(), "vdpau")) { + switch (codec_id) { + case AV_CODEC_ID_MPEG2VIDEO: + name = VideoHardwareDecoder < 0 ? "mpegvideo_vdpau" : NULL; + break; + case AV_CODEC_ID_H264: + name = VideoHardwareDecoder ? "h264_vdpau" : NULL; + break; + } + } if (name && (video_codec = avcodec_find_decoder_by_name(name))) { Debug(3, "codec: vdpau decoder found\n"); - } else if (!(video_codec = avcodec_find_decoder(codec_id))) { + } else +#endif + + if (!(video_codec = avcodec_find_decoder(codec_id))) { Fatal(_("codec: codec ID %#06x not found\n"), codec_id); // FIXME: none fatal } @@ -473,7 +491,7 @@ void CodecVideoOpen(VideoDecoder * decoder, const char *name, int codec_id) decoder->VideoCtx->opaque = decoder; // our structure - Debug(3, "codec: video '%s'\n", decoder->VideoCtx->codec_name); + Debug(3, "codec: video '%s'\n", decoder->VideoCodec->long_name); if (codec_id == AV_CODEC_ID_H264) { // 2.53 Ghz CPU is too slow for this codec at 1080i //decoder->VideoCtx->skip_loop_filter = AVDISCARD_ALL; @@ -536,9 +554,15 @@ void CodecVideoOpen(VideoDecoder * decoder, const char *name, int codec_id) // // Prepare frame buffer for decoder // +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56,28,1) + if (!(decoder->Frame = av_frame_alloc())) { + Fatal(_("codec: can't allocate video decoder frame buffer\n")); + } +#else if (!(decoder->Frame = avcodec_alloc_frame())) { - Fatal(_("codec: can't allocate decoder frame\n")); + Fatal(_("codec: can't allocate video decoder frame buffer\n")); } +#endif // reset buggy ffmpeg/libav flag decoder->GetFormatDone = 0; #ifdef FFMPEG_WORKAROUND_ARTIFACTS @@ -554,7 +578,12 @@ void CodecVideoOpen(VideoDecoder * decoder, const char *name, int codec_id) void CodecVideoClose(VideoDecoder * video_decoder) { // FIXME: play buffered data +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56,28,1) + av_frame_free(&video_decoder->Frame); // callee does checks +#else av_freep(&video_decoder->Frame); +#endif + if (video_decoder->VideoCtx) { pthread_mutex_lock(&CodecLockMutex); avcodec_close(video_decoder->VideoCtx); @@ -674,6 +703,11 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt) } } #endif + + // new AVFrame API +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56,28,1) + av_frame_unref(frame); +#endif } /** @@ -820,19 +854,16 @@ void CodecAudioDelDecoder(AudioDecoder * decoder) ** Open audio decoder. ** ** @param audio_decoder private audio decoder -** @param name audio codec name -** @param codec_id audio codec id, used if name == NULL +** @param codec_id audio codec id */ -void CodecAudioOpen(AudioDecoder * audio_decoder, const char *name, - int codec_id) +void CodecAudioOpen(AudioDecoder * audio_decoder, int codec_id) { AVCodec *audio_codec; - Debug(3, "codec: using audio codec %s or ID %#06x\n", name, codec_id); + Debug(3, "codec: using audio codec ID %#06x (%s)\n", codec_id, + avcodec_get_name(codec_id)); - if (name && (audio_codec = avcodec_find_decoder_by_name(name))) { - Debug(3, "codec: audio decoder '%s' found\n", name); - } else if (!(audio_codec = avcodec_find_decoder(codec_id))) { + if (!(audio_codec = avcodec_find_decoder(codec_id))) { Fatal(_("codec: codec ID %#06x not found\n"), codec_id); // FIXME: errors aren't fatal } @@ -843,7 +874,7 @@ void CodecAudioOpen(AudioDecoder * audio_decoder, const char *name, } if (CodecDownmix) { -#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53,61,100) || FF_API_REQUEST_CHANNELS +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53,61,100) audio_decoder->AudioCtx->request_channels = 2; #endif audio_decoder->AudioCtx->request_channel_layout = @@ -877,7 +908,7 @@ void CodecAudioOpen(AudioDecoder * audio_decoder, const char *name, } #endif pthread_mutex_unlock(&CodecLockMutex); - Debug(3, "codec: audio '%s'\n", audio_decoder->AudioCtx->codec_name); + Debug(3, "codec: audio '%s'\n", audio_decoder->AudioCodec->long_name); if (audio_codec->capabilities & CODEC_CAP_TRUNCATED) { Debug(3, "codec: audio can use truncated packets\n"); @@ -61,7 +61,7 @@ extern VideoDecoder *CodecVideoNewDecoder(VideoHwDecoder *); extern void CodecVideoDelDecoder(VideoDecoder *); /// Open video codec. -extern void CodecVideoOpen(VideoDecoder *, const char *, int); +extern void CodecVideoOpen(VideoDecoder *, int); /// Close video codec. extern void CodecVideoClose(VideoDecoder *); @@ -79,7 +79,7 @@ extern AudioDecoder *CodecAudioNewDecoder(void); extern void CodecAudioDelDecoder(AudioDecoder *); /// Open audio codec. -extern void CodecAudioOpen(AudioDecoder *, const char *, int); +extern void CodecAudioOpen(AudioDecoder *, int); /// Close audio codec. extern void CodecAudioClose(AudioDecoder *); diff --git a/po/de_DE.po b/po/de_DE.po index a0a32c7..34a4a65 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: VDR \n" "Report-Msgid-Bugs-To: <see README>\n" -"POT-Creation-Date: 2015-09-30 10:48+0200\n" +"POT-Creation-Date: 2015-10-20 14:39+0200\n" "PO-Revision-Date: blabla\n" "Last-Translator: blabla\n" "Language-Team: blabla\n" @@ -270,7 +270,7 @@ msgstr "" msgid "codec: can't open video codec!\n" msgstr "" -msgid "codec: can't allocate decoder frame\n" +msgid "codec: can't allocate video decoder frame buffer\n" msgstr "" msgid "codec: can't allocate audio decoder\n" diff --git a/softhddev.c b/softhddev.c index bc0a3a4..8881600 100644 --- a/softhddev.c +++ b/softhddev.c @@ -80,12 +80,6 @@ static void DumpMpeg(const uint8_t * data, int size); // Variables ////////////////////////////////////////////////////////////////////////////// -#ifdef USE_VDPAU -static char VdpauDecoder = 1; ///< vdpau decoder used -#else -#define VdpauDecoder 0 ///< no vdpau decoder configured -#endif - extern int ConfigAudioBufferTime; ///< config size ms of audio buffer extern int ConfigVideoClearOnSwitch; //< clear decoder on channel switch char ConfigStartX11Server; ///< flag start the x11 server @@ -707,7 +701,7 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size, Debug(3, "pesdemux: new codec %#06x -> %#06x\n", AudioCodecID, codec_id); CodecAudioClose(MyAudioDecoder); - CodecAudioOpen(MyAudioDecoder, NULL, codec_id); + CodecAudioOpen(MyAudioDecoder, codec_id); AudioCodecID = codec_id; } av_init_packet(avpkt); @@ -880,7 +874,7 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size, (q[5] & 0x7) + 1); // FIXME: support resample } - //CodecAudioOpen(MyAudioDecoder, NULL, AV_CODEC_ID_PCM_DVD); + //CodecAudioOpen(MyAudioDecoder, AV_CODEC_ID_PCM_DVD); AudioCodecID = AV_CODEC_ID_PCM_DVD; } pesdx->State = PES_LPCM_PAYLOAD; @@ -1143,7 +1137,7 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id) (p[5] & 0x7) + 1); // FIXME: support resample } - //CodecAudioOpen(MyAudioDecoder, NULL, AV_CODEC_ID_PCM_DVD); + //CodecAudioOpen(MyAudioDecoder, AV_CODEC_ID_PCM_DVD); AudioCodecID = AV_CODEC_ID_PCM_DVD; } @@ -1216,7 +1210,7 @@ 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, NULL, codec_id); + CodecAudioOpen(MyAudioDecoder, codec_id); AudioCodecID = codec_id; } av_init_packet(avpkt); @@ -1940,16 +1934,13 @@ int VideoDecodeInput(VideoStream * stream) case AV_CODEC_ID_MPEG2VIDEO: if (stream->LastCodecID != AV_CODEC_ID_MPEG2VIDEO) { stream->LastCodecID = AV_CODEC_ID_MPEG2VIDEO; - CodecVideoOpen(stream->Decoder, VideoHardwareDecoder < 0 - && VdpauDecoder ? "mpegvideo_vdpau" : NULL, - AV_CODEC_ID_MPEG2VIDEO); + CodecVideoOpen(stream->Decoder, AV_CODEC_ID_MPEG2VIDEO); } break; case AV_CODEC_ID_H264: if (stream->LastCodecID != AV_CODEC_ID_H264) { stream->LastCodecID = AV_CODEC_ID_H264; - CodecVideoOpen(stream->Decoder, VideoHardwareDecoder - && VdpauDecoder ? "h264_vdpau" : NULL, AV_CODEC_ID_H264); + CodecVideoOpen(stream->Decoder, AV_CODEC_ID_H264); } break; default: @@ -2013,9 +2004,6 @@ int VideoGetBuffers(const VideoStream * stream) static void StartVideo(void) { VideoInit(X11DisplayName); -#ifdef USE_VDPAU - VdpauDecoder = !strcasecmp(VideoGetDriverName(), "vdpau"); -#endif if (ConfigFullscreen) { // FIXME: not good looking, mapped and then resized. |