]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/srtdec.c
lavc: add a FF_API_REQUEST_CHANNELS deprecation macro
[ffmpeg] / libavcodec / srtdec.c
index 42eae322d15c2b05477864c474085ad6c53717c4..da625aacbfe625f690fc0ed8bf00e1b15b1c37b6 100644 (file)
@@ -2,25 +2,25 @@
  * SubRip subtitle decoder
  * Copyright (c) 2010  Aurelien Jacobs <aurel@gnuage.org>
  *
- * This file is part of FFmpeg.
+ * This file is part of Libav.
  *
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav 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.
  *
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav 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 FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include "libavutil/avstring.h"
-#include "libavcore/parseutils.h"
+#include "libavutil/parseutils.h"
 #include "avcodec.h"
 #include "ass.h"
 
@@ -65,7 +65,7 @@ static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end,
             out += snprintf(out, out_end-out, "{\\an1}{\\pos(%d,%d)}", x1, y1);
     }
 
-    for (; *in && out < out_end && !end; in++) {
+    for (; out < out_end && !end && *in; in++) {
         switch (*in) {
         case '\r':
             break;
@@ -211,13 +211,14 @@ static int srt_decode_frame(AVCodecContext *avctx,
     int ts_start, ts_end, x1 = -1, y1 = -1, x2 = -1, y2 = -1;
     char buffer[2048];
     const char *ptr = avpkt->data;
+    const char *end = avpkt->data + avpkt->size;
 
     if (avpkt->size <= 0)
         return avpkt->size;
 
     ff_ass_init(sub);
 
-    while (*ptr) {
+    while (ptr < end && *ptr) {
         ptr = read_ts(ptr, &ts_start, &ts_end, &x1, &y1, &x2, &y2);
         if (!ptr)
             break;
@@ -230,7 +231,7 @@ static int srt_decode_frame(AVCodecContext *avctx,
     return avpkt->size;
 }
 
-AVCodec srt_decoder = {
+AVCodec ff_srt_decoder = {
     .name         = "srt",
     .long_name    = NULL_IF_CONFIG_SMALL("SubRip subtitle"),
     .type         = AVMEDIA_TYPE_SUBTITLE,