gst: Don't declare variables inside the for loop header

This is a C99 feature.
This commit is contained in:
Sebastian Dröge 2016-12-13 22:39:01 +02:00
parent 788bb67639
commit 5c99f9cf37
16 changed files with 70 additions and 35 deletions

View file

@ -334,7 +334,7 @@ _src_smpte_init (gpointer impl, GstGLContext * context, GstVideoInfo * v_info)
plane_indices = g_new0 (gushort, N_QUADS * 6);
/* top row */
for (int i = 0; i < 7; i++) {
for (i = 0; i < 7; i++) {
coord[color_idx * 4 + 0].X = -1.0f + i * (2.0f / 7.0f);
coord[color_idx * 4 + 0].Y = 1.0f / 3.0f;
coord[color_idx * 4 + 1].X = -1.0f + (i + 1) * (2.0f / 7.0f);
@ -347,7 +347,7 @@ _src_smpte_init (gpointer impl, GstGLContext * context, GstVideoInfo * v_info)
}
/* middle row */
for (int i = 0; i < 7; i++) {
for (i = 0; i < 7; i++) {
coord[color_idx * 4 + 0].X = -1.0f + i * (2.0f / 7.0f);
coord[color_idx * 4 + 0].Y = 0.5f;
coord[color_idx * 4 + 1].X = -1.0f + (i + 1) * (2.0f / 7.0f);
@ -360,7 +360,7 @@ _src_smpte_init (gpointer impl, GstGLContext * context, GstVideoInfo * v_info)
}
/* bottom row, left three */
for (int i = 0; i < 3; i++) {
for (i = 0; i < 3; i++) {
coord[color_idx * 4 + 0].X = -1.0f + i / 3.0f;
coord[color_idx * 4 + 0].Y = 1.0f;
coord[color_idx * 4 + 1].X = -1.0f + (i + 1) / 3.0f;
@ -373,7 +373,7 @@ _src_smpte_init (gpointer impl, GstGLContext * context, GstVideoInfo * v_info)
}
/* bottom row, middle three (the blacks) */
for (int i = 0; i < 3; i++) {
for (i = 0; i < 3; i++) {
coord[color_idx * 4 + 0].X = i / 6.0f;
coord[color_idx * 4 + 0].Y = 1.0f;
coord[color_idx * 4 + 1].X = (i + 1) / 6.0f;

View file

@ -682,6 +682,7 @@ _gst_libde265_return_image (GstVideoDecoder * decoder,
GstVideoFrame outframe;
GstVideoCodecFrame *out_frame;
int frame_number;
int plane;
ref = (struct GstLibde265FrameRef *) de265_get_image_plane_user_data (img, 0);
if (ref != NULL) {
@ -731,7 +732,7 @@ _gst_libde265_return_image (GstVideoDecoder * decoder,
return GST_FLOW_ERROR;
}
for (int plane = 0; plane < 3; plane++) {
for (plane = 0; plane < 3; plane++) {
int width = de265_get_image_width (img, plane);
int height = de265_get_image_height (img, plane);
int srcstride = width;

View file

@ -214,8 +214,10 @@ private:
bool getIsNonZero (IplImage * img)
{
for (int lin = 0; lin < img->height; lin++)
for (int col = 0; col < img->width; col++) {
int lin, col;
for (lin = 0; lin < img->height; lin++)
for (col = 0; col < img->width; col++) {
if ((((uchar *) (img->imageData + img->widthStep * lin))[col]) > 0)
return true;
}
@ -224,15 +226,17 @@ private:
void setMotionCells (int p_frameWidth, int p_frameHeight)
{
int i, j;
m_cellwidth = (double) p_frameWidth / (double) m_gridx;
m_cellheight = (double) p_frameHeight / (double) m_gridy;
m_pCells = new Cell *[m_gridy];
for (int i = 0; i < m_gridy; i++)
for (i = 0; i < m_gridy; i++)
m_pCells[i] = new Cell[m_gridx];
//init cells
for (int i = 0; i < m_gridy; i++)
for (int j = 0; j < m_gridx; j++) {
for (i = 0; i < m_gridy; i++)
for (j = 0; j < m_gridx; j++) {
m_pCells[i][j].MotionArea = 0;
m_pCells[i][j].CellArea = 0;
m_pCells[i][j].MotionPercent = 0;

View file

@ -230,7 +230,7 @@ gst_vulkan_device_open (GstVulkanDevice * device, GError ** error)
goto error;
}
for (uint32_t i = 0; i < device_extension_count; i++) {
for (i = 0; i < device_extension_count; i++) {
GST_TRACE_OBJECT (device, "checking device extension %s",
device_extensions[i].extensionName);
if (!strcmp (VK_KHR_SWAPCHAIN_EXTENSION_NAME,

View file

@ -234,6 +234,7 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
gboolean swapchain_ext_found = FALSE;
gboolean winsys_ext_found = FALSE;
const gchar *winsys_ext_name;
uint32_t i;
display_type = gst_vulkan_display_choose_type (instance);
@ -245,7 +246,7 @@ gst_vulkan_instance_open (GstVulkanInstance * instance, GError ** error)
}
/* TODO: allow outside selection */
for (uint32_t i = 0; i < instance_extension_count; i++) {
for (i = 0; i < instance_extension_count; i++) {
GST_TRACE_OBJECT (instance, "checking instance extension %s",
instance_extensions[i].extensionName);

View file

@ -441,6 +441,7 @@ gst_egl_image_from_dmabuf (GstGLContext * context,
EGLImageKHR img;
gint atti = 0;
gint fourcc;
gint i;
fourcc = _drm_fourcc_from_info (in_info, plane);
type =
@ -466,7 +467,7 @@ gst_egl_image_from_dmabuf (GstGLContext * context,
attribs[atti++] = GST_VIDEO_INFO_PLANE_STRIDE (in_info, plane);
attribs[atti] = EGL_NONE;
for (int i = 0; i < atti; i++)
for (i = 0; i < atti; i++)
GST_LOG ("attr %i: %" G_GINTPTR_FORMAT, i, attribs[i]);
g_assert (atti == 12);

View file

@ -1487,7 +1487,9 @@ restart:
upload->priv->method->perform (upload->priv->method_impl, buffer,
&outbuf);
if (ret == GST_GL_UPLOAD_UNSHARED_GL_CONTEXT) {
for (int i = 0; i < G_N_ELEMENTS (upload_methods); i++) {
gint i;
for (i = 0; i < G_N_ELEMENTS (upload_methods); i++) {
if (upload_methods[i] == &_raw_data_upload) {
upload->priv->method = &_raw_data_upload;
upload->priv->method_impl = upload->priv->upload_impl[i];

View file

@ -40,7 +40,9 @@ static inline guint
msdk_get_free_surface_index (mfxFrameSurface1 * surfaces, guint size)
{
if (surfaces) {
for (guint i = 0; i < size; i++) {
guint i;
for (i = 0; i < size; i++) {
if (!surfaces[i].Data.Locked)
return i;
}
@ -53,9 +55,10 @@ mfxFrameSurface1 *
msdk_get_free_surface (mfxFrameSurface1 * surfaces, guint size)
{
guint idx = INVALID_INDEX;
guint i;
/* Poll the pool for a maximum of 20 milisecnds */
for (guint i = 0; i < 2000; i++) {
for (i = 0; i < 2000; i++) {
idx = msdk_get_free_surface_index (surfaces, size);
if (idx != INVALID_INDEX)
@ -74,6 +77,7 @@ msdk_frame_to_surface (GstVideoFrame * frame, mfxFrameSurface1 * surface)
guint8 *src, *dst;
guint sstride, dstride;
guint width, height;
guint i;
if (!surface->Data.MemId) {
surface->Data.Y = GST_VIDEO_FRAME_COMP_DATA (frame, 0);
@ -90,7 +94,7 @@ msdk_frame_to_surface (GstVideoFrame * frame, mfxFrameSurface1 * surface)
dst = surface->Data.Y;
dstride = surface->Data.Pitch;
for (guint i = 0; i < height; i++) {
for (i = 0; i < height; i++) {
memcpy (dst, src, width);
src += sstride;
dst += dstride;
@ -102,7 +106,7 @@ msdk_frame_to_surface (GstVideoFrame * frame, mfxFrameSurface1 * surface)
sstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 1);
dst = surface->Data.UV;
for (guint i = 0; i < height; i++) {
for (i = 0; i < height; i++) {
memcpy (dst, src, width);
src += sstride;
dst += dstride;

View file

@ -157,6 +157,7 @@ gst_adaptive_demux_test_check_received_data (GstAdaptiveDemuxTestEngine *
guint64 streamOffset;
GstAdaptiveDemuxTestCase *testData = GST_ADAPTIVE_DEMUX_TEST_CASE (user_data);
GstAdaptiveDemuxTestExpectedOutput *testOutputStreamData;
guint64 i;
fail_unless (stream != NULL);
fail_unless (engine->pipeline != NULL);
@ -198,7 +199,7 @@ gst_adaptive_demux_test_check_received_data (GstAdaptiveDemuxTestEngine *
gst_buffer_map (buffer, &info, GST_MAP_READ);
pattern = streamOffset - streamOffset % sizeof (pattern);
for (guint64 i = 0; i != info.size; ++i) {
for (i = 0; i != info.size; ++i) {
guint received = info.data[i];
guint expected;

View file

@ -54,7 +54,9 @@ static GstAdaptiveDemuxTestOutputStream *
getTestOutputDataByAppsink (GstAdaptiveDemuxTestEnginePrivate * priv,
GstAppSink * appsink)
{
for (guint i = 0; i < priv->engine.output_streams->len; ++i) {
guint i;
for (i = 0; i < priv->engine.output_streams->len; ++i) {
GstAdaptiveDemuxTestOutputStream *state;
state = g_ptr_array_index (priv->engine.output_streams, i);
if (state->appsink == appsink) {
@ -70,7 +72,9 @@ static GstAdaptiveDemuxTestOutputStream *
getTestOutputDataByPad (GstAdaptiveDemuxTestEnginePrivate * priv,
GstPad * pad, gboolean abort_if_not_found)
{
for (guint i = 0; i < priv->engine.output_streams->len; ++i) {
guint i;
for (i = 0; i < priv->engine.output_streams->len; ++i) {
GstAdaptiveDemuxTestOutputStream *stream;
stream = g_ptr_array_index (priv->engine.output_streams, i);
if (stream->internal_pad == pad || stream->pad == pad) {

View file

@ -443,8 +443,9 @@ static void
add_interlaced_mode_to_caps (GstCaps * caps, const gchar * mode)
{
GstStructure *s;
gint i;
for (gint i = 0; i < gst_caps_get_size (caps); i++) {
for (i = 0; i < gst_caps_get_size (caps); i++) {
s = gst_caps_get_structure (caps, i);
gst_structure_set (s, "interlace-mode", G_TYPE_STRING, mode, NULL);
}

View file

@ -137,7 +137,9 @@ gst_dashdemux_http_src_start (GstTestHTTPSrc * src,
{
const GstTestHTTPSrcTestData *test_case =
(const GstTestHTTPSrcTestData *) user_data;
for (guint i = 0; test_case->input[i].uri; ++i) {
guint i;
for (i = 0; test_case->input[i].uri; ++i) {
if (g_strcmp0 (test_case->input[i].uri, uri) == 0) {
input_data->context = (gpointer) & test_case->input[i];
input_data->size = test_case->input[i].size;
@ -166,11 +168,12 @@ gst_dashdemux_http_src_create (GstTestHTTPSrc * src,
} else {
GstMapInfo info;
guint pattern;
guint64 i;
pattern = offset - offset % sizeof (pattern);
gst_buffer_map (buf, &info, GST_MAP_WRITE);
for (guint64 i = 0; i < length; ++i) {
for (i = 0; i < length; ++i) {
gchar pattern_byte_to_write = (offset + i) % sizeof (pattern);
if (pattern_byte_to_write == 0) {
pattern = offset + i;

View file

@ -2572,7 +2572,9 @@ GST_START_TEST (dash_mpdparser_template_parsing)
};
guint count = sizeof (testUrl) / sizeof (testUrl[0]);
for (int i = 0; i < count; i++) {
gint i;
for (i = 0; i < count; i++) {
result =
gst_mpdparser_build_URL_from_template (testUrl[i].urlTemplate, id,
number, bandwidth, time);
@ -3412,6 +3414,7 @@ GST_START_TEST (dash_mpdparser_get_audio_languages)
gboolean ret;
GstMpdClient *mpdclient = gst_mpd_client_new ();
gint i;
ret = gst_mpd_parse (mpdclient, xml, (gint) strlen (xml));
assert_equals_int (ret, TRUE);
@ -3428,7 +3431,7 @@ GST_START_TEST (dash_mpdparser_get_audio_languages)
/* setup streaming from all adaptation sets */
adaptationSetsCount = gst_mpdparser_get_nb_adaptationSet (mpdclient);
for (int i = 0; i < adaptationSetsCount; i++) {
for (i = 0; i < adaptationSetsCount; i++) {
adapt_set = (GstAdaptationSetNode *) g_list_nth_data (adaptationSets, i);
fail_if (adapt_set == NULL);
ret = gst_mpd_client_setup_streaming (mpdclient, adapt_set);
@ -3463,6 +3466,7 @@ setup_mpd_client (const gchar * xml)
guint adaptationSetsCount;
gboolean ret;
GstMpdClient *mpdclient = gst_mpd_client_new ();
gint i;
ret = gst_mpd_parse (mpdclient, xml, (gint) strlen (xml));
assert_equals_int (ret, TRUE);
@ -3479,7 +3483,7 @@ setup_mpd_client (const gchar * xml)
/* setup streaming from all adaptation sets */
adaptationSetsCount = gst_mpdparser_get_nb_adaptationSet (mpdclient);
for (int i = 0; i < adaptationSetsCount; i++) {
for (i = 0; i < adaptationSetsCount; i++) {
adapt_set = (GstAdaptationSetNode *) g_list_nth_data (adaptationSets, i);
fail_if (adapt_set == NULL);
ret = gst_mpd_client_setup_streaming (mpdclient, adapt_set);

View file

@ -85,14 +85,16 @@ setup_test_variables (const gchar * funcname,
GByteArray *mpeg_ts = NULL;
if (segment_size) {
guint itd, otd;
mpeg_ts = generate_transport_stream ((segment_size));
fail_unless (mpeg_ts != NULL);
for (guint itd = 0; inputTestData[itd].uri; ++itd) {
for (itd = 0; inputTestData[itd].uri; ++itd) {
if (g_str_has_suffix (inputTestData[itd].uri, ".ts")) {
inputTestData[itd].payload = mpeg_ts->data;
}
}
for (guint otd = 0; outputTestData[otd].name; ++otd) {
for (otd = 0; outputTestData[otd].name; ++otd) {
outputTestData[otd].expected_data = mpeg_ts->data;
engineTestData->output_streams =
g_list_append (engineTestData->output_streams, &outputTestData[otd]);
@ -181,9 +183,10 @@ gst_hlsdemux_test_src_start (GstTestHTTPSrc * src,
const GstHlsDemuxTestCase *test_case =
(const GstHlsDemuxTestCase *) user_data;
guint fail_count = 0;
guint i;
GST_DEBUG ("src_start %s", uri);
for (guint i = 0; test_case->input[i].uri; ++i) {
for (i = 0; test_case->input[i].uri; ++i) {
if (strcmp (test_case->input[i].uri, uri) == 0) {
gst_hlsdemux_test_set_input_data (test_case, &test_case->input[i],
input_data);
@ -316,6 +319,7 @@ GST_START_TEST (testMasterPlaylist)
{NULL, 0, NULL}
};
const GValue *requests;
guint i;
TESTCASE_INIT_BOILERPLATE (segment_size);
http_src_callbacks.src_start = gst_hlsdemux_test_src_start;
@ -333,7 +337,7 @@ GST_START_TEST (testMasterPlaylist)
fail_unless (requests != NULL);
assert_equals_uint64 (gst_value_array_get_size (requests),
sizeof (inputTestData) / sizeof (inputTestData[0]) - 1);
for (guint i = 0; inputTestData[i].uri; ++i) {
for (i = 0; inputTestData[i].uri; ++i) {
const GValue *uri;
uri = gst_value_array_get_value (requests, i);
fail_unless (uri != NULL);

View file

@ -44,9 +44,10 @@ gst_mssdemux_http_src_start (GstTestHTTPSrc * src,
{
const GstMssDemuxTestInputData *input =
(const GstMssDemuxTestInputData *) user_data;
guint i;
for (guint i = 0; input[i].uri; ++i) {
for (i = 0; input[i].uri; ++i) {
if (strcmp (input[i].uri, uri) == 0) {
input_data->context = (gpointer) & input[i];
input_data->size = input[i].size;
@ -78,11 +79,12 @@ gst_mssdemux_http_src_create (GstTestHTTPSrc * src,
} else {
GstMapInfo info;
guint pattern;
guint64 i;
pattern = offset - offset % sizeof (pattern);
gst_buffer_map (buf, &info, GST_MAP_WRITE);
for (guint64 i = 0; i < length; ++i) {
for (i = 0; i < length; ++i) {
gchar pattern_byte_to_write = (offset + i) % sizeof (pattern);
if (pattern_byte_to_write == 0) {
pattern = offset + i;

View file

@ -565,11 +565,13 @@ gst_test_http_src_set_property (GObject * object, guint prop_id,
case PROP_KEEP_ALIVE:
src->keep_alive = g_value_get_boolean (value);
break;
case PROP_METHOD:
case PROP_METHOD:{
guint i;
g_free (src->http_method_name);
src->http_method_name = g_value_dup_string (value);
src->http_method = METHOD_INVALID;
for (guint i = 0; gst_test_http_src_methods[i].name; ++i) {
for (i = 0; gst_test_http_src_methods[i].name; ++i) {
if (strcmp (gst_test_http_src_methods[i].name,
src->http_method_name) == 0) {
src->http_method = gst_test_http_src_methods[i].method;
@ -581,6 +583,7 @@ gst_test_http_src_set_property (GObject * object, guint prop_id,
trying to open a connection.
*/
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;