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
45#define FLAG_IS_NALFF (1 << 1)45#define FLAG_IS_NALFF (1 << 1)
46 46
47typedef struct HVCCNALUnit {47typedef struct HVCCNALUnit {
48 uint8_t nuh_layer_id;
49 uint8_t parameter_set_id;
48 uint16_t nalUnitLength;50 uint16_t nalUnitLength;
49 const uint8_t *nalUnit;51 const uint8_t *nalUnit;
50} HVCCNALUnit;52} HVCCNALUnit;
@@ -378,17 +380,17 @@ static void skip_sub_layer_ordering_info(GetBitContext *gb) · 327 unmodified lines
378 get_ue_golomb_long(gb); // max_latency_increase_plus1380 get_ue_golomb_long(gb); // max_latency_increase_plus1
379}381}
380 382
381static int hvcc_parse_vps(GetBitContext *gb,383static int hvcc_parse_vps(GetBitContext *gb, HVCCNALUnit *nal,
382 HEVCDecoderConfigurationRecord *hvcc)384 HEVCDecoderConfigurationRecord *hvcc)
383{385{
384 unsigned int vps_max_sub_layers_minus1;386 unsigned int vps_max_sub_layers_minus1;
385 387
388 nal->parameter_set_id = get_bits(gb, 4);
386 /*389 /*
387 * vps_video_parameter_set_id u(4)
388 * vps_reserved_three_2bits u(2)390 * vps_reserved_three_2bits u(2)
389 * vps_max_layers_minus1 u(6)391 * vps_max_layers_minus1 u(6)
390 */392 */
391 skip_bits(gb, 12);393 skip_bits(gb, 8);
392 394
393 vps_max_sub_layers_minus1 = get_bits(gb, 3);395 vps_max_sub_layers_minus1 = get_bits(gb, 3);
394 396
@@ -501,7 +503,7 @@ static int parse_rps(GetBitContext *gb, unsigned int rps_idx, · 106 unmodified lines
501 return 0;503 return 0;
502}504}
503 505
504static int hvcc_parse_sps(GetBitContext *gb,506static int hvcc_parse_sps(GetBitContext *gb, HVCCNALUnit *nal,
505 HEVCDecoderConfigurationRecord *hvcc)507 HEVCDecoderConfigurationRecord *hvcc)
506{508{
507 unsigned int i, sps_max_sub_layers_minus1, log2_max_pic_order_cnt_lsb_minus4;509 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
526 528
527 hvcc_parse_ptl(gb, hvcc, sps_max_sub_layers_minus1);529 hvcc_parse_ptl(gb, hvcc, sps_max_sub_layers_minus1);
528 530
529 get_ue_golomb_long(gb); // sps_seq_parameter_set_id531 nal->parameter_set_id = get_ue_golomb_long(gb);
530 532
531 hvcc->chromaFormat = get_ue_golomb_long(gb);533 hvcc->chromaFormat = get_ue_golomb_long(gb);
532 534
@@ -605,12 +607,12 @@ static int hvcc_parse_sps(GetBitContext *gb, · 72 unmodified lines
605 return 0;607 return 0;
606}608}
607 609
608static int hvcc_parse_pps(GetBitContext *gb,610static int hvcc_parse_pps(GetBitContext *gb, HVCCNALUnit *nal,
609 HEVCDecoderConfigurationRecord *hvcc)611 HEVCDecoderConfigurationRecord *hvcc)
610{612{
611 uint8_t tiles_enabled_flag, entropy_coding_sync_enabled_flag;613 uint8_t tiles_enabled_flag, entropy_coding_sync_enabled_flag;
612 614
613 get_ue_golomb_long(gb); // pps_pic_parameter_set_id615 nal->parameter_set_id = get_ue_golomb_long(gb); // pps_pic_parameter_set_id
614 get_ue_golomb_long(gb); // pps_seq_parameter_set_id616 get_ue_golomb_long(gb); // pps_seq_parameter_set_id
615 617
616 /*618 /*
@@ -703,6 +705,7 @@ static int hvcc_add_nal_unit(const uint8_t *nal_buf, uint32_t nal_size, · 86 unmodified lines
703 int is_nalff = !!(flags & FLAG_IS_NALFF);705 int is_nalff = !!(flags & FLAG_IS_NALFF);
704 int ps_array_completeness = !!(flags & FLAG_ARRAY_COMPLETENESS);706 int ps_array_completeness = !!(flags & FLAG_ARRAY_COMPLETENESS);
705 HVCCNALUnitArray *const array = &hvcc->arrays[array_idx];707 HVCCNALUnitArray *const array = &hvcc->arrays[array_idx];
708 HVCCNALUnit *nal;
706 GetBitContext gbc;709 GetBitContext gbc;
707 uint8_t nal_type, nuh_layer_id;710 uint8_t nal_type, nuh_layer_id;
708 uint8_t *rbsp_buf;711 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
745 array->array_completeness = ps_array_completeness;748 array->array_completeness = ps_array_completeness;
746 }749 }
747 750
751 nal = &array->nal[array->numNalus-1];
752 nal->nuh_layer_id = nuh_layer_id;
753
748 /* Don't parse parameter sets. We already have the needed information*/754 /* Don't parse parameter sets. We already have the needed information*/
749 if (is_nalff)755 if (is_nalff)
750 goto end;756 goto end;
751 757
752 if (nal_type == HEVC_NAL_VPS)758 if (nal_type == HEVC_NAL_VPS)
753 ret = hvcc_parse_vps(&gbc, hvcc);759 ret = hvcc_parse_vps(&gbc, nal, hvcc);
754 else if (nal_type == HEVC_NAL_SPS)760 else if (nal_type == HEVC_NAL_SPS)
755 ret = hvcc_parse_sps(&gbc, hvcc);761 ret = hvcc_parse_sps(&gbc, nal, hvcc);
756 else if (nal_type == HEVC_NAL_PPS)762 else if (nal_type == HEVC_NAL_PPS)
757 ret = hvcc_parse_pps(&gbc, hvcc);763 ret = hvcc_parse_pps(&gbc, nal, hvcc);
758 if (ret < 0)764 if (ret < 0)
759 goto end;765 goto end;
760 766

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