[FFmpeg-cvslog] r12944 - in trunk/libavcodec: ac3.h ac3_parser.c ac3_parser.h ac3tab.c ac3tab.h
bwolowiec
subversion
Fri Apr 25 00:27:14 CEST 2008
Author: bwolowiec
Date: Fri Apr 25 00:27:13 2008
New Revision: 12944
Log:
add a ff_ac3_parse_header_full() which calls ff_ac3_parse_header()
and then reads the channel_map stuff
Modified:
trunk/libavcodec/ac3.h
trunk/libavcodec/ac3_parser.c
trunk/libavcodec/ac3_parser.h
trunk/libavcodec/ac3tab.c
trunk/libavcodec/ac3tab.h
Modified: trunk/libavcodec/ac3.h
==============================================================================
--- trunk/libavcodec/ac3.h (original)
+++ trunk/libavcodec/ac3.h Fri Apr 25 00:27:13 2008
@@ -97,6 +97,7 @@ typedef struct {
uint16_t frame_size;
int center_mix_level; ///< Center mix level index
int surround_mix_level; ///< Surround mix level index
+ uint16_t channel_map;
/** @} */
} AC3HeaderInfo;
Modified: trunk/libavcodec/ac3_parser.c
==============================================================================
--- trunk/libavcodec/ac3_parser.c (original)
+++ trunk/libavcodec/ac3_parser.c Fri Apr 25 00:27:13 2008
@@ -136,6 +136,35 @@ int ff_ac3_parse_header(GetBitContext *g
return 0;
}
+int ff_ac3_parse_header_full(GetBitContext *gbc, AC3HeaderInfo *hdr){
+ int ret, i;
+ ret = ff_ac3_parse_header(gbc, hdr);
+ if(!ret){
+ if(hdr->bitstream_id>10){
+ /* Enhanced AC-3 */
+ skip_bits(gbc, 5); // skip bitstream id
+
+ /* skip dialog normalization and compression gain */
+ for (i = 0; i < (hdr->channel_mode ? 1 : 2); i++) {
+ skip_bits(gbc, 5); // skip dialog normalization
+ if (get_bits1(gbc)) {
+ skip_bits(gbc, 8); //skip Compression gain word
+ }
+ }
+ /* dependent stream channel map */
+ if (hdr->frame_type == EAC3_FRAME_TYPE_DEPENDENT && get_bits1(gbc)) {
+ hdr->channel_map = get_bits(gbc, 16); //custom channel map
+ return 0;
+ }
+ }
+ //default channel map based on acmod and lfeon
+ hdr->channel_map = ff_eac3_default_chmap[hdr->channel_mode];
+ if(hdr->lfe_on)
+ hdr->channel_map |= AC3_CHMAP_LFE;
+ }
+ return ret;
+}
+
static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info,
int *need_next_header, int *new_frame_start)
{
Modified: trunk/libavcodec/ac3_parser.h
==============================================================================
--- trunk/libavcodec/ac3_parser.h (original)
+++ trunk/libavcodec/ac3_parser.h Fri Apr 25 00:27:13 2008
@@ -46,4 +46,15 @@ typedef enum {
*/
int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr);
+/**
+ * Parses AC-3 frame header and sets channel_map
+ * Parses the header up to the lfeon (channel_map in E-AC-3)
+ * element, which is the first 52, 54 or 104 bits depending
+ * on the audio coding mode.
+ * @param gbc[in] BitContext containing the first 54 bits of the frame.
+ * @param hdr[out] Pointer to struct where header info is written.
+ * @return value returned by ff_ac3_parse_header
+ */
+int ff_ac3_parse_header_full(GetBitContext *gbc, AC3HeaderInfo *hdr);
+
#endif /* FFMPEG_AC3_PARSER_H */
Modified: trunk/libavcodec/ac3tab.c
==============================================================================
--- trunk/libavcodec/ac3tab.c (original)
+++ trunk/libavcodec/ac3tab.c Fri Apr 25 00:27:13 2008
@@ -247,3 +247,16 @@ const uint8_t ff_ac3_critical_band_size_
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
3, 6, 6, 6, 6, 6, 6, 12, 12, 12, 12, 24, 24, 24, 24, 24
};
+/**
+ * Default channel map for a dependent substream defined by acmod
+ */
+const uint16_t ff_eac3_default_chmap[8] = {
+ AC3_CHMAP_L | AC3_CHMAP_R, // FIXME Ch1+Ch2
+ AC3_CHMAP_C,
+ AC3_CHMAP_L | AC3_CHMAP_R,
+ AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R,
+ AC3_CHMAP_L | AC3_CHMAP_R | AC3_CHMAP_C_SUR,
+ AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R | AC3_CHMAP_C_SUR,
+ AC3_CHMAP_L | AC3_CHMAP_R | AC3_CHMAP_L_SUR | AC3_CHMAP_R_SUR,
+ AC3_CHMAP_L | AC3_CHMAP_C | AC3_CHMAP_R | AC3_CHMAP_L_SUR | AC3_CHMAP_R_SUR
+};
Modified: trunk/libavcodec/ac3tab.h
==============================================================================
--- trunk/libavcodec/ac3tab.h (original)
+++ trunk/libavcodec/ac3tab.h Fri Apr 25 00:27:13 2008
@@ -39,5 +39,21 @@ extern const uint16_t ff_ac3_db_per_bit_
extern const int16_t ff_ac3_floor_tab[8];
extern const uint16_t ff_ac3_fast_gain_tab[8];
extern const uint8_t ff_ac3_critical_band_size_tab[50];
+extern const uint16_t ff_eac3_default_chmap[8];
+
+/** Custom channel map locations bitmask
+ * Other channels described in documentation:
+ * Lc/Rc pair, Lrs/Rrs pair, Ts, Lsd/Rsd pair,
+ * Lw/Rw pair, Lvh/Rvh pair, Cvh, Reserved, LFE2
+ */
+enum CustomChannelMapLocation{
+ AC3_CHMAP_L= 1<<(15-0),
+ AC3_CHMAP_C= 1<<(15-1),
+ AC3_CHMAP_R= 1<<(15-2),
+ AC3_CHMAP_L_SUR= 1<<(15-3),
+ AC3_CHMAP_R_SUR = 1<<(15-4),
+ AC3_CHMAP_C_SUR= 1<<(15-7),
+ AC3_CHMAP_LFE = 1<<(15-15)
+};
#endif /* FFMPEG_AC3TAB_H */
More information about the ffmpeg-cvslog
mailing list