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