AnimaEngine  1.0.0
Nintendo DS Pokemon Black, White, Black 2, and White 2 sprite extraction and preview toolchain
Macros | Functions
gif_pipeline.c File Reference

Implementations of animation GIF processing pipelines. More...

#include "gif_pipeline.h"
#include "file_util.h"
#include "gif_writer.h"
#include "sprite_composer.h"

Macros

#define GIF_DIR_IDLE   "animated_idle_gif"
 
#define GIF_DIR_BREAK   "idle_break_gif"
 
#define GIF_DIR_OTHER   "animation_gif"
 

Functions

void GifExportOptions_Init (GifExportOptions *options)
 Initializes default values for a GifExportOptions structure. More...
 
static const char * GifDirectoryForAnimation (const char *animation_name)
 Resolves default directory path naming categorization based on animation type. More...
 
static int ResolveGifPlaybackDelayCs (const GifExportOptions *options)
 Resolves fallback delay duration constraints. More...
 
static int ResolveGifMapIndex (const GifExportOptions *options, int default_idle_map, int map_count)
 Selects active layout map index. More...
 
static int ResolveNmarTimelineIndex (const GifExportOptions *options, const NmarFile *nmar, const char *animation_name)
 Resolves timeline index associated with specified track label. More...
 
static int NmarFrameCountForGif (const NmarFile *nmar, int animation_index, int delay_cs)
 Computes amount of frames to generate for an NMAR sequence. More...
 
static void ComposerTransform_FromNmarFrame (const NmarFrame *frame, ComposerTransform *out_transform)
 Converts timeline track frame parameters to standard spatial coordinate transforms. More...
 
static void ComputeNmarBoundsRange (const NcerFile *ncer, const NanrFile *nanr, const NmcrFile *nmcr, const NmarFile *nmar, int animation_index, int start_frame, int frame_count, int *out_min_x, int *out_min_y, int *out_max_x, int *out_max_y, const CoordFile *coords, int delay_cs)
 Calculates bounding coordinates across a timeline range of NMAR animation tracks. More...
 
int GifPipeline_ExportIdle (const char *out_dir, const char *side_name, const char *animation_name, const char *palette_name, const NcerFile *ncer, const NanrFile *nanr, const NmcrFile *nmcr, const NmarFile *nmar, const NcgrImage *ncgr, const NclrPalette *palette, int default_idle_map, const GifExportOptions *options, int tile_stride, int margin, const int *union_min_x, const int *union_min_y, const int *union_max_x, const int *union_max_y, const CoordFile *coords)
 Assembles and exports a composed animated GIF based on provided resources. More...
 

Detailed Description

Implementations of animation GIF processing pipelines.

Macro Definition Documentation

◆ GIF_DIR_BREAK

#define GIF_DIR_BREAK   "idle_break_gif"

◆ GIF_DIR_IDLE

#define GIF_DIR_IDLE   "animated_idle_gif"

◆ GIF_DIR_OTHER

#define GIF_DIR_OTHER   "animation_gif"

Function Documentation

◆ ComposerTransform_FromNmarFrame()

static void ComposerTransform_FromNmarFrame ( const NmarFrame frame,
ComposerTransform out_transform 
)
static

Converts timeline track frame parameters to standard spatial coordinate transforms.

Parameters
frameSource timeline keyframe attributes.
out_transformTarget destination container.

◆ ComputeNmarBoundsRange()

static void ComputeNmarBoundsRange ( const NcerFile ncer,
const NanrFile nanr,
const NmcrFile nmcr,
const NmarFile nmar,
int  animation_index,
int  start_frame,
int  frame_count,
int *  out_min_x,
int *  out_min_y,
int *  out_max_x,
int *  out_max_y,
const CoordFile coords,
int  delay_cs 
)
static

Calculates bounding coordinates across a timeline range of NMAR animation tracks.

Parameters
ncerCells metadata.
nanrKeyframes mapping.
nmcrMulti-cell layouts.
nmarMulti-animation track details.
animation_indexTarget sequence track.
start_frameBeginning index.
frame_countAmount of frames to scan.
out_min_xOutput minimum X bound.
out_min_yOutput minimum Y bound.
out_max_xOutput maximum X bound.
out_max_yOutput maximum Y bound.
coordsCoordinates anchors.
delay_csFrame duration delay.

◆ GifDirectoryForAnimation()

static const char* GifDirectoryForAnimation ( const char *  animation_name)
static

Resolves default directory path naming categorization based on animation type.

Parameters
animation_nameCategory identifier ("idle", "break").
Returns
Read-only directory folder name string.

◆ GifExportOptions_Init()

void GifExportOptions_Init ( GifExportOptions options)

Initializes default values for a GifExportOptions structure.

Parameters
optionsPointer to options struct to modify.

◆ GifPipeline_ExportIdle()

int GifPipeline_ExportIdle ( const char *  out_dir,
const char *  side_name,
const char *  animation_name,
const char *  palette_name,
const NcerFile ncer,
const NanrFile nanr,
const NmcrFile nmcr,
const NmarFile nmar,
const NcgrImage ncgr,
const NclrPalette palette,
int  default_idle_map,
const GifExportOptions options,
int  tile_stride,
int  margin,
const int *  union_min_x,
const int *  union_min_y,
const int *  union_max_x,
const int *  union_max_y,
const CoordFile coords 
)

Assembles and exports a composed animated GIF based on provided resources.

Parameters
out_dirDirectory path to write output file.
side_nameLabel used in output filename (e.g., "front", "back").
animation_nameLabel representing animation sequence (e.g., "idle", "break").
palette_nameLabel for color variant (e.g., "normal", "shiny").
ncerPointer to the parsed cell resource file (.NCER).
nanrPointer to the parsed animation resource file (.NANR).
nmcrPointer to the parsed multi-cell mapping layout (.NMCR).
nmarPointer to the parsed multi-animation sequence (.NMAR).
ncgrPointer to the parsed character graphics tiles (.NCGR).
palettePointer to the parsed color palette resource (.NCLR).
default_idle_mapDefault layout index for species' base idle frame.
optionsExport configurations.
tile_strideWidth stride (in tiles) of NCGR image data.
marginSafety boundary width in pixels around the composed animation.
union_min_xPrecalculated bounding box minimum horizontal coordinate.
union_min_yPrecalculated bounding box minimum vertical coordinate.
union_max_xPrecalculated bounding box maximum horizontal coordinate.
union_max_yPrecalculated bounding box maximum vertical coordinate.
coordsOptional CoordFile pointers to adjust horizontal/vertical offsets.
Returns
0 on success; negative value on error.

◆ NmarFrameCountForGif()

static int NmarFrameCountForGif ( const NmarFile nmar,
int  animation_index,
int  delay_cs 
)
static

Computes amount of frames to generate for an NMAR sequence.

Parameters
nmarTimeline details.
animation_indexAnimation sequence index.
delay_csFrame duration.
Returns
Resolved total frame count.

◆ ResolveGifMapIndex()

static int ResolveGifMapIndex ( const GifExportOptions options,
int  default_idle_map,
int  map_count 
)
static

Selects active layout map index.

Parameters
optionsExport configurations.
default_idle_mapBase idle index.
map_countTotal maps available.
Returns
Resolved map index.

◆ ResolveGifPlaybackDelayCs()

static int ResolveGifPlaybackDelayCs ( const GifExportOptions options)
static

Resolves fallback delay duration constraints.

Parameters
optionsTarget export configurations.
Returns
Duration length in centiseconds.

◆ ResolveNmarTimelineIndex()

static int ResolveNmarTimelineIndex ( const GifExportOptions options,
const NmarFile nmar,
const char *  animation_name 
)
static

Resolves timeline index associated with specified track label.

Parameters
optionsExport configurations.
nmarTrack list details.
animation_nameTrack label string.
Returns
Resolved timeline index, or negative on failure.