]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit '6dd93ee6f1b050ad7c4b247899e83efa293ee405'
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 30 Dec 2012 12:54:50 +0000 (13:54 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 30 Dec 2012 12:54:50 +0000 (13:54 +0100)
* commit '6dd93ee6f1b050ad7c4b247899e83efa293ee405':
  hlsenc: check append_entry return value
  hlsenc: use the basename to generate the list entries
  avstring: add av_basename and av_dirname

Conflicts:
Changelog
doc/APIchanges
libavutil/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
Changelog
doc/APIchanges
libavformat/hlsenc.c
libavutil/avstring.c
libavutil/avstring.h
libavutil/version.h

index 9eec45c9973b1c89d6b9b090cd43d88f4c30caa2..00dc6404adebc59336997b6ca4b0f646643f1cc3 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -50,6 +50,7 @@ version <next>:
 - documentation split into per-component manuals
 - pp (postproc) filter ported from MPlayer
 - NIST Sphere demuxer
+- av_basename and av_dirname
 
 
 version 1.0:
index b463749ebad0b54ffc884ca06847d1e2bf1f9a3e..a79dd2df58b2f07357cc02a6f9d69b54c7c8b3da 100644 (file)
@@ -132,6 +132,9 @@ API changes, most recent first:
 2012-03-26 - a67d9cf - lavfi 2.66.100
   Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions.
 
+2012-xx-xx - xxxxxxx - lavu 52.2.1 - avstring.h
+  Add av_basename() and av_dirname().
+
 2012-11-10 - 5980f5dd - lavu 52.2.0 - audioconvert.h
   Rename audioconvert.h to channel_layout.h. audioconvert.h is now deprecated.
 
index e85c8b0b537e16f596e5ea4dc41798c80a3d3b3d..75ae134649e2c45a2c150ea503636608e3b466a8 100644 (file)
@@ -85,7 +85,8 @@ static int append_entry(HLSContext *hls, uint64_t duration)
     if (!en)
         return AVERROR(ENOMEM);
 
-    av_get_frame_filename(en->name, sizeof(en->name), hls->basename,
+    av_get_frame_filename(en->name, sizeof(en->name),
+                          av_basename(hls->basename),
                           hls->number -1);
 
     en->duration = duration;
@@ -260,9 +261,12 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
         av_compare_ts(pkt->pts, st->time_base, end_pts, AV_TIME_BASE_Q) >= 0 &&
         pkt->flags & AV_PKT_FLAG_KEY) {
 
-        append_entry(hls, av_rescale(pkt->pts - hls->end_pts,
-                                     st->time_base.num,
-                                     st->time_base.den));
+        ret = append_entry(hls, av_rescale(pkt->pts - hls->end_pts,
+                                           st->time_base.num,
+                                           st->time_base.den));
+        if (ret)
+            return ret;
+
         hls->end_pts = pkt->pts;
 
         av_write_frame(oc, NULL); /* Flush any buffered data */
index f03df674412441ffb757d9c5ee04b0d84ecf51b2..7072a55cf3b6817f41cb4e4b6435a3aa47313452 100644 (file)
@@ -25,6 +25,8 @@
 #include <string.h>
 #include <ctype.h>
 #include "avstring.h"
+#include "config.h"
+#include "common.h"
 #include "mem.h"
 
 int av_strstart(const char *str, const char *pfx, const char **ptr)
@@ -211,6 +213,45 @@ int av_strncasecmp(const char *a, const char *b, size_t n)
     return c1 - c2;
 }
 
+const char *av_basename(const char *path)
+{
+    char *p = strrchr(path, '/');
+
+#if HAVE_DOS_PATHS
+    char *q = strrchr(path, '\\');
+    char *d = strchr(path, ':');
+
+    p = FFMAX3(p, q, d);
+#endif
+
+    if (!p)
+        return path;
+
+    return p + 1;
+}
+
+const char *av_dirname(char *path)
+{
+    char *p = strrchr(path, '/');
+
+#if HAVE_DOS_PATHS
+    char *q = strrchr(path, '\\');
+    char *d = strchr(path, ':');
+
+    d = d ? d + 1 : d;
+
+    p = FFMAX3(p, q, d);
+#endif
+
+    if (!p)
+        return ".";
+
+    *p = '\0';
+
+    return path;
+}
+
+
 #ifdef TEST
 
 #include "common.h"
index f73d6e742069b74763b577c4bb1a3902e8b23af5..d7af9ec7c3d7d93c07157ad862adf26a52ca705e 100644 (file)
@@ -202,6 +202,22 @@ int av_strcasecmp(const char *a, const char *b);
  */
 int av_strncasecmp(const char *a, const char *b, size_t n);
 
+
+/**
+ * Thread safe basename.
+ * @param path the path, on DOS both \ and / are considered separators.
+ * @return pointer to the basename substring.
+ */
+const char *av_basename(const char *path);
+
+/**
+ * Thread safe dirname.
+ * @param path the path, on DOS both \ and / are considered separators.
+ * @return the path with the separator replaced by the string terminator or ".".
+ * @note the function may change the input string.
+ */
+const char *av_dirname(char *path);
+
 /**
  * @}
  */
index f5ccd1ff2b415e93d439fb807e60aa3c6351db6f..e47e0d12b3f59092580ad98a23759b8d266e1b0c 100644 (file)
@@ -75,7 +75,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  52
-#define LIBAVUTIL_VERSION_MINOR  12
+#define LIBAVUTIL_VERSION_MINOR  13
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \