Imported Debian version 2.5.0~trusty1.1
[deb_ffmpeg.git] / ffmpeg / libavcodec / jacosubdec.c
index b64fac8a7586599607742c7561f947f88a96b359..2f949564d50dde0f5dde60e10218ef0851c809ab 100644 (file)
@@ -29,6 +29,7 @@
 #include "jacosub.h"
 #include "libavutil/avstring.h"
 #include "libavutil/bprint.h"
+#include "libavutil/time_internal.h"
 
 #undef time
 
@@ -44,11 +45,7 @@ static int insert_datetime(AVBPrint *dst, const char *in, const char *arg)
     time_t now = time(0);
     struct tm ltime;
 
-#if HAVE_LOCALTIME_R
     localtime_r(&now, &ltime);
-#else
-    ltime = *localtime(&now);
-#endif
     strftime(buf, sizeof(buf), arg, &ltime);
     av_bprintf(dst, "%s", buf);
     return 0;
@@ -162,12 +159,12 @@ static void jacosub_to_ass(AVCodecContext *avctx, AVBPrint *dst, const char *src
         if (i == FF_ARRAY_ELEMS(ass_codes_map))
             av_bprintf(dst, "%c", *src++);
     }
-    av_bprintf(dst, "\r\n");
 }
 
 static int jacosub_decode_frame(AVCodecContext *avctx,
                                 void *data, int *got_sub_ptr, AVPacket *avpkt)
 {
+    int ret;
     AVSubtitle *sub = data;
     const char *ptr = avpkt->data;
 
@@ -176,7 +173,6 @@ static int jacosub_decode_frame(AVCodecContext *avctx,
 
     if (*ptr) {
         AVBPrint buffer;
-        char *dec_sub;
 
         // skip timers
         ptr = jss_skip_whitespace(ptr);
@@ -185,9 +181,10 @@ static int jacosub_decode_frame(AVCodecContext *avctx,
 
         av_bprint_init(&buffer, JSS_MAX_LINESIZE, JSS_MAX_LINESIZE);
         jacosub_to_ass(avctx, &buffer, ptr);
-        av_bprint_finalize(&buffer, &dec_sub);
-        ff_ass_add_rect(sub, dec_sub, avpkt->pts, avpkt->duration, 0);
-        av_free(dec_sub);
+        ret = ff_ass_add_rect_bprint(sub, &buffer, avpkt->pts, avpkt->duration);
+        av_bprint_finalize(&buffer, NULL);
+        if (ret < 0)
+            return ret;
     }
 
 end: