if( ( p_dec->p_sys = p_sys = calloc( 1, sizeof(decoder_sys_t) ) ) == NULL )
return VLC_ENOMEM;
- p_context->codec_type = AVMEDIA_TYPE_VIDEO;
- p_context->codec_id = p_codec->id;
p_sys->p_context = p_context;
p_sys->p_codec = p_codec;
p_sys->p_ff_pic = avcodec_alloc_frame();
vlc_sem_init( &p_sys->sem_mt, 0 );
/* ***** Fill p_context with init values ***** */
- p_context->codec_tag = ffmpeg_CodecTag( p_dec->fmt_in.i_original_fourcc ?: p_dec->fmt_in.i_codec );
+ p_context->codec_tag = ffmpeg_CodecTag( p_dec->fmt_in.i_original_fourcc ?
+ p_dec->fmt_in.i_original_fourcc : p_dec->fmt_in.i_codec );
/* ***** Get configuration of ffmpeg plugin ***** */
p_context->workaround_bugs =
}
p_dec->pf_decode_video = DecodeVideo;
+
+ if ( p_dec->fmt_in.i_codec == VLC_CODEC_VP9 )
+ p_dec->b_need_packetized = true;
+
return VLC_SUCCESS;
}
else
{
p_pic = (picture_t *)p_sys->p_ff_pic->opaque;
- decoder_LinkPicture( p_dec, p_pic );
+ picture_Hold( p_pic );
}
if( !p_dec->fmt_in.video.i_sar_num || !p_dec->fmt_in.video.i_sar_den )
}
else
{
- decoder_DeletePicture( p_dec, p_pic );
+ picture_Release( p_pic );
}
}
wait_mt( p_sys );
+ ffmpeg_CloseCodec( p_dec );
+
if( p_sys->p_ff_pic )
avcodec_free_frame( &p_sys->p_ff_pic );
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 );
}
decoder_sys_t *sys = dec->p_sys;
vlc_va_t *va = sys->p_va;
- if (vlc_va_Setup(va, &ctx->hwaccel_context, &dec->fmt_out.video.i_chroma,
- ctx->coded_width, ctx->coded_height))
+ if (vlc_va_Setup(va, ctx, &dec->fmt_out.video.i_chroma))
{
msg_Err(dec, "hardware acceleration setup failed");
return -1;
return 0;
}
-typedef struct
-{
- decoder_t *decoder;
- picture_t *picture;
-} lavc_pic_ref_t;
-
static void lavc_dr_ReleaseFrame(void *opaque, uint8_t *data)
{
- lavc_pic_ref_t *ref = opaque;
+ picture_t *picture = opaque;
- decoder_UnlinkPicture(ref->decoder, ref->picture);
- free(ref);
+ picture_Release(picture);
(void) data;
}
/* Allocate buffer references */
for (int i = 0; i < pic->i_planes; i++)
{
- lavc_pic_ref_t *ref = malloc(sizeof (*ref));
- if (ref == NULL)
- goto error;
- ref->decoder = dec;
- ref->picture = pic;
- decoder_LinkPicture(dec, pic);
-
uint8_t *data = pic->p[i].p_pixels;
int size = pic->p[i].i_pitch * pic->p[i].i_lines;
frame->buf[i] = av_buffer_create(data, size, lavc_dr_ReleaseFrame,
- ref, 0);
+ picture_Hold(pic), 0);
if (unlikely(frame->buf[i] == NULL))
{
- lavc_dr_ReleaseFrame(ref, data);
+ lavc_dr_ReleaseFrame(pic, data);
goto error;
}
}
- decoder_UnlinkPicture(dec, pic);
+ picture_Release(pic);
(void) flags;
return pic;
error:
for (unsigned i = 0; frame->buf[i] != NULL; i++)
av_buffer_unref(&frame->buf[i]);
no_dr:
- decoder_DeletePicture(dec, pic);
+ picture_Release(pic);
return NULL;
}
vlc_va_t *p_va = p_sys->p_va;
/* hwaccel_context is not present in old ffmpeg version */
- if( vlc_va_Setup( p_va,
- &p_context->hwaccel_context, &p_dec->fmt_out.video.i_chroma,
- p_context->coded_width, p_context->coded_height ) )
+ if( vlc_va_Setup( p_va, p_context, &p_dec->fmt_out.video.i_chroma ) )
{
msg_Err( p_dec, "vlc_va_Setup failed" );
return -1;
no_dr:
if (p_pic)
- decoder_DeletePicture( p_dec, p_pic );
+ picture_Release( p_pic );
return NULL;
}
if( p_sys->p_va )
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);
+ picture_Release( (picture_t*)p_ff_pic->opaque);
else if( p_ff_pic->type == FF_BUFFER_TYPE_INTERNAL )
/* We can end up here without the AVFrame being allocated by
* avcodec_default_get_buffer() if VA is used and the frame is
vlc_va_t *p_va = p_sys->p_va;
if( p_va != NULL )
- vlc_va_Delete( p_va );
+ vlc_va_Delete( p_va, p_context );
/* Enumerate available formats */
bool can_hwaccel = false;
/* We try to call vlc_va_Setup when possible to detect errors when
* possible (later is too late) */
if( p_context->width > 0 && p_context->height > 0
- && vlc_va_Setup( p_va, &p_context->hwaccel_context,
- &p_dec->fmt_out.video.i_chroma,
- p_context->width, p_context->height ) )
+ && vlc_va_Setup( p_va, p_context, &p_dec->fmt_out.video.i_chroma ) )
{
msg_Err( p_dec, "acceleration setup failure" );
break;
return pi_fmt[i];
}
- vlc_va_Delete( p_va );
+ vlc_va_Delete( p_va, p_context );
end:
/* Fallback to default behaviour */