xref: /haiku/src/add-ons/media/plugins/raw_decoder/RawDecoderPlugin.h (revision cda5b8808fd0262f0fac472f6cfa809f846a83cf)
1 /*
2  * Copyright (c) 2003-2004, Marcus Overhagen
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  *  * Redistributions of source code must retain the above copyright notice,
9  *    this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright notice,
11  *    this list of conditions and the following disclaimer in the documentation
12  *    and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
23  * OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 #ifndef _RAW_DECODER_PLUGIN_H
26 #define _RAW_DECODER_PLUGIN_H
27 
28 #include "DecoderPlugin.h"
29 
30 class RawDecoder : public Decoder
31 {
32 public:
33 	void		GetCodecInfo(media_codec_info *info);
34 
35 	status_t	Setup(media_format *ioEncodedFormat,
36 					  const void *infoBuffer, size_t infoSize);
37 
38 	status_t	NegotiateOutputFormat(media_format *ioDecodedFormat);
39 
40 	status_t	Seek(uint32 seekTo,
41 					 int64 seekFrame, int64 *frame,
42 					 bigtime_t seekTime, bigtime_t *time);
43 
44 	status_t	Decode(void *buffer, int64 *frameCount,
45 					   media_header *mediaHeader, media_decode_info *info);
46 
47 private:
48 	status_t	NegotiateVideoOutputFormat(media_format *ioDecodedFormat);
49 	status_t	NegotiateAudioOutputFormat(media_format *ioDecodedFormat);
50 
51 private:
52 	int32			fFrameRate;
53 	int32			fInputFrameSize;
54 	int32			fOutputFrameSize;
55 	int32			fInputSampleSize;
56 	int32			fOutputSampleSize;
57 	int32			fOutputBufferFrameCount;
58 	void 			(*fSwapInput)(void *data, int32 count);
59 	void 			(*fConvert)(void *dst, const void *src, int32 count);
60 	void 			(*fSwapOutput)(void *data, int32 count);
61 
62 	const void *	fChunkBuffer;
63 	size_t			fChunkSize;
64 
65 	bigtime_t		fStartTime;
66 
67 	media_format	fInputFormat;
68 };
69 
70 
71 class RawDecoderPlugin : public DecoderPlugin
72 {
73 public:
74 	Decoder *	NewDecoder(uint index);
75 	status_t	GetSupportedFormats(media_format ** formats, size_t * count);
76 };
77 
78 #endif
79