Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://coin3d.github.io
https://www.kongsberg.com/en/kogt/
movie.c File Reference
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <config.h>
#include <simage.h>
#include <simage_private.h>
#include <string.h>
#include "../mpeg2enc/api.h"
#include "simage_avi.h"

Data Structures

struct  simage_movie_s
 
struct  simage_movie_importer
 
struct  simage_movie_exporter
 

Functions

static void add_internal_importers (void)
 
static void add_internal_exporters (void)
 
s_movies_movie_open (const char *filename)
 
s_movies_movie_create (const char *filename, s_params *params)
 
s_images_movie_get_image (s_movie *movie, s_image *prealloc, s_params *params)
 
int s_movie_put_image (s_movie *movie, s_image *image, s_params *params)
 
void s_movie_close (s_movie *movie)
 
void s_movie_destroy (s_movie *movie)
 
s_paramss_movie_params (s_movie *movie)
 
void s_movie_importer_add (s_movie_open_func *open, s_movie_get_func *get, s_movie_close_func *close)
 
void s_movie_exporter_add (s_movie_create_func *create, s_movie_put_func *put, s_movie_close_func *close)
 

Variables

static struct simage_movie_importerimporters
 
static struct simage_movie_exporterexporters
 

Function Documentation

◆ add_internal_importers()

static void add_internal_importers ( void  )
static

◆ add_internal_exporters()

static void add_internal_exporters ( void  )
static

◆ s_movie_open()

s_movie* s_movie_open ( const char *  filename)

◆ s_movie_create()

s_movie* s_movie_create ( const char *  filename,
s_params params 
)

Will create a new move file named filename and attempt to locate a suitable encoder based on the parameters ( params ) supplied.

Returns a pointer to the opened movie on success, NULL on failure

Common parameters:

  • "mime-type" <string> : The requested encoder type. There are currently 2 encoders available, with mime-types "video/mpeg" and "video/avi".
  • width <int> : Frame width (all input images must have this width)
  • height <int> : Frame height (all input images must have this height)

Parameters specific for the AVI encoder

  • fps <int> : Number of frames per second in output file
  • parameter file <int> : If this parameter is missing (or empty ""), a GUI will pop up each time this functions is run, asking the user to specify compression settings. If a filename is specified and the file doesn't exist, a GUI pops up, and the compression settings are saved in a new file with the specified filename. If the file exists, no GUI pops up, and the compression settings are read from the file. The format of the file is unspecified, and copying such a file between different computers probably won't work.
  • width and height must be divisible by 4

◆ s_movie_get_image()

s_image* s_movie_get_image ( s_movie movie,
s_image prealloc,
s_params params 
)

◆ s_movie_put_image()

int s_movie_put_image ( s_movie movie,
s_image image,
s_params params 
)

Adds (encodes) the image as one frame to the movie. params is currently used only for optimizing AVI encoding: - "allow image modification" <int> : Set to "1" to allow the encoder to modify the image buffer. If this parameter is not set, the encoder will make a local copy of the image before it is encoded.

Example code:

s_params *imgparams = s_params_create();
s_params_set(imgparams,
"allow image modification", S_INTEGER_PARAM_TYPE, 1,
NULL);
for(;;) {
s_image_set(image, width, height, 1, <get image from somewhere>);
for (int i=0; i<repeatCount;i++)
s_movie_put_image(movie, image, imgparams);
}
s_params_destroy(imgparams);

Returns 1 on success, 0 on failure

◆ s_movie_close()

void s_movie_close ( s_movie movie)

Closes the newly created movie file.

◆ s_movie_destroy()

void s_movie_destroy ( s_movie movie)

Cleans up all resources allocated by "<s_movie_create>"(...)

◆ s_movie_params()

s_params* s_movie_params ( s_movie movie)

◆ s_movie_importer_add()

void s_movie_importer_add ( s_movie_open_func open,
s_movie_get_func get,
s_movie_close_func close 
)

◆ s_movie_exporter_add()

void s_movie_exporter_add ( s_movie_create_func create,
s_movie_put_func put,
s_movie_close_func close 
)

Variable Documentation

◆ importers

struct simage_movie_importer* importers
static

◆ exporters

struct simage_movie_exporter* exporters
static