Skip to content
Permalink
Browse files

initial clean patch import

  • Loading branch information
yuvadm committed Jan 5, 2012
1 parent 126b041 commit 0eb002821a2076cb3593c823399aeef9fdd29525
Showing with 68 additions and 13 deletions.
  1. +5 −0 doc/muxers.texi
  2. +13 −3 libavformat/avformat.h
  3. +6 −3 libavformat/img2.c
  4. +41 −7 libavformat/utils.c
  5. +3 −0 libavformat/version.h
@@ -110,6 +110,11 @@ If the pattern contains "%d" or "%0@var{N}d", the first filename of
the file list specified will contain the number 1, all the following
numbers will be sequential.

The pattern may also contain "%t", this string specifies the timestamp
of the frame in hours, minutes and seconds. Note that if two frames are written at the
same second, they will be overwritten, yielding a maximum output of 1 fps.
The "%t" and "%d" patterns may not be used simultaneously.

The pattern may contain a suffix which is used to automatically
determine the format of the image files to write.

@@ -2065,8 +2065,17 @@ int64_t av_gettime(void);
attribute_deprecated int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
#endif

#if FF_API_GET_FRAME_FILENAME
/**
* Return in 'buf' the path with '%d' replaced by a number.
* Deprecated. Use av_get_frame_filename2 which supports %t.
*/
attribute_deprecated int av_get_frame_filename(char *buf, int buf_size,
const char *path, int number);
#endif

/**
* Return in 'buf' the path with '%d' replaced by the frame number,
* and '%t' replaced by the frame timestamp.
*
* Also handles the '%0nd' format where 'n' is the total number
* of digits and '%%'.
@@ -2075,10 +2084,11 @@ attribute_deprecated int find_info_tag(char *arg, int arg_size, const char *tag1
* @param buf_size destination buffer size
* @param path numbered sequence string
* @param number frame number
* @param ts frame timestamp in seconds
* @return 0 if OK, -1 on format error
*/
int av_get_frame_filename(char *buf, int buf_size,
const char *path, int number);
int av_get_frame_filename2(char *buf, int buf_size,
const char *path, int number, int ts);

/**
* Check whether filename actually is a numbered sequence generator.
@@ -389,12 +389,15 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
VideoData *img = s->priv_data;
AVIOContext *pb[3];
char filename[1024];
AVCodecContext *codec= s->streams[ pkt->stream_index ]->codec;
AVStream *stream = s->streams[ pkt->stream_index ];
AVCodecContext *codec = stream->codec;
int i;

int ts = av_rescale_q(pkt->pts, stream->time_base, AV_TIME_BASE_Q);

if (!img->is_pipe) {
if (av_get_frame_filename(filename, sizeof(filename),
img->path, img->img_number) < 0 && img->img_number>1 && !img->updatefirst) {
if (av_get_frame_filename2(filename, sizeof(filename),
img->path, img->img_number, ts) < 0 && img->img_number>1 && !img->updatefirst) {
av_log(s, AV_LOG_ERROR,
"Could not get frame filename number %d from pattern '%s'\n",
img->img_number, img->path);
@@ -3819,16 +3819,17 @@ int find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
}
#endif

int av_get_frame_filename(char *buf, int buf_size,
const char *path, int number)
int av_get_frame_filename2(char *buf, int buf_size,
const char *path, int number, int ts)
{
const char *p;
char *q, buf1[20], c;
int nd, len, percentd_found;
int nd, len, percent_found;
int hours, mins, secs, ms;

q = buf;
p = path;
percentd_found = 0;
percent_found = 0;
for(;;) {
c = *p++;
if (c == '\0')
@@ -3846,16 +3847,37 @@ int av_get_frame_filename(char *buf, int buf_size,
case '%':
goto addchar;
case 'd':
if (percentd_found)
if (percent_found)
goto fail;
percentd_found = 1;
percent_found = 1;
snprintf(buf1, sizeof(buf1), "%0*d", nd, number);
len = strlen(buf1);
if ((q - buf + len) > buf_size - 1)
goto fail;
memcpy(q, buf1, len);
q += len;
break;
case 't':
if (percent_found)
goto fail;
if (ts < 1)
goto fail;
percent_found = 1;
ms = ts % (AV_TIME_BASE / 1000);
ts /= AV_TIME_BASE;
secs = ts % 60;
ts /= 60;
mins = ts % 60;
ts /= 60;
hours = ts;
snprintf(buf1, sizeof(buf1),
"%02d.%02d.%02d.%03d", hours, mins, secs, ms);
len = strlen(buf1);
if ((q - buf + len) > buf_size - 1)
goto fail;
memcpy(q, buf1, len);
q += len;
break;
default:
goto fail;
}
@@ -3865,7 +3887,7 @@ int av_get_frame_filename(char *buf, int buf_size,
*q++ = c;
}
}
if (!percentd_found)
if (!percent_found)
goto fail;
*q = '\0';
return 0;
@@ -3874,6 +3896,18 @@ int av_get_frame_filename(char *buf, int buf_size,
return -1;
}

#if FF_API_GET_FRAME_FILENAME
int av_get_frame_filename(char *buf, int buf_size,
const char *path, int number)
{
/*
* old versions don't support timestamps in filename (%t)
* so just pass 0 as the frame timestamp
*/
return av_get_frame_filename2(buf, buf_size, path, number, 0);
}
#endif

static void hex_dump_internal(void *avcl, FILE *f, int level, uint8_t *buf, int size)
{
int len, i, j, c;
@@ -125,5 +125,8 @@
#ifndef FF_API_CLOSE_INPUT_FILE
#define FF_API_CLOSE_INPUT_FILE (LIBAVFORMAT_VERSION_MAJOR < 54)
#endif
#ifndef FF_API_GET_FRAME_FILENAME
#define FF_API_GET_FRAME_FILENAME (LIBAVFORMAT_VERSION_MAJOR < 54)
#endif

#endif /* AVFORMAT_VERSION_H */

0 comments on commit 0eb0028

Please sign in to comment.
You can’t perform that action at this time.