Skip to content

Commit

Permalink
fixed eac3 data prober - cf #1394
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlf committed Mar 7, 2022
1 parent 1f2b564 commit 89fca03
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/filters/ff_dmx.c
Expand Up @@ -515,13 +515,27 @@ GF_Err ffdmx_init_common(GF_Filter *filter, GF_FFDemuxCtx *ctx, Bool is_grab)
if (!exdata_size) {
switch (gpac_codec_id) {
case GF_CODECID_AC3:
case GF_CODECID_EAC3:
case GF_CODECID_AAC_MPEG4:
case GF_CODECID_AAC_MPEG2_MP:
case GF_CODECID_AAC_MPEG2_LCP:
case GF_CODECID_AAC_MPEG2_SSRP:
case GF_CODECID_FLAC:
case GF_CODECID_TRUEHD:
case GF_CODECID_MPEG1:
case GF_CODECID_MPEG2_422:
case GF_CODECID_MPEG2_SNR:
case GF_CODECID_MPEG2_HIGH:
case GF_CODECID_MPEG2_MAIN:
case GF_CODECID_MPEG2_SIMPLE:
case GF_CODECID_MPEG2_SPATIAL:
case GF_CODECID_MPEG4_PART2:
case GF_CODECID_AVC:
case GF_CODECID_HEVC:
case GF_CODECID_VVC:
case GF_CODECID_AV1:
case GF_CODECID_VP8:
case GF_CODECID_VP9:
force_reframer = GF_TRUE;
break;
}
Expand Down
21 changes: 20 additions & 1 deletion src/filters/reframe_ac3.c
Expand Up @@ -524,11 +524,11 @@ static void ac3dmx_finalize(GF_Filter *filter)

static const char *ac3dmx_probe_data(const u8 *data, u32 size, GF_FilterProbeScore *score)
{
GF_AC3Config ahdr;
u32 nb_frames=0;
Bool has_broken_frames = GF_FALSE;
u32 pos=0;
while (1) {
GF_AC3Config ahdr;
if (! gf_ac3_parser((u8 *) data, size, &pos, &ahdr, GF_FALSE) )
break;
u32 fsize = ahdr.framesize;
Expand All @@ -550,6 +550,25 @@ static const char *ac3dmx_probe_data(const u8 *data, u32 size, GF_FilterProbeSco
*score = has_broken_frames ? GF_FPROBE_MAYBE_NOT_SUPPORTED : GF_FPROBE_SUPPORTED;
return "audio/ac3";
}

//try eac3
GF_BitStream *bs = gf_bs_new(data, size, GF_BITSTREAM_READ);
while (gf_bs_available(bs)) {
if (!gf_eac3_parser_bs(bs, &ahdr, GF_FALSE))
break;

if (pos != (u32) gf_bs_get_position(bs))
has_broken_frames = GF_TRUE;
nb_frames++;
gf_bs_skip_bytes(bs, ahdr.framesize);
pos+=ahdr.framesize;
}
gf_bs_del(bs);
if (nb_frames>=2) {
*score = has_broken_frames ? GF_FPROBE_MAYBE_NOT_SUPPORTED : GF_FPROBE_SUPPORTED;
return "audio/eac3";
}

return NULL;
}

Expand Down

0 comments on commit 89fca03

Please sign in to comment.