|
|
@ -1066,52 +1066,15 @@ int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out, |
|
|
|
int *size, int filter_ps, int *ps_count) |
|
|
|
int *size, int filter_ps, int *ps_count) |
|
|
|
{ |
|
|
|
{ |
|
|
|
AVIOContext *pb; |
|
|
|
AVIOContext *pb; |
|
|
|
int num_ps = 0, ret = 0; |
|
|
|
int ret; |
|
|
|
uint8_t *buf, *end, *start = NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!filter_ps) { |
|
|
|
|
|
|
|
ret = ff_avc_parse_nal_units_buf(buf_in, buf_out, size); |
|
|
|
|
|
|
|
goto end; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ret = avio_open_dyn_buf(&pb); |
|
|
|
ret = avio_open_dyn_buf(&pb); |
|
|
|
if (ret < 0) |
|
|
|
if (ret < 0) |
|
|
|
goto end; |
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
|
|
ret = ff_avc_parse_nal_units_buf(buf_in, &start, size); |
|
|
|
|
|
|
|
if (ret < 0) |
|
|
|
|
|
|
|
goto end; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buf = start; |
|
|
|
|
|
|
|
end = start + *size; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (end - buf > 4) { |
|
|
|
|
|
|
|
uint32_t len = FFMIN(AV_RB32(buf), end - buf - 4); |
|
|
|
|
|
|
|
uint8_t type = (buf[4] >> 1) & 0x3f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buf += 4; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (type) { |
|
|
|
|
|
|
|
case NAL_VPS: |
|
|
|
|
|
|
|
case NAL_SPS: |
|
|
|
|
|
|
|
case NAL_PPS: |
|
|
|
|
|
|
|
num_ps++; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
avio_wb32(pb, len); |
|
|
|
|
|
|
|
avio_write(pb, buf, len); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buf += len; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ret = ff_hevc_annexb2mp4(pb, buf_in, *size, filter_ps, ps_count); |
|
|
|
*size = avio_close_dyn_buf(pb, buf_out); |
|
|
|
*size = avio_close_dyn_buf(pb, buf_out); |
|
|
|
|
|
|
|
|
|
|
|
end: |
|
|
|
|
|
|
|
av_free(start); |
|
|
|
|
|
|
|
if (ps_count) |
|
|
|
|
|
|
|
*ps_count = num_ps; |
|
|
|
|
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|