2 * GPAC - Multimedia Framework C SDK
\r
4 * Copyright (c) Jean Le Feuvre 2000-2005
\r
5 * All rights reserved
\r
7 * This file is part of GPAC / Authoring Tools sub-project
\r
9 * GPAC is free software; you can redistribute it and/or modify
\r
10 * it under the terms of the GNU Lesser General Public License as published by
\r
11 * the Free Software Foundation; either version 2, or (at your option)
\r
12 * any later version.
\r
14 * GPAC is distributed in the hope that it will be useful,
\r
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
17 * GNU Lesser General Public License for more details.
\r
19 * You should have received a copy of the GNU Lesser General Public
\r
20 * License along with this library; see the file COPYING. If not, write to
\r
21 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
\r
25 #ifndef _GF_PARSERS_AV_H_
\r
26 #define _GF_PARSERS_AV_H_
\r
33 #include <gpac/bitstream.h>
\r
35 /*basic MPEG (1,2,4) visual object parser (DSI extraction and timing/framing)*/
\r
40 u8 RAP_stream, objectType, has_shape, enh_layer;
\r
41 /*video resolution*/
\r
43 /*pixel aspect ratio*/
\r
44 u8 par_num, par_den;
\r
47 u8 NumBitsTimeIncrement;
\r
51 } GF_M4VDecSpecInfo;
\r
54 typedef struct __tag_m4v_parser GF_M4VParser;
\r
56 GF_M4VParser *gf_m4v_parser_new(char *data, u32 data_size, Bool mpeg12video);
\r
57 GF_M4VParser *gf_m4v_parser_bs_new(GF_BitStream *bs, Bool mpeg12video);
\r
58 void gf_m4v_parser_del(GF_M4VParser *m4v);
\r
59 GF_Err gf_m4v_parse_config(GF_M4VParser *m4v, GF_M4VDecSpecInfo *dsi);
\r
61 /*get a frame (can contain GOP). The parser ALWAYS resync on the next object in the bitstream
\r
62 thus you can seek the bitstream to copy the payload without re-seeking it */
\r
63 GF_Err gf_m4v_parse_frame(GF_M4VParser *m4v, GF_M4VDecSpecInfo dsi, u8 *frame_type, u32 *time_inc, u32 *size, u32 *start, Bool *is_coded);
\r
64 /*returns current object start in bitstream*/
\r
65 u32 gf_m4v_get_object_start(GF_M4VParser *m4v);
\r
66 /*returns 1 if current object is a valid MPEG-4 Visual object*/
\r
67 Bool gf_m4v_is_valid_object_type(GF_M4VParser *m4v);
\r
68 /*returns readable description of profile*/
\r
69 const char *gf_m4v_get_profile_name(u8 video_pl);
\r
71 GF_Err gf_m4v_get_config(char *rawdsi, u32 rawdsi_size, GF_M4VDecSpecInfo *dsi);
\r
72 /*rewrites PL code in DSI*/
\r
73 void gf_m4v_rewrite_pl(char **io_dsi, u32 *io_dsi_len, u8 PL);
\r
74 /*rewrites PAR code in DSI. Negative values will remove the par*/
\r
75 GF_Err gf_m4v_rewrite_par(char **o_data, u32 *o_dataLen, s32 par_n, s32 par_d);
\r
78 u8 gf_mp3_num_channels(u32 hdr);
\r
79 u16 gf_mp3_sampling_rate(u32 hdr);
\r
80 u16 gf_mp3_window_size(u32 hdr);
\r
81 u16 gf_mp3_bit_rate(u32 hdr);
\r
82 u8 gf_mp3_object_type_indication(u32 hdr);
\r
83 u8 gf_mp3_layer(u32 hdr);
\r
84 u8 gf_mp3_version(u32 hdr);
\r
85 const char *gf_mp3_version_name(u32 hdr);
\r
86 u16 gf_mp3_frame_size(u32 hdr);
\r
87 u32 gf_mp3_get_next_header(FILE* in);
\r
88 u32 gf_mp3_get_next_header_mem(char *buffer, u32 size, u32 *pos);
\r
93 u32 sample_rate, channels, version;
\r
94 s32 max_r, avg_r, low_r;
\r
95 u32 min_block, max_block;
\r
97 /*do not touch, parser private*/
\r
100 Bool mode_flag[64];
\r
103 /*call with vorbis header packets - you MUST initialize the structure to 0 before!!
\r
104 returns 1 if success, 0 if error.*/
\r
105 Bool gf_vorbis_parse_header(GF_VorbisParser *vp, char *data, u32 data_len);
\r
106 /*returns 0 if init error or not a vorbis frame, otherwise returns the number of audio samples
\r
108 u32 gf_vorbis_check_frame(GF_VorbisParser *vp, char *data, u32 data_length);
\r
113 GF_M4A_AAC_MAIN = 1,
\r
115 GF_M4A_AAC_SSR = 3,
\r
116 GF_M4A_AAC_LTP = 4,
\r
117 GF_M4A_AAC_SBR = 5,
\r
118 GF_M4A_AAC_SCALABLE = 6,
\r
123 GF_M4A_MAIN_SYNTHETIC = 13,
\r
124 GF_M4A_WAVETABLE_SYNTHESIS = 14,
\r
125 GF_M4A_GENERAL_MIDI = 15,
\r
126 GF_M4A_ALGO_SYNTH_AUDIO_FX = 16,
\r
127 GF_M4A_ER_AAC_LC = 17,
\r
128 GF_M4A_ER_AAC_LTP = 19,
\r
129 GF_M4A_ER_AAC_SCALABLE = 20,
\r
130 GF_M4A_ER_TWINVQ = 21,
\r
131 GF_M4A_ER_BSAC = 22,
\r
132 GF_M4A_ER_AAC_LD = 23,
\r
133 GF_M4A_ER_CELP = 24,
\r
134 GF_M4A_ER_HVXC = 25,
\r
135 GF_M4A_ER_HILN = 26,
\r
136 GF_M4A_ER_PARAMETRIC = 27,
\r
139 GF_M4A_LAYER1 = 32,
\r
140 GF_M4A_LAYER2 = 33,
\r
141 GF_M4A_LAYER3 = 34,
\r
146 static const u32 GF_M4ASampleRates[] =
\r
148 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050,
\r
149 16000, 12000, 11025, 8000, 7350, 0, 0, 0
\r
152 /*get Audio type from dsi. return audio codec type:*/
\r
156 u32 base_object_type, base_sr, base_sr_index;
\r
159 u32 sbr_object_type, sbr_sr, sbr_sr_index;
\r
162 } GF_M4ADecSpecInfo;
\r
163 /*parses dsi and updates audioPL*/
\r
164 GF_Err gf_m4a_get_config(char *dsi, u32 dsi_size, GF_M4ADecSpecInfo *cfg);
\r
165 /*gets audioPL for given cfg*/
\r
166 u32 gf_m4a_get_profile(GF_M4ADecSpecInfo *cfg);
\r
167 const char *gf_m4a_object_type_name(u32 objectType);
\r
168 const char *gf_m4a_get_profile_name(u8 audio_pl);
\r
170 GF_Err gf_m4a_write_config(GF_M4ADecSpecInfo *cfg, char **dsi, u32 *dsi_size);
\r
171 GF_Err gf_m4a_parse_config(GF_BitStream *bs, GF_M4ADecSpecInfo *cfg, Bool size_known);
\r
179 /*only set if full parse*/
\r
180 u8 fscod, bsid, bsmod, acmod, lfon, brcode;
\r
183 Bool gf_ac3_parser(u8 *buffer, u32 buffer_size, u32 *pos, GF_AC3Header *out_hdr, Bool full_parse);
\r
184 Bool gf_ac3_parser_bs(GF_BitStream *bs, GF_AC3Header *hdr, Bool full_parse);
\r
187 GF_Err gf_avc_get_sps_info(char *sps, u32 sps_size, u32 *width, u32 *height, s32 *par_n, s32 *par_d);
\r
189 const char *gf_avc_get_profile_name(u8 video_prof);
\r
192 /*gets image size (bs must contain the whole image)
\r
193 @OTI: image type (JPEG=0x6C, PNG=0x6D)
\r
194 @width, height: image resolution - for jpeg max size if thumbnail included*/
\r
195 void gf_img_parse(GF_BitStream *bs, u8 *OTI, u32 *mtype, u32 *width, u32 *height, char **dsi, u32 *dsi_len);
\r
197 GF_Err gf_img_jpeg_dec(char *jpg, u32 jpg_size, u32 *width, u32 *height, u32 *pixel_format, char *dst, u32 *dst_size, u32 dst_nb_comp);
\r
199 GF_Err gf_img_png_dec(char *png, u32 png_size, u32 *width, u32 *height, u32 *pixel_format, char *dst, u32 *dst_size);
\r
200 GF_Err gf_img_png_enc(char *data, u32 width, u32 height, u32 pixel_format, char *dst, u32 *dst_size);
\r
207 #endif /*_GF_PARSERS_AV_H_*/
\r