void IMB_metadata_set_field(struct IDProperty *metadata, const char *key, const char *value) { BLI_assert(metadata); IDProperty *prop = IDP_GetPropertyFromGroup(metadata, key); if (prop != NULL && prop->type != IDP_STRING) { IDP_FreeFromGroup(metadata, prop); prop = NULL; } if (prop == NULL) { prop = IDP_NewString(value, key, METADATA_MAX_VALUE_LENGTH); IDP_AddToGroup(metadata, prop); } IDP_AssignString(prop, value, METADATA_MAX_VALUE_LENGTH); }
static IDProperty *BKE_ffmpeg_property_add(RenderData *rd, const char *type, const AVOption *o, const AVOption *parent) { AVCodecContext c; IDProperty *group; IDProperty *prop; IDPropertyTemplate val; int idp_type; char name[256]; val.i = 0; avcodec_get_context_defaults3(&c, NULL); if (!rd->ffcodecdata.properties) { rd->ffcodecdata.properties = IDP_New(IDP_GROUP, &val, "ffmpeg"); } group = IDP_GetPropertyFromGroup(rd->ffcodecdata.properties, type); if (!group) { group = IDP_New(IDP_GROUP, &val, type); IDP_AddToGroup(rd->ffcodecdata.properties, group); } if (parent) { BLI_snprintf(name, sizeof(name), "%s:%s", parent->name, o->name); } else { BLI_strncpy(name, o->name, sizeof(name)); } PRINT("ffmpeg_property_add: %s %s\n", type, name); prop = IDP_GetPropertyFromGroup(group, name); if (prop) { return prop; } switch (o->type) { case AV_OPT_TYPE_INT: case AV_OPT_TYPE_INT64: val.i = FFMPEG_DEF_OPT_VAL_INT(o); idp_type = IDP_INT; break; case AV_OPT_TYPE_DOUBLE: case AV_OPT_TYPE_FLOAT: val.f = FFMPEG_DEF_OPT_VAL_DOUBLE(o); idp_type = IDP_FLOAT; break; case AV_OPT_TYPE_STRING: val.string.str = (char *)" "; val.string.len = 80; /* val.str = (char *)" ";*/ idp_type = IDP_STRING; break; case AV_OPT_TYPE_CONST: val.i = 1; idp_type = IDP_INT; break; default: return NULL; } prop = IDP_New(idp_type, &val, name); IDP_AddToGroup(group, prop); return prop; }
IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int parent_index) { AVCodecContext c; const AVOption * o; const AVOption * parent; IDProperty * group; IDProperty * prop; IDPropertyTemplate val; int idp_type; char name[256]; val.i = 0; avcodec_get_context_defaults(&c); o = c.av_class->option + opt_index; parent = c.av_class->option + parent_index; if (!rd->ffcodecdata.properties) { rd->ffcodecdata.properties = IDP_New(IDP_GROUP, val, "ffmpeg"); } group = IDP_GetPropertyFromGroup( rd->ffcodecdata.properties, (char*) type); if (!group) { group = IDP_New(IDP_GROUP, val, (char*) type); IDP_AddToGroup(rd->ffcodecdata.properties, group); } if (parent_index) { sprintf(name, "%s:%s", parent->name, o->name); } else { strcpy(name, o->name); } fprintf(stderr, "ffmpeg_property_add: %s %d %d %s\n", type, parent_index, opt_index, name); prop = IDP_GetPropertyFromGroup(group, name); if (prop) { return prop; } switch (o->type) { case FF_OPT_TYPE_INT: case FF_OPT_TYPE_INT64: val.i = FFMPEG_DEF_OPT_VAL_INT(o); idp_type = IDP_INT; break; case FF_OPT_TYPE_DOUBLE: case FF_OPT_TYPE_FLOAT: val.f = FFMPEG_DEF_OPT_VAL_DOUBLE(o); idp_type = IDP_FLOAT; break; case FF_OPT_TYPE_STRING: val.str = " "; idp_type = IDP_STRING; break; case FF_OPT_TYPE_CONST: val.i = 1; idp_type = IDP_INT; break; default: return NULL; } prop = IDP_New(idp_type, val, name); IDP_AddToGroup(group, prop); return prop; }