[FFmpeg-cvslog] avformat/avc: refactor ff_isom_write_avcc

James Almer git at videolan.org
Thu Nov 30 05:38:32 EET 2017


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Fri Nov 24 19:45:54 2017 -0300| [9cd361c5c1f3550df9b2d4bd13b02ea592727f7c] | committer: James Almer

avformat/avc: refactor ff_isom_write_avcc

This lets us remove one indentation level.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9cd361c5c1f3550df9b2d4bd13b02ea592727f7c
---

 libavformat/avc.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/libavformat/avc.c b/libavformat/avc.c
index 5232ed55f8..a764ec0422 100644
--- a/libavformat/avc.c
+++ b/libavformat/avc.c
@@ -105,17 +105,22 @@ int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
 
 int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
 {
+    uint8_t *buf = NULL, *end, *start = NULL;
+    uint8_t *sps = NULL, *pps = NULL;
+    uint32_t sps_size = 0, pps_size = 0;
+    int ret;
+
     if (len <= 6)
         return AVERROR_INVALIDDATA;
 
         /* check for H.264 start code */
-        if (AV_RB32(data) == 0x00000001 ||
-            AV_RB24(data) == 0x000001) {
-            uint8_t *buf=NULL, *end, *start;
-            uint32_t sps_size=0, pps_size=0;
-            uint8_t *sps=0, *pps=0;
+        if (AV_RB32(data) != 0x00000001 &&
+            AV_RB24(data) != 0x000001) {
+            avio_write(pb, data, len);
+            return 0;
+        }
 
-            int ret = ff_avc_parse_nal_units_buf(data, &buf, &len);
+            ret = ff_avc_parse_nal_units_buf(data, &buf, &len);
             if (ret < 0)
                 return ret;
             start = buf;
@@ -156,9 +161,6 @@ int ff_isom_write_avcc(AVIOContext *pb, const uint8_t *data, int len)
             avio_wb16(pb, pps_size);
             avio_write(pb, pps, pps_size);
             av_free(start);
-        } else {
-            avio_write(pb, data, len);
-        }
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list