You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avformat/utils: add ff_bprint_get_frame_filename
Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
@ -640,6 +640,20 @@ int ff_match_url_ext(const char *url, const char *extensions);
|
|||||||
int ff_get_frame_filename(char *buf, int buf_size, const char *path,
|
int ff_get_frame_filename(char *buf, int buf_size, const char *path,
|
||||||
int64_t number, int flags);
|
int64_t number, int flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 path path with substitution template
|
||||||
|
* @param number the number to substitute
|
||||||
|
* @param flags AV_FRAME_FILENAME_FLAGS_*
|
||||||
|
* @return 0 if OK, <0 on error.
|
||||||
|
*/
|
||||||
|
int ff_bprint_get_frame_filename(struct AVBPrint *buf, const char *path, int64_t number, int flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a dictionary value to an ISO-8601 compliant timestamp string.
|
* Set a dictionary value to an ISO-8601 compliant timestamp string.
|
||||||
*
|
*
|
||||||
|
@ -283,13 +283,12 @@ uint64_t ff_parse_ntp_time(uint64_t ntp_ts)
|
|||||||
return (sec * 1000000) + usec;
|
return (sec * 1000000) + usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_get_frame_filename(char *buf, int buf_size, const char *path, int64_t number, int flags)
|
int ff_bprint_get_frame_filename(struct AVBPrint *buf, const char *path, int64_t number, int flags)
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
char *q, buf1[20], c;
|
char c;
|
||||||
int nd, len, percentd_found;
|
int nd, percentd_found;
|
||||||
|
|
||||||
q = buf;
|
|
||||||
p = path;
|
p = path;
|
||||||
percentd_found = 0;
|
percentd_found = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -316,29 +315,30 @@ int ff_get_frame_filename(char *buf, int buf_size, const char *path, int64_t num
|
|||||||
percentd_found = 1;
|
percentd_found = 1;
|
||||||
if (number < 0)
|
if (number < 0)
|
||||||
nd += 1;
|
nd += 1;
|
||||||
snprintf(buf1, sizeof(buf1), "%0*" PRId64, nd, number);
|
av_bprintf(buf, "%0*" PRId64, nd, number);
|
||||||
len = strlen(buf1);
|
|
||||||
if ((q - buf + len) > buf_size - 1)
|
|
||||||
goto fail;
|
|
||||||
memcpy(q, buf1, len);
|
|
||||||
q += len;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
addchar:
|
addchar:
|
||||||
if ((q - buf) < buf_size - 1)
|
av_bprint_chars(buf, c, 1);
|
||||||
*q++ = c;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!percentd_found)
|
if (!percentd_found)
|
||||||
goto fail;
|
goto fail;
|
||||||
*q = '\0';
|
if (!av_bprint_is_complete(buf))
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
return 0;
|
return 0;
|
||||||
fail:
|
fail:
|
||||||
*q = '\0';
|
return AVERROR(EINVAL);
|
||||||
return -1;
|
}
|
||||||
|
|
||||||
|
int ff_get_frame_filename(char *buf, int buf_size, const char *path, int64_t number, int flags)
|
||||||
|
{
|
||||||
|
AVBPrint bp;
|
||||||
|
av_bprint_init_for_buffer(&bp, buf, buf_size);
|
||||||
|
return ff_bprint_get_frame_filename(&bp, path, number, flags) < 0 ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)
|
int av_get_frame_filename2(char *buf, int buf_size, const char *path, int number, int flags)
|
||||||
|
Reference in New Issue
Block a user