158 Commits
0.1.2 ... 0.4.8

Author SHA1 Message Date
Johns
a7f0cf6d6f Version 0.4.8 released. 2012-02-16 09:59:40 +01:00
Johns
346953d209 Fix message, if no hq scaling is supported. 2012-02-16 09:58:13 +01:00
Johns
97af9c6de2 Fix bug: wrong start of video packet. 2012-02-15 22:19:50 +01:00
Johns
8dd95dab5e VDPAU: Enable inverse telecine configuration. 2012-02-14 22:29:17 +01:00
Johns
6775173e4f Fix bug: local id variable overwrites argument. 2012-02-14 21:51:13 +01:00
Johns
9170fcf485 Removed stupid gcc warnings. 2012-02-14 21:48:42 +01:00
Johns
919428cb80 Find AC3 (Dolby Digital) inside PES packet. 2012-02-14 21:18:24 +01:00
Johns
4331692ee5 Fix bug: audio increments invalid audio PTS. 2012-02-14 16:03:08 +01:00
Johns
5aa826bdb0 Fix bug: dvd plugin not working. 2012-02-14 15:12:48 +01:00
Johns
6736db082e Fix bug: used frame-> instead of video_ctx->. 2012-02-14 14:46:49 +01:00
Johns
807b4df381 Release Version 0.4.7. 2012-02-13 23:21:11 +01:00
56edfd4f54 Fix bug: unscaled jpeg includes PNG header. 2012-02-13 20:15:25 +01:00
Johns
0a1a258d2a Update dependencies and install README. 2012-02-13 14:58:26 +01:00
Johns
09a0880d07 Update readme for new featurs. 2012-02-13 14:25:38 +01:00
Johns
a98a4adc7e Studio levels could be configured in setup menu. 2012-02-13 14:13:24 +01:00
Johns
f872f54e2a Window defaults to fullscreen without geometry. 2012-02-13 14:00:53 +01:00
33c638d538 Jpeg screengrab use VDR RgbToJpeg function. 2012-02-12 20:30:50 +01:00
Johns
0a2a221fa9 Add play/pause audio support. 2012-02-12 20:14:43 +01:00
Johns
24a065e5de Fix bug: audible glitch toggling AC-3 pass-through 2012-02-12 17:50:10 +01:00
Johns
6df970ca9e Fix bug: mpeg stills not displayed. 2012-02-12 16:57:32 +01:00
Johns
616cd9e133 Forgot to reenable FindAudioSync. 2012-02-11 18:29:20 +01:00
Johns
a91533f6d1 Detect audio stream type only after stream switch. 2012-02-11 18:22:48 +01:00
Johns
baa4500a2c Detect more h264 streams with leading zeros. 2012-02-11 17:18:44 +01:00
Johns
f28a737a9a VDPAU: support for studio levels added. 2012-02-10 15:47:52 +01:00
Johns
19cec561ba Fix bug #876: Keypad not working. 2012-02-10 10:43:31 +01:00
Johns
d8f63adaad Software deinterlacer (config/skip chroma deint):
Add support for skip chroma deinterlace to software deinterlacer.
Type of software deinterlacer now configurable from setup menu.
2012-02-09 21:22:42 +01:00
Johns
8c16466d31 Set mixer channel through command line option 2012-02-09 16:01:36 +01:00
Johns
ced54a5cf1 Fix bug: LFE moved to wrong position. 2012-02-09 00:46:02 +01:00
Johns
08246b5ac3 Guard suspend/resume against multiple calls. 2012-02-08 23:26:49 +01:00
Johns
c3a1de8c7b jpeg_mem_dest only supported by jpeg 8.0. 2012-02-08 22:32:47 +01:00
Johns
918170d00b Add support for AAC LATM audio streams. 2012-02-08 15:19:18 +01:00
Johns
bc50f37c4d Spatial deinterlacer for VA-API. 2012-02-07 18:18:13 +01:00
Johns
09cf1f5c85 Fix bug: alsa+ffmpeg use different channel layout. 2012-02-07 17:08:59 +01:00
Johns
947f6b312e Support more LPCM sample rates and channels. 2012-02-06 23:54:22 +01:00
Johns
99728258f1 Quick&dirty support for mpeg LPCM streams. 2012-02-06 22:58:42 +01:00
Johns
c972f8c4dd Workaround for text2skin undrawn OSD areas. 2012-02-06 20:54:20 +01:00
Johns
7d38dff5bf Detect dvb LPCM stream and ignore it. 2012-02-05 14:17:46 +01:00
Johns
8db8b68edd Makes Workarounds command line configurable. 2012-02-04 16:38:10 +01:00
Johns
00cafd18ed Release Version 0.4.6. 2012-02-02 23:32:51 +01:00
Johns
ab4e89132e Auto-crop improvement and nicer a-v sync display. 2012-02-02 16:01:38 +01:00
Johns
3585f1df19 Increase audio buffer, if bigger audio delay used. 2012-02-02 16:01:08 +01:00
Johns
e258c35537 Makes SkipLines configure in setup menu. 2012-02-02 16:00:26 +01:00
Johns
91dbe46786 Add A-V info output and compile time option. 2012-02-01 23:12:45 +01:00
Johns
a7389111ff Fix bug: VA-API intel software decoder broken. 2012-02-01 18:36:24 +01:00
Johns
27e9a88e2f Video updates and bug fix.
Check if surface is ready in VaapiGetSurface.
Set PTS/DTS only in the first split video packet.
Add support for 4:3 output modes.
Quicker auto-crop after channel switch.
Add auto-crop support for Intel VA-API backend.
Fix bug: Auto-Crop logo skip didn't use displayed width.
2012-02-01 16:50:48 +01:00
Johns
33e9c71aea Removed debug printf. 2012-01-31 20:48:47 +01:00
Johns
bd84e3f3b9 Workaround for mpeg2 FFMpeg+VA-API+Intel GPU hung. 2012-01-31 20:45:09 +01:00
Johns
364cc04736 Fix bug: Only black picture with VA-API hw decoder. 2012-01-30 23:09:53 +01:00
ec4a899bb8 Add support to start the plugin in suspended mode. 2012-01-30 17:03:15 +01:00
Johns
dab31e2367 Finished rewrite of video code, to support modules. 2012-01-30 15:58:21 +01:00
Johns
e613ff1f7e Add aspect change support to software decoder path 2012-01-29 23:57:22 +01:00
Johns
1886b745e5 Repair software decoder with vaapi vdpau backend. 2012-01-29 19:28:46 +01:00
Johns
422c378a5e Add workaround for Intel VA-API MPEG GPU hung. 2012-01-29 11:28:10 +01:00
Johns
eed708b9ea Release version 0.4.5. 2012-01-28 13:44:50 +01:00
Johns
60a7c36fa6 Add configurable skip lines at video top + bottom. 2012-01-28 01:44:50 +01:00
Johns
4d74ed1bfc Add auto-crop tolerance configuration. 2012-01-27 23:49:05 +01:00
Johns
c3b924a239 Reduces audio latency, increases audio buffer time. 2012-01-27 23:33:10 +01:00
Johns
f8d198636b Video bug fix.
Made video_test working again.
Disabled VA-API Intel vaAssociateSubpicture workaround.
Fix bug: Must release lock for VideoPollEvent.
Allow faster video and audio sync.
Fix bug: Software decoder use vaPutImage with Intel backend.
Fix bug: Artefacts are shown after mpeg2 channel switch.
Fix bug: VideoReleaseSurface called after VideoExit.
2012-01-27 21:08:37 +01:00
Johns
bcf6ecabc1 Support external players. 2012-01-26 15:00:49 +01:00
Johns
9063b4e3ff Add VDPAU display preemption support. 2012-01-25 15:31:49 +01:00
Johns
e3681812bd Remove pass-through test code. 2012-01-25 15:31:18 +01:00
Johns
9d14522121 Add jpeg support to ebuild. 2012-01-25 15:30:22 +01:00
2dff69dc14 Add support for grab jpeg image. 2012-01-24 22:40:06 +01:00
Johns
5668fa22d2 Video cleanup.
More functions uses new module interface.
Fix bug: VaapiOsdExit doesn't deassociate osd surface.
Fix bug: First OSD can show random pixels.
2012-01-24 22:25:33 +01:00
Johns
c7cebe1aeb Wait for X11 exit and kill it, if not. 2012-01-24 22:20:17 +01:00
Johns
037f582bad Fix still picture handling. 2012-01-24 16:37:11 +01:00
Johns
6ca4d3c44f Fix dead-lock in VdpauExit. 2012-01-24 10:02:39 +01:00
Johns
2ac2eb39c6 Workaround for dead-lock in VdpauExit. 2012-01-24 00:32:07 +01:00
Johns
217545542d Add ac3 pass-through device to OSS module. 2012-01-23 20:23:05 +01:00
Johns
5f43803236 VDPAU: Add primitive software scaler to grab image 2012-01-23 20:04:15 +01:00
Johns
993d831190 VA-API: Add auto-crop support. 2012-01-23 15:40:59 +01:00
Johns
1969b2a0a7 Fix bug: close codec missing. 2012-01-22 22:46:52 +01:00
Johns
0fad02285d AC3 device should be called 'ALSA_AC3_DEVICE'. 2012-01-22 20:53:27 +01:00
Johns
9546233175 Suspend can close and open video and audio device. 2012-01-22 20:49:43 +01:00
Johns
98d2e0f728 Cleanups and Codec..Del.. prototypes. 2012-01-22 17:07:08 +01:00
970493fb23 Use different alsa device for AC3/pass-through. 2012-01-22 16:54:22 +01:00
Johns
329dbc5f07 Add dummy player and control for suspend mode. 2012-01-22 11:12:57 +01:00
Johns
bc8a13e1ef Call VdpauMixerSetup only, if mixer setup. 2012-01-21 21:56:19 +01:00
Johns
bd7e6143c7 Buffertime compile time configurable in ms. 2012-01-21 21:46:47 +01:00
Johns
fa27a1c73a Release Version 0.4.0. 2012-01-21 15:56:45 +01:00
Johns
e32857a27a VDPAU: Add screenshot support. 2012-01-20 21:46:22 +01:00
Johns
5ba88bb822 Use common module prefix. 2012-01-20 19:56:06 +01:00
Johns
0422b6aa5a VDPAU: Add auto-crop support. 2012-01-20 15:33:37 +01:00
Johns
eb024558de VDPAU: Changed OSD alpha calculation. 2012-01-19 22:58:02 +01:00
Johns
1593d5dd83 Fix bug: Used VideoSharpen for denoise settings.
Instant update deinterlace/... configuration changes.
2012-01-19 21:28:38 +01:00
Johns
09f62307d4 Fix bug: AudioExit called without AudioInit crash. 2012-01-19 17:01:02 +01:00
Johns
87f7aa63cc Release Version 0.3.5. 2012-01-19 16:01:05 +01:00
Johns
b1ce88923e Small miscellaneous cleanups. 2012-01-19 00:16:15 +01:00
Johns
c6e66e0787 OSD improvements:
Use OSD size equal to video window.
Update only dirty area(s) of OSD.
Show/mix only used area of OSD.
Fix bug: vpdau use previous resolution for deint, ...
2012-01-18 15:15:37 +01:00
Johns
19d4eeed82 Little speed improved Intel VA-API deinterlace. 2012-01-17 18:53:53 +01:00
Johns
9f668c4750 Fix software deinterlace with VA-API. 2012-01-17 17:41:24 +01:00
Johns
e419742a40 OSS needs kernel headers. 2012-01-16 23:55:45 +01:00
Johns
2cacdc6c90 Debug, if vaapi putsurface is too slow. 2012-01-16 23:54:48 +01:00
Johns
6efe558f78 Fix bug: transposed digits 567 should be 576. 2012-01-16 20:20:01 +01:00
Johns
80100299f3 Disable VA-API if init fails. 2012-01-16 17:05:22 +01:00
Johns
5509d768ac Remove double x11-libs/xcb-util-wm. 2012-01-16 16:39:23 +01:00
Johns
c0d0a4ae7c Audio module cleanup (more to come).
Alsa + OSS can be included/build at the same time.
Alsa or OSS can be runtime selected with -a.
Add audio thread support to OSS module.
Add polled audio support to alsa module.
Removed some debug source code.
2012-01-16 15:42:17 +01:00
Johns
e619f5c836 Release Version 0.3.1. 2012-01-15 16:57:03 +01:00
Johns
973fcfe4dd Support BBC-HD (no clean solution). 2012-01-15 14:31:54 +01:00
Johns
eec30433b6 Fix bug: AudioFreeBytes fails if no audio ready. 2012-01-13 22:39:04 +01:00
Johns
baf577aba5 Fix bug: snd_pcm_state: Assertion `pcm' failed. 2012-01-13 19:33:59 +01:00
Johns
81d7ef9755 Support xcb_ewmh.h for xcb-util <0.3.8. 2012-01-13 17:20:43 +01:00
Johns
7f7de8678f Add support for fullscreen mode. 2012-01-13 16:31:29 +01:00
Johns
92bb00c410 Add vaapi color space conversion. 2012-01-13 12:28:56 +01:00
Johns
d3b98b90f4 Fix bug: devision by zero in ...UpdateOutput, 2012-01-13 10:04:26 +01:00
Johns
788636ee6b Destroy vdpau surface only, when initialized. 2012-01-13 00:58:30 +01:00
Johns
8e53cbd4a9 VAAPI: Instant use new deinterlace configuration. 2012-01-12 23:07:06 +01:00
Johns
54661f90ea Weave is deinterlace disabled. 2012-01-12 20:54:49 +01:00
Johns
30d8e8afe9 Fix subtitle position. 2012-01-12 18:55:07 +01:00
Johns
19a37bb0bf Add SVDRP support. 2012-01-12 15:20:01 +01:00
Johns
2087968d55 Rebuild objects, when Makefile changes. 2012-01-12 15:19:19 +01:00
Johns
d983f780b3 Suspend when user is inactive. 2012-01-11 18:01:18 +01:00
712b2e0de1 Patch collection from Christian Ruppert.
Move objects before $LIBS to avoid link failures with --as-needed.
Do not override CFLAGS for video test.
Rearrange *FLAGS incl. some minor fixes.
Don't override VDRDIR, LIBDIR and TMPDIR in makefile.
Don't abuse LDFLAGS in makefile.
Define CC in makefile.
Include GL/gl.h for the GL_COLOR_BUFFER_BIT definition.
VideoInit() needs an argument.
2012-01-10 22:48:42 +01:00
Johns
54f92e67fc Don't mute hardware while replaying. 2012-01-10 16:41:46 +01:00
Johns
960cd27ab5 Add support for close and resize x11 window. 2012-01-10 15:53:54 +01:00
Johns
3a97700981 Add main menu entry, which suspends the plugin. 2012-01-10 15:52:07 +01:00
Johns
8d624224e9 Version 0.3.0 released. 2012-01-09 22:10:42 +01:00
Johns
96eefca699 Video improvements.
Fix generate of video output from StillPicture.
Add support for resolution dependend video parameterts (Deinterlace,
Scaling, Denoise, Sharpen, ...).
2012-01-09 17:03:04 +01:00
Johns
5e005eeff5 Fix audio crash in ThreadExit and snd_pcm_prepare. 2012-01-09 15:31:47 +01:00
Johns
f6df79e8e6 Improved replay of recordings. 2012-01-08 21:46:00 +01:00
Johns
f1551cd321 Ebuild bug fix. 2012-01-08 14:19:48 +01:00
Johns
9568c5bd93 Fix build with vdr without yaepg support. 2012-01-07 23:47:07 +01:00
Johns
fd60c3c132 Support yaepghd video output position change.
And code and comments cleanups.
2012-01-07 22:36:06 +01:00
Johns
7b6d0ecf94 Gentoo ebuild. 2012-01-07 17:30:27 +01:00
Johns
cac1e5ce17 Release Version 0.2.0. 2012-01-07 13:21:27 +01:00
Johns
d6e2d04505 Fix compiler error with -DDEBUG. 2012-01-07 03:13:33 +01:00
Johns
45a34a3381 Add support for ac3 audio pass through. 2012-01-07 03:05:43 +01:00
Johns
92ffd978b0 Add workaround for alsa not playing hdmi sound.
Without open/close pcm, hdmi is quiet after second snd_pcm_set_params.
2012-01-07 02:35:49 +01:00
Johns
878813f206 Fix bug: broken device plugin stop and exit. 2012-01-06 15:39:32 +01:00
Johns
cb2314837c uwm window manager hide cursor workaround. 2012-01-06 15:37:21 +01:00
Johns
820c246148 Fix bug: old surface stay in video ringbuffer. 2012-01-05 22:55:57 +01:00
Johns
8dda2a0b8a Show transparent cursor to hide cursor. 2012-01-05 22:33:14 +01:00
Johns
761c06eac1 Add color standard support to vdpau. 2012-01-05 20:24:18 +01:00
Johns
0776bc5ee4 VDPAU improvements.
Add denoise, sharpness, skip chroma deinterlace support.
Show OSD only if something is to display, improves performance.
Add deinterlace mode with only 4 surfaces.
2012-01-05 17:20:44 +01:00
Johns
aba14813c0 Add OSS Mixer support. 2012-01-04 16:59:48 +01:00
Johns
0f449c2394 Remove warnings, reduce debug informations. 2012-01-04 16:58:35 +01:00
Johns
9a30d387a1 Crash and thread fixes.
Check if PTS is valid, otherwise debug code does false abort.
Fix bug: audio new stream is not thread safe.
2012-01-03 22:10:04 +01:00
Johns
c8e70ec0fe Audio update.
Alsa: report needed down sampling of 3/5/6 to 2 channels.
Moved alsa code into alsa module.
Initial OSS output support.
2012-01-03 21:42:39 +01:00
Johns
5546354cc7 Version bump. 2012-01-02 19:31:08 +01:00
Johns
442e021d87 Lock av_open/close calls.
New ffmpeg dislikes simultaneous open/close from audio/video.
Prepared audio decoder without av_parser_parse2.
Handle av_audio_resample_init errors.
2012-01-02 17:47:50 +01:00
Johns
4301718329 Documents updates. 2012-01-02 15:27:03 +01:00
Johns
3b7688b78b Print debug only, if compiled with -DDEBUG. 2012-01-02 15:21:58 +01:00
Johns
d2606a5d5f Search audio sync inside PES packets. 2012-01-01 21:14:15 +01:00
Johns
0d63fac2e8 Use only the needed number of surfaces.
Fix problem with video-xvba and too many surfaces used.
Prepare new audio driver "oss".
2011-12-31 18:55:07 +01:00
Johns
c8c760a069 Make pthread_setname_np optional for older glibc. 2011-12-31 17:28:58 +01:00
Johns
0c7170989d Remove warning, when building without vdpau. 2011-12-30 21:50:58 +01:00
Johns
12bfab3f10 Name threads for easier debugging. 2011-12-30 16:47:57 +01:00
Johns
bded2ae5df Prepared vdpau noise reduction support. 2011-12-29 19:45:00 +01:00
Johns
1f2d1d235e Vpdau displays black, when no video available. 2011-12-29 17:47:21 +01:00
Johns
f179264468 Fix bug: CodecVideoDecode destroys avpkt. 2011-12-29 13:43:12 +01:00
Johns
23300b0383 Add missing VdpauDecoderDestroy. 2011-12-29 00:55:57 +01:00
Johns
baf10db48e Cleanup video packet ringbuffer. 2011-12-26 14:27:12 +01:00
Johns
7fbfe0396e Allow build without VDPAU. 2011-12-26 14:25:42 +01:00
Johns
a5c28b9fe2 Fix bug: swapped end and start. 2011-12-25 17:23:29 +01:00
Johns
7f0ad63209 Support other than "PCM" alsa mixer channels. 2011-12-25 15:36:04 +01:00
Johns
10ab0274ab Show time used for VdpDecoderRender. 2011-12-25 11:50:17 +01:00
Johns
83413c1adf Use only one thread for hw decoding. 2011-12-25 11:36:02 +01:00
Johns
63d18ea488 Fix bug: wrong aspect video size calculation. 2011-12-25 11:35:18 +01:00
15 changed files with 9474 additions and 2306 deletions

236
ChangeLog
View File

@@ -1,4 +1,240 @@
User johns
Date: Thu Feb 16 09:59:14 CET 2012
Release Version 0.4.8
Fix bug: wrong start of video packet.
VDPAU: Enables inverse telecine configuration.
Find AC3 (Dolby Digital) inside PES packet.
Fix bug: audio increments invalid audio PTS.
Fix bug: dvd plugin not working.
Fix bug: used frame-> instead of video_ctx-> for old libav/ffmpeg.
User johns
Date: Mon Feb 13 23:20:26 CET 2012
Release Version 0.4.7
User FireFly
Date: Mon Feb 13 20:14:11 CET 2012
Fix bug: unscaled jpeg includes PNG header.
User johns
Date: Mon Feb 13 14:58:26 CET 2012
VDPAU: Studio levels could be configured in the setup menu.
Window size defaults to fullscreen, if no geometry is given.
User m.Rcu
Date: Sun Feb 12 20:28:22 CET 2012
Jpeg screengrab use VDR RgbToJpeg function.
User johns
Date: Sun Feb 12 20:14:43 CET 2012
Add play/pause audio support.
Fix bug: audible glitch when switching AC-3 pass-through <-> none.
Fix bug: mpeg stills not displayed.
Detect audio stream type only after stream switch.
Detect more h264 streams with leading zeros.
VDPAU: support for studio levels added.
Add support for skip chroma deinterlace to software deinterlacer.
Type of software deinterlacer now configurable from setup menu.
Mixer channel could be set through command line option.
Fix bug: LFE moved to wrong position.
Guard suspend/resume against multiple calls.
Add support for AAC LATM audio streams.
Fix bug: alsa and ffmpeg use different channel layout.
Support more LPCM sample rates and number of channels.
Quick&dirty support for mpeg LPCM streams.
Workaround for text2skin undrawn OSD areas.
Detect dvb LPCM stream and ignore it.
User johns
Date: Thu Feb 2 23:29:35 CET 2012
Release Version 0.4.6
Warn only on the first duplicated frame in sequence.
Increase audio buffer, if bigger audio delay is used.
Makes SkipLines configure in setup menu.
Auto-crop only enabled with normal 4:3 display mode.
Vaapi updates OSD when cropping changes.
Add A-V info output and compile time option.
Fix bug: VA-API intel software decoder broken by aspect commit.
Add support for 4:3 output modes.
Quicker auto-crop after channel switch.
Add auto-crop support for Intel VA-API backend.
Fix bug: Auto-Crop logo skip didn't use displayed width.
Workaround for mpeg2 FFMpeg + VA-API + Intel GPU hung.
Fix bug: Missing vaSyncSurface and vaDestroyImage.
Fix bug: Only black picture with VA-API hw decoder.
User HelAu
Date: Mon Jan 30 16:54:47 CET 2012
Add support to start the plugin in suspended mode.
User johns
Date: Mon Jan 30 15:58:21 CET 2012
Finished rewrite of video code, to support output modules.
Add aspect change support to software decoder path.
Repair software decoder with vaapi vdpau backend.
Add workaround for Intel VA-API MPEG GPU hung.
User johns
Date: Sat Jan 28 13:32:12 CET 2012
Release Version 0.4.5
Add configurable skip lines at video top and bottom.
Add auto-crop tolerance configuration.
Reduces audio latency, increases audio buffer time.
Made video_test working again.
Disabled VA-API Intel vaAssociateSubpicture workaround.
Fix bug: Must release lock for VideoPollEvent.
Allow faster video and audio sync.
Fix bug: Software decoder use vaPutImage with intel backend.
Fix bug: Artefacts are shown after mpeg2 channel switch.
Fix bug: VideoReleaseSurface called after VideoExit.
Support external players.
Add VDPAU display preemption support.
User m.Rcu
Date: Tue Jan 24 22:38:30 CET 2012
Add support for grab jpeg image.
User johns
Date: Tue Jan 24 22:25:33 CET 2012
Fix bug: VaapiOsdExit doesn't deassociate osd surface.
Fix bug: First OSD can show random pixels.
Wait for X11 exit and kill it, if not.
Fix still picture handling.
Fix for dead-lock in VdpauExit.
Workaround for dead-lock in VdpauExit.
VDPAU: Add very primitive software scaler for grab image.
VA-API: Add auto-crop support.
Suspend can close/open X11 window, connection and audio device.
User Morone
Date: Sun Jan 22 16:43:23 CET 2012
Use different alsa devices for AC3/pass-through and pcm.
User johns
Date: Sun Jan 22 11:12:57 CET 2012
Add dummy player and control for suspend mode.
Buffertime compile time configurable in ms.
Date: Sat Jan 21 15:49:16 CET 2012
Release Version 0.4.0
VDPAU: Add grab image support.
VDPAU: Add auto-crop support.
VDPAU: Changed OSD alpha calculation.
Fix bug: Used VideoSharpen for denoise settings.
Instant update deinterlace/... configuration changes.
Fix bug: AudioExit called without AudioInit crash.
Date: Thu Jan 19 15:58:40 CET 2012
Release Version 0.3.5
OSD improvements:
Use OSD size equal to video window.
Update only dirty area(s) of OSD.
Show/mix only used area of OSD.
Fix bug: vpdau use previous resolution for deint, ...
Fix software deinterlace with VA-API.
Fix bug: transposed digits 567 should be 576.
Audio module cleanup:
Alsa + OSS can be included/build at the same time.
Alsa or OSS can be runtime selected with -a.
Add audio thread support to OSS module.
Add polled audio support to alsa module.
Removed some debug source code.
Date: Sun Jan 15 16:56:04 CET 2012
Release Version 0.3.1
Fix bug: AudioFreeBytes didn't check if audio running/compiled.
Fix bug: snd_pcm_state: Assertion `pcm' failed.
Add support for fullscreen and fullscreen toogle.
Instant update deinterlace configuration changes.
Fix subtitle position.
Add SVDRP support.
Suspend when user is inactive.
User Christian Rupper
Date: Tue Jan 10 22:33:14 CET 2012
Move objects before $LIBS to avoid link failures with --as-needed.
Do not override CFLAGS for video test.
Rearrange *FLAGS incl. some minor fixes.
Don't override VDRDIR, LIBDIR and TMPDIR in makefile.
Don't abuse LDFLAGS in makefile.
Define CC in makefile.
Include GL/gl.h for the GL_COLOR_BUFFER_BIT definition.
VideoInit() needs an argument.
User johns
Date: Tue Jan 10 22:32:50 CET 2012
Add main menu entry, which suspends the plugin.
Add support for resize window.
Close window sends "close" as remote key press.
Date: Mon Jan 9 22:09:38 CET 2012
Release Version 0.3.0
Add support of resolution dependend video parameters (deint, scale, ...).
Add support for recording play back.
Add workaround for alsa crash in snd_pcm_prepare.
Fix bug: audio crash on exit.
Fix build with vdr without yaepg support.
Support yaepghd video picture output position change.
Date: Sat Jan 7 13:20:07 CET 2012
Release Version 0.2.0
Add support for ac3 audio pass through.
Add workaround for alsa not playing hdmi sound.
Fix bug: broken device plugin stop and exit.
Show transparent cursor to hide cursor.
VDPAU: Add color standard support.
VDPAU: Add denoise and sharpness support.
VDPAU: Add skip chroma deinterlace support.
VDPAU: Show OSD only if something is to display, improves performance.
VDPAU: Add deinterlace with only 4 surfaces.
Date: Thu Jan 4 17:00:00 CET 2012
Release Version 0.1.5
Adds OSS mixer support.
Fix bug: audio new stream is not thread safe.
New audio driver OSS.
Fix bug: needed down sampling of 3/5/6 to 2 channels not reported.
Search audio sync inside PES packets, for insane dvb streams.
Use only the needed number of surfaces.
Date: Thu Dec 29 19:44:43 CET 2011
Release Version 0.1.4
Prepared vdpau noise reduction support.
Vdpau also displays a black surface, when no video is available.
Fix bug: CodecVideoDecode destroys avpkt.
Date: Thu Dec 29 00:55:57 CET 2011
Release Version 0.1.3
Add missing VdpauDecoderDestroy.
Cleanup video packet ringbuffer.
Allow build without VDPAU.
Fix bug: swapped end and start.
Support other than "PCM" alsa mixer channels.
Date: Sat Dec 24 15:26:27 CET 2011
Release Version 0.1.2

View File

@@ -14,36 +14,32 @@ PLUGIN = softhddevice
### The version number of this plugin (taken from the main source file):
VERSION = $(shell grep 'static const char \*const VERSION *=' $(PLUGIN).cpp | awk '{ print $$7 }' | sed -e 's/[";]//g')
GIT_REV = $(shell git describe --always 2>/dev/null)
### Configuration (edit this for your needs)
CONFIG := #-DDEBUG
CONFIG += $(shell pkg-config --exists libva && echo "-DUSE_VAAPI")
CONFIG += -DAV_INFO
#CONFIG += -DHAVE_PTHREAD_NAME
CONFIG += $(shell pkg-config --exists vdpau && echo "-DUSE_VDPAU")
CONFIG += $(shell pkg-config --exists libva && echo "-DUSE_VAAPI")
CONFIG += $(shell pkg-config --exists alsa && echo "-DUSE_ALSA")
CONFIG += -DUSE_OSS
### The C++ compiler and options:
CXX ?= g++
CXXFLAGS ?= -g -O2 -W -Wall -Wextra -Woverloaded-virtual -fPIC
override CXXFLAGS += $(DEFINES) $(INCLUDES)
CFLAGS ?= -g -O2 -W -Wall -Wextra -Winit-self \
-Wdeclaration-after-statement -fPIC
#CFLAGS += -Werror
override CFLAGS += $(DEFINES) $(INCLUDES) \
$(shell pkg-config --cflags alsa libavcodec libavformat)
override LDFLAGS += -lrt \
$(shell pkg-config --libs alsa libavcodec libavformat) \
`pkg-config --libs x11 x11-xcb xcb xcb-xv xcb-shm xcb-dpms xcb-atom\
xcb-screensaver xcb-randr xcb-glx xcb-icccm xcb-keysyms`\
`pkg-config --libs gl glu` \
`pkg-config --libs vdpau` \
`pkg-config --libs libva-x11 libva-glx libva`
CC ?= gcc
CXX ?= g++
CFLAGS ?= -g -O2 -W -Wall -Wextra -Winit-self \
-Wdeclaration-after-statement \
-ftree-vectorize -msse3 -flax-vector-conversions
CXXFLAGS ?= -g -O2 -W -Wall -Wextra -Woverloaded-virtual
### The directory environment:
VDRDIR = ../../..
LIBDIR = ../../lib
TMPDIR = /tmp
VDRDIR ?= ../../..
LIBDIR ?= ../../lib
TMPDIR ?= /tmp
### Make sure that necessary options are included:
@@ -62,11 +58,40 @@ APIVERSION = $(shell sed -ne '/define APIVERSION/s/^.*"\(.*\)".*$$/\1/p' $(VDRDI
ARCHIVE = $(PLUGIN)-$(VERSION)
PACKAGE = vdr-$(ARCHIVE)
### Includes and Defines (add further entries here):
### Includes, Defines and dependencies (add further entries here):
INCLUDES += -I$(VDRDIR)/include
DEFINES += $(CONFIG) -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"'
DEFINES += $(CONFIG) -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"$(PLUGIN)"' \
$(if $(GIT_REV), -DGIT_REV='"$(GIT_REV)"')
_CFLAGS = $(DEFINES) $(INCLUDES) \
$(shell pkg-config --cflags libavcodec libavformat) \
`pkg-config --cflags x11 x11-xcb xcb xcb-xv xcb-shm xcb-dpms xcb-atom\
xcb-screensaver xcb-randr xcb-glx xcb-icccm xcb-keysyms`\
`pkg-config --cflags gl glu` \
$(if $(findstring USE_VDPAU,$(CONFIG)), \
`pkg-config --cflags vdpau`) \
$(if $(findstring USE_VAAPI,$(CONFIG)), \
`pkg-config --cflags libva-x11 libva-glx libva`) \
$(if $(findstring USE_ALSA,$(CONFIG)), \
`pkg-config --cflags alsa`)
#override _CFLAGS += -Werror
override CXXFLAGS += $(_CFLAGS)
override CFLAGS += $(_CFLAGS)
LIBS += -lrt \
$(shell pkg-config --libs libavcodec libavformat) \
`pkg-config --libs x11 x11-xcb xcb xcb-xv xcb-shm xcb-dpms xcb-atom\
xcb-screensaver xcb-randr xcb-glx xcb-icccm xcb-keysyms`\
`pkg-config --libs gl glu` \
$(if $(findstring USE_VDPAU,$(CONFIG)), \
`pkg-config --libs vdpau`) \
$(if $(findstring USE_VAAPI,$(CONFIG)), \
`pkg-config --libs libva-x11 libva-glx libva`) \
$(if $(findstring USE_ALSA,$(CONFIG)), \
`pkg-config --libs alsa`)
### The object files (add further files here):
@@ -89,15 +114,17 @@ DEPFILE = .dependencies
$(DEPFILE): Makefile
@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(SRCS) >$@
$(OBJS): Makefile
-include $(DEPFILE)
### Internationalization (I18N):
PODIR = po
PODIR = po
LOCALEDIR = $(VDRDIR)/locale
I18Npo = $(wildcard $(PODIR)/*.po)
I18Npo = $(wildcard $(PODIR)/*.po)
I18Nmsgs = $(addprefix $(LOCALEDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, $(notdir $(foreach file, $(I18Npo), $(basename $(file))))))
I18Npot = $(PODIR)/$(PLUGIN).pot
I18Npot = $(PODIR)/$(PLUGIN).pot
%.mo: %.po
msgfmt -c -o $@ $<
@@ -121,7 +148,7 @@ i18n: $(I18Nmsgs) $(I18Npot)
### Targets:
libvdr-$(PLUGIN).so: $(OBJS) Makefile
$(CXX) $(CXXFLAGS) -shared $(OBJS) -o $@ $(LDFLAGS)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared -fPIC $(OBJS) -o $@ $(LIBS)
@cp --remove-destination $@ $(LIBDIR)/$@.$(APIVERSION)
dist: $(I18Npo) clean
@@ -146,6 +173,6 @@ indent:
indent $$i; unexpand -a $$i > $$i.up; mv $$i.up $$i; \
done
video_test: video.c
$(CC) -DVIDEO_TEST -DVERSION='"$(VERSION)"' $(CFLAGS) $(LDFLAGS) $(LIBS) \
-O0 -g -o $@ $<
video_test: video.c Makefile
$(CC) -DVIDEO_TEST -DVERSION='"$(VERSION)"' $(CFLAGS) $(LDFLAGS) $< $(LIBS) \
-o $@

View File

@@ -1,6 +1,6 @@
@file README.txt @brief A software HD output device for VDR
Copyright (c) 2011 by Johns. All Rights Reserved.
Copyright (c) 2011, 2012 by Johns. All Rights Reserved.
Contributor(s):
@@ -20,14 +20,24 @@ $Id$
A software and GPU emulated HD output device plugin for VDR.
o Video VA-API/VA-API
o Video VA-API/VA-API (with intel, nvidia and amd backend supported)
o Video CPU/VA-API
o Video VDPAU/VDPAU
o Video CPU/VDPAU
o Audio FFMpeg/Alsa/Analog
o Audio FFMpeg/Alsa/Digital
o Audio FFMpeg/OSS/Analog
o HDMI/SPDIF Passthrough
o VA-API bob software deinterlace
o Auto-crop
o planned: Video VA-API/Opengl
o planned: Video VDPAU/Opengl
o planned: Video CPU/Xv
o planned: Video CPU/Opengl
o planned: Software Deinterlacer
o Audio FFMpeg/Analog
o Audio FFMpeg/Digital
o planned: HDMI/SPDIF Passthrough
o planned: Improved Software Deinterlacer (yadif or/and ffmpeg filters)
o planned: Video XvBA/XvBA
o planned: atmo light support
To compile you must have the 'requires' installed.
@@ -54,34 +64,176 @@ Install:
http://projects.vdr-developer.org/projects/plg-softhddevice/files
tar vxf vdr-softhddevice-*.tar.bz2
cd vdr-softhddevice
cd softhddevice-*
make VDRDIR=<path-to-your-vdr-files> LIBDIR=.
Setup: /etc/vdr/setup.conf
You can edit Makefile to enable/disable VDPAU / VA-API / Alsa / OSS
support.
Setup: environment
------
Following is supported:
softhddevice.Deinterlace = 0
0 = bob, 1 = weave, 2 = temporal, 3 = temporal_spatial, 4 = software
(only 0, 1 supported)
DISPLAY=:0.0
x11 display name
NO_HW=1
if set don't use the hardware decoders
NO_MPEG_HW=1
if set don't use the hardware decoder for mpeg1/2
STUDIO_LEVELS=1
if set use studio levels with vdpau (deprecated use setup)
only if alsa is configured
ALSA_DEVICE=default
alsa PCM device name
ALSA_AC3_DEVICE=
alsa AC3/pass-though device name
ALSA_MIXER=default
alsa control device name
ALSA_MIXER_CHANNEL=PCM
alsa control channel name
only if oss is configured
OSS_AUDIODEV=/dev/dsp
oss dsp device name
OSS_AC3_AUDIODEV=
oss AC3/pass-though device name
OSS_MIXERDEV=/dev/mixer
oss mixer device name
OSS_MIXER_CHANNEL=pcm
oss mixer channel name
Setup: /etc/vdr/setup.conf
------
Following is supported:
softhddevice.MakePrimary = 1
0 = no change, 1 make softhddevice primary at start
softhddevice.Scaling = 0
softhddevice.HideMainMenuEntry = 0
0 = show softhddevice main menu entry, 1 = hide entry
<res> of the next parameters is 576i, 720p, 1080i_fake or 1080i.
1080i_fake is 1280x1080 or 1440x1080
1080i is "real" 1920x1080
softhddevice.<res>.Scaling = 0
0 = normal, 1 = fast, 2 = HQ, 3 = anamorphic
softhddevice.<res>.Deinterlace = 0
0 = bob, 1 = weave, 2 = temporal, 3 = temporal_spatial, 4 = software
(only 0, 1 supported with vaapi)
softhddevice.<res>.SkipChromaDeinterlace = 0
0 = disabled, 1 = enabled (for slower cards, poor qualit<69>t)
softhddevice.<res>.InverseTelecine = 0
0 = disabled, 1 = enabled
softhddevice.<res>.Denoise = 0
0 .. 1000 noise reduction level (0 off, 1000 max)
softhddevice.<res>.Sharpness = 0
-1000 .. 1000 noise reduction level (0 off, -1000 max blur,
1000 max sharp)
softhddevice.AudioDelay = 0
+n or -n ms
softhddevice.AudioPassthrough = 0
0 = none, 1 = AC-3
for AC-3 the pass-through device is used.
softhddevice.AutoCrop.Interval = 0
0 disables auto-crop
n each 'n' frames auto-crop is checked.
softhddevice.AutoCrop.Delay = 0
if auto-crop is over 'n' intervals the same, the cropping is
used.
softhddevice.AutoCrop.Tolerance = 0
if detected crop area is too small, cut max 'n' pixels at top and
bottom.
softhddevice.SkipLines = 0
skip 'n' lines at top and bottom of the video picture.
softhddevice.StudioLevels = 0
0 use PC levels (0-255) with vdpau.
1 use studio levels (16-235) with vdpau.
softhddevice.Suspend.Close = 0
1 suspend closes x11 window, connection and audio device.
(use svdrpsend plug softhddevice RESU to resume, if you have no lirc)
softhddevice.Suspend.X11 = 0
1 suspend stops X11 server (not working yet)
VideoDisplayFormat = ?
0 pan and scan
1 letter box
2 center cut-out
Setup: /etc/vdr/remote.conf
------
Add "XKeySym." definitions to /etc/vdr/remote.conf to control
the vdr and plugin with the connected input device.
fe.
XKeySym.Up Up
XKeySym.Down Down
...
Additional to the x11 input sends the window close button "Close".
fe.
XKeySym.Power Close
Commandline:
------------
Use vdr -h to see the command line arguments supported by the plugin.
-a audio_device
Selects audio output module and device.
"" to disable audio output
/... to use oss audio module (if compiled with oss
support)
other to use alsa audio module (if compiled with alsa
support)
SVDRP:
------
Use 'svdrpsend.pl plug softhddevice HELP' to see the SVDRP commands
help and which are supported by the plugin.
Running:
--------
Click into video window to toggle fullscreen/window mode, only if you
have a window manager running.
Warning:
--------
libav is not supported, expect many bugs with it.
Requires:
---------
media-video/ffmpeg
media-video/ffmpeg (version >=0.7)
Complete solution to record, convert and stream audio and
video. Includes libavcodec.
http://ffmpeg.org
media-libs/alsa-lib
Advanced Linux Sound Architecture Library
http://www.alsa-project.org
or
kernel support for oss/oss4 or alsa oss emulation
x11-libs/libva
Video Acceleration (VA) API for Linux
http://www.freedesktop.org/wiki/Software/vaapi
@@ -92,7 +244,7 @@ Requires:
x11-libs/vdpau-video
VDPAU Backend for Video Acceleration (VA) API
http://www.freedesktop.org/wiki/Software/vaapi
or untested
or
x11-libs/xvba-video
XVBA Backend for Video Acceleration (VA) API
http://www.freedesktop.org/wiki/Software/vaapi
@@ -104,7 +256,7 @@ Requires:
x11-libs/xcb-util-keysyms
X C-language Bindings library
http://xcb.freedesktop.org
Only versions >= 0.3.8 are supported
Only versions >= 0.3.8 are good supported
x11-libs/libX11
X.Org X11 library

135
Todo
View File

@@ -1,52 +1,127 @@
@file Todo @brief A software HD output device for VDR
Copyright (c) 2011, 2012 by Johns. All Rights Reserved.
Contributor(s):
License: AGPLv3
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
$Id: $
missing:
video out with xv
video out with opengl
software decoder for xv / opengl
software deinterlace
auto crop
atmolight
zoom/fit-zoom 4:3
multistream handling
software deinterlace (yadif, ...)
software decoder with software deinterlace
suspend output / energie saver: stop and restart X11
suspend plugin didn't restore full-screen (is this wanted?)
Option deinterlace off / deinterlace force!
ColorSpace aren't configurable with the gui.
Inverse telecine isn't configurable with the gui.
crash:
AudioPlayHandlerThread -> pthread_cond_wait
video:
subtitle not cleared
subtitle could be asyncron
reduce warnings after channel switch
grab image with hardware and better scaling support
hard channel switch
OSD can only be shown after some stream could be shown
yaepghd changed position is lost on channel switch
pause (live tv) has sometime problems with SAT1 HD Pro7 HD
vdpau:
1080i with temporal spatial too slow GT 520
Dr. Dish H264 black picture
software decoder path not working
libva:
yaepghd (VaapiSetOutputPosition) support
can associate only displayed part of osd
grab image for va-api
remove stderr output of libva init
still many: (workaround export NO_MPEG_HW=1)
[drm:i915_hangcheck_elapsed] *ERROR* Hangcheck timer elapsed... GPU hung
[drm:i915_wait_request] *ERROR* i915_wait_request returns -11 ...
libva: branch vaapi-ext
add support for vaapi-ext
libva-intel-driver:
intel still has hangups most with 1080i
1080i does no v-sync (workaround written)
osd has sometimes wrong size (workaround written)
deinterlace only supported with vaapi-ext
1080i does no v-sync (sometimes correct working with vaapi-ext)
OSD has sometimes wrong size (workaround written)
sometimes software decoder deinterlace isn't working and 1080i channels
show artefacts
libva-vdpau-driver:
G210 osd update too slow (needs hardware problem workaround)
OSD update is too slow
G210/GT520 OSD update too slow (needs hardware problem workaround)
hangup on exit (VaapiDelDecoder -> VaapiCleanup
-> vaDestroyContext -> pthread_rwlock_wrlock)
OSD still has some problems with auto-crop and 4:3 zoom.
libva-xvba-driver:
mpeg1/2 needs software decoder fixed
x11:
support resize of x11 window
support fullscreen window
support fullscreen / window toggle
close window should send power button
disable cursor
disable screensaver
skip multiple configure-notify, handle only the last one.
support embedded mode
audio:
write TS -> PES parser, which feeds audio before the next start packet
Combine alsa+oss ringbuffer code.
Make alsa thread/polled and oss thread/polled output module runtime
selectable.
software volume support (could be done with asound.conf)
Mute should do a real mute and not only set volume to zero.
Starting suspended and muted, didn't register the mute.
audio/alsa:
video/audio asyncron
random crash in av_parser_parse2, when switching channels
better downmix of >2 channels on 2 channel hardware
remix support of unsupported sample rates
libav supports only resample of mono to 2 channels
ffmpeg didn't support resample of 5 to 2 channels
playback of >2 channels on 2 channel hardware
done?
audio/oss:
alsa oss emulation mixer "pcm" not working
oss4 mixer channel not working
ring buffer overflow with alsa oss emulation
on some channels it takes long time until sound can be heared.
this channels has packet start not at the beginning of the start packet
HDMI/SPDIF Passthrough:
only AC-3 written
playback of recording
play back is too fast
pause is not reset, when replay exit
replay/pause need 100% cpu
setup:
Setup menu parameters aren't automatic loaded?
Setup parameters are not used until restart.
Setup of decoder type.
Setup of output type.
Setup of display type.
Setup 4:3 zoom type
Some setup parameters are not used until restart.
Can a notice be added to the setup menu?
unsorted:
stoping vdr while plugin is suspended opens and closes a window.
future features (not planed for 1.0 - 1.5)
video out with xv
video out with opengl
video out with xvba
software decoder for xv / opengl
atmolight support
multistream handling
pip support
save and use auto-crop with channel zapping
upmix stereo to AC-3 (supported by alsa plugin)

1935
audio.c

File diff suppressed because it is too large Load Diff

28
audio.h
View File

@@ -1,7 +1,7 @@
///
/// @file audio.h @brief Audio module headerfile
///
/// Copyright (c) 2009 - 2011 by Johns. All Rights Reserved.
/// Copyright (c) 2009 - 2012 by Johns. All Rights Reserved.
///
/// Contributor(s):
///
@@ -28,22 +28,30 @@
//----------------------------------------------------------------------------
extern void AudioEnqueue(const void *, int); ///< buffer audio samples
extern void AudioFlushBuffers(void); ///< flush audio buffers
extern void AudioPoller(void); ///< poll audio events/handling
extern int AudioFreeBytes(void); ///< free bytes in audio output
//extern int AudioFreeBytes(void); ///< free bytes in audio output
//extern int AudioUsedBytes(void); ///< used bytes in audio output
extern uint64_t AudioGetDelay(void); ///< get current audio delay
extern void AudioSetClock(int64_t); ///< set audio clock base
extern int64_t AudioGetClock(); ///< get current audio clock
extern uint64_t AudioGetDelay(void); ///< get current audio delay
extern int AudioSetup(int *, int *); ///< setup audio output
//extern void AudioPlay(void); ///< play audio
//extern void AudioPause(void); ///< pause audio
extern void AudioSetVolume(int); ///< set volume
extern int AudioSetup(int *, int *, int); ///< setup audio output
extern void AudioSetDevice(const char *); ///< set alsa PCM audio device
extern void AudioPlay(void); ///< play audio
extern void AudioPause(void); ///< pause audio
extern void AudioSetDevice(const char *); ///< set PCM audio device
extern void AudioSetDeviceAC3(const char *); ///< set pass-through device
extern void AudioSetChannel(const char *); ///< set mixer channel
extern void AudioInit(void); ///< setup audio module
extern void AudioExit(void); ///< cleanup and exit audio module
//----------------------------------------------------------------------------
// Variables
//----------------------------------------------------------------------------
extern char AudioAlsaDriverBroken; ///< disable broken driver message
/// @}

470
codec.c
View File

@@ -1,7 +1,7 @@
///
/// @file codec.c @brief Codec functions
///
/// Copyright (c) 2009 - 2011 by Johns. All Rights Reserved.
/// Copyright (c) 2009 - 2012 by Johns. All Rights Reserved.
///
/// Contributor(s):
///
@@ -26,9 +26,21 @@
/// This module contains all decoder and codec functions.
/// It is uses ffmpeg (http://ffmpeg.org) as backend.
///
/// It may work with libav (http://libav.org), but the tests show
/// many bugs and incompatiblity in it. Don't use this shit.
///
/**
** use av_parser to support insane dvb audio streams.
*/
#define USE_AVPARSER
/// compile with passthrough support (experimental)
#define USE_PASSTHROUGH
#include <stdio.h>
#include <unistd.h>
#include <endian.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -44,6 +56,11 @@
#include <libavcodec/vdpau.h>
#endif
#ifndef __USE_GNU
#define __USE_GNU
#endif
#include <pthread.h>
#ifdef MAIN_H
#include MAIN_H
#endif
@@ -52,6 +69,18 @@
#include "audio.h"
#include "codec.h"
//----------------------------------------------------------------------------
// Global
//----------------------------------------------------------------------------
///
/// ffmpeg lock mutex
///
/// new ffmpeg dislikes simultanous open/close
/// this breaks our code, until this is fixed use lock.
///
static pthread_mutex_t CodecLockMutex;
//----------------------------------------------------------------------------
// Video
//----------------------------------------------------------------------------
@@ -120,6 +149,7 @@ static int Codec_get_buffer(AVCodecContext * video_ctx, AVFrame * frame)
fmts[1] = PIX_FMT_NONE;
Codec_get_format(video_ctx, fmts);
}
#ifdef USE_VDPAU
// VDPAU: PIX_FMT_VDPAU_H264 .. PIX_FMT_VDPAU_VC1 PIX_FMT_VDPAU_MPEG4
if ((PIX_FMT_VDPAU_H264 <= video_ctx->pix_fmt
&& video_ctx->pix_fmt <= PIX_FMT_VDPAU_VC1)
@@ -151,6 +181,7 @@ static int Codec_get_buffer(AVCodecContext * video_ctx, AVFrame * frame)
}
return 0;
}
#endif
// VA-API:
if (video_ctx->hwaccel_context) {
unsigned surface;
@@ -188,6 +219,7 @@ static int Codec_get_buffer(AVCodecContext * video_ctx, AVFrame * frame)
*/
static void Codec_release_buffer(AVCodecContext * video_ctx, AVFrame * frame)
{
#ifdef USE_VDPAU
// VDPAU: PIX_FMT_VDPAU_H264 .. PIX_FMT_VDPAU_VC1 PIX_FMT_VDPAU_MPEG4
if ((PIX_FMT_VDPAU_H264 <= video_ctx->pix_fmt
&& video_ctx->pix_fmt <= PIX_FMT_VDPAU_VC1)
@@ -209,6 +241,7 @@ static void Codec_release_buffer(AVCodecContext * video_ctx, AVFrame * frame)
return;
}
#endif
// VA-API
if (video_ctx->hwaccel_context) {
VideoDecoder *decoder;
@@ -252,6 +285,7 @@ static void Codec_draw_horiz_band(AVCodecContext * video_ctx,
int type, __attribute__ ((unused))
int height)
{
#ifdef USE_VDPAU
// VDPAU: PIX_FMT_VDPAU_H264 .. PIX_FMT_VDPAU_VC1 PIX_FMT_VDPAU_MPEG4
if ((PIX_FMT_VDPAU_H264 <= video_ctx->pix_fmt
&& video_ctx->pix_fmt <= PIX_FMT_VDPAU_VC1)
@@ -269,8 +303,12 @@ static void Codec_draw_horiz_band(AVCodecContext * video_ctx,
//Debug(3, "codec: %d references\n", vrs->info.h264.num_ref_frames);
VideoDrawRenderState(decoder->HwDecoder, vrs);
return;
}
return;
#else
(void)video_ctx;
(void)frame;
#endif
}
//----------------------------------------------------------------------------
@@ -282,20 +320,30 @@ static void Codec_draw_horiz_band(AVCodecContext * video_ctx,
**
** @param hw_decoder video hardware decoder
**
** @returns private decoder pointer for audio/video decoder.
** @returns private decoder pointer for video decoder.
*/
VideoDecoder *CodecVideoNewDecoder(VideoHwDecoder * hw_decoder)
{
VideoDecoder *decoder;
if (!(decoder = calloc(1, sizeof(*decoder)))) {
Fatal(_("codec: Can't allocate vodeo decoder\n"));
Fatal(_("codec: can't allocate vodeo decoder\n"));
}
decoder->HwDecoder = hw_decoder;
return decoder;
}
/**
** Deallocate a video decoder context.
**
** @param decoder private video decoder
*/
void CodecVideoDelDecoder(VideoDecoder * decoder)
{
free(decoder);
}
/**
** Open video decoder.
**
@@ -309,6 +357,9 @@ void CodecVideoOpen(VideoDecoder * decoder, const char *name, int codec_id)
Debug(3, "codec: using codec %s or ID %#04x\n", name, codec_id);
if (decoder->VideoCtx) {
Error(_("codec: missing close\n"));
}
//
// ffmpeg compatibility hack
//
@@ -337,25 +388,25 @@ void CodecVideoOpen(VideoDecoder * decoder, const char *name, int codec_id)
if (!(decoder->VideoCtx = avcodec_alloc_context3(video_codec))) {
Fatal(_("codec: can't allocate video codec context\n"));
}
// FIXME: for software decoder use all cpus, otherwise 1
decoder->VideoCtx->thread_count = 1;
pthread_mutex_lock(&CodecLockMutex);
// open codec
#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(53,5,0)
if (avcodec_open(decoder->VideoCtx, video_codec) < 0) {
pthread_mutex_unlock(&CodecLockMutex);
Fatal(_("codec: can't open video codec!\n"));
}
#else
if (avcodec_open2(decoder->VideoCtx, video_codec, NULL) < 0) {
pthread_mutex_unlock(&CodecLockMutex);
Fatal(_("codec: can't open video codec!\n"));
}
#endif
pthread_mutex_unlock(&CodecLockMutex);
decoder->VideoCtx->opaque = decoder; // our structure
/*
// FIXME: the number of cpu's should be configurable
// Today this makes no big sense H264 is broken with current streams.
avcodec_thread_init(decoder->VideoCtx, 2); // support dual-cpu's
*/
Debug(3, "codec: video '%s'\n", decoder->VideoCtx->codec_name);
if (codec_id == CODEC_ID_H264) {
// 2.53 Ghz CPU is too slow for this codec at 1080i
@@ -431,7 +482,9 @@ void CodecVideoClose(VideoDecoder * video_decoder)
// FIXME: play buffered data
av_freep(&video_decoder->Frame);
if (video_decoder->VideoCtx) {
pthread_mutex_lock(&CodecLockMutex);
avcodec_close(video_decoder->VideoCtx);
pthread_mutex_unlock(&CodecLockMutex);
av_freep(&video_decoder->VideoCtx);
}
}
@@ -441,9 +494,9 @@ void CodecVideoClose(VideoDecoder * video_decoder)
/**
** Display pts...
**
** ffmpeg 0.9 pts always AV_NOPTS_VALUE
** ffmpeg 0.9 pkt_pts nice monotonic (only with HD)
** ffmpeg 0.9 pkt_dts wild jumping -160 - 340 ms
** ffmpeg-0.9 pts always AV_NOPTS_VALUE
** ffmpeg-0.9 pkt_pts nice monotonic (only with HD)
** ffmpeg-0.9 pkt_dts wild jumping -160 - 340 ms
**
** libav 0.8_pre20111116 pts always AV_NOPTS_VALUE
** libav 0.8_pre20111116 pkt_pts always 0 (could be fixed?)
@@ -478,32 +531,28 @@ void DisplayPts(AVCodecContext * video_ctx, AVFrame * frame)
**
** @param decoder video decoder data
** @param avpkt video packet
**
** @note this version destroys avpkt!!
*/
void CodecVideoDecode(VideoDecoder * decoder, AVPacket * avpkt)
void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
{
AVCodecContext *video_ctx;
AVFrame *frame;
int used;
int got_frame;
AVPacket pkt[1];
video_ctx = decoder->VideoCtx;
frame = decoder->Frame;
*pkt = *avpkt; // use copy
next_part:
// FIXME: this function can crash with bad packets
used = avcodec_decode_video2(video_ctx, frame, &got_frame, avpkt);
Debug(4, "%s: %p %d -> %d %d\n", __FUNCTION__, avpkt->data, avpkt->size,
used, got_frame);
used = avcodec_decode_video2(video_ctx, frame, &got_frame, pkt);
Debug(4, "%s: %p %d -> %d %d\n", __FUNCTION__, pkt->data, pkt->size, used,
got_frame);
if (got_frame) { // frame completed
//DisplayPts(video_ctx, frame);
if (video_ctx->hwaccel_context) {
VideoRenderFrame(decoder->HwDecoder, video_ctx, frame);
} else {
VideoRenderFrame(decoder->HwDecoder, video_ctx, frame);
}
VideoRenderFrame(decoder->HwDecoder, video_ctx, frame);
} else {
// some frames are needed for references, interlaced frames ...
// could happen with h264 dvb streams, just drop data.
@@ -511,23 +560,28 @@ void CodecVideoDecode(VideoDecoder * decoder, AVPacket * avpkt)
Debug(4, "codec: %8d incomplete interlaced frame %d bytes used\n",
video_ctx->frame_number, used);
}
if (used != avpkt->size) {
if (used == 0) {
goto next_part;
}
if (used >= 0) {
if (used != pkt->size) {
if (used >= 0 && used < pkt->size) {
// some tv channels, produce this
Debug(4,
"codec: ooops didn't use complete video packet used %d of %d\n",
used, avpkt->size);
avpkt->data += used;
avpkt->size -= used;
used, pkt->size);
pkt->size -= used;
pkt->data += used;
goto next_part;
}
Debug(3, "codec: bad frame %d\n", used);
}
}
return;
/**
** Flush the video decoder.
**
** @param decoder video decoder data
*/
void CodecVideoFlushBuffers(VideoDecoder * decoder)
{
avcodec_flush_buffers(decoder->VideoCtx);
}
//----------------------------------------------------------------------------
@@ -549,35 +603,56 @@ struct _audio_decoder_
AVCodec *AudioCodec; ///< audio codec
AVCodecContext *AudioCtx; ///< audio codec context
/// audio parser to support wired dvb streaks
/// audio parser to support insane dvb streaks
AVCodecParserContext *AudioParser;
int SampleRate; ///< current sample rate
int Channels; ///< current channels
int PassthroughAC3; ///< current ac-3 pass-through
int SampleRate; ///< current stream sample rate
int Channels; ///< current stream channels
int HwSampleRate; ///< hw sample rate
int HwChannels; ///< hw channels
ReSampleContext *ReSample; ///< audio resampling context
};
#ifdef USE_PASSTHROUGH
//static char CodecPassthroughPCM; ///< pass pcm through (unsupported)
static char CodecPassthroughAC3; ///< pass ac3 through
//static char CodecPassthroughDTS; ///< pass dts through (unsupported)
//static char CodecPassthroughMPA; ///< pass mpa through (unsupported)
#else
static const int CodecPassthroughAC3 = 0;
#endif
/**
** Allocate a new audio decoder context.
**
** @param hw_decoder video hardware decoder
**
** @returns private decoder pointer for audio/video decoder.
** @returns private decoder pointer for audio decoder.
*/
AudioDecoder *CodecAudioNewDecoder(void)
{
AudioDecoder *audio_decoder;
if (!(audio_decoder = calloc(1, sizeof(*audio_decoder)))) {
Fatal(_("codec: Can't allocate audio decoder\n"));
Fatal(_("codec: can't allocate audio decoder\n"));
}
return audio_decoder;
}
/**
** Deallocate an audio decoder context.
**
** @param decoder private audio decoder
*/
void CodecAudioDelDecoder(AudioDecoder * decoder)
{
free(decoder);
}
/**
** Open audio decoder.
**
@@ -601,16 +676,20 @@ void CodecAudioOpen(AudioDecoder * audio_decoder, const char *name,
if (!(audio_decoder->AudioCtx = avcodec_alloc_context3(audio_codec))) {
Fatal(_("codec: can't allocate audio codec context\n"));
}
pthread_mutex_lock(&CodecLockMutex);
// open codec
#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(53,5,0)
if (avcodec_open(audio_decoder->AudioCtx, audio_codec) < 0) {
pthread_mutex_unlock(&CodecLockMutex);
Fatal(_("codec: can't open audio codec\n"));
}
#else
if (avcodec_open2(audio_decoder->AudioCtx, audio_codec, NULL) < 0) {
pthread_mutex_unlock(&CodecLockMutex);
Fatal(_("codec: can't open audio codec\n"));
}
#endif
pthread_mutex_unlock(&CodecLockMutex);
Debug(3, "codec: audio '%s'\n", audio_decoder->AudioCtx->codec_name);
if (audio_codec->capabilities & CODEC_CAP_TRUNCATED) {
@@ -645,31 +724,99 @@ void CodecAudioClose(AudioDecoder * audio_decoder)
audio_decoder->AudioParser = NULL;
}
if (audio_decoder->AudioCtx) {
pthread_mutex_lock(&CodecLockMutex);
avcodec_close(audio_decoder->AudioCtx);
pthread_mutex_unlock(&CodecLockMutex);
av_freep(&audio_decoder->AudioCtx);
}
}
/**
** Set audio pass-through.
*/
void CodecSetAudioPassthrough(int mask)
{
#ifdef USE_PASSTHROUGH
CodecPassthroughAC3 = mask & 1 ? 1 : 0;
#endif
(void)mask;
}
/**
** Reorder audio frame.
**
** ffmpeg L R C Ls Rs -> alsa L R Ls Rs C
** ffmpeg L R C LFE Ls Rs -> alsa L R Ls Rs C LFE
** ffmpeg L R C LFE Ls Rs Rl Rr -> alsa L R Ls Rs C LFE Rl Rr
*/
static void CodecReorderAudioFrame(int16_t * buf, int size, int channels)
{
int i;
int c;
int ls;
int rs;
int lfe;
switch (channels) {
case 5:
size /= 2;
for (i = 0; i < size; i += 5) {
c = buf[i + 2];
ls = buf[i + 3];
rs = buf[i + 4];
buf[i + 2] = ls;
buf[i + 3] = rs;
buf[i + 4] = c;
}
break;
case 6:
size /= 2;
for (i = 0; i < size; i += 6) {
c = buf[i + 2];
lfe = buf[i + 3];
ls = buf[i + 4];
rs = buf[i + 5];
buf[i + 2] = ls;
buf[i + 3] = rs;
buf[i + 4] = c;
buf[i + 5] = lfe;
}
break;
case 8:
size /= 2;
for (i = 0; i < size; i += 8) {
c = buf[i + 2];
lfe = buf[i + 3];
ls = buf[i + 4];
rs = buf[i + 5];
buf[i + 2] = ls;
buf[i + 3] = rs;
buf[i + 4] = c;
buf[i + 5] = lfe;
}
break;
}
}
#ifdef USE_AVPARSER
/**
** Decode an audio packet.
**
** PTS must be handled self.
**
** @param audio_decoder audio_Decoder data
** @param audio_decoder audio decoder data
** @param avpkt audio packet
*/
void CodecAudioDecode(AudioDecoder * audio_decoder, AVPacket * avpkt)
void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
{
int16_t buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 4 +
FF_INPUT_BUFFER_PADDING_SIZE] __attribute__ ((aligned(16)));
AVCodecContext *audio_ctx;
int index;
if (!audio_decoder->AudioParser) {
Fatal(_("codec: internal error parser freeded while running\n"));
}
#define spkt avpkt
#if 0 // didn't fix crash in av_parser_parse2
//#define spkt avpkt
#if 1 // didn't fix crash in av_parser_parse2
AVPacket spkt[1];
// av_new_packet reserves FF_INPUT_BUFFER_PADDING_SIZE and clears it
@@ -681,6 +828,11 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, AVPacket * avpkt)
spkt->pts = avpkt->pts;
spkt->dts = avpkt->dts;
#endif
#ifdef DEBUG
if (!audio_decoder->AudioParser) {
Fatal(_("codec: internal error parser freeded while running\n"));
}
#endif
audio_ctx = audio_decoder->AudioCtx;
index = 0;
@@ -695,6 +847,7 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, AVPacket * avpkt)
!index ? (uint64_t) spkt->pts : AV_NOPTS_VALUE,
!index ? (uint64_t) spkt->dts : AV_NOPTS_VALUE, -1);
// FIXME: make this a function for both #ifdef cases
if (dpkt->size) {
int buf_sz;
@@ -702,8 +855,12 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, AVPacket * avpkt)
dpkt->dts = audio_decoder->AudioParser->dts;
buf_sz = sizeof(buf);
l = avcodec_decode_audio3(audio_ctx, buf, &buf_sz, dpkt);
if (l == AVERROR(EAGAIN)) {
index += n; // this is needed for aac latm
continue;
}
if (l < 0) { // no audio frame could be decompressed
Error(_("codec: error audio data\n"));
Error(_("codec: error audio data at %d\n"), index);
break;
}
#ifdef notyetFF_API_OLD_DECODE_AUDIO
@@ -718,10 +875,15 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, AVPacket * avpkt)
AudioSetClock(dpkt->pts);
}
// FIXME: must first play remainings bytes, than change and play new.
if (audio_decoder->SampleRate != audio_ctx->sample_rate
if (audio_decoder->PassthroughAC3 != CodecPassthroughAC3
|| audio_decoder->SampleRate != audio_ctx->sample_rate
|| audio_decoder->Channels != audio_ctx->channels) {
int err;
int isAC3;
audio_decoder->PassthroughAC3 = CodecPassthroughAC3;
// FIXME: use swr_convert from swresample (only in ffmpeg!)
// FIXME: tell ac3 decoder to use downmix
if (audio_decoder->ReSample) {
audio_resample_close(audio_decoder->ReSample);
audio_decoder->ReSample = NULL;
@@ -730,14 +892,23 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, AVPacket * avpkt)
audio_decoder->SampleRate = audio_ctx->sample_rate;
audio_decoder->HwSampleRate = audio_ctx->sample_rate;
audio_decoder->Channels = audio_ctx->channels;
audio_decoder->HwChannels = audio_ctx->channels;
// SPDIF/HDMI passthrough
if (CodecPassthroughAC3 && audio_ctx->codec_id == CODEC_ID_AC3) {
audio_decoder->HwChannels = 2;
isAC3 = 1;
} else {
audio_decoder->HwChannels = audio_ctx->channels;
isAC3 = 0;
}
// channels not support?
if ((err =
AudioSetup(&audio_decoder->HwSampleRate,
&audio_decoder->HwChannels))) {
Debug(3, "codec/audio: resample %d -> %d\n",
audio_ctx->channels, audio_decoder->HwChannels);
&audio_decoder->HwChannels, isAC3))) {
Debug(3, "codec/audio: resample %dHz *%d -> %dHz *%d\n",
audio_ctx->sample_rate, audio_ctx->channels,
audio_decoder->HwSampleRate,
audio_decoder->HwChannels);
if (err == 1) {
audio_decoder->ReSample =
@@ -745,10 +916,18 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, AVPacket * avpkt)
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;
}
} else {
Debug(3, "codec/audio: audio setup error\n");
// FIXME: handle errors
audio_decoder->HwChannels = 0;
audio_decoder->HwSampleRate = 0;
break;
}
}
}
@@ -761,11 +940,105 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, AVPacket * avpkt)
__attribute__ ((aligned(16)));
int outlen;
// FIXME: libav-0.7.2 crash here
outlen =
audio_resample(audio_decoder->ReSample, outbuf, buf,
buf_sz);
AudioEnqueue(outbuf, outlen);
#ifdef DEBUG
if (outlen != buf_sz) {
Debug(3, "codec/audio: possible fixed ffmpeg\n");
}
#endif
if (outlen) {
// outlen seems to be wrong in ffmpeg-0.9
outlen /= audio_decoder->Channels *
av_get_bytes_per_sample(audio_ctx->sample_fmt);
outlen *=
audio_decoder->HwChannels *
av_get_bytes_per_sample(audio_ctx->sample_fmt);
Debug(4, "codec/audio: %d -> %d\n", buf_sz, outlen);
CodecReorderAudioFrame(outbuf, outlen,
audio_decoder->HwChannels);
AudioEnqueue(outbuf, outlen);
}
} else {
#ifdef USE_PASSTHROUGH
// SPDIF/HDMI passthrough
if (CodecPassthroughAC3
&& audio_ctx->codec_id == CODEC_ID_AC3) {
// build SPDIF header and append A52 audio to it
// dpkt is the original data
buf_sz = 6144;
if (buf_sz < dpkt->size + 8) {
Error(_
("codec/audio: decoded data smaller than encoded\n"));
break;
}
// copy original data for output
// FIXME: not 100% sure, if endian is correct
buf[0] = htole16(0xF872); // iec 61937 sync word
buf[1] = htole16(0x4E1F);
buf[2] = htole16(0x01 | (dpkt->data[5] & 0x07) << 8);
buf[3] = htole16(dpkt->size * 8);
swab(dpkt->data, buf + 4, dpkt->size);
memset(buf + 4 + dpkt->size / 2, 0,
buf_sz - 8 - dpkt->size);
}
#if 0
//
// old experimental code
//
if (1) {
// FIXME: need to detect dts
// copy original data for output
// FIXME: buf is sint
buf[0] = 0x72;
buf[1] = 0xF8;
buf[2] = 0x1F;
buf[3] = 0x4E;
buf[4] = 0x00;
switch (dpkt->size) {
case 512:
buf[5] = 0x0B;
break;
case 1024:
buf[5] = 0x0C;
break;
case 2048:
buf[5] = 0x0D;
break;
default:
Debug(3,
"codec/audio: dts sample burst not supported\n");
buf[5] = 0x00;
break;
}
buf[6] = (dpkt->size * 8);
buf[7] = (dpkt->size * 8) >> 8;
//buf[8] = 0x0B;
//buf[9] = 0x77;
//printf("%x %x\n", dpkt->data[0],dpkt->data[1]);
// swab?
memcpy(buf + 8, dpkt->data, dpkt->size);
memset(buf + 8 + dpkt->size, 0,
buf_sz - 8 - dpkt->size);
} else if (1) {
// FIXME: need to detect mp2
// FIXME: mp2 passthrough
// see softhddev.c version/layer
// 0x04 mpeg1 layer1
// 0x05 mpeg1 layer23
// 0x06 mpeg2 ext
// 0x07 mpeg2.5 layer 1
// 0x08 mpeg2.5 layer 2
// 0x09 mpeg2.5 layer 3
}
// DTS HD?
// True HD?
#endif
#endif
CodecReorderAudioFrame(buf, buf_sz,
audio_decoder->HwChannels);
AudioEnqueue(buf, buf_sz);
}
}
@@ -778,11 +1051,96 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, AVPacket * avpkt)
index += n;
}
#if 0
#if 1
// or av_free_packet, make no difference here
av_destruct_packet(spkt);
#endif
}
#else
/**
** Decode an audio packet.
**
** PTS must be handled self.
**
** @param audio_decoder audio decoder data
** @param avpkt audio packet
*/
void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
{
int16_t buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 4 +
FF_INPUT_BUFFER_PADDING_SIZE] __attribute__ ((aligned(16)));
AVCodecContext *audio_ctx;
int index;
//#define spkt avpkt
#if 1
AVPacket spkt[1];
// av_new_packet reserves FF_INPUT_BUFFER_PADDING_SIZE and clears it
if (av_new_packet(spkt, avpkt->size)) {
Error(_("codec: out of memory\n"));
return;
}
memcpy(spkt->data, avpkt->data, avpkt->size);
spkt->pts = avpkt->pts;
spkt->dts = avpkt->dts;
#endif
audio_ctx = audio_decoder->AudioCtx;
index = 0;
while (spkt->size > index) {
int n;
int buf_sz;
AVPacket dpkt[1];
av_init_packet(dpkt);
dpkt->data = spkt->data + index;
dpkt->size = spkt->size - index;
buf_sz = sizeof(buf);
n = avcodec_decode_audio3(audio_ctx, buf, &buf_sz, dpkt);
if (n < 0) { // no audio frame could be decompressed
Error(_("codec: error audio data at %d\n"), index);
break;
}
#ifdef DEBUG
Debug(4, "codec/audio: -> %d\n", buf_sz);
if ((unsigned)buf_sz > sizeof(buf)) {
abort();
}
#endif
#ifdef notyetFF_API_OLD_DECODE_AUDIO
// FIXME: ffmpeg git comeing
int got_frame;
avcodec_decode_audio4(audio_ctx, frame, &got_frame, dpkt);
#else
#endif
// FIXME: see above, old code removed
index += n;
}
#if 1
// or av_free_packet, make no difference here
av_destruct_packet(spkt);
#endif
}
#endif
/**
** Flush the audio decoder.
**
** @param decoder audio decoder data
*/
void CodecAudioFlushBuffers(AudioDecoder * decoder)
{
// FIXME: reset audio parser
avcodec_flush_buffers(decoder->AudioCtx);
}
//----------------------------------------------------------------------------
// Codec
//----------------------------------------------------------------------------
@@ -802,6 +1160,7 @@ static void CodecNoopCallback( __attribute__ ((unused))
*/
void CodecInit(void)
{
pthread_mutex_init(&CodecLockMutex, NULL);
#ifndef DEBUG
// disable display ffmpeg error messages
av_log_set_callback(CodecNoopCallback);
@@ -816,4 +1175,5 @@ void CodecInit(void)
*/
void CodecExit(void)
{
pthread_mutex_destroy(&CodecLockMutex);
}

30
codec.h
View File

@@ -1,7 +1,7 @@
///
/// @file codec.h @brief Codec module headerfile
///
/// Copyright (c) 2009 - 2011 by Johns. All Rights Reserved.
/// Copyright (c) 2009 - 2012 by Johns. All Rights Reserved.
///
/// Contributor(s):
///
@@ -40,26 +40,38 @@ typedef struct _audio_decoder_ AudioDecoder;
/// Allocate a new video decoder context.
extern VideoDecoder *CodecVideoNewDecoder(VideoHwDecoder *);
/// Open video codec
/// Deallocate a video decoder context.
extern void CodecVideoDelDecoder(VideoDecoder *);
/// Open video codec.
extern void CodecVideoOpen(VideoDecoder *, const char *, int);
/// Close video codec
/// Close video codec.
extern void CodecVideoClose(VideoDecoder *);
/// Decode a video packet
extern void CodecVideoDecode(VideoDecoder *, AVPacket * pkt);
/// Decode a video packet.
extern void CodecVideoDecode(VideoDecoder *, const AVPacket *);
/// Flush video buffers.
extern void CodecVideoFlushBuffers(VideoDecoder *);
/// Allocate a new audio decoder context.
extern AudioDecoder *CodecAudioNewDecoder(void);
/// Open audio codec
/// Deallocate an audio decoder context.
extern void CodecAudioDelDecoder(AudioDecoder *);
/// Open audio codec.
extern void CodecAudioOpen(AudioDecoder *, const char *, int);
/// Close audio codec
/// Close audio codec.
extern void CodecAudioClose(AudioDecoder *);
/// Decode an audio packet
extern void CodecAudioDecode(AudioDecoder *, AVPacket * pkt);
/// Decode an audio packet.
extern void CodecAudioDecode(AudioDecoder *, const AVPacket *);
/// Flush audio buffers.
extern void CodecAudioFlushBuffers(AudioDecoder *);
/// Setup and initialize codec module.
extern void CodecInit(void);

29
misc.h
View File

@@ -1,7 +1,7 @@
///
/// @file misc.h @brief Misc function header file
///
/// Copyright (c) 2009 - 2011 by Lutz Sammer. All Rights Reserved.
/// Copyright (c) 2009 - 2012 by Lutz Sammer. All Rights Reserved.
///
/// Contributor(s):
/// Copied from uwm.
@@ -46,24 +46,28 @@ extern int SysLogLevel; ///< how much information wanted
// Prototypes
//////////////////////////////////////////////////////////////////////////////
static inline void Debug(const int, const char *format, ...)
static inline void Syslog(const int, const char *format, ...)
__attribute__ ((format(printf, 2, 3)));
//////////////////////////////////////////////////////////////////////////////
// Inlines
//////////////////////////////////////////////////////////////////////////////
#ifdef DEBUG
#define DebugLevel 4 /// private debug level
#else
#define DebugLevel 0 /// private debug level
#endif
/**
** Debug output function.
** Syslog output function.
**
** - 0 fatal errors and errors
** - 1 warnings
** - 2 info
** - 3 important debug and fixme's
*/
static inline void Debug(const int level, const char *format, ...)
static inline void Syslog(const int level, const char *format, ...)
{
if (SysLogLevel > level || DebugLevel > level) {
va_list ap;
@@ -77,22 +81,31 @@ static inline void Debug(const int level, const char *format, ...)
/**
** Show error.
*/
#define Error(fmt...) Debug(0, fmt)
#define Error(fmt...) Syslog(0, fmt)
/**
** Show fatal error.
*/
#define Fatal(fmt...) do { Error(fmt); exit(-1); } while (0)
#define Fatal(fmt...) do { Error(fmt); abort(); } while (0)
/**
** Show warning.
*/
#define Warning(fmt...) Debug(1, fmt)
#define Warning(fmt...) Syslog(1, fmt)
/**
** Show info.
*/
#define Info(fmt...) Debug(2, fmt)
#define Info(fmt...) Syslog(2, fmt)
/**
** Show debug.
*/
#ifdef DEBUG
#define Debug(level, fmt...) Syslog(level, fmt)
#else
#define Debug(level, fmt...) /* disabled */
#endif
/**
** Get ticks in ms.

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
///
/// @file softhddev.h @brief software HD device plugin header file.
///
/// Copyright (c) 2011 by Johns. All Rights Reserved.
/// Copyright (c) 2011 - 2012 by Johns. All Rights Reserved.
///
/// Contributor(s):
///
@@ -36,7 +36,7 @@ extern "C"
extern void OsdDrawARGB(int, int, int, int, const uint8_t *);
/// C plugin play audio packet
extern void PlayAudio(const uint8_t *, int, uint8_t);
extern int PlayAudio(const uint8_t *, int, uint8_t);
/// C plugin mute audio
extern void Mute(void);
/// C plugin set audio volume
@@ -46,6 +46,8 @@ extern "C"
extern int PlayVideo(const uint8_t *, int);
/// C plugin play TS video packet
extern void PlayTsVideo(const uint8_t *, int);
/// C plugin grab an image
extern uint8_t *GrabImage(int *, int, int, int, int);
/// C plugin set play mode
extern void SetPlayMode(void);
@@ -55,8 +57,12 @@ extern "C"
extern void Play(void);
/// C plugin sets the device into "freeze frame" mode
extern void Freeze(void);
/// C plugin display I-frame as a still picture.
extern void StillPicture(const uint8_t *, int);
/// C plugin poll if ready
extern int Poll(int);
/// C plugin flush output buffers
extern int Flush(int);
/// C plugin command line help
extern const char *CommandLineHelp(void);
@@ -72,6 +78,10 @@ extern "C"
/// C plugin main thread hook
extern void MainThreadHook(void);
/// Suspend plugin
extern void Suspend(int, int, int);
/// Resume plugin
extern void Resume(void);
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,75 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI="3"
inherit eutils vdr-plugin
if [[ ${PV} == "9999" ]] ; then
inherit git-2
EGIT_REPO_URI="git://projects.vdr-developer.org/vdr-plugin-softhddevice.git"
else
SRC_URI="http://projects.vdr-developer.org/attachments/download/838/${P}.tgz"
fi
DESCRIPTION="A software and GPU emulated HD output device plugin for VDR."
HOMEPAGE="http://projects.vdr-developer.org/projects/show/plg-softhddevice"
SRC_URI=""
LICENSE="AGPL-3"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE="vaapi vdpau alsa oss yaepg opengl jpeg"
DEPEND=">=x11-libs/libxcb-1.8
x11-libs/xcb-util
x11-libs/xcb-util-wm
x11-libs/xcb-util-keysyms
x11-libs/xcb-util-renderutil
x11-libs/libX11
opengl? ( virtual/opengl )
>=virtual/ffmpeg-0.7
sys-devel/gettext
sys-devel/make
dev-util/pkgconfig
yaepg? ( >=media-video/vdr-1.7.23[yaepg] )
!yaepg? ( >=media-video/vdr-1.7.23 )
vdpau? ( x11-libs/libvdpau )
vaapi? ( x11-libs/libva )
alsa? ( media-libs/alsa-lib )
oss? ( sys-kernel/linux-headers )
jpeg? ( virtual/jpeg )
"
src_prepare() {
vdr-plugin_src_prepare
}
src_compile() {
local myconf
myconf="-DHAVE_PTHREAD_NAME"
use vdpau && myconf="${myconf} -DUSE_VDPAU"
use vaapi && myconf="${myconf} -DUSE_VAAPI"
use alsa && myconf="${myconf} -DUSE_ALSA"
use oss && myconf="${myconf} -DUSE_OSS"
use jpeg && myconf="${myconf} -DUSE_JPEG"
emake all CC="$(tc-getCC)" CFLAGS="${CFLAGS}" \
LDFLAGS="${LDFLAGS}" CONFIG="${myconf}" LIBDIR="." || die
}
src_install() {
vdr-plugin_src_install
dodoc README.txt
#dodir /etc/vdr/plugins || die
#insinto /etc/vdr/plugins
#fowners -R vdr:vdr /etc/vdr || die
#insinto /etc/conf.d
#doins vdr.softhddevice
}

6162
video.c

File diff suppressed because it is too large Load Diff

107
video.h
View File

@@ -1,7 +1,7 @@
///
/// @file video.h @brief Video module header file
///
/// Copyright (c) 2009 - 2011 by Johns. All Rights Reserved.
/// Copyright (c) 2009 - 2012 by Johns. All Rights Reserved.
///
/// Contributor(s):
///
@@ -30,13 +30,6 @@
/// Video hardware decoder typedef
typedef struct _video_hw_decoder_ VideoHwDecoder;
//----------------------------------------------------------------------------
// Variables
//----------------------------------------------------------------------------
//extern unsigned VideoWindowWidth; ///< current video output width
//extern unsigned VideoWindowHeight; ///< current video output height
//----------------------------------------------------------------------------
// Prototypes
//----------------------------------------------------------------------------
@@ -44,66 +37,106 @@ typedef struct _video_hw_decoder_ VideoHwDecoder;
/// Allocate new video hardware decoder.
extern VideoHwDecoder *VideoNewHwDecoder(void);
/// Deallocate video hardware decoder.
extern void VideoDelHwDecoder(VideoHwDecoder *);
/// Get and allocate a video hardware surface.
extern unsigned VideoGetSurface(VideoHwDecoder *);
/// Release a video hardware surface.
/// Release a video hardware surface
extern void VideoReleaseSurface(VideoHwDecoder *, unsigned);
#ifdef LIBAVCODEC_VERSION
/// Render a ffmpeg frame
extern void VideoRenderFrame(VideoHwDecoder *, AVCodecContext *, AVFrame *);
/// Get ffmpeg vaapi context
extern struct vaapi_context *VideoGetVaapiContext(VideoHwDecoder *);
/// Callback to negotiate the PixelFormat.
extern enum PixelFormat Video_get_format(VideoHwDecoder *, AVCodecContext *,
const enum PixelFormat *);
/// Render a ffmpeg frame.
extern void VideoRenderFrame(VideoHwDecoder *, const AVCodecContext *,
const AVFrame *);
/// Get ffmpeg vaapi context.
extern struct vaapi_context *VideoGetVaapiContext(VideoHwDecoder *);
#ifdef AVCODEC_VDPAU_H
/// Draw vdpau render state
/// Draw vdpau render state.
extern void VideoDrawRenderState(VideoHwDecoder *,
struct vdpau_render_state *);
#endif
#endif
/// Display video TEST
extern void VideoDisplayHandler(void);
/// Poll video events
/// Poll video events.
extern void VideoPollEvent(void);
/// set video mode
//extern void VideoSetVideoMode(int, int, int, int);
/// Wakeup display handler.
extern void VideoDisplayWakeup(void);
/// set video geometry
/// Set video geometry.
extern int VideoSetGeometry(const char *);
/// set deinterlace
extern void VideoSetDeinterlace(int);
/// Set video output position.
extern void VideoSetOutputPosition(int, int, int, int);
/// set scaling
extern void VideoSetScaling(int);
/// Set video mode.
extern void VideoSetVideoMode(int, int, int, int);
/// set audio delay
/// Set display format.
extern void VideoSetDisplayFormat(int);
/// Set video fullscreen mode.
extern void VideoSetFullscreen(int);
/// Set deinterlace.
extern void VideoSetDeinterlace(int[]);
/// Set skip chroma deinterlace.
extern void VideoSetSkipChromaDeinterlace(int[]);
/// Set inverse telecine.
extern void VideoSetInverseTelecine(int[]);
/// Set scaling.
extern void VideoSetScaling(int[]);
/// Set denoise.
extern void VideoSetDenoise(int[]);
/// Set sharpen.
extern void VideoSetSharpen(int[]);
/// Set skip lines.
extern void VideoSetSkipLines(int);
/// Set studio levels.
extern void VideoSetStudioLevels(int);
/// Set audio delay.
extern void VideoSetAudioDelay(int);
/// Clear OSD
/// Set auto-crop parameters.
extern void VideoSetAutoCrop(int, int, int);
/// Clear OSD.
extern void VideoOsdClear(void);
/// Draw an OSD ARGB image
/// Draw an OSD ARGB image.
extern void VideoOsdDrawARGB(int, int, int, int, const uint8_t *);
extern int64_t VideoGetClock(void); ///< get video clock
/// Get OSD size.
extern void VideoGetOsdSize(int *, int *);
extern void VideoOsdInit(void); ///< setup osd
extern void VideoOsdExit(void); ///< cleanup osd
extern int64_t VideoGetClock(void); ///< Get video clock.
extern void VideoInit(const char *); ///< setup video module
extern void VideoExit(void); ///< cleanup and exit video module
/// Grab screen.
extern uint8_t *VideoGrab(int *, int *, int *, int);
extern void VideoFlushInput(void); ///< flush codec input buffers
extern int VideoDecode(void); ///< decode
extern void VideoOsdInit(void); ///< Setup osd.
extern void VideoOsdExit(void); ///< Cleanup osd.
extern void VideoInit(const char *); ///< Setup video module.
extern void VideoExit(void); ///< Cleanup and exit video module.
extern void VideoFlushInput(void); ///< Flush video input buffers.
extern int VideoDecode(void); ///< Decode video input buffers.
/// @}