mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-28 11:55:39 +00:00
mfc: Request input buffers explicitely
This commit is contained in:
parent
644ef86728
commit
0fbfe0225c
4 changed files with 30 additions and 16 deletions
|
@ -35,9 +35,10 @@ plugin_init (GstPlugin * plugin)
|
|||
/* Just check here once if we can create a MFC context, i.e.
|
||||
* if the hardware is available */
|
||||
mfc_dec_init_debug ();
|
||||
context = mfc_dec_create (CODEC_TYPE_H264, 1);
|
||||
context = mfc_dec_create (CODEC_TYPE_H264);
|
||||
if (!context) {
|
||||
GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, "Failed to initialize MFC decoder context");
|
||||
GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING,
|
||||
"Failed to initialize MFC decoder context");
|
||||
return FALSE;
|
||||
}
|
||||
mfc_dec_destroy (context);
|
||||
|
|
|
@ -144,7 +144,7 @@ gst_mfc_dec_open (GstVideoDecoder * decoder)
|
|||
/* Just check here once if we can create a MFC context, i.e.
|
||||
* if the hardware is available
|
||||
*/
|
||||
self->context = mfc_dec_create (CODEC_TYPE_H264, 1);
|
||||
self->context = mfc_dec_create (CODEC_TYPE_H264);
|
||||
if (!self->context) {
|
||||
GST_ELEMENT_ERROR (self, LIBRARY, INIT,
|
||||
("Failed to initialize MFC decoder context"), (NULL));
|
||||
|
@ -237,7 +237,7 @@ gst_mfc_dec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state)
|
|||
self->initialized = FALSE;
|
||||
|
||||
if (gst_structure_has_name (s, "video/x-h264")) {
|
||||
self->context = mfc_dec_create (CODEC_TYPE_H264, 1);
|
||||
self->context = mfc_dec_create (CODEC_TYPE_H264);
|
||||
if (!self->context) {
|
||||
GST_ELEMENT_ERROR (self, LIBRARY, INIT,
|
||||
("Failed to initialize MFC decoder context"), (NULL));
|
||||
|
@ -252,9 +252,9 @@ gst_mfc_dec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state)
|
|||
return FALSE;
|
||||
|
||||
if (mpegversion == 1 || mpegversion == 2) {
|
||||
self->context = mfc_dec_create (CODEC_TYPE_MPEG2, 1);
|
||||
self->context = mfc_dec_create (CODEC_TYPE_MPEG2);
|
||||
} else {
|
||||
self->context = mfc_dec_create (CODEC_TYPE_MPEG4, 1);
|
||||
self->context = mfc_dec_create (CODEC_TYPE_MPEG4);
|
||||
}
|
||||
|
||||
if (!self->context) {
|
||||
|
@ -263,7 +263,7 @@ gst_mfc_dec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state)
|
|||
return FALSE;
|
||||
}
|
||||
} else if (gst_structure_has_name (s, "video/x-h263")) {
|
||||
self->context = mfc_dec_create (CODEC_TYPE_H263, 1);
|
||||
self->context = mfc_dec_create (CODEC_TYPE_H263);
|
||||
if (!self->context) {
|
||||
GST_ELEMENT_ERROR (self, LIBRARY, INIT,
|
||||
("Failed to initialize MFC decoder context"), (NULL));
|
||||
|
@ -273,6 +273,12 @@ gst_mfc_dec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state)
|
|||
g_return_val_if_reached (FALSE);
|
||||
}
|
||||
|
||||
if (mfc_dec_init_input (self->context, 1) < 0) {
|
||||
GST_ELEMENT_ERROR (self, LIBRARY, INIT,
|
||||
("Failed to initialize MFC decoder context input"), (NULL));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gst_buffer_replace (&self->codec_data, state->codec_data);
|
||||
|
||||
done:
|
||||
|
@ -721,7 +727,7 @@ gst_mfc_dec_dequeue_output (GstMFCDec * self)
|
|||
|
||||
if (!self->initialized) {
|
||||
GST_DEBUG_OBJECT (self, "Initializing decoder");
|
||||
if ((mfc_ret = mfc_dec_init (self->context, 1)) < 0)
|
||||
if ((mfc_ret = mfc_dec_init_output (self->context, 1)) < 0)
|
||||
goto initialize_error;
|
||||
self->initialized = TRUE;
|
||||
}
|
||||
|
|
|
@ -220,7 +220,6 @@ static int request_input_buffers(struct mfc_dec_context *ctx, int num)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int request_output_buffers(struct mfc_dec_context *ctx, int num)
|
||||
{
|
||||
struct v4l2_requestbuffers reqbuf = {
|
||||
|
@ -276,7 +275,7 @@ static int request_output_buffers(struct mfc_dec_context *ctx, int num)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct mfc_dec_context* mfc_dec_create(unsigned int codec, int num_input_buffers)
|
||||
struct mfc_dec_context* mfc_dec_create(unsigned int codec)
|
||||
{
|
||||
struct mfc_dec_context *ctx;
|
||||
struct v4l2_capability caps;
|
||||
|
@ -320,8 +319,7 @@ struct mfc_dec_context* mfc_dec_create(unsigned int codec, int num_input_buffers
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (mfc_dec_set_codec(ctx, codec) ||
|
||||
request_input_buffers(ctx, num_input_buffers)) {
|
||||
if (mfc_dec_set_codec(ctx, codec) < 0) {
|
||||
mfc_dec_destroy(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -400,7 +398,15 @@ static int start_output_stream(struct mfc_dec_context *ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int mfc_dec_init(struct mfc_dec_context *ctx, int extra_buffers)
|
||||
int mfc_dec_init_input(struct mfc_dec_context *ctx, int num_input_buffers)
|
||||
{
|
||||
if (request_input_buffers(ctx, num_input_buffers) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mfc_dec_init_output(struct mfc_dec_context *ctx, int extra_buffers)
|
||||
{
|
||||
if (start_input_stream(ctx) < 0)
|
||||
return -1;
|
||||
|
|
|
@ -84,8 +84,9 @@ void mfc_dec_init_debug (void);
|
|||
* context is needed for most other calls below, and should be
|
||||
* deallocated with mfc_dec_destroy().
|
||||
*/
|
||||
struct mfc_dec_context* mfc_dec_create(enum mfc_codec_type codec,
|
||||
int num_input_buffers);
|
||||
struct mfc_dec_context* mfc_dec_create(enum mfc_codec_type codec);
|
||||
|
||||
int mfc_dec_init_input(struct mfc_dec_context*, int num_input_buffers);
|
||||
|
||||
/*
|
||||
* Destroy context created with mfc_dec_create().
|
||||
|
@ -105,7 +106,7 @@ void mfc_dec_destroy(struct mfc_dec_context*);
|
|||
*
|
||||
* Returns: Zero for success, negative value on failure.
|
||||
*/
|
||||
int mfc_dec_init(struct mfc_dec_context*, int extra_buffers);
|
||||
int mfc_dec_init_output(struct mfc_dec_context*, int extra_buffers);
|
||||
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue