1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat/matroskadec: Set several stream parameters earlier

Don't do it in between parsing and setting extradata.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2023-08-09 00:28:30 +02:00
parent f32a83c4eb
commit 8507b9203c

View File

@ -2654,12 +2654,44 @@ static int matroska_parse_tracks(AVFormatContext *s)
}
sti = ffstream(st);
if (track->flag_default)
st->disposition |= AV_DISPOSITION_DEFAULT;
if (track->flag_forced)
st->disposition |= AV_DISPOSITION_FORCED;
if (track->flag_comment)
st->disposition |= AV_DISPOSITION_COMMENT;
if (track->flag_hearingimpaired)
st->disposition |= AV_DISPOSITION_HEARING_IMPAIRED;
if (track->flag_visualimpaired)
st->disposition |= AV_DISPOSITION_VISUAL_IMPAIRED;
if (track->flag_original.count > 0)
st->disposition |= track->flag_original.el.u ? AV_DISPOSITION_ORIGINAL
: AV_DISPOSITION_DUB;
if (key_id_base64) {
/* export encryption key id as base64 metadata tag */
av_dict_set(&st->metadata, "enc_key_id", key_id_base64,
AV_DICT_DONT_STRDUP_VAL);
}
if (strcmp(track->language, "und"))
av_dict_set(&st->metadata, "language", track->language, 0);
av_dict_set(&st->metadata, "title", track->name, 0);
if (track->time_scale < 0.01) {
av_log(matroska->ctx, AV_LOG_WARNING,
"Track TimestampScale too small %f, assuming 1.0.\n",
track->time_scale);
track->time_scale = 1.0;
}
avpriv_set_pts_info(st, 64, matroska->time_scale * track->time_scale,
1000 * 1000 * 1000); /* 64 bit pts in ns */
/* convert the delay from ns to the track timebase */
track->codec_delay_in_track_tb = av_rescale_q(track->codec_delay,
(AVRational){ 1, 1000000000 },
st->time_base);
if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC") &&
track->codec_priv.size >= 40 &&
track->codec_priv.data) {
@ -2923,40 +2955,8 @@ static int matroska_parse_tracks(AVFormatContext *s)
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown/unsupported AVCodecID %s.\n", track->codec_id);
if (track->time_scale < 0.01) {
av_log(matroska->ctx, AV_LOG_WARNING,
"Track TimestampScale too small %f, assuming 1.0.\n",
track->time_scale);
track->time_scale = 1.0;
}
avpriv_set_pts_info(st, 64, matroska->time_scale * track->time_scale,
1000 * 1000 * 1000); /* 64 bit pts in ns */
/* convert the delay from ns to the track timebase */
track->codec_delay_in_track_tb = av_rescale_q(track->codec_delay,
(AVRational){ 1, 1000000000 },
st->time_base);
st->codecpar->codec_id = codec_id;
if (strcmp(track->language, "und"))
av_dict_set(&st->metadata, "language", track->language, 0);
av_dict_set(&st->metadata, "title", track->name, 0);
if (track->flag_default)
st->disposition |= AV_DISPOSITION_DEFAULT;
if (track->flag_forced)
st->disposition |= AV_DISPOSITION_FORCED;
if (track->flag_comment)
st->disposition |= AV_DISPOSITION_COMMENT;
if (track->flag_hearingimpaired)
st->disposition |= AV_DISPOSITION_HEARING_IMPAIRED;
if (track->flag_visualimpaired)
st->disposition |= AV_DISPOSITION_VISUAL_IMPAIRED;
if (track->flag_original.count > 0)
st->disposition |= track->flag_original.el.u ? AV_DISPOSITION_ORIGINAL
: AV_DISPOSITION_DUB;
if (!st->codecpar->extradata) {
if (extradata) {
st->codecpar->extradata = extradata;