Example #1
0
void *transcode_thread(void *arg)
{
    
    //fprintf(stdout, "[FFmpeg-video thread] transcode thread [%d] created\n",thread_count++);
    VideoState *is = (VideoState *)arg;
    int index;
    for(;;)
    {
        if(is->quit)
        {
            break;
        }
        pthread_mutex_lock(&is->mutex);
        pthread_cond_wait(&is->cond, &is->mutex);
        index=get_frame_status(is, FRAME_WAIT_TRANSCODE);
        pthread_mutex_unlock(&is->mutex);
        if(index!=FRAME_SIZE)
        {
            init_picture(is, index);
            set_frame_status(is, FRAME_WAIT_READ);
        }
    }
    fprintf(stdout, "[FFmpeg-transcode thread] thread terminated\n");
    return NULL;
}
static GstVaapiDecoderStatus
decode_picture (GstVaapiDecoderVp8 * decoder, const guchar * buf,
    guint buf_size)
{
  GstVaapiDecoderVp8Private *const priv = &decoder->priv;
  GstVaapiPicture *picture;
  GstVaapiDecoderStatus status;

  status = ensure_context (decoder);
  if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
    return status;

  /* Create new picture */
  picture = GST_VAAPI_PICTURE_NEW (VP8, decoder);
  if (!picture) {
    GST_ERROR ("failed to allocate picture");
    return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
  }
  gst_vaapi_picture_replace (&priv->current_picture, picture);
  gst_vaapi_picture_unref (picture);

  status = ensure_quant_matrix (decoder, picture);
  if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
    return status;

  status = ensure_probability_table (decoder, picture);
  if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
    return status;

  init_picture (decoder, picture);
  if (!fill_picture (decoder, picture))
    return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;

  return decode_slice (decoder, picture, buf, buf_size);
}
Example #3
0
void	Gui::dump()
{
  init_picture();
  SDL_FillRect(screen, NULL, 0);
  aff_score(0);
  handleEvents();
}
Example #4
0
int main(int argc, char **argv)
{
    struct parameters params;
    uint32_t *picture;
    struct list *koch;

    init_parameters(&params, argc, argv);
    init_koch(&koch, params.image_size, params.segment_length);
    
    if (!params.all_images) {
      init_picture(&picture, params.image_size, params.bg_color);
      generer_koch(koch, params.nb_iterations);
      render_image_bresenham(picture, koch, params.image_size, params.fg_color);
      create_image_ppm(picture, params.image_size, params.image_size, params.outfile);
    } else {
      // Iteration 0
      char fname[strlen(params.outfile)];
      sprintf(fname, "0%d_", 0);
      strcat(fname, params.outfile);

      init_picture(&picture, params.image_size, params.bg_color);
      render_image_bresenham(picture, koch, params.image_size, params.fg_color);
      create_image_ppm(picture, params.image_size, params.image_size, fname);

      for (uint32_t i = 0; i < params.nb_iterations; i++) {
        // Iteration i+1
        char fname[strlen(params.outfile)];
        if (i+1 < 10) sprintf(fname, "0%d_", (int) i+1);
        else sprintf(fname, "%d_", (int) i+1);
        strcat(fname, params.outfile);

        init_picture(&picture, params.image_size, params.bg_color);
        generer_koch(koch, 1);
        render_image_bresenham(picture, koch, params.image_size, params.fg_color);
        create_image_ppm(picture, params.image_size, params.image_size, fname);
      }
    }

    free_koch(koch);

    return EXIT_SUCCESS;
}
Example #5
0
void	Gui::dump() 
{
  glClear(GL_COLOR_BUFFER_BIT);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  init_picture(m_nibbler.getMap());
  glEnd();
  glFlush();
  aff_score(0);
  SDL_GL_SwapBuffers();   
  handleEvents(); 
}
Example #6
0
void *video_thread(void *arg)
{
    //fprintf(stdout, "[FFmpeg-decode thread] video_thread created\n");
    VideoState *is = (VideoState *)arg;
    AVPacket pkt1, *packet = &pkt1;
    int frameFinished=0;
    int index=0;

    //pthread_create(&is->trans_tid, NULL, transcode_thread, (void *)is);
    
    //fprintf(stdout, "[FFmpeg-video thread] decode frame\n");
    index=get_frame_status(is,FRAME_WAIT_WRITE);
    for(;;)
    {
        if(is->quit)
        {
            break;
        }
        if(packet_queue_get(&is->videoq, packet, 1) < 0)
        {
            // means we quit getting packets
            break;
        }
        // Decode video frame
        
        avcodec_decode_video2(is->video_st->codec, is->frames[0], &frameFinished, packet);
        //fprintf(stdout,"Current packs in queue:%d\n",is->videoq.nb_packets);
        if(frameFinished)
        {
            init_picture(is, 0);

//            if(index!=FRAME_SIZE)
//            {
//                pthread_mutex_lock(&is->mutex);
//                pthread_cond_signal(&is->cond);
//                set_frame_status(is, FRAME_WAIT_TRANSCODE);
//                pthread_mutex_unlock(&is->mutex);
//            }
//            index=get_frame_status(is,FRAME_WAIT_WRITE);
        }
        av_free_packet(packet);
    }
    
    fprintf(stdout, "[FFmpeg-video thread] thread terminated\n");
    return NULL;
}
Example #7
0
int 
main (int argc, char *argv[]) 
{
  
    int n_iter,			/* degre de nettete  */  
	x_size, y_size;		/* & dimensions de l'image */  
    double x_min, x_max, y_min, y_max; /* bornes de la representation */
    char *pathname;		/* fichier destination */
    picture_t pict;

    parse_argv(argc, argv, 
	       &n_iter, 
	       &x_min, &x_max, &y_min, &y_max, 
	       &x_size, &y_size, &pathname);

    init_picture (& pict, x_size, y_size);
    compute (& pict, n_iter, x_min, x_max, y_min, y_max);
    save_picture (& pict, pathname);

    exit(EXIT_SUCCESS);
}
Example #8
0
/* Programme "Flocon de Koch" */
int main(int argc, char *argv[])
{
	struct parameters parameters;
	struct list *koch = NULL;
	uint32_t *picture = NULL;
	char *outfile = NULL;
	bool screenshots = false;

	srand(time(NULL));

#ifdef PSP2
	vita2d_init();
	vita2d_set_clear_color(RGBA8(0, 0, 0, 0xFF));

	vita2d_texture *tex = vita2d_create_empty_texture(960, 544);
	uint32_t *tex_data = vita2d_texture_get_datap(tex);

	SceCtrlData pad, lastbuttons;
	memset(&pad, 0, sizeof(pad));
#endif


	/* Initialisations */
	init_parameters(&parameters, argc, argv);
	show_parameters(parameters);
	init_koch(&koch, parameters.image_size, parameters.segment_length);
	outfile = malloc(3 + strlen(parameters.outfile) + 1);


	int32_t i = 0, step = 1;
	bool done = false;

	/* Génération de chaque flocon */
	while (!done)
	{
#ifdef PSP2
		lastbuttons = pad;

		sceCtrlPeekBufferPositive(0, &pad, 1);
		if (pad.buttons & PSP2_CTRL_TRIANGLE) break;


		if (PRESSED(lastbuttons.buttons, pad.buttons, PSP2_CTRL_LTRIGGER))
			parameters.fg_color = RGBA8(rand()%255, rand()%255, rand()%255, 255);

		//if (PRESSED(lastbuttons.buttons, pad.buttons, PSP2_CTRL_RTRIGGER))
		//	screenshots ^= 1;

		vita2d_start_drawing();
		vita2d_clear_screen();
#endif
		sprintf(outfile, "%02d_%s", i, parameters.outfile);

		if (step > 0)
			generer_koch(koch, i);
		else {

			for (uint32_t j = 0; j < i; j++)
				generer_koch(koch, j);
		}
		//show_koch_list(koch);

		/* Ne générer l'image que si c'est la dernière ou qu'on les génère toutes */
		if (parameters.all_images || i == parameters.nb_iterations)
		{
			init_picture(&picture, parameters.image_size, parameters.bg_color);

			render_image_bresenham(picture, koch, parameters.image_size, parameters.fg_color);

			#ifndef PSP2

			const uint32_t LEN = 960 * 544;

			uint32_t *data = calloc(LEN, sizeof(uint32_t));

			for (uint32_t i = 0; i < LEN; i++)
				data[i] = 0;


			uint32_t k = 0;

			for (uint32_t i = 0; i < 544; i++)
				for (uint32_t j = 0; j < 960; j++) {

					if (208 <= j && j < 752 && k < 544*544)
						data[i * 960 + j] = picture[k++];

					else
						data[i * 960 + j] = 0;
				}

			create_image(data, 960, 544, outfile);
			//create_image(picture, parameters.image_size, parameters.image_size, outfile);
			#else

			uint32_t k = 0;
			for (uint32_t i = 0; i < 544; i++)
				for (uint32_t j = 0; j < 960; j++) {

					if (208 <= j && j < 752 && k < 544*544)
						tex_data[i * 960 + j] = picture[k++];

					else
						tex_data[i * 960 + j] = 0;
				}

			if (screenshots)
				create_image(tex_data, 960, 544, outfile);

			#endif
		}


#ifdef PSP2
		vita2d_draw_texture(tex, 0, 0);
		vita2d_end_drawing();
		vita2d_swap_buffers();
		sceKernelDelayThread(100000);
#endif



		i = i + step;


		if (i == parameters.nb_iterations)
#ifdef PSP2
			i--, step = -1;
#else
			done = true;
#endif

		else if (i == 0) {
			step = 1;
			free_koch(koch);
			init_koch(&koch, parameters.image_size, parameters.segment_length);
		}

		if (step < 0) {
			free_koch(koch);
			init_koch(&koch, parameters.image_size, parameters.segment_length);
		}

		if (parameters.nb_iterations == 1)
			done = true;
	}