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.

Co-authored-by: Filip Mašić <shoutplenty@gmail.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
This commit is contained in:
Zhao Zhili 2024-09-23 23:14:19 +08:00
parent 8e76c99301
commit a2d9663241
2 changed files with 24 additions and 3 deletions

View File

@ -745,6 +745,22 @@ void ff_format_set_url(AVFormatContext *s, char *url);
*/
int ff_match_url_ext(const char *url, const char *extensions);
/**
* Return in 'buf' the path with '%d' replaced by a number.
*
* Also handles the '%0nd' format where 'n' is the total number
* of digits and '%%'.
*
* @param buf destination buffer
* @param buf_size destination buffer size
* @param path path with substitution template
* @param number the number to substitute
* @param flags AV_FRAME_FILENAME_FLAGS_*
* @return 0 if OK, -1 on format error
*/
int ff_get_frame_filename(char *buf, int buf_size, const char *path,
int64_t number, int flags);
struct FFOutputFormat;
struct FFInputFormat;
void avpriv_register_devices(const struct FFOutputFormat * const o[],

View File

@ -280,7 +280,7 @@ uint64_t ff_parse_ntp_time(uint64_t ntp_ts)
return (sec * 1000000) + usec;
}
int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)
int ff_get_frame_filename(char *buf, int buf_size, const char *path, int64_t number, int flags)
{
const char *p;
char *q, buf1[20], c;
@ -313,7 +313,7 @@ int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number
percentd_found = 1;
if (number < 0)
nd += 1;
snprintf(buf1, sizeof(buf1), "%0*d", nd, number);
snprintf(buf1, sizeof(buf1), "%0*" PRId64, nd, number);
len = strlen(buf1);
if ((q - buf + len) > buf_size - 1)
goto fail;
@ -338,9 +338,14 @@ fail:
return -1;
}
int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)
{
return ff_get_frame_filename(buf, buf_size, path, number, flags);
}
int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
{
return av_get_frame_filename2(buf, buf_size, path, number, 0);
return ff_get_frame_filename(buf, buf_size, path, number, 0);
}
void av_url_split(char *proto, int proto_size,