summaryrefslogtreecommitdiff
path: root/decoder.h
blob: c14a48f92a2c4c5965d5ecb4322093fa5f14f5d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * decoder.h: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id$
 */

#ifndef __decoder_h_
#define __decoder_h_

#define __STDC_CONSTANT_MACROS

#include <vdr/tools.h> // needed for (d/e/i)syslog
#include <stdint.h>
#include <sched.h>

#ifndef DECLARE_ALIGNED
#define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n)))
#endif

#ifndef CPU_COUNT
#define CPU_COUNT(i) 1 // very crude ;)
#endif

#ifndef uchar
typedef unsigned char uchar;
#endif

extern "C"
{
#include <libavcodec/avcodec.h>

#if LIBAVCODEC_VERSION_INT < ((52<<16)+(23<<8)+0)
#include <libavformat/avformat.h>
#endif
}

#include "global.h"

class cMarkAdDecoder
{
private:
    int recvnumber;
    int16_t *audiobuf;
    int audiobufsize;

    AVCodecContext *ac3_context;
    AVCodecContext *mp2_context;
    AVCodecContext *video_context;
    AVFrame *video_frame;

    int8_t *last_qscale_table;

    bool SetAudioInfos(MarkAdContext *maContext, AVCodecContext *Audio_Context);

    void PAR2DAR(AVRational a, AVRational *erg);
    bool SetVideoInfos(MarkAdContext *maContext,AVCodecContext *Video_Context,
                       AVFrame *Video_Frame, AVRational *DAR);
public:
    bool DecodeVideo(MarkAdContext *maContext, uchar *pkt, int plen);
    bool DecodeMP2(MarkAdContext *maContext, uchar *espkt, int eslen);
    bool DecodeAC3(MarkAdContext *maContext, uchar *espkt, int eslen);
    cMarkAdDecoder(int recvnumber, bool useH264, bool useMP2, bool hasAC3);
    ~cMarkAdDecoder();
};



#endif