openh264: Run gst-indent over everything

This commit is contained in:
Sebastian Dröge 2014-10-03 13:54:22 +03:00
parent 09f5b9acec
commit 088cf16bf9
3 changed files with 862 additions and 782 deletions

View file

@ -35,197 +35,221 @@
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/video/gstvideodecoder.h>
#include <string.h> /* for memcpy */
#include <string.h> /* for memcpy */
#define GST_OPENH264DEC_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ( \
(obj), GST_TYPE_OPENH264DEC, \
GstOpenh264DecPrivate))
GST_DEBUG_CATEGORY_STATIC(gst_openh264dec_debug_category);
GST_DEBUG_CATEGORY_STATIC (gst_openh264dec_debug_category);
#define GST_CAT_DEFAULT gst_openh264dec_debug_category
/* prototypes */
static void gst_openh264dec_set_property(GObject *object,
guint property_id, const GValue *value, GParamSpec *pspec);
static void gst_openh264dec_get_property(GObject *object, guint property_id,
GValue *value, GParamSpec *pspec);
static void gst_openh264dec_set_property (GObject * object,
guint property_id, const GValue * value, GParamSpec * pspec);
static void gst_openh264dec_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec);
static gboolean gst_openh264dec_start(GstVideoDecoder *decoder);
static gboolean gst_openh264dec_stop(GstVideoDecoder *decoder);
static gboolean gst_openh264dec_start (GstVideoDecoder * decoder);
static gboolean gst_openh264dec_stop (GstVideoDecoder * decoder);
static gboolean gst_openh264dec_set_format(GstVideoDecoder *decoder, GstVideoCodecState *state);
static gboolean gst_openh264dec_reset(GstVideoDecoder *decoder, gboolean hard);
static GstFlowReturn gst_openh264dec_finish(GstVideoDecoder *decoder);
static GstFlowReturn gst_openh264dec_handle_frame(GstVideoDecoder *decoder,
GstVideoCodecFrame *frame);
static gboolean gst_openh264dec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query);
static gboolean gst_openh264dec_set_format (GstVideoDecoder * decoder,
GstVideoCodecState * state);
static gboolean gst_openh264dec_reset (GstVideoDecoder * decoder,
gboolean hard);
static GstFlowReturn gst_openh264dec_finish (GstVideoDecoder * decoder);
static GstFlowReturn gst_openh264dec_handle_frame (GstVideoDecoder * decoder,
GstVideoCodecFrame * frame);
static gboolean gst_openh264dec_decide_allocation (GstVideoDecoder * decoder,
GstQuery * query);
enum
{
PROP_0,
N_PROPERTIES
PROP_0,
N_PROPERTIES
};
struct _GstOpenh264DecPrivate
{
ISVCDecoder *decoder;
GstVideoCodecState *input_state;
guint width, height;
ISVCDecoder *decoder;
GstVideoCodecState *input_state;
guint width, height;
};
/* pad templates */
static GstStaticPadTemplate gst_openh264dec_sink_template = GST_STATIC_PAD_TEMPLATE("sink",
static GstStaticPadTemplate gst_openh264dec_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS("video/x-h264, stream-format=(string)byte-stream, alignment=(string)au"));
GST_STATIC_CAPS
("video/x-h264, stream-format=(string)byte-stream, alignment=(string)au"));
static GstStaticPadTemplate gst_openh264dec_src_template = GST_STATIC_PAD_TEMPLATE("src",
static GstStaticPadTemplate gst_openh264dec_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS(GST_VIDEO_CAPS_MAKE("I420")));
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("I420")));
/* class initialization */
G_DEFINE_TYPE_WITH_CODE(GstOpenh264Dec, gst_openh264dec, GST_TYPE_VIDEO_DECODER,
GST_DEBUG_CATEGORY_INIT(gst_openh264dec_debug_category,
"openh264dec", 0, "debug category for openh264dec element"));
G_DEFINE_TYPE_WITH_CODE (GstOpenh264Dec, gst_openh264dec,
GST_TYPE_VIDEO_DECODER,
GST_DEBUG_CATEGORY_INIT (gst_openh264dec_debug_category, "openh264dec", 0,
"debug category for openh264dec element"));
static void gst_openh264dec_class_init(GstOpenh264DecClass *klass)
static void
gst_openh264dec_class_init (GstOpenh264DecClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
GstVideoDecoderClass *video_decoder_class = GST_VIDEO_DECODER_CLASS(klass);
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstVideoDecoderClass *video_decoder_class = GST_VIDEO_DECODER_CLASS (klass);
g_type_class_add_private(klass, sizeof(GstOpenh264DecPrivate));
g_type_class_add_private (klass, sizeof (GstOpenh264DecPrivate));
/* Setting up pads and setting metadata should be moved to
base_class_init if you intend to subclass this class. */
gst_element_class_add_pad_template(GST_ELEMENT_CLASS(klass),
gst_static_pad_template_get(&gst_openh264dec_sink_template));
gst_element_class_add_pad_template(GST_ELEMENT_CLASS(klass),
gst_static_pad_template_get(&gst_openh264dec_src_template));
/* Setting up pads and setting metadata should be moved to
base_class_init if you intend to subclass this class. */
gst_element_class_add_pad_template (GST_ELEMENT_CLASS (klass),
gst_static_pad_template_get (&gst_openh264dec_sink_template));
gst_element_class_add_pad_template (GST_ELEMENT_CLASS (klass),
gst_static_pad_template_get (&gst_openh264dec_src_template));
gst_element_class_set_static_metadata(GST_ELEMENT_CLASS(klass), "OpenH264 video decoder", "Decoder/Video", "OpenH264 video decoder", "Ericsson AB, http://www.ericsson.com");
gobject_class->set_property = gst_openh264dec_set_property;
gobject_class->get_property = gst_openh264dec_get_property;
gst_element_class_set_static_metadata (GST_ELEMENT_CLASS (klass),
"OpenH264 video decoder", "Decoder/Video", "OpenH264 video decoder",
"Ericsson AB, http://www.ericsson.com");
gobject_class->set_property = gst_openh264dec_set_property;
gobject_class->get_property = gst_openh264dec_get_property;
video_decoder_class->start = GST_DEBUG_FUNCPTR(gst_openh264dec_start);
video_decoder_class->stop = GST_DEBUG_FUNCPTR(gst_openh264dec_stop);
video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_openh264dec_start);
video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_openh264dec_stop);
video_decoder_class->set_format = GST_DEBUG_FUNCPTR(gst_openh264dec_set_format);
video_decoder_class->reset = GST_DEBUG_FUNCPTR(gst_openh264dec_reset);
video_decoder_class->finish = GST_DEBUG_FUNCPTR(gst_openh264dec_finish);
video_decoder_class->handle_frame = GST_DEBUG_FUNCPTR(gst_openh264dec_handle_frame);
video_decoder_class->decide_allocation = GST_DEBUG_FUNCPTR(gst_openh264dec_decide_allocation);
video_decoder_class->set_format =
GST_DEBUG_FUNCPTR (gst_openh264dec_set_format);
video_decoder_class->reset = GST_DEBUG_FUNCPTR (gst_openh264dec_reset);
video_decoder_class->finish = GST_DEBUG_FUNCPTR (gst_openh264dec_finish);
video_decoder_class->handle_frame =
GST_DEBUG_FUNCPTR (gst_openh264dec_handle_frame);
video_decoder_class->decide_allocation =
GST_DEBUG_FUNCPTR (gst_openh264dec_decide_allocation);
}
static void gst_openh264dec_init(GstOpenh264Dec *openh264dec)
static void
gst_openh264dec_init (GstOpenh264Dec * openh264dec)
{
openh264dec->priv = GST_OPENH264DEC_GET_PRIVATE(openh264dec);
openh264dec->priv = GST_OPENH264DEC_GET_PRIVATE (openh264dec);
openh264dec->priv->decoder = NULL;
gst_video_decoder_set_packetized (GST_VIDEO_DECODER (openh264dec), TRUE);
gst_video_decoder_set_needs_format (GST_VIDEO_DECODER (openh264dec), TRUE);
}
void
gst_openh264dec_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec)
{
GstOpenh264Dec *openh264dec = GST_OPENH264DEC (object);
GST_DEBUG_OBJECT (openh264dec, "set_property");
switch (property_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
void
gst_openh264dec_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
{
GstOpenh264Dec *openh264dec = GST_OPENH264DEC (object);
GST_DEBUG_OBJECT (openh264dec, "get_property");
switch (property_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static gboolean
gst_openh264dec_start (GstVideoDecoder * decoder)
{
GstOpenh264Dec *openh264dec = GST_OPENH264DEC (decoder);
gint ret;
SDecodingParam dec_param = { 0 };
if (openh264dec->priv->decoder != NULL) {
openh264dec->priv->decoder->Uninitialize ();
WelsDestroyDecoder (openh264dec->priv->decoder);
openh264dec->priv->decoder = NULL;
}
WelsCreateDecoder (&(openh264dec->priv->decoder));
gst_video_decoder_set_packetized(GST_VIDEO_DECODER(openh264dec), TRUE);
gst_video_decoder_set_needs_format(GST_VIDEO_DECODER(openh264dec), TRUE);
dec_param.uiTargetDqLayer = 255;
dec_param.uiEcActiveFlag = 1;
dec_param.iOutputColorFormat = videoFormatI420;
dec_param.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_AVC;
ret = openh264dec->priv->decoder->Initialize (&dec_param);
GST_DEBUG_OBJECT (openh264dec,
"openh264_dec_start called, openh264dec %sinitialized OK!",
(ret != cmResultSuccess) ? "NOT " : "");
return (ret == cmResultSuccess);
}
void gst_openh264dec_set_property(GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec)
static gboolean
gst_openh264dec_stop (GstVideoDecoder * decoder)
{
GstOpenh264Dec *openh264dec = GST_OPENH264DEC(object);
GstOpenh264Dec *openh264dec = GST_OPENH264DEC (decoder);
gint ret = TRUE;
GST_DEBUG_OBJECT(openh264dec, "set_property");
if (openh264dec->priv->decoder) {
ret = openh264dec->priv->decoder->Uninitialize ();
WelsDestroyDecoder (openh264dec->priv->decoder);
openh264dec->priv->decoder = NULL;
}
switch (property_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
if (openh264dec->priv->input_state) {
gst_video_codec_state_unref (openh264dec->priv->input_state);
openh264dec->priv->input_state = NULL;
}
openh264dec->priv->width = openh264dec->priv->height = 0;
return ret;
}
void gst_openh264dec_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
static gboolean
gst_openh264dec_set_format (GstVideoDecoder * decoder,
GstVideoCodecState * state)
{
GstOpenh264Dec *openh264dec = GST_OPENH264DEC(object);
GstOpenh264Dec *openh264dec = GST_OPENH264DEC (decoder);
GST_DEBUG_OBJECT(openh264dec, "get_property");
GST_DEBUG_OBJECT (openh264dec,
"openh264_dec_set_format called, caps: %" GST_PTR_FORMAT, state->caps);
switch (property_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
if (openh264dec->priv->input_state) {
gst_video_codec_state_unref (openh264dec->priv->input_state);
openh264dec->priv->input_state = NULL;
}
openh264dec->priv->input_state = gst_video_codec_state_ref (state);
return TRUE;
}
static gboolean gst_openh264dec_start(GstVideoDecoder *decoder)
static gboolean
gst_openh264dec_reset (GstVideoDecoder * decoder, gboolean hard)
{
GstOpenh264Dec *openh264dec = GST_OPENH264DEC(decoder);
gint ret;
SDecodingParam dec_param = {0};
GstOpenh264Dec *openh264dec = GST_OPENH264DEC (decoder);
if (openh264dec->priv->decoder != NULL)
{
openh264dec->priv->decoder->Uninitialize();
WelsDestroyDecoder(openh264dec->priv->decoder);
openh264dec->priv->decoder = NULL;
}
WelsCreateDecoder(&(openh264dec->priv->decoder));
GST_DEBUG_OBJECT (openh264dec, "reset");
dec_param.uiTargetDqLayer = 255;
dec_param.uiEcActiveFlag = 1;
dec_param.iOutputColorFormat = videoFormatI420;
dec_param.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_AVC;
ret = openh264dec->priv->decoder->Initialize(&dec_param);
GST_DEBUG_OBJECT(openh264dec, "openh264_dec_start called, openh264dec %sinitialized OK!", (ret != cmResultSuccess) ? "NOT " : "");
return (ret == cmResultSuccess);
}
static gboolean gst_openh264dec_stop(GstVideoDecoder *decoder)
{
GstOpenh264Dec *openh264dec = GST_OPENH264DEC(decoder);
gint ret = TRUE;
if (openh264dec->priv->decoder) {
ret = openh264dec->priv->decoder->Uninitialize();
WelsDestroyDecoder(openh264dec->priv->decoder);
openh264dec->priv->decoder = NULL;
}
if (openh264dec->priv->input_state) {
gst_video_codec_state_unref (openh264dec->priv->input_state);
openh264dec->priv->input_state = NULL;
}
openh264dec->priv->width = openh264dec->priv->height = 0;
return ret;
}
static gboolean gst_openh264dec_set_format(GstVideoDecoder *decoder, GstVideoCodecState *state)
{
GstOpenh264Dec *openh264dec = GST_OPENH264DEC(decoder);
GST_DEBUG_OBJECT(openh264dec, "openh264_dec_set_format called, caps: %" GST_PTR_FORMAT, state->caps);
if (openh264dec->priv->input_state) {
gst_video_codec_state_unref (openh264dec->priv->input_state);
openh264dec->priv->input_state = NULL;
}
openh264dec->priv->input_state = gst_video_codec_state_ref (state);
return TRUE;
}
static gboolean gst_openh264dec_reset(GstVideoDecoder *decoder, gboolean hard)
{
GstOpenh264Dec *openh264dec = GST_OPENH264DEC(decoder);
GST_DEBUG_OBJECT(openh264dec, "reset");
return TRUE;
return TRUE;
}
static GstVideoCodecFrame *
@ -254,144 +278,160 @@ get_oldest_pts_frame (GstVideoDecoder * decoder)
return oldest;
}
static GstFlowReturn gst_openh264dec_handle_frame(GstVideoDecoder *decoder, GstVideoCodecFrame *frame)
static GstFlowReturn
gst_openh264dec_handle_frame (GstVideoDecoder * decoder,
GstVideoCodecFrame * frame)
{
GstOpenh264Dec *openh264dec = GST_OPENH264DEC(decoder);
GstMapInfo map_info;
GstVideoCodecState *state;
SBufferInfo dst_buf_info;
DECODING_STATE ret;
guint8 *yuvdata[3];
GstFlowReturn flow_status;
GstVideoFrame video_frame;
guint actual_width, actual_height;
guint i;
guint8 *p;
guint row_stride, component_width, component_height, src_width, row;
GstOpenh264Dec *openh264dec = GST_OPENH264DEC (decoder);
GstMapInfo map_info;
GstVideoCodecState *state;
SBufferInfo dst_buf_info;
DECODING_STATE ret;
guint8 *yuvdata[3];
GstFlowReturn flow_status;
GstVideoFrame video_frame;
guint actual_width, actual_height;
guint i;
guint8 *p;
guint row_stride, component_width, component_height, src_width, row;
if (frame) {
if (!gst_buffer_map(frame->input_buffer, &map_info, GST_MAP_READ)) {
GST_ERROR_OBJECT(openh264dec, "Cannot map input buffer!");
return GST_FLOW_ERROR;
}
GST_LOG_OBJECT(openh264dec, "handle frame, %d", map_info.size > 4 ? map_info.data[4] & 0x1f : -1);
memset (&dst_buf_info, 0, sizeof (SBufferInfo));
ret = openh264dec->priv->decoder->DecodeFrame2(map_info.data, map_info.size, yuvdata, &dst_buf_info);
if (ret == dsNoParamSets) {
GST_DEBUG_OBJECT(openh264dec, "Requesting a key unit");
gst_pad_push_event(GST_VIDEO_DECODER_SINK_PAD(decoder),
gst_video_event_new_upstream_force_key_unit(GST_CLOCK_TIME_NONE, FALSE, 0));
}
if (ret != dsErrorFree && ret != dsNoParamSets) {
GST_DEBUG_OBJECT(openh264dec, "Requesting a key unit");
gst_pad_push_event(GST_VIDEO_DECODER_SINK_PAD(decoder),
gst_video_event_new_upstream_force_key_unit(GST_CLOCK_TIME_NONE, FALSE, 0));
GST_LOG_OBJECT(openh264dec, "error decoding nal, return code: %d", ret);
}
gst_buffer_unmap(frame->input_buffer, &map_info);
gst_video_codec_frame_unref (frame);
frame = NULL;
} else {
memset (&dst_buf_info, 0, sizeof (SBufferInfo));
ret = openh264dec->priv->decoder->DecodeFrame2(NULL, 0, yuvdata, &dst_buf_info);
if (ret != dsErrorFree)
return GST_FLOW_EOS;
if (frame) {
if (!gst_buffer_map (frame->input_buffer, &map_info, GST_MAP_READ)) {
GST_ERROR_OBJECT (openh264dec, "Cannot map input buffer!");
return GST_FLOW_ERROR;
}
/* FIXME: openh264 has no way for us to get a connection
* between the input and output frames, we just have to
* guess based on the input */
frame = get_oldest_pts_frame (decoder);
if (!frame) {
/* Can only happen in finish() */
GST_LOG_OBJECT (openh264dec, "handle frame, %d",
map_info.size > 4 ? map_info.data[4] & 0x1f : -1);
memset (&dst_buf_info, 0, sizeof (SBufferInfo));
ret =
openh264dec->priv->decoder->DecodeFrame2 (map_info.data, map_info.size,
yuvdata, &dst_buf_info);
if (ret == dsNoParamSets) {
GST_DEBUG_OBJECT (openh264dec, "Requesting a key unit");
gst_pad_push_event (GST_VIDEO_DECODER_SINK_PAD (decoder),
gst_video_event_new_upstream_force_key_unit (GST_CLOCK_TIME_NONE,
FALSE, 0));
}
if (ret != dsErrorFree && ret != dsNoParamSets) {
GST_DEBUG_OBJECT (openh264dec, "Requesting a key unit");
gst_pad_push_event (GST_VIDEO_DECODER_SINK_PAD (decoder),
gst_video_event_new_upstream_force_key_unit (GST_CLOCK_TIME_NONE,
FALSE, 0));
GST_LOG_OBJECT (openh264dec, "error decoding nal, return code: %d", ret);
}
gst_buffer_unmap (frame->input_buffer, &map_info);
gst_video_codec_frame_unref (frame);
frame = NULL;
} else {
memset (&dst_buf_info, 0, sizeof (SBufferInfo));
ret =
openh264dec->priv->decoder->DecodeFrame2 (NULL, 0, yuvdata,
&dst_buf_info);
if (ret != dsErrorFree)
return GST_FLOW_EOS;
}
}
/* No output available yet */
if (dst_buf_info.iBufferStatus != 1) {
return GST_FLOW_OK;
}
actual_width = dst_buf_info.UsrData.sSystemBuffer.iWidth;
actual_height = dst_buf_info.UsrData.sSystemBuffer.iHeight;
if (!gst_pad_has_current_caps (GST_VIDEO_DECODER_SRC_PAD (openh264dec)) || actual_width != openh264dec->priv->width || actual_height != openh264dec->priv->height) {
state = gst_video_decoder_set_output_state(decoder,
GST_VIDEO_FORMAT_I420,
actual_width,
actual_height,
openh264dec->priv->input_state);
openh264dec->priv->width = actual_width;
openh264dec->priv->height = actual_height;
if (!gst_video_decoder_negotiate(decoder)) {
GST_ERROR_OBJECT(openh264dec, "Failed to negotiate with downstream elements");
return GST_FLOW_NOT_NEGOTIATED;
}
} else {
state = gst_video_decoder_get_output_state(decoder);
}
flow_status = gst_video_decoder_allocate_output_frame(decoder, frame);
if (flow_status != GST_FLOW_OK) {
gst_video_codec_state_unref (state);
return flow_status;
}
if (!gst_video_frame_map(&video_frame, &state->info, frame->output_buffer, GST_MAP_WRITE)) {
GST_ERROR_OBJECT(openh264dec, "Cannot map output buffer!");
gst_video_codec_state_unref (state);
return GST_FLOW_ERROR;
}
for (i = 0; i < 3; i++) {
p = GST_VIDEO_FRAME_COMP_DATA(&video_frame, i);
row_stride = GST_VIDEO_FRAME_COMP_STRIDE(&video_frame, i);
component_width = GST_VIDEO_FRAME_COMP_WIDTH(&video_frame, i);
component_height = GST_VIDEO_FRAME_COMP_HEIGHT(&video_frame, i);
src_width = i < 1 ? dst_buf_info.UsrData.sSystemBuffer.iStride[0] : dst_buf_info.UsrData.sSystemBuffer.iStride[1];
for (row = 0; row < component_height; row++) {
memcpy(p, yuvdata[i], component_width);
p += row_stride;
yuvdata[i] += src_width;
}
}
gst_video_codec_state_unref (state);
gst_video_frame_unmap(&video_frame);
return gst_video_decoder_finish_frame(decoder, frame);
}
static GstFlowReturn gst_openh264dec_finish(GstVideoDecoder *decoder)
{
GstOpenh264Dec *openh264dec = GST_OPENH264DEC(decoder);
GST_DEBUG_OBJECT(openh264dec, "finish");
/* Decoder not negotiated yet */
if (openh264dec->priv->width == 0)
return GST_FLOW_OK;
/* Drain all pending frames */
while ((gst_openh264dec_handle_frame (decoder, NULL)) == GST_FLOW_OK);
/* FIXME: openh264 has no way for us to get a connection
* between the input and output frames, we just have to
* guess based on the input */
frame = get_oldest_pts_frame (decoder);
if (!frame) {
/* Can only happen in finish() */
return GST_FLOW_EOS;
}
/* No output available yet */
if (dst_buf_info.iBufferStatus != 1) {
return GST_FLOW_OK;
}
actual_width = dst_buf_info.UsrData.sSystemBuffer.iWidth;
actual_height = dst_buf_info.UsrData.sSystemBuffer.iHeight;
if (!gst_pad_has_current_caps (GST_VIDEO_DECODER_SRC_PAD (openh264dec))
|| actual_width != openh264dec->priv->width
|| actual_height != openh264dec->priv->height) {
state =
gst_video_decoder_set_output_state (decoder, GST_VIDEO_FORMAT_I420,
actual_width, actual_height, openh264dec->priv->input_state);
openh264dec->priv->width = actual_width;
openh264dec->priv->height = actual_height;
if (!gst_video_decoder_negotiate (decoder)) {
GST_ERROR_OBJECT (openh264dec,
"Failed to negotiate with downstream elements");
return GST_FLOW_NOT_NEGOTIATED;
}
} else {
state = gst_video_decoder_get_output_state (decoder);
}
flow_status = gst_video_decoder_allocate_output_frame (decoder, frame);
if (flow_status != GST_FLOW_OK) {
gst_video_codec_state_unref (state);
return flow_status;
}
if (!gst_video_frame_map (&video_frame, &state->info, frame->output_buffer,
GST_MAP_WRITE)) {
GST_ERROR_OBJECT (openh264dec, "Cannot map output buffer!");
gst_video_codec_state_unref (state);
return GST_FLOW_ERROR;
}
for (i = 0; i < 3; i++) {
p = GST_VIDEO_FRAME_COMP_DATA (&video_frame, i);
row_stride = GST_VIDEO_FRAME_COMP_STRIDE (&video_frame, i);
component_width = GST_VIDEO_FRAME_COMP_WIDTH (&video_frame, i);
component_height = GST_VIDEO_FRAME_COMP_HEIGHT (&video_frame, i);
src_width =
i <
1 ? dst_buf_info.UsrData.sSystemBuffer.
iStride[0] : dst_buf_info.UsrData.sSystemBuffer.iStride[1];
for (row = 0; row < component_height; row++) {
memcpy (p, yuvdata[i], component_width);
p += row_stride;
yuvdata[i] += src_width;
}
}
gst_video_codec_state_unref (state);
gst_video_frame_unmap (&video_frame);
return gst_video_decoder_finish_frame (decoder, frame);
}
static gboolean gst_openh264dec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
static GstFlowReturn
gst_openh264dec_finish (GstVideoDecoder * decoder)
{
GstOpenh264Dec *openh264dec = GST_OPENH264DEC (decoder);
GST_DEBUG_OBJECT (openh264dec, "finish");
/* Decoder not negotiated yet */
if (openh264dec->priv->width == 0)
return GST_FLOW_OK;
/* Drain all pending frames */
while ((gst_openh264dec_handle_frame (decoder, NULL)) == GST_FLOW_OK);
return GST_FLOW_OK;
}
static gboolean
gst_openh264dec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
{
GstVideoCodecState *state;
GstBufferPool *pool;
guint size, min, max;
GstStructure *config;
if (!GST_VIDEO_DECODER_CLASS (gst_openh264dec_parent_class)->decide_allocation (decoder,
query))
if (!GST_VIDEO_DECODER_CLASS (gst_openh264dec_parent_class)->decide_allocation
(decoder, query))
return FALSE;
state = gst_video_decoder_get_output_state (decoder);
@ -413,4 +453,3 @@ static gboolean gst_openh264dec_decide_allocation (GstVideoDecoder * decoder, Gs
return TRUE;
}

File diff suppressed because it is too large Load diff

View file

@ -36,21 +36,19 @@
#include "gstopenh264enc.h"
static gboolean
plugin_init(GstPlugin *plugin)
plugin_init (GstPlugin * plugin)
{
gst_element_register(plugin, "openh264dec", GST_RANK_NONE, GST_TYPE_OPENH264DEC);
gst_element_register(plugin, "openh264enc", GST_RANK_NONE, GST_TYPE_OPENH264ENC);
gst_element_register (plugin, "openh264dec", GST_RANK_NONE,
GST_TYPE_OPENH264DEC);
gst_element_register (plugin, "openh264enc", GST_RANK_NONE,
GST_TYPE_OPENH264ENC);
return TRUE;
return TRUE;
}
GST_PLUGIN_DEFINE(
GST_VERSION_MAJOR,
GST_VERSION_MINOR,
openh264,
"OpenH264 encoder/decoder plugin",
plugin_init,
VERSION,
"BSD",
"OpenWebRTC GStreamer plugins",
"http://www.ericsson.com")
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
openh264,
"OpenH264 encoder/decoder plugin",
plugin_init,
VERSION, "BSD", "OpenWebRTC GStreamer plugins", "http://www.ericsson.com")