00001 /* 00002 * Copyright (C) Massimo Cora' 2006 <maxcvs@email.it> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #ifndef _OSTREAMVIDEODECODER_H_ 00020 #define _OSTREAMVIDEODECODER_H_ 00021 00022 #include <cv.h> 00023 #include <highgui.h> 00024 #include <ffmpeg/avcodec.h> 00025 #include <ffmpeg/avformat.h> 00026 00027 #include "OStreamConfig.hh" 00028 00034 class OStreamVideoDecoder 00035 { 00036 public: 00047 OStreamVideoDecoder( unsigned int io_buf_size, ostream_decoding_type decoding_type, 00048 int fps = 25, 00049 PixelFormat opencv_pix_fmt = PIX_FMT_BGR24 ); 00050 00051 virtual ~OStreamVideoDecoder(); 00052 00059 IplImage* decode_video_frame( unsigned char* buf, int buf_size ); 00060 00061 private: // functions 00066 bool decoder_initialize (); 00067 00077 AVFrame* create_avframe( int pixel_format, int frame_width, int frame_height ); 00078 00079 private: // data 00081 bool _initialized; 00082 00084 unsigned char* _internal_buffer; 00085 int _internal_buffer_size; 00086 00088 int _decoding_type; 00089 00091 int _fps; 00092 00094 AVCodec *_codec_decode; 00095 00097 AVCodecContext *_codec_context; 00098 00100 AVFrame *_decoded_frame; 00101 00103 AVFrame *_opencv_ready_frame; 00104 00106 PixelFormat _opencv_pix_fmt; 00107 }; 00108 00109 00110 #endif //_OSTREAMVIDEODECODER_H_ 00111