fftools/ffmpeg: prepare FrameData for having allocated fields
Will be useful in following commits.
This commit is contained in:
parent
efab83c156
commit
b98af440c5
@ -402,23 +402,44 @@ InputStream *ist_iter(InputStream *prev)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void frame_data_free(void *opaque, uint8_t *data)
|
||||||
|
{
|
||||||
|
av_free(data);
|
||||||
|
}
|
||||||
|
|
||||||
static int frame_data_ensure(AVBufferRef **dst, int writable)
|
static int frame_data_ensure(AVBufferRef **dst, int writable)
|
||||||
{
|
{
|
||||||
if (!*dst) {
|
AVBufferRef *src = *dst;
|
||||||
|
|
||||||
|
if (!src || (writable && !av_buffer_is_writable(src))) {
|
||||||
FrameData *fd;
|
FrameData *fd;
|
||||||
|
|
||||||
*dst = av_buffer_allocz(sizeof(*fd));
|
fd = av_mallocz(sizeof(*fd));
|
||||||
if (!*dst)
|
if (!fd)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
fd = (FrameData*)((*dst)->data);
|
|
||||||
|
|
||||||
fd->dec.frame_num = UINT64_MAX;
|
*dst = av_buffer_create((uint8_t *)fd, sizeof(*fd),
|
||||||
fd->dec.pts = AV_NOPTS_VALUE;
|
frame_data_free, NULL, 0);
|
||||||
|
if (!*dst) {
|
||||||
|
av_buffer_unref(&src);
|
||||||
|
av_freep(&fd);
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned i = 0; i < FF_ARRAY_ELEMS(fd->wallclock); i++)
|
if (src) {
|
||||||
fd->wallclock[i] = INT64_MIN;
|
const FrameData *fd_src = (const FrameData *)src->data;
|
||||||
} else if (writable)
|
|
||||||
return av_buffer_make_writable(dst);
|
memcpy(fd, fd_src, sizeof(*fd));
|
||||||
|
|
||||||
|
av_buffer_unref(&src);
|
||||||
|
} else {
|
||||||
|
fd->dec.frame_num = UINT64_MAX;
|
||||||
|
fd->dec.pts = AV_NOPTS_VALUE;
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < FF_ARRAY_ELEMS(fd->wallclock); i++)
|
||||||
|
fd->wallclock[i] = INT64_MIN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user