Merge commit '69ab9f53f901eac6a649e22d28cf093357870627'
[ffmpeg.git] / libavcodec / hevc_parse.c
index 32a440b..260f1e1 100644 (file)
@@ -1,20 +1,20 @@
 /*
  * HEVC common code
  *
- * This file is part of Libav.
+ * This file is part of FFmpeg.
  *
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 
 /* FIXME: This is adapted from ff_h264_decode_nal, avoiding duplication
  * between these functions would be nice. */
-int ff_hevc_extract_rbsp(const uint8_t *src, int length,
+int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
                          HEVCNAL *nal)
 {
     int i, si, di;
     uint8_t *dst;
 
+    if (s)
+        s->skipped_bytes = 0;
 #define STARTCODE_TEST                                                  \
         if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) {     \
             if (src[i + 2] != 3) {                                      \
@@ -108,6 +110,19 @@ int ff_hevc_extract_rbsp(const uint8_t *src, int length,
                 dst[di++] = 0;
                 si       += 3;
 
+                if (s) {
+                        s->skipped_bytes++;
+                        if (s->skipped_bytes_pos_size < s->skipped_bytes) {
+                        s->skipped_bytes_pos_size *= 2;
+                        av_reallocp_array(&s->skipped_bytes_pos,
+                                s->skipped_bytes_pos_size,
+                                sizeof(*s->skipped_bytes_pos));
+                        if (!s->skipped_bytes_pos)
+                                return AVERROR(ENOMEM);
+                        }
+                        if (s->skipped_bytes_pos)
+                        s->skipped_bytes_pos[s->skipped_bytes-1] = di - 1;
+                }
                 continue;
             } else // next start code
                 goto nsc;
@@ -127,3 +142,4 @@ nsc:
     nal->raw_size = si;
     return si;
 }
+