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

avcodec: provide default implementation for HW picture release callback

parent 1b927cdd
...@@ -49,7 +49,6 @@ static void Close( vlc_va_t * , AVCodecContext *); ...@@ -49,7 +49,6 @@ static void Close( vlc_va_t * , AVCodecContext *);
static int Setup( vlc_va_t *, AVCodecContext *, vlc_fourcc_t *); static int Setup( vlc_va_t *, AVCodecContext *, vlc_fourcc_t *);
static int Get( vlc_va_t *, picture_t *, uint8_t ** ); static int Get( vlc_va_t *, picture_t *, uint8_t ** );
static int Extract( vlc_va_t *, picture_t *, uint8_t * ); static int Extract( vlc_va_t *, picture_t *, uint8_t * );
static void Release( void *, uint8_t * );
static void vda_Copy422YpCbCr8( picture_t *p_pic, static void vda_Copy422YpCbCr8( picture_t *p_pic,
CVPixelBufferRef buffer ) CVPixelBufferRef buffer )
...@@ -144,7 +143,7 @@ static int Open( vlc_va_t *va, AVCodecContext *ctx, ...@@ -144,7 +143,7 @@ static int Open( vlc_va_t *va, AVCodecContext *ctx,
va->pix_fmt = PIX_FMT_VDA_VLD; va->pix_fmt = PIX_FMT_VDA_VLD;
va->setup = Setup; va->setup = Setup;
va->get = Get; va->get = Get;
va->release = Release; va->release = NULL;
va->extract = Extract; va->extract = Extract;
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -299,18 +298,6 @@ static int Extract( vlc_va_t *va, picture_t *p_picture, uint8_t *data ) ...@@ -299,18 +298,6 @@ static int Extract( vlc_va_t *va, picture_t *p_picture, uint8_t *data )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static void Release( void *opaque, uint8_t *data )
{
#if 0
CVPixelBufferRef cv_buffer = ( CVPixelBufferRef )p_ff->data[3];
if ( cv_buffer )
CVPixelBufferRelease( cv_buffer );
#endif
picture_Release(opaque);
(void) data;
}
#else #else
vlc_module_begin () vlc_module_begin ()
...@@ -329,7 +316,7 @@ static int Open( vlc_va_t *va, AVCodecContext *avctx, const es_format_t *fmt ) ...@@ -329,7 +316,7 @@ static int Open( vlc_va_t *va, AVCodecContext *avctx, const es_format_t *fmt )
va->pix_fmt = AV_PIX_FMT_VDA; va->pix_fmt = AV_PIX_FMT_VDA;
va->setup = Setup; va->setup = Setup;
va->get = Get; va->get = Get;
va->release = Release; va->release = NULL;
va->extract = Extract; va->extract = Extract;
msg_Dbg( va, "VDA decoder Open success!"); msg_Dbg( va, "VDA decoder Open success!");
...@@ -383,11 +370,4 @@ static int Extract( vlc_va_t *va, picture_t *p_picture, uint8_t *data ) ...@@ -383,11 +370,4 @@ static int Extract( vlc_va_t *va, picture_t *p_picture, uint8_t *data )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static void Release( void *opaque, uint8_t *data )
{
picture_Release(opaque);
(void) data;
}
#endif #endif
...@@ -945,6 +945,14 @@ static void ffmpeg_InitCodec( decoder_t *p_dec ) ...@@ -945,6 +945,14 @@ static void ffmpeg_InitCodec( decoder_t *p_dec )
} }
} }
static void lavc_ReleaseFrame(void *opaque, uint8_t *data)
{
picture_t *picture = opaque;
picture_Release(picture);
(void) data;
}
static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame, static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame,
int flags) int flags)
{ {
...@@ -971,10 +979,14 @@ static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame, ...@@ -971,10 +979,14 @@ static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame,
* data[3] actually contains the format-specific surface handle. */ * data[3] actually contains the format-specific surface handle. */
frame->data[3] = frame->data[0]; frame->data[3] = frame->data[0];
frame->buf[0] = av_buffer_create(frame->data[0], 0, va->release, pic, 0); void (*release)(void *, uint8_t *) = va->release;
if (va->release == NULL)
release = lavc_ReleaseFrame;
frame->buf[0] = av_buffer_create(frame->data[0], 0, release, pic, 0);
if (unlikely(frame->buf[0] == NULL)) if (unlikely(frame->buf[0] == NULL))
{ {
vlc_va_Release(va, pic, frame->data[0]); release(pic, frame->data[0]);
return -1; return -1;
} }
...@@ -984,14 +996,6 @@ static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame, ...@@ -984,14 +996,6 @@ static int lavc_va_GetFrame(struct AVCodecContext *ctx, AVFrame *frame,
return 0; return 0;
} }
static void lavc_dr_ReleaseFrame(void *opaque, uint8_t *data)
{
picture_t *picture = opaque;
picture_Release(picture);
(void) data;
}
static picture_t *lavc_dr_GetFrame(struct AVCodecContext *ctx, static picture_t *lavc_dr_GetFrame(struct AVCodecContext *ctx,
AVFrame *frame, int flags) AVFrame *frame, int flags)
{ {
...@@ -1054,11 +1058,11 @@ static picture_t *lavc_dr_GetFrame(struct AVCodecContext *ctx, ...@@ -1054,11 +1058,11 @@ static picture_t *lavc_dr_GetFrame(struct AVCodecContext *ctx,
uint8_t *data = pic->p[i].p_pixels; uint8_t *data = pic->p[i].p_pixels;
int size = pic->p[i].i_pitch * pic->p[i].i_lines; int size = pic->p[i].i_pitch * pic->p[i].i_lines;
frame->buf[i] = av_buffer_create(data, size, lavc_dr_ReleaseFrame, frame->buf[i] = av_buffer_create(data, size, lavc_ReleaseFrame,
picture_Hold(pic), 0); picture_Hold(pic), 0);
if (unlikely(frame->buf[i] == NULL)) if (unlikely(frame->buf[i] == NULL))
{ {
lavc_dr_ReleaseFrame(pic, data); lavc_ReleaseFrame(pic, data);
goto error; goto error;
} }
} }
......
...@@ -146,12 +146,6 @@ static int Lock(vlc_va_t *va, picture_t *pic, uint8_t **data) ...@@ -146,12 +146,6 @@ static int Lock(vlc_va_t *va, picture_t *pic, uint8_t **data)
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static void Unlock(void *opaque, uint8_t *data)
{
picture_Release(opaque);
(void) data;
}
static int Copy(vlc_va_t *va, picture_t *pic, uint8_t *data) static int Copy(vlc_va_t *va, picture_t *pic, uint8_t *data)
{ {
(void) va; (void) pic; (void) data; (void) va; (void) pic; (void) data;
...@@ -389,7 +383,7 @@ static int Open(vlc_va_t *va, AVCodecContext *avctx, const es_format_t *fmt) ...@@ -389,7 +383,7 @@ static int Open(vlc_va_t *va, AVCodecContext *avctx, const es_format_t *fmt)
va->pix_fmt = AV_PIX_FMT_VDPAU; va->pix_fmt = AV_PIX_FMT_VDPAU;
va->setup = Setup; va->setup = Setup;
va->get = Lock; va->get = Lock;
va->release = Unlock; va->release = NULL;
va->extract = Copy; va->extract = Copy;
return VLC_SUCCESS; return VLC_SUCCESS;
......
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