mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-04-07 17:52:54 +00:00
lavfi/avcodec: add consistency checks in avfilter_copy_buf_props()
The function will abort through an assert if the source is not defined, or if the internal state of the source is inconsistent (e.g. type = AUDIO && !src->audio).
This commit is contained in:
parent
6808759a58
commit
f0394f28c3
@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
|
#include "libavutil/avassert.h"
|
||||||
#include "libavutil/opt.h"
|
#include "libavutil/opt.h"
|
||||||
|
|
||||||
int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
|
int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
|
||||||
@ -83,6 +84,11 @@ int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
|
|||||||
{
|
{
|
||||||
int planes, nb_channels;
|
int planes, nb_channels;
|
||||||
|
|
||||||
|
if (!dst)
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
/* abort in case the src is NULL and dst is not, avoid inconsistent state in dst */
|
||||||
|
av_assert0(src);
|
||||||
|
|
||||||
memcpy(dst->data, src->data, sizeof(dst->data));
|
memcpy(dst->data, src->data, sizeof(dst->data));
|
||||||
memcpy(dst->linesize, src->linesize, sizeof(dst->linesize));
|
memcpy(dst->linesize, src->linesize, sizeof(dst->linesize));
|
||||||
|
|
||||||
@ -91,6 +97,7 @@ int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
|
|||||||
|
|
||||||
switch (src->type) {
|
switch (src->type) {
|
||||||
case AVMEDIA_TYPE_VIDEO:
|
case AVMEDIA_TYPE_VIDEO:
|
||||||
|
av_assert0(src->video);
|
||||||
dst->width = src->video->w;
|
dst->width = src->video->w;
|
||||||
dst->height = src->video->h;
|
dst->height = src->video->h;
|
||||||
dst->sample_aspect_ratio = src->video->sample_aspect_ratio;
|
dst->sample_aspect_ratio = src->video->sample_aspect_ratio;
|
||||||
@ -100,6 +107,7 @@ int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
|
|||||||
dst->pict_type = src->video->pict_type;
|
dst->pict_type = src->video->pict_type;
|
||||||
break;
|
break;
|
||||||
case AVMEDIA_TYPE_AUDIO:
|
case AVMEDIA_TYPE_AUDIO:
|
||||||
|
av_assert0(src->audio);
|
||||||
nb_channels = av_get_channel_layout_nb_channels(src->audio->channel_layout);
|
nb_channels = av_get_channel_layout_nb_channels(src->audio->channel_layout);
|
||||||
planes = av_sample_fmt_is_planar(src->format) ? nb_channels : 1;
|
planes = av_sample_fmt_is_planar(src->format) ? nb_channels : 1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user