OSDN Git Service

add tstools.
[rec10/rec10-git.git] / tstools / DtsEdit / src / gpac / avparse.h
diff --git a/tstools/DtsEdit/src/gpac/avparse.h b/tstools/DtsEdit/src/gpac/avparse.h
new file mode 100644 (file)
index 0000000..6cc9aaf
--- /dev/null
@@ -0,0 +1,208 @@
+/*\r
+ *                     GPAC - Multimedia Framework C SDK\r
+ *\r
+ *                     Copyright (c) Jean Le Feuvre 2000-2005 \r
+ *                                     All rights reserved\r
+ *\r
+ *  This file is part of GPAC / Authoring Tools sub-project\r
+ *\r
+ *  GPAC is free software; you can redistribute it and/or modify\r
+ *  it under the terms of the GNU Lesser General Public License as published by\r
+ *  the Free Software Foundation; either version 2, or (at your option)\r
+ *  any later version.\r
+ *   \r
+ *  GPAC is distributed in the hope that it will be useful,\r
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *  GNU Lesser General Public License for more details.\r
+ *   \r
+ *  You should have received a copy of the GNU Lesser General Public\r
+ *  License along with this library; see the file COPYING.  If not, write to\r
+ *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. \r
+ *\r
+ */\r
+\r
+#ifndef _GF_PARSERS_AV_H_\r
+#define _GF_PARSERS_AV_H_\r
+\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+#include <gpac/bitstream.h>\r
+\r
+/*basic MPEG (1,2,4) visual object parser (DSI extraction and timing/framing)*/\r
+typedef struct\r
+{\r
+       /*video PL*/\r
+       u8 VideoPL;\r
+       u8 RAP_stream, objectType, has_shape, enh_layer;\r
+       /*video resolution*/\r
+       u16 width, height;\r
+       /*pixel aspect ratio*/\r
+       u8 par_num, par_den;\r
+\r
+       u16 clock_rate;\r
+       u8 NumBitsTimeIncrement;\r
+       u32 time_increment;\r
+       /*for MPEG 1/2*/\r
+       Double fps;\r
+} GF_M4VDecSpecInfo;\r
+\r
+\r
+typedef struct __tag_m4v_parser GF_M4VParser;\r
+\r
+GF_M4VParser *gf_m4v_parser_new(char *data, u32 data_size, Bool mpeg12video);\r
+GF_M4VParser *gf_m4v_parser_bs_new(GF_BitStream *bs, Bool mpeg12video);\r
+void gf_m4v_parser_del(GF_M4VParser *m4v);\r
+GF_Err gf_m4v_parse_config(GF_M4VParser *m4v, GF_M4VDecSpecInfo *dsi);\r
+\r
+/*get a frame (can contain GOP). The parser ALWAYS resync on the next object in the bitstream\r
+thus you can seek the bitstream to copy the payload without re-seeking it */\r
+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
+/*returns current object start in bitstream*/\r
+u32 gf_m4v_get_object_start(GF_M4VParser *m4v);\r
+/*returns 1 if current object is a valid MPEG-4 Visual object*/\r
+Bool gf_m4v_is_valid_object_type(GF_M4VParser *m4v);\r
+/*returns readable description of profile*/\r
+const char *gf_m4v_get_profile_name(u8 video_pl);\r
+/*decodes DSI*/\r
+GF_Err gf_m4v_get_config(char *rawdsi, u32 rawdsi_size, GF_M4VDecSpecInfo *dsi);\r
+/*rewrites PL code in DSI*/\r
+void gf_m4v_rewrite_pl(char **io_dsi, u32 *io_dsi_len, u8 PL);\r
+/*rewrites PAR code in DSI. Negative values will remove the par*/\r
+GF_Err gf_m4v_rewrite_par(char **o_data, u32 *o_dataLen, s32 par_n, s32 par_d);\r
+\r
+/*MP3 tools*/\r
+u8 gf_mp3_num_channels(u32 hdr);\r
+u16 gf_mp3_sampling_rate(u32 hdr);\r
+u16 gf_mp3_window_size(u32 hdr);\r
+u16 gf_mp3_bit_rate(u32 hdr);\r
+u8 gf_mp3_object_type_indication(u32 hdr);\r
+u8 gf_mp3_layer(u32 hdr);\r
+u8 gf_mp3_version(u32 hdr);\r
+const char *gf_mp3_version_name(u32 hdr);\r
+u16 gf_mp3_frame_size(u32 hdr);\r
+u32 gf_mp3_get_next_header(FILE* in);\r
+u32 gf_mp3_get_next_header_mem(char *buffer, u32 size, u32 *pos);\r
+\r
+/*vorbis tools*/\r
+typedef struct\r
+{\r
+       u32 sample_rate, channels, version;\r
+       s32 max_r, avg_r, low_r;\r
+       u32 min_block, max_block;\r
+\r
+       /*do not touch, parser private*/\r
+       Bool is_init;\r
+       u32 modebits;\r
+       Bool mode_flag[64];\r
+} GF_VorbisParser;\r
+\r
+/*call with vorbis header packets - you MUST initialize the structure to 0 before!!\r
+returns 1 if success, 0 if error.*/\r
+Bool gf_vorbis_parse_header(GF_VorbisParser *vp, char *data, u32 data_len);\r
+/*returns 0 if init error or not a vorbis frame, otherwise returns the number of audio samples\r
+in this frame*/\r
+u32 gf_vorbis_check_frame(GF_VorbisParser *vp, char *data, u32 data_length);\r
+\r
+\r
+enum\r
+{\r
+    GF_M4A_AAC_MAIN = 1,\r
+    GF_M4A_AAC_LC = 2,\r
+    GF_M4A_AAC_SSR = 3,\r
+    GF_M4A_AAC_LTP = 4,\r
+    GF_M4A_AAC_SBR = 5,\r
+    GF_M4A_AAC_SCALABLE = 6,\r
+    GF_M4A_TWINVQ = 7,\r
+    GF_M4A_CELP = 8, \r
+    GF_M4A_HVXC = 9,\r
+    GF_M4A_TTSI = 12,\r
+    GF_M4A_MAIN_SYNTHETIC = 13,\r
+    GF_M4A_WAVETABLE_SYNTHESIS = 14,\r
+    GF_M4A_GENERAL_MIDI = 15,\r
+    GF_M4A_ALGO_SYNTH_AUDIO_FX = 16,\r
+    GF_M4A_ER_AAC_LC = 17,\r
+    GF_M4A_ER_AAC_LTP = 19,\r
+    GF_M4A_ER_AAC_SCALABLE = 20,\r
+    GF_M4A_ER_TWINVQ = 21,\r
+    GF_M4A_ER_BSAC = 22,\r
+    GF_M4A_ER_AAC_LD = 23,\r
+    GF_M4A_ER_CELP = 24,\r
+    GF_M4A_ER_HVXC = 25,\r
+    GF_M4A_ER_HILN = 26,\r
+    GF_M4A_ER_PARAMETRIC = 27,\r
+    GF_M4A_SSC = 28,\r
+    //GF_M4A_PS = 29,\r
+    GF_M4A_LAYER1 = 32,\r
+    GF_M4A_LAYER2 = 33,\r
+    GF_M4A_LAYER3 = 34,\r
+    GF_M4A_DST = 35,\r
+    GF_M4A_ALS = 36,\r
+};\r
+\r
+static const u32 GF_M4ASampleRates[] =\r
+{\r
+    96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, \r
+       16000, 12000, 11025, 8000, 7350, 0, 0, 0\r
+};\r
+\r
+/*get Audio type from dsi. return audio codec type:*/\r
+typedef struct\r
+{\r
+       u32 nb_chan;\r
+       u32 base_object_type, base_sr, base_sr_index;\r
+       /*SBR*/\r
+       Bool has_sbr;\r
+       u32 sbr_object_type, sbr_sr, sbr_sr_index;\r
+       /*PL indication*/\r
+       u8 audioPL;\r
+} GF_M4ADecSpecInfo;\r
+/*parses dsi and updates audioPL*/\r
+GF_Err gf_m4a_get_config(char *dsi, u32 dsi_size, GF_M4ADecSpecInfo *cfg);\r
+/*gets audioPL for given cfg*/\r
+u32 gf_m4a_get_profile(GF_M4ADecSpecInfo *cfg);\r
+const char *gf_m4a_object_type_name(u32 objectType);\r
+const char *gf_m4a_get_profile_name(u8 audio_pl);\r
+\r
+GF_Err gf_m4a_write_config(GF_M4ADecSpecInfo *cfg, char **dsi, u32 *dsi_size);\r
+GF_Err gf_m4a_parse_config(GF_BitStream *bs, GF_M4ADecSpecInfo *cfg, Bool size_known);\r
+\r
+typedef struct\r
+{\r
+       u32 bitrate;\r
+       u32 sample_rate;\r
+       u32 framesize;\r
+       u32 channels;\r
+       /*only set if full parse*/\r
+       u8 fscod, bsid, bsmod, acmod, lfon, brcode;\r
+} GF_AC3Header;\r
+\r
+Bool gf_ac3_parser(u8 *buffer, u32 buffer_size, u32 *pos, GF_AC3Header *out_hdr, Bool full_parse);\r
+Bool gf_ac3_parser_bs(GF_BitStream *bs, GF_AC3Header *hdr, Bool full_parse);\r
+\r
+\r
+GF_Err gf_avc_get_sps_info(char *sps, u32 sps_size, u32 *width, u32 *height, s32 *par_n, s32 *par_d);\r
+\r
+const char *gf_avc_get_profile_name(u8 video_prof);\r
+\r
+\r
+/*gets image size (bs must contain the whole image) \r
+@OTI: image type (JPEG=0x6C, PNG=0x6D)\r
+@width, height: image resolution - for jpeg max size if thumbnail included*/\r
+void gf_img_parse(GF_BitStream *bs, u8 *OTI, u32 *mtype, u32 *width, u32 *height, char **dsi, u32 *dsi_len);\r
+\r
+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
+\r
+GF_Err gf_img_png_dec(char *png, u32 png_size, u32 *width, u32 *height, u32 *pixel_format, char *dst, u32 *dst_size);\r
+GF_Err gf_img_png_enc(char *data, u32 width, u32 height, u32 pixel_format, char *dst, u32 *dst_size);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+\r
+#endif /*_GF_PARSERS_AV_H_*/\r
+\r