Created by the British Broadcasting Corporation.
00001 /* ***** BEGIN LICENSE BLOCK ***** 00002 * 00003 * $Id: pic_io.h,v 1.9 2004/09/10 11:34:02 asuraparaju Exp $ $Name: Dirac_0_4_3 $ 00004 * 00005 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 00006 * 00007 * The contents of this file are subject to the Mozilla Public License 00008 * Version 1.1 (the "License"); you may not use this file except in compliance 00009 * with the License. You may obtain a copy of the License at 00010 * http://www.mozilla.org/MPL/ 00011 * 00012 * Software distributed under the License is distributed on an "AS IS" basis, 00013 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 00014 * the specific language governing rights and limitations under the License. 00015 * 00016 * The Original Code is BBC Research and Development code. 00017 * 00018 * The Initial Developer of the Original Code is the British Broadcasting 00019 * Corporation. 00020 * Portions created by the Initial Developer are Copyright (C) 2004. 00021 * All Rights Reserved. 00022 * 00023 * Contributor(s): Thomas Davies (Original Author), 00024 * Scott Robert Ladd, 00025 * Stuart Cunningham, 00026 * Tim Borer 00027 * 00028 * Alternatively, the contents of this file may be used under the terms of 00029 * the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser 00030 * Public License Version 2.1 (the "LGPL"), in which case the provisions of 00031 * the GPL or the LGPL are applicable instead of those above. If you wish to 00032 * allow use of your version of this file only under the terms of the either 00033 * the GPL or LGPL and not to allow others to use your version of this file 00034 * under the MPL, indicate your decision by deleting the provisions above 00035 * and replace them with the notice and other provisions required by the GPL 00036 * or LGPL. If you do not delete the provisions above, a recipient may use 00037 * your version of this file under the terms of any one of the MPL, the GPL 00038 * or the LGPL. 00039 * ***** END LICENSE BLOCK ***** */ 00040 00041 #ifndef _PIC_IO_H_ 00042 #define _PIC_IO_H_ 00043 00044 #include <iostream> 00045 #include <fstream> 00046 00047 #include <libdirac_common/common.h> 00048 #include <libdirac_common/frame.h> 00049 00051 //--------------------------------------// 00052 //- -// 00053 //-Uncompressed picture file IO wrapper-// 00054 //- -// 00055 //--------------------------------------// 00057 00058 //Currently just a temporary fix to write raw bytes to file with a separate header. Horrible. 00059 //Should be extended for interfacing with players (DirectShow etc) and for wrapping frames 00060 //in MXF with suitable metadata as a single file/stream of uncompressed video. TJD 10Feb04. 00061 00062 //Subclass these to provide functionality for different file formats and for streaming. 00063 00065 00069 class PicOutput{ 00070 public: 00071 00073 00079 PicOutput(const char* output_name, 00080 const SeqParams& sp, 00081 bool write_header_only = false); 00082 00084 virtual ~PicOutput(); 00085 00087 virtual bool WriteNextFrame(const Frame& myframe); 00088 00090 virtual bool WritePicHeader(); 00091 00093 SeqParams& GetSeqParams() {return m_sparams;} 00094 00095 protected: 00096 00097 SeqParams m_sparams; 00098 std::ofstream* m_op_pic_ptr; 00099 std::ofstream* m_op_head_ptr; 00100 00102 virtual bool WriteComponent(const PicArray& pic_data, const CompSort& cs); 00103 00105 virtual bool OpenHeader(const char* output_name); 00106 00108 virtual bool OpenYUV(const char* output_name); 00109 }; 00110 00112 00115 class PicInput 00116 { 00117 public: 00118 00120 00124 PicInput(const char* input_name); 00125 00127 virtual ~PicInput(); 00128 00130 void SetPadding(const int xpd, const int ypd); 00131 00133 virtual bool ReadNextFrame(Frame& myframe); 00134 00136 virtual bool ReadPicHeader(); 00137 00139 void Skip( const int n); 00140 00141 00143 const SeqParams& GetSeqParams() const {return m_sparams;} 00144 00146 bool End() const ; 00147 00148 protected: 00149 00150 SeqParams m_sparams; 00151 std::ifstream* m_ip_pic_ptr; 00152 std::ifstream* m_ip_head_ptr; 00153 00154 //padding values 00155 int m_xpad,m_ypad; 00156 00158 virtual bool ReadComponent(PicArray& pic_data,const CompSort& cs); 00159 }; 00160 00161 #endif
© 2004 British Broadcasting Corporation.
Dirac code licensed under the Mozilla Public License (MPL) Version 1.1.
HTML documentation generated by Dimitri van Heesch's
excellent Doxygen tool.