use BLI_strncpy and BLI_snprintf when the size of the string is known.
[blender-staging.git] / source / blender / blenkernel / intern / writeffmpeg.c
index bdca3c8e6186b497f6892125965679199bfe31b6..bcdd93ed70be1bd8093a3a154eeec2c4c5882228 100644 (file)
@@ -343,8 +343,8 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports)
 
        if (c->pix_fmt != PIX_FMT_BGR32) {
                sws_scale(img_convert_ctx, (const uint8_t * const*) rgb_frame->data,
-                         rgb_frame->linesize, 0, c->height, 
-                         current_frame->data, current_frame->linesize);
+                         rgb_frame->linesize, 0, c->height,
+                         current_frame->data, current_frame->linesize);
                delete_picture(rgb_frame);
        }
        return current_frame;
@@ -1046,7 +1046,7 @@ void ffmpeg_property_del(RenderData *rd, void *type, void *prop_)
        }
 }
 
-IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int parent_index)
+IDProperty *ffmpeg_property_add(RenderData *rd, const char *type, int opt_index, int parent_index)
 {
        AVCodecContext c;
        const AVOption * o;
@@ -1066,20 +1066,20 @@ IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int
 
        if (!rd->ffcodecdata.properties) {
                rd->ffcodecdata.properties 
-                       = IDP_New(IDP_GROUP, val, "ffmpeg"); 
+                       = IDP_New(IDP_GROUP, &val, "ffmpeg"); 
        }
 
        group = IDP_GetPropertyFromGroup(rd->ffcodecdata.properties, type);
        
        if (!group) {
-               group = IDP_New(IDP_GROUP, val, type);
+               group = IDP_New(IDP_GROUP, &val, type);
                IDP_AddToGroup(rd->ffcodecdata.properties, group);
        }
 
        if (parent_index) {
-               sprintf(name, "%s:%s", parent->name, o->name);
+               BLI_snprintf(name, sizeof(name), "%s:%s", parent->name, o->name);
        } else {
-               strcpy(name, o->name);
+               BLI_strncpy(name, o->name, sizeof(name));
        }
 
        fprintf(stderr, "ffmpeg_property_add: %s %d %d %s\n",
@@ -1102,7 +1102,9 @@ IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int
                idp_type = IDP_FLOAT;
                break;
        case FF_OPT_TYPE_STRING:
-               val.str = "                                                                               ";
+               val.string.str = (char *)"                                                                               ";
+               val.string.len = 80;
+/*             val.str = (char *)"                                                                               ";*/
                idp_type = IDP_STRING;
                break;
        case FF_OPT_TYPE_CONST:
@@ -1112,7 +1114,7 @@ IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int
        default:
                return NULL;
        }
-       prop = IDP_New(idp_type, val, name);
+       prop = IDP_New(idp_type, &val, name);
        IDP_AddToGroup(group, prop);
        return prop;
 }
@@ -1331,11 +1333,11 @@ void ffmpeg_set_preset(RenderData *rd, int preset)
        }
 }
 
-void ffmpeg_verify_image_type(RenderData *rd)
+void ffmpeg_verify_image_type(RenderData *rd, ImageFormatData *imf)
 {
        int audio= 0;
 
-       if(rd->imtype == R_FFMPEG) {
+       if(imf->imtype == R_IMF_IMTYPE_FFMPEG) {
                if(rd->ffcodecdata.type <= 0 ||
                   rd->ffcodecdata.codec <= 0 ||
                   rd->ffcodecdata.audio_codec <= 0 ||
@@ -1351,19 +1353,19 @@ void ffmpeg_verify_image_type(RenderData *rd)
 
                audio= 1;
        }
-       else if(rd->imtype == R_H264) {
+       else if(imf->imtype == R_IMF_IMTYPE_H264) {
                if(rd->ffcodecdata.codec != CODEC_ID_H264) {
                        ffmpeg_set_preset(rd, FFMPEG_PRESET_H264);
                        audio= 1;
                }
        }
-       else if(rd->imtype == R_XVID) {
+       else if(imf->imtype == R_IMF_IMTYPE_XVID) {
                if(rd->ffcodecdata.codec != CODEC_ID_MPEG4) {
                        ffmpeg_set_preset(rd, FFMPEG_PRESET_XVID);
                        audio= 1;
                }
        }
-       else if(rd->imtype == R_THEORA) {
+       else if(imf->imtype == R_IMF_IMTYPE_THEORA) {
                if(rd->ffcodecdata.codec != CODEC_ID_THEORA) {
                        ffmpeg_set_preset(rd, FFMPEG_PRESET_THEORA);
                        audio= 1;
@@ -1377,4 +1379,3 @@ void ffmpeg_verify_image_type(RenderData *rd)
 }
 
 #endif
-