History

avformat/mov: split off lcevc stream group initialization to its own function

James Almer committed 2 years ago

Commit e907bf61 parent d5eb0e71 file · +53 −42Browse files

Unified · Split

libavformat/mov.c+53−42
@@ -10301,6 +10301,56 @@ static AVStream *mov_find_reference_track(AVFormatContext *s, AVStream *st, · 10300 unmodified lines
10301 return NULL;10301 return NULL;
10302}10302}
10303 10303
10304static int mov_parse_lcevc_streams(AVFormatContext *s)
10305{
10306 int err;
10307
10308 for (int i = 0; i < s->nb_streams; i++) {
10309 AVStreamGroup *stg;
10310 AVStream *st = s->streams[i];
10311 AVStream *st_base;
10312 MOVStreamContext *sc = st->priv_data;
10313 int j = 0;
10314
10315 /* Find an enhancement stream. */
10316 if (st->codecpar->codec_id != AV_CODEC_ID_LCEVC ||
10317 !(sc->tref_flags & MOV_TREF_FLAG_ENHANCEMENT))
10318 continue;
10319
10320 st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
10321
10322 stg = avformat_stream_group_create(s, AV_STREAM_GROUP_PARAMS_LCEVC, NULL);
10323 if (!stg)
10324 return AVERROR(ENOMEM);
10325
10326 stg->id = st->id;
10327 stg->params.lcevc->width = st->codecpar->width;
10328 stg->params.lcevc->height = st->codecpar->height;
10329 st->codecpar->width = 0;
10330 st->codecpar->height = 0;
10331
10332 while (st_base = mov_find_reference_track(s, st, j)) {
10333 err = avformat_stream_group_add_stream(stg, st_base);
10334 if (err < 0)
10335 return err;
10336
10337 j = st_base->index + 1;
10338 }
10339 if (!j) {
10340 av_log(s, AV_LOG_ERROR, "Failed to find base stream for enhancement stream\n");
10341 return AVERROR_INVALIDDATA;
10342 }
10343
10344 err = avformat_stream_group_add_stream(stg, st);
10345 if (err < 0)
10346 return err;
10347
10348 stg->params.lcevc->lcevc_index = stg->nb_streams - 1;
10349 }
10350
10351 return 0;
10352}
10353
10304static int mov_read_header(AVFormatContext *s)10354static int mov_read_header(AVFormatContext *s)
10305{10355{
10306 MOVContext *mov = s->priv_data;10356 MOVContext *mov = s->priv_data;
@@ -10387,48 +10437,9 @@ static int mov_read_header(AVFormatContext *s) · 80 unmodified lines
10387 export_orphan_timecode(s);10437 export_orphan_timecode(s);
10388 10438
10389 /* Create LCEVC stream groups. */10439 /* Create LCEVC stream groups. */
10390 for (i = 0; i < s->nb_streams; i++) {10440 err = mov_parse_lcevc_streams(s);
10391 AVStreamGroup *stg;10441 if (err < 0)
10392 AVStream *st = s->streams[i];10442 return err;
10393 AVStream *st_base;
10394 MOVStreamContext *sc = st->priv_data;
10395
10396 /* Find an enhancement stream. */
10397 if (st->codecpar->codec_id != AV_CODEC_ID_LCEVC ||
10398 !(sc->tref_flags & MOV_TREF_FLAG_ENHANCEMENT))
10399 continue;
10400
10401 st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
10402
10403 stg = avformat_stream_group_create(s, AV_STREAM_GROUP_PARAMS_LCEVC, NULL);
10404 if (!stg)
10405 return AVERROR(ENOMEM);
10406
10407 stg->id = st->id;
10408 stg->params.lcevc->width = st->codecpar->width;
10409 stg->params.lcevc->height = st->codecpar->height;
10410 st->codecpar->width = 0;
10411 st->codecpar->height = 0;
10412
10413 j = 0;
10414 while (st_base = mov_find_reference_track(s, st, j)) {
10415 err = avformat_stream_group_add_stream(stg, st_base);
10416 if (err < 0)
10417 return err;
10418
10419 j = st_base->index + 1;
10420 }
10421 if (!j) {
10422 av_log(s, AV_LOG_ERROR, "Failed to find base stream for enhancement stream\n");
10423 return AVERROR_INVALIDDATA;
10424 }
10425
10426 err = avformat_stream_group_add_stream(stg, st);
10427 if (err < 0)
10428 return err;
10429
10430 stg->params.lcevc->lcevc_index = stg->nb_streams - 1;
10431 }
10432 10443
10433 for (i = 0; i < s->nb_streams; i++) {10444 for (i = 0; i < s->nb_streams; i++) {
10434 AVStream *st = s->streams[i];10445 AVStream *st = s->streams[i];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t