Skip to content

Commit

Permalink
mpegts-mythtv.c: export disposition from ISO_639_LANGUAGE_DESCRIPTOR
Browse files Browse the repository at this point in the history
This replaces the use of the MythTV added, exported PMT for detecting
these in AvFormatDecoder::GetAudioTrackType().

disposition is copied over to the AVStream in mpegts_add_stream().

language is only 4 bytes, so don't write past the end.
i.e. the loop is invalid.
  • Loading branch information
ulmus-scott authored and bennettpeter committed Jul 1, 2022
1 parent e250207 commit 446c530
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
40 changes: 29 additions & 11 deletions mythtv/external/FFmpeg/libavformat/mpegts-mythtv.c
Expand Up @@ -1690,26 +1690,44 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, pmt_entry_t *item, int stream
#endif
*pp += 4;
break;
case 0x0a: /* ISO 639 language descriptor */
case ISO_639_LANGUAGE_DESCRIPTOR:
#ifdef UPSTREAM_TO_MYTHTV
for (i = 0; i + 4 <= desc_len; i += 4) {
language[i + 0] = get8(pp, desc_end);
language[i + 1] = get8(pp, desc_end);
language[i + 2] = get8(pp, desc_end);
language[i + 3] = ',';
#if 0
switch (get8(pp, desc_end)) {
case 0x01: st->disposition |= AV_DISPOSITION_CLEAN_EFFECTS; break;
case 0x02: st->disposition |= AV_DISPOSITION_HEARING_IMPAIRED; break;
case 0x03: st->disposition |= AV_DISPOSITION_VISUAL_IMPAIRED; break;
switch (get8(pp, desc_end)) {
case 0x01:
st->disposition |= AV_DISPOSITION_CLEAN_EFFECTS;
break;
case 0x02:
st->disposition |= AV_DISPOSITION_HEARING_IMPAIRED;
break;
case 0x03:
st->disposition |= AV_DISPOSITION_VISUAL_IMPAIRED;
st->disposition |= AV_DISPOSITION_DESCRIPTIONS;
break;
}
}
if (i && language[0]) {
language[i - 1] = 0;
/* don't overwrite language, as it may already have been set by
* another, more specific descriptor (e.g. supplementary audio) */
av_dict_set(&st->metadata, "language", language, AV_DICT_DONT_OVERWRITE);
}
}
#else
language[0] = get8(pp, desc_end);
language[1] = get8(pp, desc_end);
language[2] = get8(pp, desc_end);
language[3] = 0;

switch (get8(pp, desc_end)) {
case 0x01: dvbci->disposition |= AV_DISPOSITION_CLEAN_EFFECTS; break;
case 0x02: dvbci->disposition |= AV_DISPOSITION_HEARING_IMPAIRED; break;
case 0x03: dvbci->disposition |= AV_DISPOSITION_VISUAL_IMPAIRED; break;
}
get8(pp, desc_end);
#endif
if (i) {
language[i - 1] = 0;
}
break;
case 0x05: /* registration descriptor */
dvbci->codec_tag = bytestream_get_le32(pp);
Expand Down
13 changes: 0 additions & 13 deletions mythtv/libs/libmythtv/decoders/avformatdecoder.cpp
Expand Up @@ -2541,19 +2541,6 @@ AudioTrackType AvFormatDecoder::GetAudioTrackType(uint StreamIndex)
AudioTrackType type = kAudioTypeNormal;
AVStream *stream = m_ic->streams[StreamIndex];

if (m_ic->cur_pmt_sect) // mpeg-ts
{
const ProgramMapTable pmt(PSIPTable(m_ic->cur_pmt_sect));
switch (pmt.GetAudioType(StreamIndex))
{
case 0x01 : type = kAudioTypeCleanEffects; break;
case 0x02 : type = kAudioTypeHearingImpaired; break;
case 0x03 : type = kAudioTypeAudioDescription; break;
case 0x00 :
default: type = kAudioTypeNormal;
}
}
else // all other containers
{
// We only support labelling/filtering of these two types for now
if (stream->disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
Expand Down

0 comments on commit 446c530

Please sign in to comment.