Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gst-plugins-base
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sebastian Dröge
gst-plugins-base
Commits
14839972
Commit
14839972
authored
Apr 24, 2012
by
Sebastian Dröge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
videodecoder: Add support for subclasses to configure the buffer pool
parent
85712933
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
13 deletions
+46
-13
gst-libs/gst/video/gstvideodecoder.c
gst-libs/gst/video/gstvideodecoder.c
+39
-12
gst-libs/gst/video/gstvideodecoder.h
gst-libs/gst/video/gstvideodecoder.h
+7
-1
No files found.
gst-libs/gst/video/gstvideodecoder.c
View file @
14839972
...
@@ -283,6 +283,8 @@ static gboolean gst_video_decoder_sink_event_default (GstVideoDecoder * decoder,
...
@@ -283,6 +283,8 @@ static gboolean gst_video_decoder_sink_event_default (GstVideoDecoder * decoder,
GstEvent
*
event
);
GstEvent
*
event
);
static
gboolean
gst_video_decoder_src_event_default
(
GstVideoDecoder
*
decoder
,
static
gboolean
gst_video_decoder_src_event_default
(
GstVideoDecoder
*
decoder
,
GstEvent
*
event
);
GstEvent
*
event
);
static
gboolean
gst_video_decoder_configure_buffer_pool_default
(
GstVideoDecoder
*
decoder
,
GstQuery
*
query
,
GstBufferPool
*
pool
);
/* we can't use G_DEFINE_ABSTRACT_TYPE because we need the klass in the _init
/* we can't use G_DEFINE_ABSTRACT_TYPE because we need the klass in the _init
* method to get to the padtemplates */
* method to get to the padtemplates */
...
@@ -334,6 +336,8 @@ gst_video_decoder_class_init (GstVideoDecoderClass * klass)
...
@@ -334,6 +336,8 @@ gst_video_decoder_class_init (GstVideoDecoderClass * klass)
klass
->
sink_event
=
gst_video_decoder_sink_event_default
;
klass
->
sink_event
=
gst_video_decoder_sink_event_default
;
klass
->
src_event
=
gst_video_decoder_src_event_default
;
klass
->
src_event
=
gst_video_decoder_src_event_default
;
klass
->
configure_buffer_pool
=
gst_video_decoder_configure_buffer_pool_default
;
}
}
static
void
static
void
...
@@ -1947,7 +1951,8 @@ gst_video_decoder_finish_frame (GstVideoDecoder * decoder,
...
@@ -1947,7 +1951,8 @@ gst_video_decoder_finish_frame (GstVideoDecoder * decoder,
GST_LOG_OBJECT
(
decoder
,
"finish frame"
);
GST_LOG_OBJECT
(
decoder
,
"finish frame"
);
if
(
G_UNLIKELY
(
priv
->
output_state_changed
))
if
(
G_UNLIKELY
(
priv
->
output_state_changed
||
(
priv
->
output_state
&&
gst_pad_check_reconfigure
(
decoder
->
srcpad
))))
gst_video_decoder_set_src_caps
(
decoder
);
gst_video_decoder_set_src_caps
(
decoder
);
GST_VIDEO_DECODER_STREAM_LOCK
(
decoder
);
GST_VIDEO_DECODER_STREAM_LOCK
(
decoder
);
...
@@ -2375,6 +2380,25 @@ gst_video_decoder_get_frame (GstVideoDecoder * decoder, int frame_number)
...
@@ -2375,6 +2380,25 @@ gst_video_decoder_get_frame (GstVideoDecoder * decoder, int frame_number)
return
frame
;
return
frame
;
}
}
static
gboolean
gst_video_decoder_configure_buffer_pool_default
(
GstVideoDecoder
*
decoder
,
GstQuery
*
query
,
GstBufferPool
*
pool
)
{
GstStructure
*
config
;
if
(
gst_query_has_allocation_meta
(
query
,
GST_VIDEO_META_API_TYPE
))
{
config
=
gst_buffer_pool_get_config
(
pool
);
/* just set the option, if the pool can support it we will transparently use
* it through the video info API. We could also see if the pool support this
* option and only activate it then. */
gst_buffer_pool_config_add_option
(
config
,
GST_BUFFER_POOL_OPTION_VIDEO_META
);
gst_buffer_pool_set_config
(
pool
,
config
);
}
return
TRUE
;
}
/**
/**
* gst_video_decoder_set_src_caps:
* gst_video_decoder_set_src_caps:
* @decoder: a #GstVideoDecoder
* @decoder: a #GstVideoDecoder
...
@@ -2389,6 +2413,7 @@ static gboolean
...
@@ -2389,6 +2413,7 @@ static gboolean
gst_video_decoder_set_src_caps
(
GstVideoDecoder
*
decoder
)
gst_video_decoder_set_src_caps
(
GstVideoDecoder
*
decoder
)
{
{
GstVideoCodecState
*
state
=
decoder
->
priv
->
output_state
;
GstVideoCodecState
*
state
=
decoder
->
priv
->
output_state
;
GstVideoDecoderClass
*
klass
;
GstQuery
*
query
;
GstQuery
*
query
;
GstBufferPool
*
pool
;
GstBufferPool
*
pool
;
GstStructure
*
config
;
GstStructure
*
config
;
...
@@ -2400,6 +2425,8 @@ gst_video_decoder_set_src_caps (GstVideoDecoder * decoder)
...
@@ -2400,6 +2425,8 @@ gst_video_decoder_set_src_caps (GstVideoDecoder * decoder)
GST_VIDEO_DECODER_STREAM_LOCK
(
decoder
);
GST_VIDEO_DECODER_STREAM_LOCK
(
decoder
);
klass
=
GST_VIDEO_DECODER_GET_CLASS
(
decoder
);
GST_DEBUG_OBJECT
(
decoder
,
"output_state par %d/%d fps %d/%d"
,
GST_DEBUG_OBJECT
(
decoder
,
"output_state par %d/%d fps %d/%d"
,
state
->
info
.
par_n
,
state
->
info
.
par_d
,
state
->
info
.
par_n
,
state
->
info
.
par_d
,
state
->
info
.
fps_n
,
state
->
info
.
fps_d
);
state
->
info
.
fps_n
,
state
->
info
.
fps_d
);
...
@@ -2442,18 +2469,14 @@ gst_video_decoder_set_src_caps (GstVideoDecoder * decoder)
...
@@ -2442,18 +2469,14 @@ gst_video_decoder_set_src_caps (GstVideoDecoder * decoder)
config
=
gst_buffer_pool_get_config
(
pool
);
config
=
gst_buffer_pool_get_config
(
pool
);
gst_buffer_pool_config_set_params
(
config
,
state
->
caps
,
size
,
min
,
max
);
gst_buffer_pool_config_set_params
(
config
,
state
->
caps
,
size
,
min
,
max
);
gst_buffer_pool_set_config
(
pool
,
config
);
if
(
gst_query_has_allocation_meta
(
query
,
GST_VIDEO_META_API_TYPE
))
{
if
(
klass
->
configure_buffer_pool
)
/* just set the option, if the pool can support it we will transparently use
ret
=
klass
->
configure_buffer_pool
(
decoder
,
query
,
pool
);
* it through the video info API. We could also see if the pool support this
* option and only activate it then. */
gst_buffer_pool_config_add_option
(
config
,
GST_BUFFER_POOL_OPTION_VIDEO_META
);
}
gst_buffer_pool_set_config
(
pool
,
config
);
/* and activate */
/* and activate */
gst_buffer_pool_set_active
(
pool
,
TRUE
);
if
(
ret
)
gst_buffer_pool_set_active
(
pool
,
TRUE
);
gst_query_unref
(
query
);
gst_query_unref
(
query
);
...
@@ -2482,7 +2505,9 @@ gst_video_decoder_alloc_output_buffer (GstVideoDecoder * decoder)
...
@@ -2482,7 +2505,9 @@ gst_video_decoder_alloc_output_buffer (GstVideoDecoder * decoder)
GST_DEBUG
(
"alloc src buffer"
);
GST_DEBUG
(
"alloc src buffer"
);
GST_VIDEO_DECODER_STREAM_LOCK
(
decoder
);
GST_VIDEO_DECODER_STREAM_LOCK
(
decoder
);
if
(
G_UNLIKELY
(
decoder
->
priv
->
output_state_changed
))
if
(
G_UNLIKELY
(
decoder
->
priv
->
output_state_changed
||
(
decoder
->
priv
->
output_state
&&
gst_pad_check_reconfigure
(
decoder
->
srcpad
))))
gst_video_decoder_set_src_caps
(
decoder
);
gst_video_decoder_set_src_caps
(
decoder
);
gst_buffer_pool_acquire_buffer
(
decoder
->
priv
->
pool
,
&
buffer
,
NULL
);
gst_buffer_pool_acquire_buffer
(
decoder
->
priv
->
pool
,
&
buffer
,
NULL
);
...
@@ -2516,7 +2541,9 @@ gst_video_decoder_alloc_output_frame (GstVideoDecoder *
...
@@ -2516,7 +2541,9 @@ gst_video_decoder_alloc_output_frame (GstVideoDecoder *
g_return_val_if_fail
(
num_bytes
!=
0
,
GST_FLOW_ERROR
);
g_return_val_if_fail
(
num_bytes
!=
0
,
GST_FLOW_ERROR
);
if
(
G_UNLIKELY
(
decoder
->
priv
->
output_state_changed
))
if
(
G_UNLIKELY
(
decoder
->
priv
->
output_state_changed
||
(
decoder
->
priv
->
output_state
&&
gst_pad_check_reconfigure
(
decoder
->
srcpad
))))
gst_video_decoder_set_src_caps
(
decoder
);
gst_video_decoder_set_src_caps
(
decoder
);
GST_LOG_OBJECT
(
decoder
,
"alloc buffer size %d"
,
num_bytes
);
GST_LOG_OBJECT
(
decoder
,
"alloc buffer size %d"
,
num_bytes
);
...
...
gst-libs/gst/video/gstvideodecoder.h
View file @
14839972
...
@@ -247,7 +247,11 @@ struct _GstVideoDecoder
...
@@ -247,7 +247,11 @@ struct _GstVideoDecoder
* Event handler on the source pad. This function should return
* Event handler on the source pad. This function should return
* TRUE if the event was handled and should be discarded
* TRUE if the event was handled and should be discarded
* (i.e. not unref'ed).
* (i.e. not unref'ed).
*
* @configure_buffer_pool: Optional.
* Configure the buffer that is used for allocation of output
* buffers. The passed query contains the result of the allocation
* query. The default implementation will add the VIDEO_META if
* supported by the buffer pool.
* Subclasses can override any of the available virtual methods or not, as
* Subclasses can override any of the available virtual methods or not, as
* needed. At minimum @handle_frame needs to be overridden, and @set_format
* needed. At minimum @handle_frame needs to be overridden, and @set_format
* and likely as well. If non-packetized input is supported or expected,
* and likely as well. If non-packetized input is supported or expected,
...
@@ -291,6 +295,8 @@ struct _GstVideoDecoderClass
...
@@ -291,6 +295,8 @@ struct _GstVideoDecoderClass
gboolean
(
*
src_event
)
(
GstVideoDecoder
*
decoder
,
gboolean
(
*
src_event
)
(
GstVideoDecoder
*
decoder
,
GstEvent
*
event
);
GstEvent
*
event
);
gboolean
(
*
configure_buffer_pool
)
(
GstVideoDecoder
*
decoder
,
GstQuery
*
query
,
GstBufferPool
*
pool
);
/*< private >*/
/*< private >*/
/* FIXME before moving to base */
/* FIXME before moving to base */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment