History

Merge commit '6dd93ee6f1b050ad7c4b247899e83efa293ee405'

* 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

Michael Niedermayer committed 13 years ago

Commit 2ce43b32 parents 613001d 6dd93ee6 files · +70 −5Browse files

Unified · Split

6 files
  1. Changelog +1 −0
  2. doc/APIchanges +3 −0
  3. libavformat/hlsenc.c +8 −4
  4. libavutil/avstring.c +41 −0
  5. libavutil/avstring.h +16 −0
  6. libavutil/version.h +1 −1
Changelog+1−0
@@ -50,6 +50,7 @@ version <next>: · 49 unmodified lines
5050 - documentation split into per-component manuals
5151 - pp (postproc) filter ported from MPlayer
5252 - NIST Sphere demuxer
53+- av_basename and av_dirname
5354
5455
5556 version 1.0:
doc/APIchanges+3−0
@@ -132,6 +132,9 @@ API changes, most recent first: · 131 unmodified lines
132132 2012-03-26 - a67d9cf - lavfi 2.66.100
133133 Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions.
134134
135+2012-xx-xx - xxxxxxx - lavu 52.2.1 - avstring.h
136+ Add av_basename() and av_dirname().
137+
135138 2012-11-10 - 5980f5dd - lavu 52.2.0 - audioconvert.h
136139 Rename audioconvert.h to channel_layout.h. audioconvert.h is now deprecated.
137140
libavformat/hlsenc.c+8−4
@@ -85,7 +85,8 @@ static int append_entry(HLSContext *hls, uint64_t duration) · 84 unmodified lines
8585 if (!en)
8686 return AVERROR(ENOMEM);
8787
88− av_get_frame_filename(en->name, sizeof(en->name), hls->basename,
88+ av_get_frame_filename(en->name, sizeof(en->name),
89+ av_basename(hls->basename),
8990 hls->number -1);
9091
9192 en->duration = duration;
@@ -260,9 +261,12 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) · 168 unmodified lines
260261 av_compare_ts(pkt->pts, st->time_base, end_pts, AV_TIME_BASE_Q) >= 0 &&
261262 pkt->flags & AV_PKT_FLAG_KEY) {
262263
263− append_entry(hls, av_rescale(pkt->pts - hls->end_pts,
264− st->time_base.num,
265− st->time_base.den));
264+ ret = append_entry(hls, av_rescale(pkt->pts - hls->end_pts,
265+ st->time_base.num,
266+ st->time_base.den));
267+ if (ret)
268+ return ret;
269+
266270 hls->end_pts = pkt->pts;
267271
268272 av_write_frame(oc, NULL); /* Flush any buffered data */
libavutil/avstring.c+41−0
@@ -25,6 +25,8 @@ · 24 unmodified lines
2525 #include <string.h>
2626 #include <ctype.h>
2727 #include "avstring.h"
28+#include "config.h"
29+#include "common.h"
2830 #include "mem.h"
2931
3032 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) · 180 unmodified lines
211213 return c1 - c2;
212214 }
213215
216+const char *av_basename(const char *path)
217+{
218+ char *p = strrchr(path, '/');
219+
220+#if HAVE_DOS_PATHS
221+ char *q = strrchr(path, '\\');
222+ char *d = strchr(path, ':');
223+
224+ p = FFMAX3(p, q, d);
225+#endif
226+
227+ if (!p)
228+ return path;
229+
230+ return p + 1;
231+}
232+
233+const char *av_dirname(char *path)
234+{
235+ char *p = strrchr(path, '/');
236+
237+#if HAVE_DOS_PATHS
238+ char *q = strrchr(path, '\\');
239+ char *d = strchr(path, ':');
240+
241+ d = d ? d + 1 : d;
242+
243+ p = FFMAX3(p, q, d);
244+#endif
245+
246+ if (!p)
247+ return ".";
248+
249+ *p = '\0';
250+
251+ return path;
252+}
253+
254+
214255 #ifdef TEST
215256
216257 #include "common.h"
libavutil/avstring.h+16−0
@@ -202,6 +202,22 @@ int av_strcasecmp(const char *a, const char *b); · 201 unmodified lines
202202 */
203203 int av_strncasecmp(const char *a, const char *b, size_t n);
204204
205+
206+/**
207+ * Thread safe basename.
208+ * @param path the path, on DOS both \ and / are considered separators.
209+ * @return pointer to the basename substring.
210+ */
211+const char *av_basename(const char *path);
212+
213+/**
214+ * Thread safe dirname.
215+ * @param path the path, on DOS both \ and / are considered separators.
216+ * @return the path with the separator replaced by the string terminator or ".".
217+ * @note the function may change the input string.
218+ */
219+const char *av_dirname(char *path);
220+
205221 /**
206222 * @}
207223 */
libavutil/version.h+1−1
@@ -75,7 +75,7 @@ · 74 unmodified lines
7575 */
7676
7777 #define LIBAVUTIL_VERSION_MAJOR 52
78−#define LIBAVUTIL_VERSION_MINOR 12
78+#define LIBAVUTIL_VERSION_MINOR 13
7979 #define LIBAVUTIL_VERSION_MICRO 100
8080
8181 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t