diff options
author | Andreas Brachold <vdr07@deltab.de> | 2008-01-02 11:08:47 +0000 |
---|---|---|
committer | Andreas Brachold <vdr07@deltab.de> | 2008-01-02 11:08:47 +0000 |
commit | 6a26a396ee4aa7be91967050cdc30d5c10bfb55c (patch) | |
tree | 9cecb7516f8baa5804ea8f12a64109d9abe0fcdf /liboutput | |
parent | 943932297e9f6e15119a2ff1178635b43df14cbf (diff) | |
download | vdr-plugin-image-6a26a396ee4aa7be91967050cdc30d5c10bfb55c.tar.gz vdr-plugin-image-6a26a396ee4aa7be91967050cdc30d5c10bfb55c.tar.bz2 |
- Reimplement 'Playback mode via DeviceStillPicture'
Diffstat (limited to 'liboutput')
-rw-r--r-- | liboutput/encode.c | 46 | ||||
-rw-r--r-- | liboutput/encode.h | 38 | ||||
-rw-r--r-- | liboutput/stillimage-player.c | 39 | ||||
-rw-r--r-- | liboutput/stillimage-player.h | 37 | ||||
-rw-r--r-- | liboutput/stillimage.c | 82 | ||||
-rw-r--r-- | liboutput/stillimage.h | 38 |
6 files changed, 141 insertions, 139 deletions
diff --git a/liboutput/encode.c b/liboutput/encode.c index c0e33c2..9877340 100644 --- a/liboutput/encode.c +++ b/liboutput/encode.c @@ -1,25 +1,23 @@ -/*************************************************************************** - * encode.c +/* + * Image plugin to VDR (C++) * - * (C) Copyright 2004-2007 Andreas Brachold <anbr at users.berlios.de> + * (C) Copyright 2004-2008 Andreas Brachold <anbr at users.berlios.de> * Created: Thu Aug 5 2004 - * - ****************************************************************************/ - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. + * This code is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * This code 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Or, point your browser to http://www.gnu.org/copyleft/gpl.html */ #include <stdio.h> @@ -45,10 +43,10 @@ AVCodec *cEncode::m_pavCodec = NULL; /******************************************************************************* */ -cEncode::cEncode() +cEncode::cEncode(unsigned int nNumberOfFramesToEncode) : m_pImageFilled(NULL) , m_pImageYUV(NULL) -, m_nNumberOfFramesToEncode(4) +, m_nNumberOfFramesToEncode(nNumberOfFramesToEncode) , m_pMPEG(NULL) , m_pImageRGB(NULL) { @@ -167,7 +165,9 @@ void cEncode::SetupEncodingParameters(AVCodecContext *context) //IPB //1 => Encode only I-Frames, bigger context->gop_size=m_nNumberOfFramesToEncode-1; - + if(context->gop_size <= 1) { + context->gop_size = 1; + } context->max_b_frames=1; context->flags |= CODEC_FLAG_QSCALE; context->pix_fmt = PIX_FMT_YUV420P; @@ -340,11 +340,11 @@ bool cEncode::Load(const char* szFileName) */ bool cEncode::Save(const char* szFileName) const { - if(m_pMPEG && m_nData) + if(Data() && Size()) { FILE * outf=fopen(szFileName, "w"); if(outf) { - fwrite(m_pMPEG, 1, m_nData, outf); + fwrite(Data(), 1, Size(), outf); fclose(outf); return true; } diff --git a/liboutput/encode.h b/liboutput/encode.h index ccbe51b..aaec993 100644 --- a/liboutput/encode.h +++ b/liboutput/encode.h @@ -1,25 +1,23 @@ -/*************************************************************************** - * encode.h +/* + * Image plugin to VDR (C++) * - * (C) Copyright 2004 Andreas Brachold <anbr at users.berlios.de> + * (C) Copyright 2004-2008 Andreas Brachold <anbr at users.berlios.de> * Created: Thu Aug 5 2004 - * - ****************************************************************************/ - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. + * This code is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This code 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 General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Or, point your browser to http://www.gnu.org/copyleft/gpl.html */ #ifndef _ENCODE_H @@ -34,7 +32,7 @@ extern "C" { } #include "../setup-image.h" -//#define TESTCODE +#define TESTCODE class cEncode { @@ -54,7 +52,7 @@ protected: unsigned int *m_pFrameSizes; public: - cEncode(); + cEncode(unsigned int nNumberOfFramesToEncode); virtual ~cEncode(); /*Load Shared Library and Register Codec*/ diff --git a/liboutput/stillimage-player.c b/liboutput/stillimage-player.c index 77cd1b1..102c30d 100644 --- a/liboutput/stillimage-player.c +++ b/liboutput/stillimage-player.c @@ -1,32 +1,31 @@ -/*************************************************************************** - * stillimage-player.c - * (C) Copyright 2004-2005 Andreas Brachold <anbr at users.berlios.de> - * Created: Thu Aug 5 2004 - * - ****************************************************************************/ - /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Image plugin to VDR (C++) + * + * (C) Copyright 2004-2008 Andreas Brachold <anbr at users.berlios.de> + * Created: Thu Aug 5 2004 + * + * This code is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. + * This code 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 General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Or, point your browser to http://www.gnu.org/copyleft/gpl.html */ #include "stillimage-player.h" #include "stillimage.h" -cStillImagePlayer::cStillImagePlayer(ePlayMode PlayMode) +cStillImagePlayer::cStillImagePlayer(ePlayMode PlayMode,bool bUseDeviceStillPicture) : cPlayer(PlayMode) - , m_StillImage(this) + , m_StillImage(this,bUseDeviceStillPicture) { } diff --git a/liboutput/stillimage-player.h b/liboutput/stillimage-player.h index e1d5dc2..ee96649 100644 --- a/liboutput/stillimage-player.h +++ b/liboutput/stillimage-player.h @@ -1,24 +1,23 @@ -/*************************************************************************** - * stillimage-player.h - * (C) Copyright 2004 Andreas Brachold <anbr at users.berlios.de> - * Created: Thu Aug 5 2004 - * - ****************************************************************************/ - /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Image plugin to VDR (C++) + * + * (C) Copyright 2004-2008 Andreas Brachold <anbr at users.berlios.de> + * Created: Thu Aug 5 2004 + * + * This code is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. + * This code 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 General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Or, point your browser to http://www.gnu.org/copyleft/gpl.html */ #ifndef STILLIMAGEPLAYER_H @@ -35,7 +34,7 @@ class cStillImagePlayer protected: cStillImage m_StillImage; public: - cStillImagePlayer(ePlayMode PlayMode); + cStillImagePlayer(ePlayMode PlayMode,bool bUseDeviceStillPicture); virtual ~cStillImagePlayer(); inline unsigned int UseWidth() const diff --git a/liboutput/stillimage.c b/liboutput/stillimage.c index 6cefd44..0dd7eff 100644 --- a/liboutput/stillimage.c +++ b/liboutput/stillimage.c @@ -1,28 +1,27 @@ -/*************************************************************************** - * stillimage.c - * (C) Copyright 2004 <anbr at users.berlios.de> +/* + * Image plugin to VDR (C++) + * + * (C) 2004-2008 Andreas Brachold <anbr at users.berlios.de> * Created: Thu Aug 5 2004 * * parts of the code (c) Peter Seyringer * (c) Marcel Wiesweg - ****************************************************************************/ - -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. + * This code is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This code 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 General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Or, point your browser to http://www.gnu.org/copyleft/gpl.html */ - #include <string.h> #include <unistd.h> @@ -32,10 +31,13 @@ -cStillImage::cStillImage(cStillImagePlayer *pl) +cStillImage::cStillImage(cStillImagePlayer *pl,bool bUseDeviceStillPicture) +: cEncode(bUseDeviceStillPicture ? 2 : 4) +, player(pl) +, m_bEncodeRequired(false) +, m_bUseDeviceStillPicture(bUseDeviceStillPicture) { - m_bEncodeRequired = false; - player=pl; + } cStillImage::~cStillImage() @@ -53,7 +55,6 @@ void cStillImage::Action(void) bool bMPEGValid = false; bool bQueueEmpty = false; bool bFreeze = true; - unsigned int nFrame = 0,nFrameOff=0; int nMircoSekWait; while (Running()) { @@ -114,23 +115,28 @@ void cStillImage::Action(void) /* Methode C ************************************************************/ //BuildPesPacket(Data(), Size(),1); - /* Methode D ************************************************************/ - //player->DeviceStillPicture(Data(), Size()); - - /* Methode E ************************************************************/ - - - unsigned int nFrameSize = GetFrameSize(nFrame); - if(nFrameSize) // Skip empty Frames - { - BuildPesPacket(Data() + nFrameOff, nFrameSize,1); - nFrameOff += nFrameSize; + if(m_bUseDeviceStillPicture) { + player->DeviceStillPicture(Data(), Size()); + if(!bFreeze) + { + player->DeviceFreeze(); + bFreeze = true; + } + bMPEGValid = false; + } else { + + unsigned int nFrameSize = GetFrameSize(nFrame); + if(nFrameSize) // Skip empty Frames + { + BuildPesPacket(Data() + nFrameOff, nFrameSize,1); + nFrameOff += nFrameSize; + } + if(++nFrame>=GetFrames()) + { + nFrame = 0; + nFrameOff = 0; + } } - if(++nFrame>=GetFrames()) - { - nFrame = 0; - nFrameOff = 0; - } nMircoSekWait = (1000000/(GetFrameRate()*4)); // Wait duration off 1/4 frame diff --git a/liboutput/stillimage.h b/liboutput/stillimage.h index 35abae1..1ca6cd3 100644 --- a/liboutput/stillimage.h +++ b/liboutput/stillimage.h @@ -1,24 +1,23 @@ -/*************************************************************************** - * stillimage.h - * (C) Copyright 2004 Andreas Brachold <anbr at users.berlios.de> - * Created: Thu Aug 5 2004 - * - ****************************************************************************/ - /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Image plugin to VDR (C++) + * + * (C) 2004-2008 Andreas Brachold <anbr at users.berlios.de> + * Created: Thu Aug 5 2004 + * + * This code is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Library General Public License for more details. + * This code 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 General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Or, point your browser to http://www.gnu.org/copyleft/gpl.html */ #ifndef STILLIMAGE_H @@ -36,12 +35,13 @@ class cStillImage cStillImagePlayer *player; volatile bool m_bEncodeRequired; + bool m_bUseDeviceStillPicture; protected: virtual void Action(void); void BuildPesPacket(const unsigned char *data, int len, int timestamp); public: - cStillImage(cStillImagePlayer *); + cStillImage(cStillImagePlayer *,bool bUseDeviceStillPicture); virtual ~cStillImage(); void Stop(); |