@@ -404,18 +404,26 @@ PRIVATE ATTR_RETNONNULL WUNUSED struct video_anim_ops *CC _cached_anim_ops(void)
404404
405405/* Return a wrapper for `self' that caches animation frames during
406406 * the first loop, and simply replays them during any subsequent loop.
407+ * @param: domain: When non-null, animation frames are cached in this
408+ * domain, rather than being kept in `self->va_domain'
407409 * @param: format: When non-null, animation frames are converted into
408- * this pixel format, rather than being copied verbatim.
409- * @param: type: The type of video buffer to use for cached images. */
410+ * this pixel format, rather than being copied verbatim. */
410411DEFINE_PUBLIC_ALIAS (video_anim_cached , libvideo_anim_cached );
411- INTERN WUNUSED ATTR_INOUT (1 ) ATTR_IN_OPT (2 ) REF struct video_anim * CC
412+ INTERN WUNUSED ATTR_INOUT (1 ) ATTR_IN_OPT (2 ) ATTR_IN_OPT ( 3 ) REF struct video_anim * CC
412413libvideo_anim_cached (struct video_anim * __restrict self ,
414+ struct video_domain const * domain ,
413415 struct video_format const * format ) {
414416 REF struct cached_anim * result ;
417+ if (domain == NULL )
418+ domain = self -> va_domain ;
415419 if (self -> va_ops == & cached_anim_ops ) {
416420 /* Check for special case: `self' is already cached and uses a compatible format */
417421 struct cached_anim * me = (struct cached_anim * )self ;
418- if (!format ) {
422+ if (format == NULL )
423+ format = & me -> ca_fmt ;
424+ if (format -> vf_codec == me -> ca_fmt .vf_codec &&
425+ format -> vf_pal == me -> ca_fmt .vf_pal &&
426+ me -> va_domain == domain ) {
419427 video_anim_incref (me );
420428 return me ;
421429 }
@@ -428,11 +436,12 @@ libvideo_anim_cached(struct video_anim *__restrict self,
428436 if (format == NULL )
429437 format = & frame -> vb_format ;
430438 if (frame -> vb_format .vf_codec == format -> vf_codec &&
431- frame -> vb_format .vf_pal == format -> vf_pal ) {
439+ frame -> vb_format .vf_pal == format -> vf_pal &&
440+ frame -> vb_domain == domain ) {
432441 video_anim_incref (me );
433442 return me ;
434443 }
435- converted = libvideo_buffer_convert (frame , me -> va_domain , format );
444+ converted = libvideo_buffer_convert (frame , domain , format );
436445 if unlikely (!converted )
437446 goto err ;
438447 oneframe_result = libvideo_anim_fromframe (converted );
@@ -443,7 +452,7 @@ libvideo_anim_cached(struct video_anim *__restrict self,
443452 result = (REF struct cached_anim * )malloc (sizeof (struct cached_anim ));
444453 if unlikely (!result )
445454 goto err ;
446- result -> va_domain = self -> va_domain ;
455+ result -> va_domain = domain ? domain : self -> va_domain ;
447456 result -> va_ops = _cached_anim_ops ();
448457 result -> va_xdim = self -> va_xdim ;
449458 result -> va_ydim = self -> va_ydim ;
0 commit comments