avformat/mpegtsenc: Preserve disposition in the absence of language
Implements ticket #9113. Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -459,6 +459,8 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
|
|||||||
AVStream *st = s->streams[i];
|
AVStream *st = s->streams[i];
|
||||||
MpegTSWriteStream *ts_st = st->priv_data;
|
MpegTSWriteStream *ts_st = st->priv_data;
|
||||||
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
|
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
|
||||||
|
const char default_language[] = "und";
|
||||||
|
const char *language = lang && strlen(lang->value) >= 3 ? lang->value : default_language;
|
||||||
enum AVCodecID codec_id = st->codecpar->codec_id;
|
enum AVCodecID codec_id = st->codecpar->codec_id;
|
||||||
|
|
||||||
if (s->nb_programs) {
|
if (s->nb_programs) {
|
||||||
@@ -598,16 +600,18 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lang) {
|
if (language != default_language ||
|
||||||
char *p;
|
st->disposition & (AV_DISPOSITION_CLEAN_EFFECTS |
|
||||||
char *next = lang->value;
|
AV_DISPOSITION_HEARING_IMPAIRED |
|
||||||
|
AV_DISPOSITION_VISUAL_IMPAIRED)) {
|
||||||
|
const char *p, *next;
|
||||||
uint8_t *len_ptr;
|
uint8_t *len_ptr;
|
||||||
|
|
||||||
*q++ = ISO_639_LANGUAGE_DESCRIPTOR;
|
*q++ = ISO_639_LANGUAGE_DESCRIPTOR;
|
||||||
len_ptr = q++;
|
len_ptr = q++;
|
||||||
*len_ptr = 0;
|
*len_ptr = 0;
|
||||||
|
|
||||||
for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next + 1) {
|
for (p = next = language; next && *len_ptr < 255 / 4 * 4; p = next + 1) {
|
||||||
if (q - data > SECTION_LENGTH - 4) {
|
if (q - data > SECTION_LENGTH - 4) {
|
||||||
err = 1;
|
err = 1;
|
||||||
break;
|
break;
|
||||||
@@ -637,10 +641,6 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_SUBTITLE:
|
case AVMEDIA_TYPE_SUBTITLE:
|
||||||
{
|
|
||||||
const char default_language[] = "und";
|
|
||||||
const char *language = lang && strlen(lang->value) >= 3 ? lang->value : default_language;
|
|
||||||
|
|
||||||
if (codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
|
if (codec_id == AV_CODEC_ID_DVB_SUBTITLE) {
|
||||||
uint8_t *len_ptr;
|
uint8_t *len_ptr;
|
||||||
int extradata_copied = 0;
|
int extradata_copied = 0;
|
||||||
@@ -715,7 +715,6 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
|
|||||||
|
|
||||||
*len_ptr = q - len_ptr - 1;
|
*len_ptr = q - len_ptr - 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
if (stream_type == STREAM_TYPE_VIDEO_DIRAC) {
|
if (stream_type == STREAM_TYPE_VIDEO_DIRAC) {
|
||||||
|
Reference in New Issue
Block a user