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 extern "C" { 18 #include "swscale.h" 19 } 20 21 #include "DecoderPlugin.h" 22 #include "ReaderPlugin.h" 23 24 #include "CodecTable.h" 25 26 27 class AVCodecDecoder : public Decoder { 28 public: 29 AVCodecDecoder(); 30 31 virtual ~AVCodecDecoder(); 32 33 virtual void GetCodecInfo(media_codec_info* mci); 34 35 virtual status_t Setup(media_format* ioEncodedFormat, 36 const void* infoBuffer, size_t infoSize); 37 38 virtual status_t NegotiateOutputFormat( 39 media_format* inOutFormat); 40 41 virtual status_t Decode(void* outBuffer, int64* outFrameCount, 42 media_header* mediaHeader, 43 media_decode_info* info); 44 45 virtual status_t Seek(uint32 seekTo, int64 seekFrame, 46 int64* frame, bigtime_t seekTime, 47 bigtime_t* time); 48 49 50 private: 51 status_t _NegotiateAudioOutputFormat( 52 media_format* inOutFormat); 53 54 status_t _NegotiateVideoOutputFormat( 55 media_format* inOutFormat); 56 57 status_t _DecodeAudio(void* outBuffer, 58 int64* outFrameCount, 59 media_header* mediaHeader, 60 media_decode_info* info); 61 62 status_t _DecodeVideo(void* outBuffer, 63 int64* outFrameCount, 64 media_header* mediaHeader, 65 media_decode_info* info); 66 67 68 media_header fHeader; 69 media_format fInputFormat; 70 media_raw_video_format fOutputVideoFormat; 71 72 int64 fFrame; 73 bool fIsAudio; 74 75 int fCodecIndexInTable; 76 // helps to find codecpretty 77 78 // FFmpeg related members 79 AVCodec* fCodec; 80 AVCodecContext* fContext; 81 AVFrame* fInputPicture; 82 AVFrame* fOutputPicture; 83 84 bool fCodecInitDone; 85 86 gfx_convert_func fFormatConversionFunc; 87 SwsContext* fSwsContext; 88 89 char* fExtraData; 90 int fExtraDataSize; 91 int fBlockAlign; 92 93 bigtime_t fStartTime; 94 int32 fOutputFrameCount; 95 float fOutputFrameRate; 96 int fOutputFrameSize; 97 // sample size * channel count 98 99 const void* fChunkBuffer; 100 int32 fChunkBufferOffset; 101 size_t fChunkBufferSize; 102 bool fAudioDecodeError; 103 104 char* fOutputBuffer; 105 int32 fOutputBufferOffset; 106 int32 fOutputBufferSize; 107 108 }; 109 110 #endif // AVCODEC_DECODER_H 111