From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 05/20] avformat/matroskadec: Set AVCodecParameters earlier
Date: Mon, 4 Sep 2023 13:27:44 +0200
Message-ID: <AS8P250MB0744D09CF7D4AEF4C93FE0E88FE9A@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <AS8P250MB0744314AD7A516CFC71F61BF8FE9A@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>
This is in preparation for future commits.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavformat/matroskadec.c | 55 ++++++++++++++++++++-------------------
1 file changed, 28 insertions(+), 27 deletions(-)
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 50a159460d..e1524a5943 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2528,7 +2528,6 @@ static int matroska_parse_tracks(AVFormatContext *s)
AVStream *st;
FFStream *sti;
char* key_id_base64 = NULL;
- int bit_depth = -1;
/* Apply some sanity checks. */
if (track->type != MATROSKA_TRACK_TYPE_VIDEO &&
@@ -2662,6 +2661,9 @@ static int matroska_parse_tracks(AVFormatContext *s)
sti = ffstream(st);
par = st->codecpar;
+ par->codec_id = codec_id;
+ par->codec_tag = fourcc;
+
if (track->flag_default)
st->disposition |= AV_DISPOSITION_DEFAULT;
if (track->flag_forced)
@@ -2704,13 +2706,13 @@ static int matroska_parse_tracks(AVFormatContext *s)
track->codec_priv.size >= 40 &&
track->codec_priv.data) {
track->ms_compat = 1;
- bit_depth = AV_RL16(track->codec_priv.data + 14);
- fourcc = AV_RL32(track->codec_priv.data + 16);
- codec_id = ff_codec_get_id(ff_codec_bmp_tags,
- fourcc);
- if (!codec_id)
- codec_id = ff_codec_get_id(ff_codec_movvideo_tags,
- fourcc);
+ par->bits_per_coded_sample = AV_RL16(track->codec_priv.data + 14);
+ par->codec_tag = AV_RL32(track->codec_priv.data + 16);
+ par->codec_id = ff_codec_get_id(ff_codec_bmp_tags,
+ par->codec_tag);
+ if (!par->codec_id)
+ par->codec_id = ff_codec_get_id(ff_codec_movvideo_tags,
+ par->codec_tag);
extradata_offset = 40;
} else if (!strcmp(track->codec_id, "A_MS/ACM") &&
track->codec_priv.size >= 14 &&
@@ -2723,13 +2725,12 @@ static int matroska_parse_tracks(AVFormatContext *s)
track->codec_priv.size, 0);
if (ret < 0)
return ret;
- codec_id = par->codec_id;
- fourcc = par->codec_tag;
extradata_offset = FFMIN(track->codec_priv.size, 18);
} else if (!strcmp(track->codec_id, "A_QUICKTIME")
/* Normally 36, but allow noncompliant private data */
&& (track->codec_priv.size >= 32)
&& (track->codec_priv.data)) {
+ uint32_t fourcc;
uint16_t sample_size;
int ret = get_qt_codec(track, &fourcc, &codec_id);
if (ret < 0)
@@ -2748,9 +2749,12 @@ static int matroska_parse_tracks(AVFormatContext *s)
fourcc == MKTAG('s','o','w','t')) &&
sample_size == 8)
codec_id = AV_CODEC_ID_PCM_S8;
+ par->codec_id = codec_id;
+ par->codec_tag = fourcc;
} else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
(track->codec_priv.size >= 21) &&
(track->codec_priv.data)) {
+ uint32_t fourcc;
int ret = get_qt_codec(track, &fourcc, &codec_id);
if (ret < 0)
return ret;
@@ -2758,11 +2762,12 @@ static int matroska_parse_tracks(AVFormatContext *s)
fourcc = MKTAG('S','V','Q','3');
codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc);
}
+ par->codec_id = codec_id;
if (codec_id == AV_CODEC_ID_NONE)
av_log(matroska->ctx, AV_LOG_ERROR,
"mov FourCC not found %s.\n", av_fourcc2str(fourcc));
if (track->codec_priv.size >= 86) {
- bit_depth = AV_RB16(track->codec_priv.data + 82);
+ unsigned bit_depth = AV_RB16(track->codec_priv.data + 82);
ffio_init_context(&b, track->codec_priv.data,
track->codec_priv.size,
0, NULL, NULL, NULL, NULL);
@@ -2770,34 +2775,36 @@ static int matroska_parse_tracks(AVFormatContext *s)
bit_depth &= 0x1F;
track->has_palette = 1;
}
+ par->bits_per_coded_sample = bit_depth;
}
+ par->codec_tag = fourcc;
} else if (codec_id == AV_CODEC_ID_PCM_S16BE) {
switch (track->audio.bitdepth) {
case 8:
- codec_id = AV_CODEC_ID_PCM_U8;
+ par->codec_id = AV_CODEC_ID_PCM_U8;
break;
case 24:
- codec_id = AV_CODEC_ID_PCM_S24BE;
+ par->codec_id = AV_CODEC_ID_PCM_S24BE;
break;
case 32:
- codec_id = AV_CODEC_ID_PCM_S32BE;
+ par->codec_id = AV_CODEC_ID_PCM_S32BE;
break;
}
} else if (codec_id == AV_CODEC_ID_PCM_S16LE) {
switch (track->audio.bitdepth) {
case 8:
- codec_id = AV_CODEC_ID_PCM_U8;
+ par->codec_id = AV_CODEC_ID_PCM_U8;
break;
case 24:
- codec_id = AV_CODEC_ID_PCM_S24LE;
+ par->codec_id = AV_CODEC_ID_PCM_S24LE;
break;
case 32:
- codec_id = AV_CODEC_ID_PCM_S32LE;
+ par->codec_id = AV_CODEC_ID_PCM_S32LE;
break;
}
} else if (codec_id == AV_CODEC_ID_PCM_F32LE &&
track->audio.bitdepth == 64) {
- codec_id = AV_CODEC_ID_PCM_F64LE;
+ par->codec_id = AV_CODEC_ID_PCM_F64LE;
} else if (codec_id == AV_CODEC_ID_AAC && !track->codec_priv.size) {
int profile = matroska_aac_profile(track->codec_id);
int sri = matroska_aac_sri(track->audio.samplerate);
@@ -2912,7 +2919,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
extradata_size = WAVPACK_EXTRADATA_SIZE;
AV_WL16(extradata, 0x410);
} else if (codec_id == AV_CODEC_ID_PRORES && track->codec_priv.size == 4) {
- fourcc = AV_RL32(track->codec_priv.data);
+ par->codec_tag = AV_RL32(track->codec_priv.data);
} else if (codec_id == AV_CODEC_ID_VP9) {
/* we don't need any value stored in CodecPrivate.
make sure that it's not exported as extradata. */
@@ -2949,12 +2956,10 @@ static int matroska_parse_tracks(AVFormatContext *s)
}
track->codec_priv.size -= extradata_offset;
- if (codec_id == AV_CODEC_ID_NONE)
+ if (par->codec_id == AV_CODEC_ID_NONE)
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown/unsupported AVCodecID %s.\n", track->codec_id);
- par->codec_id = codec_id;
-
if (!par->extradata && (extradata_size > 0 || track->codec_priv.size > 0)) {
const uint8_t *src = extradata_size > 0 ? extradata :
track->codec_priv.data + extradata_offset;
@@ -2972,9 +2977,6 @@ static int matroska_parse_tracks(AVFormatContext *s)
int display_height_mul = 1;
par->codec_type = AVMEDIA_TYPE_VIDEO;
- par->codec_tag = fourcc;
- if (bit_depth >= 0)
- par->bits_per_coded_sample = bit_depth;
par->width = track->video.pixel_width;
par->height = track->video.pixel_height;
@@ -3049,7 +3051,6 @@ static int matroska_parse_tracks(AVFormatContext *s)
return ret;
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
par->codec_type = AVMEDIA_TYPE_AUDIO;
- par->codec_tag = fourcc;
par->sample_rate = track->audio.out_samplerate;
// channel layout may be already set by codec private checks above
if (!av_channel_layout_check(&par->ch_layout)) {
@@ -3075,7 +3076,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
(AVRational){1, 1000000000},
(AVRational){1, par->sample_rate});
}
- } else if (codec_id == AV_CODEC_ID_WEBVTT) {
+ } else if (par->codec_id == AV_CODEC_ID_WEBVTT) {
par->codec_type = AVMEDIA_TYPE_SUBTITLE;
if (!strcmp(track->codec_id, "D_WEBVTT/CAPTIONS")) {
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2023-09-04 11:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-04 11:26 [FFmpeg-devel] [PATCH 01/20] fate/matroska: Add test for remuxing non-rotation displaymatrix Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 02/20] avformat/matroskadec: Set several stream parameters earlier Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 03/20] avformat/matroskadec: Use dedicated pointer for access to codecpar Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 04/20] avformat/matroskadec: Redo handling extradata allocation Andreas Rheinhardt
2023-09-04 11:27 ` Andreas Rheinhardt [this message]
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 06/20] avformat/matroskdec: Factor audio parsing out of matroska_parse_tracks() Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 07/20] avformat/matroskadec: Remove redundant checks Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 08/20] avformat/matroskadec: Reindent after the previous commit Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 09/20] avformat/matroskadec: Factor video parsing out of matroska_parse_tracks() Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 10/20] avformat/matroskadec: Reindent after the previous commit Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 11/20] avformat/matroskadec: Move reading color space to a better place Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 12/20] avformat/matroskadec: Avoid clobbering CodecPrivate size Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 13/20] avformat/matroskadec: Use av_dict_set_int() where appropriate Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 14/20] avformat/matroskadec: Factor parsing subtitle codecs out Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 15/20] avformat/matroskadec: Factor generic parsing of video tracks out Andreas Rheinhardt
2023-09-04 11:46 ` James Almer
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 16/20] avformat/matroskadec: Reindent after the previous commit Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 17/20] avformat/matroskadec: Factor generic parsing of audio tracks out Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 18/20] avformat/matroskdec: Reindent after the previous commit Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 19/20] avformat/matroskadec: Move WEBVTT code to mkv_parse_subtitle_codec() Andreas Rheinhardt
2023-09-04 11:27 ` [FFmpeg-devel] [PATCH 20/20] avformat/matroskadec: Factor parsing content encodings out Andreas Rheinhardt
2023-09-06 9:37 ` [FFmpeg-devel] [PATCH 01/20] fate/matroska: Add test for remuxing non-rotation displaymatrix Andreas Rheinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AS8P250MB0744D09CF7D4AEF4C93FE0E88FE9A@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
--to=andreas.rheinhardt@outlook.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git