diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2023-10-08 12:25:07 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-06-12 11:38:13 +0200 |
commit | fe6037fd04db8837dcdb9013f9c4ad4e7eb0592e (patch) | |
tree | f1d9d01bd96a2ae05710d737961340c40986e35b /libavcodec/vaapi_vc1.c | |
parent | dac15a5b6edec3c055a3add853a80b99246d6829 (diff) | |
download | ffmpeg-fe6037fd04db8837dcdb9013f9c4ad4e7eb0592e.tar.gz |
avcodec/mpegpicture: Split MPVPicture into WorkPicture and ordinary Pic
There are two types of MPVPictures: Three (cur_pic, last_pic, next_pic)
that are directly part of MpegEncContext and an array of MPVPictures
that are separately allocated and are mostly accessed via pointers
(cur|last|next)_pic_ptr; they are also used to store AVFrames in the
encoder (necessary due to B-frames). As the name implies, each of the
former is directly associated with one of the _ptr pointers:
They actually share the same underlying buffers, but the ones
that are part of the context can have their data pointers offset
and their linesize doubled for field pictures.
Up until now, each of these had their own references; in particular,
there was an underlying av_frame_ref() to sync cur_pic and cur_pic_ptr
etc. This is wasteful.
This commit changes this relationship: cur_pic, last_pic and next_pic
now become MPVWorkPictures; this structure does not have an AVFrame
at all any more, but only the cached values of data and linesize.
It also contains a pointer to the corresponding MPVPicture, establishing
a more natural relationsship between the two.
This already means that creating the context-pictures from the pointers
can no longer fail.
What has not been changed is the fact that the MPVPicture* pointers
are not ownership pointers and that the MPVPictures are part of an
array of MPVPictures that is owned by a single AVCodecContext.
Doing so will be done in a latter commit.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/vaapi_vc1.c')
-rw-r--r-- | libavcodec/vaapi_vc1.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libavcodec/vaapi_vc1.c b/libavcodec/vaapi_vc1.c index 6fc89c0bd7..7d001882fd 100644 --- a/libavcodec/vaapi_vc1.c +++ b/libavcodec/vaapi_vc1.c @@ -253,11 +253,11 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t { const VC1Context *v = avctx->priv_data; const MpegEncContext *s = &v->s; - VAAPIDecodePicture *pic = s->cur_pic_ptr->hwaccel_picture_private; + VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private; VAPictureParameterBufferVC1 pic_param; int err; - pic->output_surface = ff_vaapi_get_surface_id(s->cur_pic_ptr->f); + pic->output_surface = ff_vaapi_get_surface_id(s->cur_pic.ptr->f); pic_param = (VAPictureParameterBufferVC1) { .forward_reference_picture = VA_INVALID_ID, @@ -374,10 +374,12 @@ static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t switch (s->pict_type) { case AV_PICTURE_TYPE_B: - pic_param.backward_reference_picture = ff_vaapi_get_surface_id(s->next_pic.f); + if (s->next_pic.ptr) + pic_param.backward_reference_picture = ff_vaapi_get_surface_id(s->next_pic.ptr->f); // fall-through case AV_PICTURE_TYPE_P: - pic_param.forward_reference_picture = ff_vaapi_get_surface_id(s->last_pic.f); + if (s->last_pic.ptr) + pic_param.forward_reference_picture = ff_vaapi_get_surface_id(s->last_pic.ptr->f); break; } @@ -450,7 +452,7 @@ static int vaapi_vc1_end_frame(AVCodecContext *avctx) { VC1Context *v = avctx->priv_data; MpegEncContext *s = &v->s; - VAAPIDecodePicture *pic = s->cur_pic_ptr->hwaccel_picture_private; + VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private; int ret; ret = ff_vaapi_decode_issue(avctx, pic); @@ -465,7 +467,7 @@ static int vaapi_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, { const VC1Context *v = avctx->priv_data; const MpegEncContext *s = &v->s; - VAAPIDecodePicture *pic = s->cur_pic_ptr->hwaccel_picture_private; + VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private; VASliceParameterBufferVC1 slice_param; int mb_height; int err; |