1/*
2 *  ac3_decoder.h
3 *  Copyright (C) 2004 Marcus Overhagen <marcus@overhagen.de>
4 *
5 *  This file is part of an AC-3 decoder plugin for the OpenBeOS
6 *  media kit. OpenBeOS can be found at http://www.openbeos.org
7 *
8 *  This file is distributed under the terms of the MIT license.
9 *  You can also use it under the terms of the GPL version 2.
10 *
11 *  Since this file is linked against a GPL licensed library,
12 *  the combined work of this file and the liba52 library, the
13 *  ac3_decoder plugin must be distributed as GPL licensed.
14 */
15
16#ifndef _AC3_DECODER_H
17#define _AC3_DECODER_H
18
19#include <inttypes.h>
20#include "DecoderPlugin.h"
21
22extern "C" {
23	#include "liba52/config.h"
24	#include "liba52/a52.h"
25}
26
27
28class AC3Decoder : public Decoder
29{
30public:
31				AC3Decoder();
32				~AC3Decoder();
33
34	void		GetCodecInfo(media_codec_info *info);
35
36	status_t	Setup(media_format *ioEncodedFormat,
37					  const void *infoBuffer, size_t infoSize);
38
39	status_t	NegotiateOutputFormat(media_format *ioDecodedFormat);
40
41	status_t	SeekedTo(int64 frame, bigtime_t time);
42
43	bool		GetStreamInfo();
44
45	status_t	Decode(void *buffer, int64 *frameCount,
46					   media_header *mediaHeader, media_decode_info *info);
47
48	bool		InputGetData(void **buffer, int size);
49	void		InputRemoveData(int size);
50
51	bool		DecodeNext();
52
53private:
54	enum {		INPUT_BUFFER_MAX_SIZE = 4000 }; // must be >= 3840
55	void *		fInputBuffer;
56	int			fInputBufferSize;
57
58	const void *fInputChunk;
59	size_t		fInputChunkSize;
60	int			fInputChunkOffset;
61
62	bigtime_t	fStartTime;
63	bool		fHasStreamInfo;
64	bool		fDisableDynamicCompression;
65
66	float *		fSamples;
67
68	a52_state_t *fState;
69
70	int 		fFlags;
71	int			fFrameRate;
72	int			fBitRate;
73	int			fFrameSize;
74	int			fChannelCount;
75	int			fChannelMask;
76	int			*fInterleaveOffset;
77
78	char		fChannelInfo[120];
79};
80
81
82class AC3DecoderPlugin : public DecoderPlugin
83{
84public:
85	Decoder *	NewDecoder(uint index);
86	status_t	GetSupportedFormats(media_format ** formats, size_t * count);
87};
88
89
90#endif // _AC3_DECODER_H
91