@@ -120,20 +120,13 @@ int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size)
{
const uint8_t *p = buf_in;
const uint8_t *end = p + size;
- const uint8_t *nal_start, *nal_end;
+ const uint8_t *nal_start, *nal_end = NULL;
size = 0;
- nal_start = ff_avc_find_startcode(p, end);
- for (;;) {
- while (nal_start < end && !*(nal_start++));
- if (nal_start == end)
- break;
-
- nal_end = ff_avc_find_startcode(nal_start, end);
+ while (nal_start = ff_avc_parse_nalu(&p, &nal_end, end)) {
avio_wb32(pb, nal_end - nal_start);
avio_write(pb, nal_start, nal_end - nal_start);
size += 4 + nal_end - nal_start;
- nal_start = nal_end;
}
return size;
}
@@ -194,7 +194,7 @@ int ff_mov_cenc_avc_parse_nal_units(MOVMuxCencContext* ctx, AVIOContext *pb,
{
const uint8_t *p = buf_in;
const uint8_t *end = p + size;
- const uint8_t *nal_start, *nal_end;
+ const uint8_t *nal_start, *nal_end = NULL;
int ret;
ret = mov_cenc_start_packet(ctx);
@@ -203,14 +203,7 @@ int ff_mov_cenc_avc_parse_nal_units(MOVMuxCencContext* ctx, AVIOContext *pb,
}
size = 0;
- nal_start = ff_avc_find_startcode(p, end);
- for (;;) {
- while (nal_start < end && !*(nal_start++));
- if (nal_start == end)
- break;
-
- nal_end = ff_avc_find_startcode(nal_start, end);
-
+ while (nal_start = ff_avc_parse_nalu(&p, &nal_end, end)) {
avio_wb32(pb, nal_end - nal_start);
avio_w8(pb, *nal_start);
mov_cenc_write_encrypted(ctx, pb, nal_start + 1, nal_end - nal_start - 1);
@@ -218,7 +211,6 @@ int ff_mov_cenc_avc_parse_nal_units(MOVMuxCencContext* ctx, AVIOContext *pb,
auxiliary_info_add_subsample(ctx, 5, nal_end - nal_start - 1);
size += 4 + nal_end - nal_start;
- nal_start = nal_end;
}
ret = mov_cenc_end_packet(ctx);
by using the new ff_avc_parse_nalu function. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- libavformat/avc.c | 11 ++--------- libavformat/movenccenc.c | 12 ++---------- 2 files changed, 4 insertions(+), 19 deletions(-)