static GstVaapiEncoderStatus gst_vaapi_encoder_mpeg2_encode (GstVaapiEncoder * base_encoder, GstVaapiEncPicture * picture, GstVaapiCodedBufferProxy * codedbuf) { GstVaapiEncoderMpeg2 *const encoder = GST_VAAPI_ENCODER_MPEG2_CAST (base_encoder); GstVaapiEncoderStatus ret = GST_VAAPI_ENCODER_STATUS_ERROR_UNKNOWN; GstVaapiSurfaceProxy *reconstruct = NULL; reconstruct = gst_vaapi_encoder_create_surface (base_encoder); g_assert (GST_VAAPI_SURFACE_PROXY_SURFACE (reconstruct)); if (!ensure_sequence (encoder, picture)) goto error; if (!ensure_picture (encoder, picture, codedbuf, reconstruct)) goto error; if (!set_misc_parameters (encoder, picture)) goto error; if (!ensure_slices (encoder, picture)) goto error; if (!gst_vaapi_enc_picture_encode (picture)) goto error; if (picture->type != GST_VAAPI_PICTURE_TYPE_B) { if (encoder->new_gop) clear_references (encoder); push_reference (encoder, reconstruct); } else if (reconstruct) gst_vaapi_encoder_release_surface (GST_VAAPI_ENCODER (encoder), reconstruct); return GST_VAAPI_ENCODER_STATUS_SUCCESS; /* ERRORS */ error: { if (reconstruct) gst_vaapi_encoder_release_surface (GST_VAAPI_ENCODER (encoder), reconstruct); return ret; } }
static GstVaapiEncoderStatus gst_vaapi_encoder_vp8_encode (GstVaapiEncoder * base_encoder, GstVaapiEncPicture * picture, GstVaapiCodedBufferProxy * codedbuf) { GstVaapiEncoderVP8 *const encoder = GST_VAAPI_ENCODER_VP8_CAST (base_encoder); GstVaapiEncoderStatus ret = GST_VAAPI_ENCODER_STATUS_ERROR_UNKNOWN; GstVaapiSurfaceProxy *reconstruct = NULL; reconstruct = gst_vaapi_encoder_create_surface (base_encoder); g_assert (GST_VAAPI_SURFACE_PROXY_SURFACE (reconstruct)); if (!ensure_sequence (encoder, picture)) goto error; if (!ensure_misc_params (encoder, picture)) goto error; if (!ensure_picture (encoder, picture, codedbuf, reconstruct)) goto error; if (!ensure_quantization_table (encoder, picture)) goto error; if (!gst_vaapi_enc_picture_encode (picture)) goto error; if (reconstruct) { if (picture->type == GST_VAAPI_PICTURE_TYPE_I) clear_references (encoder); push_reference (encoder, reconstruct); } return GST_VAAPI_ENCODER_STATUS_SUCCESS; /* ERRORS */ error: { if (reconstruct) gst_vaapi_encoder_release_surface (GST_VAAPI_ENCODER (encoder), reconstruct); return ret; } }
void ensure_uniform_sequence( boost::python::object seq, index_type expected_length=-1 ){ ensure_sequence( seq, expected_length ); index_type length = sequence_len( seq ); for( index_type index = 0; index < length; ++index ){ boost::python::object item = seq[index]; boost::python::extract<ExpectedType> type_checker( item ); if( !type_checker.check() ){ std::string expected_type_name( boost::python::type_id<ExpectedType>().name() ); std::string item_type_name("different"); PyObject* item_impl = item.ptr(); if( item_impl && item_impl->ob_type && item_impl->ob_type->tp_name ){ item_type_name = std::string( item_impl->ob_type->tp_name ); } std::stringstream err; err << "Sequence should contain only items with type \"" << expected_type_name << "\". " << "Item at position " << index << " has \"" << item_type_name << "\" type."; raise_error( PyExc_ValueError, err.str().c_str() ); } } }