ff->opaque = surface;
return VLC_SUCCESS;
}
-static void Release(void *opaque)
+
+static void Release(void *opaque, uint8_t *data)
{
vlc_va_surface_t *surface = opaque;
surface->refcount--;
+ (void) data;
}
+
static void Close(vlc_va_t *external)
{
vlc_va_dxva2_t *va = vlc_va_dxva2_Get(external);
add_shortcut("dummy")
vlc_module_end()
-#define DECODER_MAGIC 0x12345678
-#define SURFACE_MAGIC 0x87654321
+#define DECODER_MAGIC 0xdec0dea0
+#define DATA_MAGIC 0xda1a0000
+#define OPAQUE_MAGIC 0x0da00e00
struct vlc_va_sys_t
{
ff->linesize[i] = 0;
}
- ff->data[0] = (void *)(uintptr_t)SURFACE_MAGIC; /* must be non-NULL */
- ff->data[3] = (void *)(uintptr_t)SURFACE_MAGIC;
- ff->opaque = (void *)(uintptr_t)SURFACE_MAGIC;
+ ff->data[0] = (void *)(uintptr_t)DATA_MAGIC; /* must be non-NULL */
+ ff->data[3] = (void *)(uintptr_t)DATA_MAGIC;
+ ff->opaque = (void *)(uintptr_t)OPAQUE_MAGIC;
return VLC_SUCCESS;
}
-static void Unlock(void *opaque)
+static void Unlock(void *opaque, uint8_t *data)
{
- assert((uintptr_t)opaque == SURFACE_MAGIC);
+ assert((uintptr_t)opaque == OPAQUE_MAGIC);
+ assert((uintptr_t)data == DATA_MAGIC);
}
static VdpStatus Render(VdpDecoder decoder, VdpVideoSurface target,
(void) decoder; (void) target; (void) picture_info;
(void) bitstream_buffer_count; (void) bitstream_buffers;
assert(decoder == DECODER_MAGIC);
- assert(target == SURFACE_MAGIC);
+ assert(target == DATA_MAGIC);
return VDP_STATUS_OK;
}
{
(void) va; (void) ff;
- assert((uintptr_t)ff->data[3] == SURFACE_MAGIC);
- assert((uintptr_t)ff->opaque == SURFACE_MAGIC);
+ assert((uintptr_t)ff->data[3] == DATA_MAGIC);
+ assert((uintptr_t)ff->opaque == OPAQUE_MAGIC);
/* Put some dummy picture content */
memset(pic->p[0].p_pixels, 0xF0,
int (*setup)(vlc_va_t *, void **hw, vlc_fourcc_t *output,
int width, int height);
int (*get)(vlc_va_t *, AVFrame *frame);
- void (*release)(void *opaque);
+ void (*release)(void *opaque, uint8_t *surface);
int (*extract)(vlc_va_t *, picture_t *dst, AVFrame *src);
};
* Releases a hardware surface from a libavcodec frame.
* The surface has been previously allocated with vlc_va_Get().
*
- * @param opaque opaque data pointer of the AVFrame passed to vlc_va_Get().
+ * @param opaque opaque data pointer of the AVFrame set by vlc_va_Get()
+ * @param data data[0] pointer of the AVFrame set by vlc_va_Get()
*
* @note This function needs not be reentrant. However it may be called
* concurrently with vlc_va_Get() and/or vlc_va_Extract() from other threads
*
* @param frame libavcodec frame previously allocated by vlc_va_Get()
*/
-static inline void vlc_va_Release(vlc_va_t *va, void *opaque)
+static inline void vlc_va_Release(vlc_va_t *va, void *opaque, uint8_t *data)
{
- va->release(opaque);
+ va->release(opaque, data);
}
/**
return VLC_SUCCESS;
}
-static void Release( void *opaque )
+static void Release( void *opaque, uint8_t *data )
{
vlc_va_surface_t *p_surface = opaque;
vlc_mutex_lock( p_surface->p_lock );
p_surface->i_refcount--;
vlc_mutex_unlock( p_surface->p_lock );
+ (void) data;
}
static void Close( vlc_va_sys_t *sys )
return VLC_SUCCESS;
}
-static void Release( void *opaque )
+static void Release( void *opaque, uint8_t *data )
{
assert( opaque == NULL );
#if 0
if ( cv_buffer )
CVPixelBufferRelease( cv_buffer );
#endif
+ (void) data;
}
static void Close( vlc_va_t *external )
}
#if LIBAVCODEC_VERSION_MAJOR >= 55
-typedef struct
-{
- vlc_va_t *va;
- void *opaque;
-} lavc_hw_ref_t;
-
-static void lavc_va_ReleaseFrame(void *opaque, uint8_t *data)
-{
- lavc_hw_ref_t *ref = opaque;
-
- vlc_va_Release(ref->va, ref->opaque);
- free(ref);
- (void) data;
-}
-
static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame,
int flags)
{
return -1;
}
- lavc_hw_ref_t *ref = malloc(sizeof (*ref));
- if (unlikely(ref == NULL))
- {
- vlc_va_Release(va, frame->opaque);
- return -1;
- }
- ref->va = va;
- ref->opaque = frame->opaque;
-
- frame->buf[0] = av_buffer_create(frame->data[0], 0, lavc_va_ReleaseFrame,
- ref, 0);
+ frame->buf[0] = av_buffer_create(frame->data[0], 0, va->release,
+ frame->opaque, 0);
if (unlikely(frame->buf[0] == NULL))
{
- lavc_va_ReleaseFrame(ref, frame->data[0]);
+ vlc_va_Release(va, frame->opaque, frame->data[0]);
return -1;
}
assert(frame->data[0] != NULL);
decoder_sys_t *p_sys = p_dec->p_sys;
if( p_sys->p_va )
- vlc_va_Release( p_sys->p_va, p_ff_pic->opaque );
+ vlc_va_Release( p_sys->p_va, p_ff_pic->opaque, p_ff_pic->data[0] );
else if( p_ff_pic->opaque )
decoder_UnlinkPicture( p_dec, (picture_t*)p_ff_pic->opaque);
else if( p_ff_pic->type == FF_BUFFER_TYPE_INTERNAL )
return VLC_SUCCESS;
}
-static void Unlock(void *opaque)
+static void Unlock(void *opaque, uint8_t *data)
{
vlc_vdp_video_field_t *field = opaque;
assert(field != NULL);
field->destroy(field);
+ (void) data;
}
static int Copy(vlc_va_t *va, picture_t *pic, AVFrame *ff)