1 /* 2 * Copyright (C) 2001 Carlos Hasan. 3 * Copyright (C) 2001 François Revol. 4 * Copyright (C) 2001 Axel Dörfler. 5 * Copyright (C) 2004 Marcus Overhagen. 6 * Copyright (C) 2009 Stephan Aßmus <superstippi@gmx.de>. 7 * 8 * All rights reserved. Distributed under the terms of the MIT License. 9 */ 10 #ifndef AVCODEC_DECODER_H 11 #define AVCODEC_DECODER_H 12 13 //! libavcodec based decoder for Haiku 14 15 #include <MediaFormats.h> 16 17 #include "DecoderPlugin.h" 18 #include "ReaderPlugin.h" 19 20 #include "CodecTable.h" 21 22 23 class AVCodecDecoder : public Decoder { 24 public: 25 AVCodecDecoder(); 26 27 virtual ~AVCodecDecoder(); 28 29 virtual void GetCodecInfo(media_codec_info* mci); 30 31 virtual status_t Setup(media_format* ioEncodedFormat, 32 const void* infoBuffer, size_t infoSize); 33 34 virtual status_t NegotiateOutputFormat( 35 media_format* inOutFormat); 36 37 virtual status_t Decode(void* outBuffer, int64* outFrameCount, 38 media_header* mediaHeader, 39 media_decode_info* info); 40 41 virtual status_t Seek(uint32 seekTo, int64 seekFrame, 42 int64* frame, bigtime_t seekTime, 43 bigtime_t* time); 44 45 46 private: 47 status_t _NegotiateAudioOutputFormat( 48 media_format* inOutFormat); 49 50 status_t _NegotiateVideoOutputFormat( 51 media_format* inOutFormat); 52 53 status_t _DecodeAudio(void* outBuffer, 54 int64* outFrameCount, 55 media_header* mediaHeader, 56 media_decode_info* info); 57 58 status_t _DecodeVideo(void* outBuffer, 59 int64* outFrameCount, 60 media_header* mediaHeader, 61 media_decode_info* info); 62 63 64 media_header fHeader; 65 media_format fInputFormat; 66 media_raw_video_format fOutputVideoFormat; 67 68 int64 fFrame; 69 bool fIsAudio; 70 71 int fCodecIndexInTable; 72 // helps to find codecpretty 73 74 // FFmpeg related members 75 AVCodec* fCodec; 76 AVCodecContext* fContext; 77 AVFrame* fInputPicture; 78 AVFrame* fOutputPicture; 79 80 bool fCodecInitDone; 81 82 gfx_convert_func fFormatConversionFunc; 83 84 char* fExtraData; 85 int fExtraDataSize; 86 int fBlockAlign; 87 88 bigtime_t fStartTime; 89 int32 fOutputFrameCount; 90 float fOutputFrameRate; 91 int fOutputFrameSize; 92 // sample size * channel count 93 94 const void* fChunkBuffer; 95 int32 fChunkBufferOffset; 96 size_t fChunkBufferSize; 97 98 char* fOutputBuffer; 99 int32 fOutputBufferOffset; 100 int32 fOutputBufferSize; 101 102 }; 103 104 #endif // AVCODEC_DECODER_H 105