History

avformat/internal: Add ff_get_frame_filename

It's similar to av_get_frame_filename2 but with int64_t number support. Make av_get_frame_filename* a wrapper over ff_get_frame_filename.

Zhao Zhili committed 2 years ago

Commit a2d96631 parent 8e76c992 files · +24 −3Browse files

Unified · Split

2 files
  1. libavformat/internal.h +16 −0
  2. libavformat/utils.c +8 −3
libavformat/internal.h+16−0
@@ -745,6 +745,22 @@ void ff_format_set_url(AVFormatContext *s, char *url); · 744 unmodified lines
745745 */
746746 int ff_match_url_ext(const char *url, const char *extensions);
747747
748+/**
749+ * Return in 'buf' the path with '%d' replaced by a number.
750+ *
751+ * Also handles the '%0nd' format where 'n' is the total number
752+ * of digits and '%%'.
753+ *
754+ * @param buf destination buffer
755+ * @param buf_size destination buffer size
756+ * @param path path with substitution template
757+ * @param number the number to substitute
758+ * @param flags AV_FRAME_FILENAME_FLAGS_*
759+ * @return 0 if OK, -1 on format error
760+ */
761+int ff_get_frame_filename(char *buf, int buf_size, const char *path,
762+ int64_t number, int flags);
763+
748764 struct FFOutputFormat;
749765 struct FFInputFormat;
750766 void avpriv_register_devices(const struct FFOutputFormat * const o[],
libavformat/utils.c+8−3
@@ -280,7 +280,7 @@ uint64_t ff_parse_ntp_time(uint64_t ntp_ts) · 279 unmodified lines
280280 return (sec * 1000000) + usec;
281281 }
282282
283−int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)
283+int ff_get_frame_filename(char *buf, int buf_size, const char *path, int64_t number, int flags)
284284 {
285285 const char *p;
286286 char *q, buf1[20], c;
@@ -313,7 +313,7 @@ int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number · 26 unmodified lines
313313 percentd_found = 1;
314314 if (number < 0)
315315 nd += 1;
316− snprintf(buf1, sizeof(buf1), "%0*d", nd, number);
316+ snprintf(buf1, sizeof(buf1), "%0*" PRId64, nd, number);
317317 len = strlen(buf1);
318318 if ((q - buf + len) > buf_size - 1)
319319 goto fail;
@@ -338,9 +338,14 @@ fail: · 18 unmodified lines
338338 return -1;
339339 }
340340
341+int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)
342+{
343+ return ff_get_frame_filename(buf, buf_size, path, number, flags);
344+}
345+
341346 int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
342347 {
343− return av_get_frame_filename2(buf, buf_size, path, number, 0);
348+ return ff_get_frame_filename(buf, buf_size, path, number, 0);
344349 }
345350
346351 void av_url_split(char *proto, int proto_size,

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