log:
Adding parse_header in aac_ac3_parser and correct read of number of channels
in eac3.
can you check the patch, please?
--
Bartlomiej Wolowiec
Index: libavcodec/aac_ac3_parser.c
===================================================================
--- libavcodec/aac_ac3_parser.c (wersja 13030)
+++ libavcodec/aac_ac3_parser.c (kopia robocza)
@@ -70,6 +70,8 @@
*poutbuf_size = buf_size;
/* update codec info */
+ if(s->parse_header)
+ s->parse_header(buf, buf_size, s);
avctx->sample_rate = s->sample_rate;
/* allow downmixing to stereo (or mono for AC3) */
if(avctx->request_channels > 0 &&
Index: libavcodec/aac_ac3_parser.h
===================================================================
--- libavcodec/aac_ac3_parser.h (wersja 13030)
+++ libavcodec/aac_ac3_parser.h (kopia robocza)
@@ -31,6 +31,8 @@
int header_size;
int (*sync)(uint64_t state, struct AACAC3ParseContext *hdr_info,
int *need_next_header, int *new_frame_start);
+ int (*parse_header)(const uint8_t *buf, int buf_size,
+ struct AACAC3ParseContext *hdr_info);
int channels;
int sample_rate;
Index: libavcodec/ac3tab.c
===================================================================
--- libavcodec/ac3tab.c (wersja 13030)
+++ libavcodec/ac3tab.c (kopia robocza)
@@ -260,3 +260,9 @@
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
};
+
+const uint8_t ff_ac3_channels_multiple[16] = {
+ 1,1,0,1,2,2,2,1,
+ 1,2,2,1,1,1,1,1
+};
+
Index: libavcodec/ac3tab.h
===================================================================
--- libavcodec/ac3tab.h (wersja 13030)
+++ libavcodec/ac3tab.h (kopia robocza)
@@ -41,6 +41,9 @@
extern const uint8_t ff_ac3_critical_band_size_tab[50];
extern const uint16_t ff_eac3_default_chmap[8];
+///The number of channels coded by one bit in channel_map
+extern const uint8_t ff_ac3_channels_multiple[16];
+
/** Custom channel map locations bitmask
* Other channels described in documentation:
* Lc/Rc pair, Lrs/Rrs pair, Ts, Lsd/Rsd pair,
Index: libavcodec/ac3_parser.c
===================================================================
--- libavcodec/ac3_parser.c (wersja 13030)
+++ libavcodec/ac3_parser.c (kopia robocza)
@@ -189,11 +189,37 @@
return hdr.frame_size;
}
+static int ac3_parse_header(const uint8_t *buf, int buf_size,
+ AACAC3ParseContext *hdr_info){
+ uint16_t bitmask=0;
+ AC3HeaderInfo hdr;
+ GetBitContext gbc;
+ int i=0;
+
+ hdr_info->bit_rate = 0;
+ do{
+ init_get_bits(&gbc, buf+i, buf_size-i);
+ if(ff_ac3_parse_header_full(&gbc, &hdr)<0 || !hdr.frame_size)
+ return -1;
+ bitmask |= hdr.channel_map;
+ hdr_info->bit_rate += hdr.bit_rate;
+ i+=hdr.frame_size;
+ }while(i<buf_size);
+
+ hdr_info->channels=0;
+ for(i=0; bitmask; i++, bitmask>>=1){
+ if(bitmask&1)
+ hdr_info->channels += ff_ac3_channels_multiple[i];
+ }
+ return 0;
+}
+
static av_cold int ac3_parse_init(AVCodecParserContext *s1)
{
AACAC3ParseContext *s = s1->priv_data;
s->header_size = AC3_HEADER_SIZE;
s->sync = ac3_sync;
+ s->parse_header = ac3_parse_header;
return 0;
}
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc