Commit ee961d8f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

avcodec: pass AVCodecContext to VA destroy callback

parent f8fa5d73
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
#include "../../video_chroma/copy.h" #include "../../video_chroma/copy.h"
static int Open(vlc_va_t *, AVCodecContext *, const es_format_t *); static int Open(vlc_va_t *, AVCodecContext *, const es_format_t *);
static void Close(vlc_va_t *); static void Close(vlc_va_t *, AVCodecContext *);
vlc_module_begin() vlc_module_begin()
set_description(N_("DirectX Video Acceleration (DXVA) 2.0")) set_description(N_("DirectX Video Acceleration (DXVA) 2.0"))
...@@ -463,10 +463,11 @@ static void Release(void *opaque, uint8_t *data) ...@@ -463,10 +463,11 @@ static void Release(void *opaque, uint8_t *data)
(void) data; (void) data;
} }
static void Close(vlc_va_t *va) static void Close(vlc_va_t *va, AVCodecContext *ctx)
{ {
vlc_va_sys_t *sys = va->sys; vlc_va_sys_t *sys = va->sys;
(void) ctx;
DxDestroyVideoConversion(sys); DxDestroyVideoConversion(sys);
DxDestroyVideoDecoder(sys); DxDestroyVideoDecoder(sys);
DxDestroyVideoService(sys); DxDestroyVideoService(sys);
...@@ -540,7 +541,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const es_format_t *fmt) ...@@ -540,7 +541,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const es_format_t *fmt)
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
Close(va); Close(va, ctx);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* */ /* */
......
...@@ -41,9 +41,10 @@ static int vlc_va_Start(void *func, va_list ap) ...@@ -41,9 +41,10 @@ static int vlc_va_Start(void *func, va_list ap)
static void vlc_va_Stop(void *func, va_list ap) static void vlc_va_Stop(void *func, va_list ap)
{ {
vlc_va_t *va = va_arg(ap, vlc_va_t *); vlc_va_t *va = va_arg(ap, vlc_va_t *);
void (*close)(vlc_va_t *) = func; AVCodecContext *ctx = va_arg(ap, AVCodecContext *);
void (*close)(vlc_va_t *, AVCodecContext *) = func;
close(va); close(va, ctx);
} }
vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx, vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
...@@ -63,8 +64,8 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx, ...@@ -63,8 +64,8 @@ vlc_va_t *vlc_va_New(vlc_object_t *obj, AVCodecContext *avctx,
return va; return va;
} }
void vlc_va_Delete(vlc_va_t *va) void vlc_va_Delete(vlc_va_t *va, AVCodecContext *avctx)
{ {
vlc_module_unload(va->module, vlc_va_Stop, va); vlc_module_unload(va->module, vlc_va_Stop, va, avctx);
vlc_object_release(va); vlc_object_release(va);
} }
...@@ -124,6 +124,6 @@ static inline int vlc_va_Extract(vlc_va_t *va, picture_t *dst, void *opaque, ...@@ -124,6 +124,6 @@ static inline int vlc_va_Extract(vlc_va_t *va, picture_t *dst, void *opaque,
* Destroys a libavcodec hardware acceleration back-end. * Destroys a libavcodec hardware acceleration back-end.
* All allocated surfaces shall have been released beforehand. * All allocated surfaces shall have been released beforehand.
*/ */
void vlc_va_Delete(vlc_va_t *); void vlc_va_Delete(vlc_va_t *, AVCodecContext *);
#endif #endif
...@@ -416,10 +416,11 @@ static int Setup( vlc_va_t *va, void **pp_hw_ctx, vlc_fourcc_t *pi_chroma, ...@@ -416,10 +416,11 @@ static int Setup( vlc_va_t *va, void **pp_hw_ctx, vlc_fourcc_t *pi_chroma,
return VLC_EGENERIC; return VLC_EGENERIC;
} }
static void Delete( vlc_va_t *va ) static void Delete( vlc_va_t *va, AVCodecContext *avctx )
{ {
vlc_va_sys_t *sys = va->sys; vlc_va_sys_t *sys = va->sys;
(void) avctx;
if( sys->i_surface_width || sys->i_surface_height ) if( sys->i_surface_width || sys->i_surface_height )
DestroySurfaces( sys ); DestroySurfaces( sys );
......
...@@ -154,7 +154,7 @@ static int Open( vlc_va_t *external, AVCodecContext *ctx, ...@@ -154,7 +154,7 @@ static int Open( vlc_va_t *external, AVCodecContext *ctx,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static void Close( vlc_va_t *external ) static void Close( vlc_va_t *external, AVCodecContext *ctx )
{ {
vlc_va_vda_t *p_va = vlc_va_vda_Get( external ); vlc_va_vda_t *p_va = vlc_va_vda_Get( external );
...@@ -166,6 +166,7 @@ static void Close( vlc_va_t *external ) ...@@ -166,6 +166,7 @@ static void Close( vlc_va_t *external )
CopyCleanCache( &p_va->image_cache ); CopyCleanCache( &p_va->image_cache );
free( p_va ); free( p_va );
(void) ctx;
} }
static int Setup( vlc_va_t *external, void **pp_hw_ctx, vlc_fourcc_t *pi_chroma, static int Setup( vlc_va_t *external, void **pp_hw_ctx, vlc_fourcc_t *pi_chroma,
...@@ -367,11 +368,10 @@ static int Open( vlc_va_t *external, AVCodecContext *avctx, ...@@ -367,11 +368,10 @@ static int Open( vlc_va_t *external, AVCodecContext *avctx,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static void Close( vlc_va_t *external ) static void Close( vlc_va_t *external, AVCodecContext *avctx )
{ {
vlc_va_vda_t *p_va = vlc_va_vda_Get( external ); av_vda_default_free(avctx);
(void) external;
av_vda_default_free(p_va->avctx);
} }
static int Setup( vlc_va_t *external, void **pp_hw_ctx, vlc_fourcc_t *pi_chroma, static int Setup( vlc_va_t *external, void **pp_hw_ctx, vlc_fourcc_t *pi_chroma,
......
...@@ -823,7 +823,7 @@ void EndVideoDec( decoder_t *p_dec ) ...@@ -823,7 +823,7 @@ void EndVideoDec( decoder_t *p_dec )
avcodec_free_frame( &p_sys->p_ff_pic ); avcodec_free_frame( &p_sys->p_ff_pic );
if( p_sys->p_va ) if( p_sys->p_va )
vlc_va_Delete( p_sys->p_va ); vlc_va_Delete( p_sys->p_va, p_sys->p_context );
vlc_sem_destroy( &p_sys->sem_mt ); vlc_sem_destroy( &p_sys->sem_mt );
} }
...@@ -1323,7 +1323,7 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context, ...@@ -1323,7 +1323,7 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context,
vlc_va_t *p_va = p_sys->p_va; vlc_va_t *p_va = p_sys->p_va;
if( p_va != NULL ) if( p_va != NULL )
vlc_va_Delete( p_va ); vlc_va_Delete( p_va, p_context );
/* Enumerate available formats */ /* Enumerate available formats */
bool can_hwaccel = false; bool can_hwaccel = false;
...@@ -1383,7 +1383,7 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context, ...@@ -1383,7 +1383,7 @@ static enum PixelFormat ffmpeg_GetFormat( AVCodecContext *p_context,
return pi_fmt[i]; return pi_fmt[i];
} }
vlc_va_Delete( p_va ); vlc_va_Delete( p_va, p_context );
end: end:
/* Fallback to default behaviour */ /* Fallback to default behaviour */
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include "../../codec/avcodec/va.h" #include "../../codec/avcodec/va.h"
static int Open(vlc_va_t *, AVCodecContext *, const es_format_t *); static int Open(vlc_va_t *, AVCodecContext *, const es_format_t *);
static void Close(vlc_va_t *); static void Close(vlc_va_t *, AVCodecContext *);
vlc_module_begin() vlc_module_begin()
set_description(N_("VDPAU video decoder")) set_description(N_("VDPAU video decoder"))
...@@ -293,7 +293,7 @@ error: ...@@ -293,7 +293,7 @@ error:
return VLC_EGENERIC; return VLC_EGENERIC;
} }
static void Close(vlc_va_t *va) static void Close(vlc_va_t *va, AVCodecContext *avctx)
{ {
vlc_va_sys_t *sys = va->sys; vlc_va_sys_t *sys = va->sys;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment