[FFmpeg-devel] [PATCH V3 2/2] hwaccel_mpeg: check reference pictures are available
Michael Niedermayer
michael at niedermayer.cc
Thu Oct 12 23:21:04 EEST 2017
On Thu, Oct 12, 2017 at 04:20:45PM +0800, Zhong Li wrote:
> some reference pictures are not existed but valiad surface_ids are set,
> (for example, the second field of the first key frame can be
> P_Picture_Type but there is no preivous frame.)
> then may cause some driver problems (e.g, segment fault on mesa/AMD driver).
>
> Signed-off-by: Zhong Li <zhong.li at intel.com>
> ---
[...]
> diff --git a/libavcodec/vdpau_mpeg12.c b/libavcodec/vdpau_mpeg12.c
> index b657007ee7..6d73d45f1a 100644
> --- a/libavcodec/vdpau_mpeg12.c
> +++ b/libavcodec/vdpau_mpeg12.c
> @@ -45,13 +45,18 @@ static int vdpau_mpeg_start_frame(AVCodecContext *avctx,
>
> switch (s->pict_type) {
> case AV_PICTURE_TYPE_B:
> - ref = ff_vdpau_get_surface_id(s->next_picture.f);
> - assert(ref != VDP_INVALID_HANDLE);
> - info->backward_reference = ref;
> + if (s->next_picture_ptr) {
> + ref = ff_vdpau_get_surface_id(s->next_picture.f);
> + assert(ref != VDP_INVALID_HANDLE);
> + info->backward_reference = ref;
> + }
> /* fall through to forward prediction */
> case AV_PICTURE_TYPE_P:
> - ref = ff_vdpau_get_surface_id(s->last_picture.f);
> - info->forward_reference = ref;
> + if (s->last_picture_ptr) {
> + ref = ff_vdpau_get_surface_id(s->last_picture.f);
> + assert(ref != VDP_INVALID_HANDLE);
please use av_assert*()
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20171012/dddd9503/attachment.sig>
More information about the ffmpeg-devel
mailing list