History

avformat/hevc: store parameter set and layer IDs in HVCCNALUnit

James Almer committed 2 years ago

Commit cee43e51 parent 361b0131 file · +16 −10Browse files

Unified · Split

libavformat/hevc.c+16−10
@@ -45,6 +45,8 @@ enum { · 44 unmodified lines
4545 #define FLAG_IS_NALFF (1 << 1)
4646
4747 typedef struct HVCCNALUnit {
48+ uint8_t nuh_layer_id;
49+ uint8_t parameter_set_id;
4850 uint16_t nalUnitLength;
4951 const uint8_t *nalUnit;
5052 } HVCCNALUnit;
@@ -378,17 +380,17 @@ static void skip_sub_layer_ordering_info(GetBitContext *gb) · 327 unmodified lines
378380 get_ue_golomb_long(gb); // max_latency_increase_plus1
379381 }
380382
381−static int hvcc_parse_vps(GetBitContext *gb,
383+static int hvcc_parse_vps(GetBitContext *gb, HVCCNALUnit *nal,
382384 HEVCDecoderConfigurationRecord *hvcc)
383385 {
384386 unsigned int vps_max_sub_layers_minus1;
385387
388+ nal->parameter_set_id = get_bits(gb, 4);
386389 /*
387− * vps_video_parameter_set_id u(4)
388390 * vps_reserved_three_2bits u(2)
389391 * vps_max_layers_minus1 u(6)
390392 */
391− skip_bits(gb, 12);
393+ skip_bits(gb, 8);
392394
393395 vps_max_sub_layers_minus1 = get_bits(gb, 3);
394396
@@ -501,7 +503,7 @@ static int parse_rps(GetBitContext *gb, unsigned int rps_idx, · 106 unmodified lines
501503 return 0;
502504 }
503505
504−static int hvcc_parse_sps(GetBitContext *gb,
506+static int hvcc_parse_sps(GetBitContext *gb, HVCCNALUnit *nal,
505507 HEVCDecoderConfigurationRecord *hvcc)
506508 {
507509 unsigned int i, sps_max_sub_layers_minus1, log2_max_pic_order_cnt_lsb_minus4;
@@ -526,7 +528,7 @@ static int hvcc_parse_sps(GetBitContext *gb, · 18 unmodified lines
526528
527529 hvcc_parse_ptl(gb, hvcc, sps_max_sub_layers_minus1);
528530
529− get_ue_golomb_long(gb); // sps_seq_parameter_set_id
531+ nal->parameter_set_id = get_ue_golomb_long(gb);
530532
531533 hvcc->chromaFormat = get_ue_golomb_long(gb);
532534
@@ -605,12 +607,12 @@ static int hvcc_parse_sps(GetBitContext *gb, · 72 unmodified lines
605607 return 0;
606608 }
607609
608−static int hvcc_parse_pps(GetBitContext *gb,
610+static int hvcc_parse_pps(GetBitContext *gb, HVCCNALUnit *nal,
609611 HEVCDecoderConfigurationRecord *hvcc)
610612 {
611613 uint8_t tiles_enabled_flag, entropy_coding_sync_enabled_flag;
612614
613− get_ue_golomb_long(gb); // pps_pic_parameter_set_id
615+ nal->parameter_set_id = get_ue_golomb_long(gb); // pps_pic_parameter_set_id
614616 get_ue_golomb_long(gb); // pps_seq_parameter_set_id
615617
616618 /*
@@ -703,6 +705,7 @@ static int hvcc_add_nal_unit(const uint8_t *nal_buf, uint32_t nal_size, · 86 unmodified lines
703705 int is_nalff = !!(flags & FLAG_IS_NALFF);
704706 int ps_array_completeness = !!(flags & FLAG_ARRAY_COMPLETENESS);
705707 HVCCNALUnitArray *const array = &hvcc->arrays[array_idx];
708+ HVCCNALUnit *nal;
706709 GetBitContext gbc;
707710 uint8_t nal_type, nuh_layer_id;
708711 uint8_t *rbsp_buf;
@@ -745,16 +748,19 @@ static int hvcc_add_nal_unit(const uint8_t *nal_buf, uint32_t nal_size, · 36 unmodified lines
745748 array->array_completeness = ps_array_completeness;
746749 }
747750
751+ nal = &array->nal[array->numNalus-1];
752+ nal->nuh_layer_id = nuh_layer_id;
753+
748754 /* Don't parse parameter sets. We already have the needed information*/
749755 if (is_nalff)
750756 goto end;
751757
752758 if (nal_type == HEVC_NAL_VPS)
753− ret = hvcc_parse_vps(&gbc, hvcc);
759+ ret = hvcc_parse_vps(&gbc, nal, hvcc);
754760 else if (nal_type == HEVC_NAL_SPS)
755− ret = hvcc_parse_sps(&gbc, hvcc);
761+ ret = hvcc_parse_sps(&gbc, nal, hvcc);
756762 else if (nal_type == HEVC_NAL_PPS)
757− ret = hvcc_parse_pps(&gbc, hvcc);
763+ ret = hvcc_parse_pps(&gbc, nal, hvcc);
758764 if (ret < 0)
759765 goto end;
760766

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