Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / asset.C
index fd6e97e4436f738e172c4215ecf034655c52c885..59454153a5b92ea40079a5b334b48c86e905a6da 100644 (file)
@@ -132,7 +132,11 @@ int Asset::init_values()
 
        ac3_bitrate = 128;
 
+       flac_compression = 0;
+
        png_use_alpha = 0;
+       png_depth = 8;
+       png_compression = 0;
 
        exr_use_alpha = 0;
        exr_compression = 0;
@@ -163,7 +167,9 @@ void Asset::reset_video()
        actual_width = width = 0;
        actual_height = height = 0;
        proxy_scale = 0; // not a proxy
+       proxy_edl = 0; // not proxy from edl
        video_length = 0;
+       timecode = -2; // unknown
        single_frame = 0;
        vmpeg_cmodel = BC_YUV420P;
        frame_rate = 0;
@@ -177,9 +183,9 @@ void Asset::boundaries()
 // sample_rate & frame_rate are user defined
 //     CLAMP(sample_rate, 1, 1000000);
 //     CLAMP(frame_rate, 0.001, 1000000);
-       CLAMP(channels, 0, 16);
-       CLAMP(width, 0, 10000);
-       CLAMP(height, 0, 10000);
+       CLAMP(channels, 0, MAX_CHANNELS-1);
+       CLAMP(width, 0, ASSET_MAX_WIDTH);
+       CLAMP(height, 0, ASSET_MAX_HEIGHT);
 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
 }
 
@@ -214,6 +220,7 @@ void Asset::copy_format(Asset *asset, int do_index)
        use_header = asset->use_header;
        aspect_ratio = asset->aspect_ratio;
        interlace_mode = asset->interlace_mode;
+       timecode = asset->timecode;
 
        video_data = asset->video_data;
        layers = asset->layers;
@@ -224,6 +231,7 @@ void Asset::copy_format(Asset *asset, int do_index)
        actual_width = asset->actual_width;
        actual_height = asset->actual_height;
        proxy_scale = asset->proxy_scale;
+       proxy_edl = asset->proxy_edl;
        strcpy(vcodec, asset->vcodec);
        strcpy(acodec, asset->acodec);
 
@@ -279,13 +287,16 @@ void Asset::copy_format(Asset *asset, int do_index)
        ac3_bitrate = asset->ac3_bitrate;
 
        png_use_alpha = asset->png_use_alpha;
+       png_depth = asset->png_depth;
+       png_compression = asset->png_compression;
        exr_use_alpha = asset->exr_use_alpha;
        exr_compression = asset->exr_compression;
 
        tiff_cmodel = asset->tiff_cmodel;
        tiff_compression = asset->tiff_compression;
-       
-       
+
+       flac_compression = asset->flac_compression;
+
        mov_sphere = asset->mov_sphere;
        jpeg_sphere = asset->jpeg_sphere;
 }
@@ -361,11 +372,6 @@ int Asset::equivalent(Asset &asset, int test_audio, int test_video, EDL *edl)
                        header == asset.header &&
                        dither == asset.dither &&
                        !strcmp(acodec, asset.acodec));
-               if( result && format == FILE_FFMPEG )
-                       result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
-                               !strcmp(ff_sample_format, asset.ff_sample_format) &&
-                               ff_audio_bitrate == asset.ff_audio_bitrate &&
-                               ff_audio_quality == asset.ff_audio_quality;
        }
 
 
@@ -373,19 +379,13 @@ int Asset::equivalent(Asset &asset, int test_audio, int test_video, EDL *edl)
                result = (layers == asset.layers &&
                        program == asset.program &&
                        frame_rate == asset.frame_rate &&
-                       asset.interlace_mode    == interlace_mode &&
+                       asset.interlace_mode == interlace_mode &&
+                       asset.timecode == timecode &&
                        width == asset.width &&
                        height == asset.height &&
                        !strcmp(vcodec, asset.vcodec) &&
                        mov_sphere == asset.mov_sphere &&
                        jpeg_sphere == asset.jpeg_sphere);
-               if( result && format == FILE_FFMPEG )
-                       result = !strcmp(ff_video_options, asset.ff_video_options) &&
-                               !strcmp(ff_pixel_format, asset.ff_pixel_format) &&
-                               ff_video_bitrate == asset.ff_video_bitrate &&
-                               ff_video_quality == asset.ff_video_quality &&
-                               ff_color_space == asset.ff_color_space &&
-                               ff_color_range == asset.ff_color_range;
        }
 
        return result;
@@ -467,6 +467,7 @@ int Asset::read_video(FileXML *file)
        height = file->tag.get_property("HEIGHT", height);
        width = file->tag.get_property("WIDTH", width);
        proxy_scale = file->tag.get_property("PROXY_SCALE", 0);
+       proxy_edl = file->tag.get_property("PROXY_EDL", 0);
        layers = file->tag.get_property("LAYERS", layers);
        program = file->tag.get_property("PROGRAM", program);
 // This is loaded from the index file after the EDL but this
@@ -476,6 +477,7 @@ int Asset::read_video(FileXML *file)
        file->tag.get_property("VCODEC", vcodec);
 
        video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
+       timecode = file->tag.get_property("TIMECODE", -2);
        mov_sphere = file->tag.get_property("MOV_SPHERE", 0);
        jpeg_sphere = file->tag.get_property("JPEG_SPHERE", 0);
        single_frame = file->tag.get_property("SINGLE_FRAME", (int64_t)0);
@@ -635,6 +637,7 @@ int Asset::write_video(FileXML *file)
        file->tag.set_property("HEIGHT", height);
        file->tag.set_property("WIDTH", width);
        file->tag.set_property("PROXY_SCALE", proxy_scale);
+       file->tag.set_property("PROXY_EDL", proxy_edl);
        file->tag.set_property("LAYERS", layers);
        file->tag.set_property("PROGRAM", program);
        file->tag.set_property("FRAMERATE", frame_rate);
@@ -642,6 +645,7 @@ int Asset::write_video(FileXML *file)
                file->tag.set_property("VCODEC", vcodec);
 
        file->tag.set_property("VIDEO_LENGTH", video_length);
+       file->tag.set_property("TIMECODE", timecode);
        file->tag.set_property("MOV_SPHERE", mov_sphere);
        file->tag.set_property("JPEG_SPHERE", jpeg_sphere);
        file->tag.set_property("SINGLE_FRAME", single_frame);
@@ -738,6 +742,7 @@ void Asset::load_defaults(BC_Hash *defaults,
                actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
                actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
                proxy_scale = GET_DEFAULT("PROXY_SCALE", proxy_scale);
+               proxy_edl = GET_DEFAULT("PROXY_SCALE", proxy_edl);
                program = GET_DEFAULT("PROGRAM", program);
                layers = GET_DEFAULT("LAYERS", layers);
                if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
@@ -792,21 +797,17 @@ void Asset::load_defaults(BC_Hash *defaults,
        vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
        vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
 
-       theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
-       theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
-       theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
-       theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
-       theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
-       theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
-
 
        ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
 
        png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
+       png_depth = GET_DEFAULT("PNG_DEPTH", png_depth);
+       png_compression = GET_DEFAULT("PNG_COMPRESSION", png_compression);
        exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
        exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
        tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
        tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
+       flac_compression = GET_DEFAULT("FLAC_COMPRESSION", flac_compression);
 
        mov_sphere = GET_DEFAULT("MOV_SPHERE", mov_sphere);
        jpeg_sphere = GET_DEFAULT("JPEG_SPHERE", jpeg_sphere);
@@ -899,12 +900,14 @@ void Asset::save_defaults(BC_Hash *defaults,
 
 
                UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
+               UPDATE_DEFAULT("PNG_DEPTH", png_depth);
+               UPDATE_DEFAULT("PNG_COMPRESSION", png_compression);
                UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
                UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
                UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
                UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
 
-
+               UPDATE_DEFAULT("FLAC_COMPRESSION", flac_compression);
 
                UPDATE_DEFAULT("MOV_SPHERE", mov_sphere);
                UPDATE_DEFAULT("JPEG_SPHERE", jpeg_sphere);
@@ -937,6 +940,7 @@ void Asset::save_defaults(BC_Hash *defaults,
                UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
                UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
                UPDATE_DEFAULT("PROXY_SCALE", proxy_scale);
+               UPDATE_DEFAULT("PROXY_EDL", proxy_edl);
                UPDATE_DEFAULT("PROGRAM", program);
                UPDATE_DEFAULT("LAYERS", layers);
                UPDATE_DEFAULT("FRAMERATE", frame_rate);
@@ -982,11 +986,10 @@ int Asset::dump(FILE *fp)
                " height %d vcodec %s aspect_ratio %f ilace_mode %s\n",
                video_data, layers, program, frame_rate, width, height,
                vcodec, aspect_ratio,string);
-       fprintf(fp,"   actual_width %d actual_height %d proxy_scale %d"
-               " video_length %jd repeat %d\n",
-               actual_width, actual_height, proxy_scale, video_length,
-               single_frame);
-       fprintf(fp,"   video_length %jd repeat %d\n", video_length, single_frame);
+       fprintf(fp,"   actual_width %d actual_height %d proxy_scale %d proxy_edl %d\n",
+               actual_width, actual_height, proxy_scale, proxy_edl);
+       fprintf(fp,"   video_length %jd repeat %d timecode %f\n",
+               video_length, single_frame, timecode);
        fprintf(fp,"   mov_sphere=%d jpeg_sphere=%d\n", mov_sphere, jpeg_sphere);
        return 0;
 }