You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
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. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
@@ -1068,29 +1068,27 @@ int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out,
|
|||||||
int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data,
|
int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data,
|
||||||
int size, int ps_array_completeness)
|
int size, int ps_array_completeness)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
|
||||||
uint8_t *buf, *end, *start = NULL;
|
|
||||||
HEVCDecoderConfigurationRecord hvcc;
|
HEVCDecoderConfigurationRecord hvcc;
|
||||||
|
uint8_t *buf, *end, *start;
|
||||||
hvcc_init(&hvcc);
|
int ret;
|
||||||
|
|
||||||
if (size < 6) {
|
if (size < 6) {
|
||||||
/* We can't write a valid hvcC from the provided data */
|
/* We can't write a valid hvcC from the provided data */
|
||||||
ret = AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
goto end;
|
|
||||||
} else if (*data == 1) {
|
} else if (*data == 1) {
|
||||||
/* Data is already hvcC-formatted */
|
/* Data is already hvcC-formatted */
|
||||||
avio_write(pb, data, size);
|
avio_write(pb, data, size);
|
||||||
goto end;
|
return 0;
|
||||||
} else if (!(AV_RB24(data) == 1 || AV_RB32(data) == 1)) {
|
} else if (!(AV_RB24(data) == 1 || AV_RB32(data) == 1)) {
|
||||||
/* Not a valid Annex B start code prefix */
|
/* Not a valid Annex B start code prefix */
|
||||||
ret = AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ff_avc_parse_nal_units_buf(data, &start, &size);
|
ret = ff_avc_parse_nal_units_buf(data, &start, &size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto end;
|
return ret;
|
||||||
|
|
||||||
|
hvcc_init(&hvcc);
|
||||||
|
|
||||||
buf = start;
|
buf = start;
|
||||||
end = start + size;
|
end = start + size;
|
||||||
|
Reference in New Issue
Block a user