diff options
author | James Almer <jamrial@gmail.com> | 2017-11-24 19:47:47 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2017-11-30 00:17:41 -0300 |
commit | df20619b649e82598d0e6efab291b427922b8ca4 (patch) | |
tree | 16b5c2b004df9120c535b2befb84149a347b2ace /libavformat/avc.c | |
parent | 9cd361c5c1f3550df9b2d4bd13b02ea592727f7c (diff) | |
download | ffmpeg-df20619b649e82598d0e6efab291b427922b8ca4.tar.gz |
avformat/avc: reindent after the last commit
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/avc.c')
-rw-r--r-- | libavformat/avc.c | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/libavformat/avc.c b/libavformat/avc.c index a764ec0422..85441df8f7 100644 --- a/libavformat/avc.c +++ b/libavformat/avc.c @@ -113,54 +113,55 @@ int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len) if (len <= 6) return AVERROR_INVALIDDATA; - /* check for H.264 start code */ - if (AV_RB32(data) != 0x00000001 && - AV_RB24(data) != 0x000001) { - avio_write(pb, data, len); - return 0; + /* check for H.264 start code */ + if (AV_RB32(data) != 0x00000001 && + AV_RB24(data) != 0x000001) { + avio_write(pb, data, len); + return 0; + } + + ret = ff_avc_parse_nal_units_buf(data, &buf, &len); + if (ret < 0) + return ret; + start = buf; + end = buf + len; + + /* look for sps and pps */ + while (end - buf > 4) { + uint32_t size; + uint8_t nal_type; + size = FFMIN(AV_RB32(buf), end - buf - 4); + buf += 4; + nal_type = buf[0] & 0x1f; + + if (nal_type == 7) { /* SPS */ + sps = buf; + sps_size = size; + } else if (nal_type == 8) { /* PPS */ + pps = buf; + pps_size = size; } - ret = ff_avc_parse_nal_units_buf(data, &buf, &len); - if (ret < 0) - return ret; - start = buf; - end = buf + len; - - /* look for sps and pps */ - while (end - buf > 4) { - uint32_t size; - uint8_t nal_type; - size = FFMIN(AV_RB32(buf), end - buf - 4); - buf += 4; - nal_type = buf[0] & 0x1f; - - if (nal_type == 7) { /* SPS */ - sps = buf; - sps_size = size; - } else if (nal_type == 8) { /* PPS */ - pps = buf; - pps_size = size; - } - - buf += size; - } + buf += size; + } + + if (!sps || !pps || sps_size < 4 || sps_size > UINT16_MAX || pps_size > UINT16_MAX) + return AVERROR_INVALIDDATA; + + avio_w8(pb, 1); /* version */ + avio_w8(pb, sps[1]); /* profile */ + avio_w8(pb, sps[2]); /* profile compat */ + avio_w8(pb, sps[3]); /* level */ + avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */ + avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */ + + avio_wb16(pb, sps_size); + avio_write(pb, sps, sps_size); + avio_w8(pb, 1); /* number of pps */ + avio_wb16(pb, pps_size); + avio_write(pb, pps, pps_size); + av_free(start); - if (!sps || !pps || sps_size < 4 || sps_size > UINT16_MAX || pps_size > UINT16_MAX) - return AVERROR_INVALIDDATA; - - avio_w8(pb, 1); /* version */ - avio_w8(pb, sps[1]); /* profile */ - avio_w8(pb, sps[2]); /* profile compat */ - avio_w8(pb, sps[3]); /* level */ - avio_w8(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */ - avio_w8(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */ - - avio_wb16(pb, sps_size); - avio_write(pb, sps, sps_size); - avio_w8(pb, 1); /* number of pps */ - avio_wb16(pb, pps_size); - avio_write(pb, pps, pps_size); - av_free(start); return 0; } |