* 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
Unified · Split
| @@ -50,6 +50,7 @@ version <next>: · 49 unmodified lines | ||
| 50 | 50 | - documentation split into per-component manuals |
| 51 | 51 | - pp (postproc) filter ported from MPlayer |
| 52 | 52 | - NIST Sphere demuxer |
| 53 | +- av_basename and av_dirname | |
| 53 | 54 | |
| 54 | 55 | |
| 55 | 56 | version 1.0: |
| @@ -132,6 +132,9 @@ API changes, most recent first: · 131 unmodified lines | ||
| 132 | 132 | 2012-03-26 - a67d9cf - lavfi 2.66.100 |
| 133 | 133 | Add avfilter_fill_frame_from_{audio_,}buffer_ref() functions. |
| 134 | 134 | |
| 135 | +2012-xx-xx - xxxxxxx - lavu 52.2.1 - avstring.h | |
| 136 | + Add av_basename() and av_dirname(). | |
| 137 | + | |
| 135 | 138 | 2012-11-10 - 5980f5dd - lavu 52.2.0 - audioconvert.h |
| 136 | 139 | Rename audioconvert.h to channel_layout.h. audioconvert.h is now deprecated. |
| 137 | 140 | |
| @@ -85,7 +85,8 @@ static int append_entry(HLSContext *hls, uint64_t duration) · 84 unmodified lines | ||
| 85 | 85 | if (!en) |
| 86 | 86 | return AVERROR(ENOMEM); |
| 87 | 87 | |
| 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), | |
| 89 | 90 | hls->number -1); |
| 90 | 91 | |
| 91 | 92 | en->duration = duration; |
| @@ -260,9 +261,12 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) · 168 unmodified lines | ||
| 260 | 261 | av_compare_ts(pkt->pts, st->time_base, end_pts, AV_TIME_BASE_Q) >= 0 && |
| 261 | 262 | pkt->flags & AV_PKT_FLAG_KEY) { |
| 262 | 263 | |
| 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 | + | |
| 266 | 270 | hls->end_pts = pkt->pts; |
| 267 | 271 | |
| 268 | 272 | av_write_frame(oc, NULL); /* Flush any buffered data */ |
| @@ -25,6 +25,8 @@ · 24 unmodified lines | ||
| 25 | 25 | #include <string.h> |
| 26 | 26 | #include <ctype.h> |
| 27 | 27 | #include "avstring.h" |
| 28 | +#include "config.h" | |
| 29 | +#include "common.h" | |
| 28 | 30 | #include "mem.h" |
| 29 | 31 | |
| 30 | 32 | 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 | ||
| 211 | 213 | return c1 - c2; |
| 212 | 214 | } |
| 213 | 215 | |
| 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 | + | |
| 214 | 255 | #ifdef TEST |
| 215 | 256 | |
| 216 | 257 | #include "common.h" |
| @@ -202,6 +202,22 @@ int av_strcasecmp(const char *a, const char *b); · 201 unmodified lines | ||
| 202 | 202 | */ |
| 203 | 203 | int av_strncasecmp(const char *a, const char *b, size_t n); |
| 204 | 204 | |
| 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 | + | |
| 205 | 221 | /** |
| 206 | 222 | * @} |
| 207 | 223 | */ |
| @@ -75,7 +75,7 @@ · 74 unmodified lines | ||
| 75 | 75 | */ |
| 76 | 76 | |
| 77 | 77 | #define LIBAVUTIL_VERSION_MAJOR 52 |
| 78 | −#define LIBAVUTIL_VERSION_MINOR 12 | |
| 78 | +#define LIBAVUTIL_VERSION_MINOR 13 | |
| 79 | 79 | #define LIBAVUTIL_VERSION_MICRO 100 |
| 80 | 80 | |
| 81 | 81 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |