• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 Amlogic Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 
19 /**
20 * @file codec_type.h
21 * @brief  Definitions of codec type and structures
22 * @author Zhang Chen <chen.zhang@amlogic.com>
23 * @version 1.0.0
24 * @date 2011-02-24
25 */
26 /* Copyright (C) 2007-2011, Amlogic Inc.
27 * All right reserved
28 *
29 */
30 #ifndef CODEC_TYPE_H_
31 #define CODEC_TYPE_H_
32 
33 #include "amports/amstream.h"
34 #include "amports/vformat.h"
35 #include "amports/aformat.h"
36 #include "ppmgr/ppmgr.h"
37 #include <stdlib.h>
38 #include <stdint.h>
39 
40 typedef int CODEC_HANDLE;
41 
42 typedef enum {
43     STREAM_TYPE_UNKNOW,
44     STREAM_TYPE_ES_VIDEO,
45     STREAM_TYPE_ES_AUDIO,
46     STREAM_TYPE_ES_SUB,
47     STREAM_TYPE_PS,
48     STREAM_TYPE_TS,
49     STREAM_TYPE_RM,
50 } stream_type_t;
51 
52 typedef enum {
53     DECODER_TYPE_SINGLE_MODE,
54     DECODER_TYPE_FRAME_MODE,
55     DECODER_TYPE_STREAM_MODE,
56 } decoder_type_t;
57 
58 typedef enum {
59     DISPLAY_MODE_AMVIDEO,
60     DISPLAY_MODE_PIPVIDEO,
61 } display_mode_type_t;
62 
63 typedef struct {
64     unsigned int    format;  ///< video format, such as H264, MPEG2...
65     unsigned int    width;   ///< video source width
66     unsigned int    height;  ///< video source height
67     unsigned int    rate;    ///< video source frame duration
68     unsigned int    extra;   ///< extra data information of video stream
69     unsigned int    status;  ///< status of video stream
70     unsigned int    ratio;   ///< aspect ratio of video source
71     void *          param;   ///< other parameters for video decoder
72     unsigned long long    ratio64;   ///< aspect ratio of video source
73 } dec_sysinfo_t;
74 
75 typedef struct {
76     int valid;               ///< audio extradata valid(1) or invalid(0), set by dsp
77     int sample_rate;         ///< audio stream sample rate
78     int channels;            ///< audio stream channels
79     int bitrate;             ///< audio stream bit rate
80     int codec_id;            ///< codec format id
81     int block_align;         ///< audio block align from ffmpeg
82     int extradata_size;      ///< extra data size
83     char extradata[AUDIO_EXTRA_DATA_SIZE];;   ///< extra data information for decoder
84 } audio_info_t;
85 
86 typedef struct {
87     int valid;               ///< audio extradata valid(1) or invalid(0), set by dsp
88     int sample_rate;         ///< audio stream sample rate
89     int channels;            ///< audio stream channels
90     int bitrate;             ///< audio stream bit rate
91     int codec_id;            ///< codec format id
92     int block_align;         ///< audio block align from ffmpeg
93     int extradata_size;      ///< extra data size
94     char extradata[512];;   ///< extra data information for decoder
95 } Asf_audio_info_t;
96 
97 typedef struct {
98     CODEC_HANDLE handle;        ///< codec device handler
99     CODEC_HANDLE cntl_handle;   ///< video control device handler
100     CODEC_HANDLE sub_handle;    ///< subtile device handler
101     CODEC_HANDLE audio_utils_handle;  ///< audio utils handler
102     stream_type_t stream_type;  ///< stream type(es, ps, rm, ts)
103 unsigned int has_video:
104     1;                          ///< stream has video(1) or not(0)
105 unsigned int  has_audio:
106     1;                          ///< stream has audio(1) or not(0)
107 unsigned int has_sub:
108     1;                          ///< stream has subtitle(1) or not(0)
109 unsigned int noblock:
110     1;                          ///< codec device is NONBLOCK(1) or not(0)
111     int video_type;             ///< stream video type(H264, VC1...)
112     int audio_type;             ///< stream audio type(PCM, WMA...)
113     int sub_type;               ///< stream subtitle type(TXT, SSA...)
114     int video_pid;              ///< stream video pid
115     int audio_pid;              ///< stream audio pid
116     int sub_pid;                ///< stream subtitle pid
117     int audio_channels;         ///< stream audio channel number
118     int audio_samplerate;       ///< steram audio sample rate
119     int vbuf_size;              ///< video buffer size of codec device
120     int abuf_size;              ///< audio buffer size of codec device
121     dec_sysinfo_t am_sysinfo;   ///< system information for video
122     audio_info_t audio_info;    ///< audio information pass to audiodsp
123     int packet_size;            ///< data size per packet
124     int avsync_threshold;    ///<for adec in ms>
125     void * adec_priv;          ///<for adec>
126     void * amsub_priv;          // <for amsub>
127     int SessionID;
128     int dspdec_not_supported;//check some profile that audiodsp decoder can not support,we switch to arm decoder
129     int switch_audio_flag;      //<switch audio flag switching(1) else(0)
130     int automute_flag;
131     decoder_type_t decoder_type;
132     display_mode_type_t display_mode;
133     char *sub_filename;
134     int associate_dec_supported;//support associate or not
135     int mixing_level;
136     int use_hardabuf;
137     unsigned int drmmode;
138     enum FRAME_BASE_VIDEO_PATH video_path;
139 } codec_para_t;
140 
141 typedef struct {
142     signed char id;
143     unsigned char width;
144     unsigned char height;
145     unsigned char type;
146 } subtitle_info_t;
147 #define MAX_SUB_NUM         (32)
148 
149 #define IS_VALID_PID(t)     (t>=0 && t<=0x1fff)
150 #define IS_VALID_STREAM(t)  (t>0 && t<=0x1fff)
151 #define IS_VALID_ATYPE(t)   (t>=0 && t<AFORMAT_MAX)
152 #define IS_VALID_VTYPE(t)   (t>=0 && t<VFORMAT_MAX)
153 
154 //pass to arm audio decoder
155 typedef struct {
156     int sample_rate;         ///< audio stream sample rate
157     int channels;            ///< audio stream channels
158     int format;            ///< codec format id
159     int bitrate;
160     int block_align;
161     int codec_id;         //original codecid corespingding to ffmepg
162     int handle;        ///< codec device handler
163     int extradata_size;      ///< extra data size
164     char extradata[AUDIO_EXTRA_DATA_SIZE];
165     int SessionID;
166     int dspdec_not_supported;//check some profile that audiodsp decoder can not support,we switch to arm decoder
167     int droppcm_flag;               // drop pcm flag, if switch audio (1)
168     int automute;
169     unsigned int has_video;
170     int associate_dec_supported;//support associate or not
171     int mixing_level;
172 	int use_hardabuf;
173 } arm_audio_info;
174 
175 
176 typedef struct {
177     int sub_type;
178     int sub_pid;
179     int stream_type;  // to judge sub how to get data
180     char *sub_filename;
181     unsigned int curr_timeMs; //for idx+sub
182     unsigned int next_pts; //for idx+sub
183 
184     unsigned int pts;
185     unsigned int m_delay;
186     unsigned short sub_start_x;
187     unsigned short sub_start_y;
188     unsigned short sub_width;
189     unsigned short sub_height;
190     char * odata;    // point to decoder data
191     unsigned buffer_size;
192 } amsub_info_t;
193 
194 #define TYPE_DRMINFO   0x80
195 #define TYPE_PATTERN   0x40
196 
197 typedef enum {
198     DRM_LEVEL1     = 1,
199     DRM_LEVEL2     = 2,
200     DRM_LEVEL3     = 3,
201     DRM_NONE       = 4,
202 } drm_level_t;
203 
204 typedef struct drm_info {
205     drm_level_t drm_level;
206     uint32_t drm_flag;
207     uint32_t drm_hasesdata;
208     uint32_t drm_priv;
209     uint32_t drm_pktsize;
210     uint32_t drm_pktpts;
211     uint32_t drm_phy;
212     uint32_t drm_vir;
213     uint32_t drm_remap;
214     uint32_t data_offset;
215     uint32_t handle;
216     uint32_t extpad[7];
217 } drminfo_t;
218 
219 //audio decoder type, default arc
220 #define AUDIO_ARC_DECODER 0
221 #define AUDIO_ARM_DECODER 1
222 #define AUDIO_FFMPEG_DECODER 2
223 #define AUDIO_ARMWFD_DECODER  3
224 #endif
225