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
745 */745 */
746int ff_match_url_ext(const char *url, const char *extensions);746int ff_match_url_ext(const char *url, const char *extensions);
747 747
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 */
761int ff_get_frame_filename(char *buf, int buf_size, const char *path,
762 int64_t number, int flags);
763
748struct FFOutputFormat;764struct FFOutputFormat;
749struct FFInputFormat;765struct FFInputFormat;
750void avpriv_register_devices(const struct FFOutputFormat * const o[],766void 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
280 return (sec * 1000000) + usec;280 return (sec * 1000000) + usec;
281}281}
282 282
283int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)283int ff_get_frame_filename(char *buf, int buf_size, const char *path, int64_t number, int flags)
284{284{
285 const char *p;285 const char *p;
286 char *q, buf1[20], c;286 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
313 percentd_found = 1;313 percentd_found = 1;
314 if (number < 0)314 if (number < 0)
315 nd += 1;315 nd += 1;
316 snprintf(buf1, sizeof(buf1), "%0*d", nd, number);316 snprintf(buf1, sizeof(buf1), "%0*" PRId64, nd, number);
317 len = strlen(buf1);317 len = strlen(buf1);
318 if ((q - buf + len) > buf_size - 1)318 if ((q - buf + len) > buf_size - 1)
319 goto fail;319 goto fail;
@@ -338,9 +338,14 @@ fail: · 18 unmodified lines
338 return -1;338 return -1;
339}339}
340 340
341int 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
341int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)346int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
342{347{
343 return av_get_frame_filename2(buf, buf_size, path, number, 0);348 return ff_get_frame_filename(buf, buf_size, path, number, 0);
344}349}
345 350
346void av_url_split(char *proto, int proto_size,351void 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