1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
|
/* gap_drawable_vref_parasite.c
*
* This module handles gap specific video reference drawable parasites.
* Such parasites are typically used to identify extracted video file frames
* for usage in filtermacro as persistent drawable_id references at recording time of filtermacros.
*
* The gap player does attach such vref drawable parasites (as temporary parasites)
* when extracting a videoframe at original size (by click on the preview)
*
* Copyright (C) 2008 Wolfgang Hofer <hof@gimp.org>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <string.h>
#include "gap_drawable_vref_parasite.h"
extern int gap_debug; /* ==0 ... dont print debug infos */
/* ------------------------------------------
* gap_dvref_debug_print_GapDrawableVideoRef
* ------------------------------------------
*/
void
gap_dvref_debug_print_GapDrawableVideoRef(GapDrawableVideoRef *dvref)
{
if(gap_debug)
{
if(dvref == NULL)
{
printf("GapDrawableVideoRef: dvref:(null)\n");
return;
}
if(dvref->videofile == NULL)
{
printf("GapDrawableVideoRef: videofile:(null) frame:%d seltrack:%d (%s)\n"
,dvref->para.framenr
,dvref->para.seltrack
,&dvref->para.preferred_decoder[0]
);
return;
}
printf("GapDrawableVideoRef: videofile:%s frame:%d seltrack:%d (%s)\n"
,dvref->videofile
,dvref->para.framenr
,dvref->para.seltrack
,&dvref->para.preferred_decoder[0]
);
}
} /* end gap_dvref_debug_print_GapDrawableVideoRef */
/* -------------------
* gap_dvref_free
* -------------------
*/
void
gap_dvref_free(GapDrawableVideoRef **dvref_ptr)
{
GapDrawableVideoRef *dvref;
dvref = *dvref_ptr;
if (dvref)
{
if(dvref->videofile)
{
g_free(dvref->videofile);
}
g_free(dvref);
}
*dvref_ptr = NULL;
} /* end gap_dvref_free */
/* ---------------------------------------------------
* gap_dvref_get_drawable_video_reference_via_parasite
* ---------------------------------------------------
* return Gap drawable video reference parasite if such a parasite is atached to the specified drawable_id
* oterwise return NULL;
*/
GapDrawableVideoRef *
gap_dvref_get_drawable_video_reference_via_parasite(gint32 drawable_id)
{
GapDrawableVideoRef *dvref;
GimpParasite *l_parasite;
dvref = NULL;
l_parasite = gimp_drawable_parasite_find(drawable_id, GAP_DRAWABLE_VIDEOFILE_PARASITE_NAME);
if(l_parasite)
{
if(gap_debug)
{
printf("gap_dvref_get_drawable_video_reference_via_parasite: size:%d data:%s\n"
,l_parasite->size
,(char *)l_parasite->data
);
}
dvref = g_new(GapDrawableVideoRef, 1);
dvref->videofile = g_malloc0(l_parasite->size +1);
memcpy(dvref->videofile, l_parasite->data, l_parasite->size);
gimp_parasite_free(l_parasite);
l_parasite = gimp_drawable_parasite_find(drawable_id, GAP_DRAWABLE_VIDEOPARAMS_PARASITE_NAME);
if(l_parasite)
{
memcpy(&dvref->para, l_parasite->data, sizeof(GapDrawableVideoParasite));
gimp_parasite_free(l_parasite);
if(gap_debug)
{
printf("gap_dvref_get_drawable_video_reference_via_parasite: dvref PARASITES OK\n");
gap_dvref_debug_print_GapDrawableVideoRef(dvref);
}
return (dvref);
}
}
if(gap_debug)
{
printf("gap_dvref_get_drawable_video_reference_via_parasite: NO dvref parasites found.\n");
}
return (NULL);
} /* end gap_dvref_get_drawable_video_reference_via_parasite */
/* --------------------------------------
* gap_dvref_assign_videoref_parasites
* --------------------------------------
* if gpp->drawable_vref contains vaild video reference
* then
* assign video reference parasites to the specified drawable_id (typically this is a layer.)
* (one parasite contains only the videfilename and has variable length,
* the other contains framenumber and other information that was used to fetch
* the frame from the videofile).
*
* the video reference is typically set on successful fetch
* from a video file. (and reset on all other types of frame fetches)
*
+ TODO: query gimprc parameter that can configures using persitent drawable_videoref_parasites.
* (default shall be temporary parasites)
*/
void
gap_dvref_assign_videoref_parasites(GapDrawableVideoRef *dvref, gint32 drawable_id)
{
GimpParasite *l_parasite;
if(gap_debug)
{
printf("gap_assign_drawable_videoref_parasite: START\n");
gap_dvref_debug_print_GapDrawableVideoRef(dvref);
}
if(dvref->videofile == NULL)
{
/* no viedo reference available for the current frame */
return;
}
l_parasite = gimp_parasite_new(GAP_DRAWABLE_VIDEOFILE_PARASITE_NAME
,0 /* GIMP_PARASITE_PERSISTENT 0 for non persistent */
,1 + strlen(dvref->videofile)
,dvref->videofile /* parasite data */
);
if(l_parasite)
{
gimp_drawable_parasite_attach(drawable_id, l_parasite);
gimp_parasite_free(l_parasite);
}
l_parasite = gimp_parasite_new(GAP_DRAWABLE_VIDEOPARAMS_PARASITE_NAME
,0 /* GIMP_PARASITE_PERSISTENT */
,sizeof(GapDrawableVideoParasite)
,&dvref->para /* parasite data */
);
if(l_parasite)
{
gimp_drawable_parasite_attach(drawable_id, l_parasite);
gimp_parasite_free(l_parasite);
}
} /* end gap_dvref_assign_videoref_parasites */
|