diff options
author | Lynne <dev@lynne.ee> | 2023-01-06 03:32:56 +0100 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2023-05-29 00:41:57 +0200 |
commit | 6733a1a456b1720ec58f83c21352d54406229102 (patch) | |
tree | 3e8e888e06eb1cf6181274729ca2cf271f9fe1c6 /libavcodec | |
parent | be07145109074e128bd7a8255d81a2b9fdcdf10b (diff) | |
download | ffmpeg-6733a1a456b1720ec58f83c21352d54406229102.tar.gz |
avcodec: add AVHWAccel.flush callback
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/av1dec.c | 3 | ||||
-rw-r--r-- | libavcodec/avcodec.h | 5 | ||||
-rw-r--r-- | libavcodec/h264dec.c | 3 | ||||
-rw-r--r-- | libavcodec/hevcdec.c | 3 | ||||
-rw-r--r-- | libavcodec/vp8.c | 3 | ||||
-rw-r--r-- | libavcodec/vp9.c | 3 |
6 files changed, 20 insertions, 0 deletions
diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 3ab1a47d19..7e423427b2 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -1452,6 +1452,9 @@ static void av1_decode_flush(AVCodecContext *avctx) ff_cbs_fragment_reset(&s->current_obu); ff_cbs_flush(s->cbc); + + if (avctx->hwaccel && avctx->hwaccel->flush) + avctx->hwaccel->flush(avctx); } #define OFFSET(x) offsetof(AV1DecContext, x) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 82c9aaab53..84e29a02db 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2267,6 +2267,11 @@ typedef struct AVHWAccel { * @param data the per-frame hardware accelerator private data to be freed. */ void (*free_frame_priv)(void *hwctx, uint8_t *data); + + /** + * Callback to flush the hwaccel state. + */ + void (*flush)(AVCodecContext *avctx); } AVHWAccel; /** diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 521b1e2235..a10b4bb85c 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -484,6 +484,9 @@ static void h264_decode_flush(AVCodecContext *avctx) ff_h264_free_tables(h); h->context_initialized = 0; + + if (avctx->hwaccel && avctx->hwaccel->flush) + avctx->hwaccel->flush(avctx); } static int get_last_needed_nal(H264Context *h) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index b01563177b..8764e0bd83 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -3708,6 +3708,9 @@ static void hevc_decode_flush(AVCodecContext *avctx) av_buffer_unref(&s->rpu_buf); s->max_ra = INT_MAX; s->eos = 1; + + if (avctx->hwaccel && avctx->hwaccel->flush) + avctx->hwaccel->flush(avctx); } #define OFFSET(x) offsetof(HEVCContext, x) diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index b410e0eb79..50afe19b7a 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -167,6 +167,9 @@ static void vp8_decode_flush_impl(AVCodecContext *avctx, int free_mem) if (free_mem) free_buffers(s); + + if (avctx->hwaccel && avctx->hwaccel->flush) + avctx->hwaccel->flush(avctx); } static void vp8_decode_flush(AVCodecContext *avctx) diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index 03883d254b..4f704ec0dd 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -1801,6 +1801,9 @@ static void vp9_decode_flush(AVCodecContext *avctx) vp9_frame_unref(avctx, &s->s.frames[i]); for (i = 0; i < 8; i++) ff_thread_release_ext_buffer(avctx, &s->s.refs[i]); + + if (avctx->hwaccel && avctx->hwaccel->flush) + avctx->hwaccel->flush(avctx); } static av_cold int vp9_decode_init(AVCodecContext *avctx) |