mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-08 06:09:50 +00:00
fftools/ffmpeg: make sure FrameData is writable when we modify it
Also, add a function that returns const FrameData* for cases that only read from it.
This commit is contained in:
parent
1d536e0283
commit
99d2fa38ad
3 changed files with 21 additions and 6 deletions
|
|
@ -427,21 +427,34 @@ InputStream *ist_iter(InputStream *prev)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
FrameData *frame_data(AVFrame *frame)
|
||||
static int frame_data_ensure(AVFrame *frame, int writable)
|
||||
{
|
||||
if (!frame->opaque_ref) {
|
||||
FrameData *fd;
|
||||
|
||||
frame->opaque_ref = av_buffer_allocz(sizeof(*fd));
|
||||
if (!frame->opaque_ref)
|
||||
return NULL;
|
||||
return AVERROR(ENOMEM);
|
||||
fd = (FrameData*)frame->opaque_ref->data;
|
||||
|
||||
fd->dec.frame_num = UINT64_MAX;
|
||||
fd->dec.pts = AV_NOPTS_VALUE;
|
||||
}
|
||||
} else if (writable)
|
||||
return av_buffer_make_writable(&frame->opaque_ref);
|
||||
|
||||
return (FrameData*)frame->opaque_ref->data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
FrameData *frame_data(AVFrame *frame)
|
||||
{
|
||||
int ret = frame_data_ensure(frame, 1);
|
||||
return ret < 0 ? NULL : (FrameData*)frame->opaque_ref->data;
|
||||
}
|
||||
|
||||
const FrameData *frame_data_c(AVFrame *frame)
|
||||
{
|
||||
int ret = frame_data_ensure(frame, 0);
|
||||
return ret < 0 ? NULL : (const FrameData*)frame->opaque_ref->data;
|
||||
}
|
||||
|
||||
void remove_avoptions(AVDictionary **a, AVDictionary *b)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue