History

avformat/hevc: Defer initializations in ff_isom_write_hvcc()

Saves initialization of an HEVCDecoderConfigurationRecord when the data is already in ISOBMFF-format or if it is plainly invalid.

Andreas Rheinhardt committed 6 years ago

Commit 1884d881 parent 297d5a11 file · +8 −10Browse files

Unified · Split

libavformat/hevc.c+8−10
@@ -1068,29 +1068,27 @@ int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out, · 1067 unmodified lines
1068int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data,1068int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data,
1069 int size, int ps_array_completeness)1069 int size, int ps_array_completeness)
1070{1070{
1071 int ret = 0;
1072 uint8_t *buf, *end, *start = NULL;
1073 HEVCDecoderConfigurationRecord hvcc;1071 HEVCDecoderConfigurationRecord hvcc;
1074 1072 uint8_t *buf, *end, *start;
1075 hvcc_init(&hvcc);1073 int ret;
1076 1074
1077 if (size < 6) {1075 if (size < 6) {
1078 /* We can't write a valid hvcC from the provided data */1076 /* We can't write a valid hvcC from the provided data */
1079 ret = AVERROR_INVALIDDATA;1077 return AVERROR_INVALIDDATA;
1080 goto end;
1081 } else if (*data == 1) {1078 } else if (*data == 1) {
1082 /* Data is already hvcC-formatted */1079 /* Data is already hvcC-formatted */
1083 avio_write(pb, data, size);1080 avio_write(pb, data, size);
1084 goto end;1081 return 0;
1085 } else if (!(AV_RB24(data) == 1 || AV_RB32(data) == 1)) {1082 } else if (!(AV_RB24(data) == 1 || AV_RB32(data) == 1)) {
1086 /* Not a valid Annex B start code prefix */1083 /* Not a valid Annex B start code prefix */
1087 ret = AVERROR_INVALIDDATA;1084 return AVERROR_INVALIDDATA;
1088 goto end;
1089 }1085 }
1090 1086
1091 ret = ff_avc_parse_nal_units_buf(data, &start, &size);1087 ret = ff_avc_parse_nal_units_buf(data, &start, &size);
1092 if (ret < 0)1088 if (ret < 0)
1093 goto end;1089 return ret;
1090
1091 hvcc_init(&hvcc);
1094 1092
1095 buf = start;1093 buf = start;
1096 end = start + size;1094 end = start + size;

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