X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.0%2Fcinelerra%2Ffilecr2.C;fp=cinelerra-5.0%2Fcinelerra%2Ffilecr2.C;h=0000000000000000000000000000000000000000;hb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd;hp=074076ec7b3106b4ce172be607ab698ec2a9c7fd;hpb=52fcc46226f9df46f9ce9d0566dc568455a7db0b;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.0/cinelerra/filecr2.C b/cinelerra-5.0/cinelerra/filecr2.C deleted file mode 100644 index 074076ec..00000000 --- a/cinelerra-5.0/cinelerra/filecr2.C +++ /dev/null @@ -1,279 +0,0 @@ - -/* - * CINELERRA - * Copyright (C) 2008 Adam Williams - * - * 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 "asset.h" -#include "bchash.h" -#include "clip.h" -#include "bccmodels.h" -#include "format.inc" -#include "file.h" -#include "filecr2.h" -#include "mutex.h" -#include -#include - - -extern "C" -{ -extern char dcraw_info[1024]; -extern float **dcraw_data; -extern int dcraw_alpha; -extern float dcraw_matrix[9]; -int dcraw_main (int argc, const char **argv); -} - - -FileCR2::FileCR2(Asset *asset, File *file) - : FileList(asset, file, "CR2LIST", ".cr2", FILE_CR2, FILE_CR2_LIST) -{ - reset(); - if(asset->format == FILE_UNKNOWN) - asset->format = FILE_CR2; -} - -FileCR2::~FileCR2() -{ -//printf("FileCR2::~FileCR2\n"); - close_file(); -} - - -void FileCR2::reset() -{ -} - -int FileCR2::check_sig(Asset *asset) -{ - char *ptr = strstr(asset->path, ".pcm"); - if(ptr) return 0; -//printf("FileCR2::check_sig %d\n", __LINE__); - FILE *stream = fopen(asset->path, "rb"); - - if(stream) - { - char test[10]; - (void)fread(test, 10, 1, stream); - fclose(stream); - - if(test[0] == 'C' && test[1] == 'R' && test[2] == '2' && - test[3] == 'L' && test[4] == 'I' && test[5] == 'S' && test[6] == 'T') - { -//printf("FileCR2::check_sig %d\n", __LINE__); - return 1; - } - } - -//printf("FileCR2::check_sig %d\n", __LINE__); - - - char string[BCTEXTLEN]; - int argc = 3; - - strcpy(string, asset->path); - - const char *argv[4] = - { - "dcraw", - "-i", - string, - 0 - }; - - int result = dcraw_main(argc, argv); - -//printf("FileCR2::check_sig %d %d\n", __LINE__, result); - - return !result; -} - -// int FileCR2::open_file(int rd, int wr) -// { -// -// int argc = 3; -// const char *argv[4] = -// { -// "dcraw", -// "-i", -// asset->path, -// 0 -// }; -// -// int result = dcraw_main(argc, argv); -// if(!result) format_to_asset(); -// -// return result; -// } - -int FileCR2::read_frame_header(char *path) -{ - int argc = 3; -printf("FileCR2::read_frame_header %d\n", __LINE__); - const char *argv[4] = - { - "dcraw", - "-i", - path, - 0 - }; - - int result = dcraw_main(argc, argv); - if(!result) format_to_asset(); - -printf("FileCR2::read_frame_header %d %d\n", __LINE__, result); - return result; -} - - - - -// int FileCR2::close_file() -// { -// return 0; -// } -// -void FileCR2::format_to_asset() -{ - asset->video_data = 1; - asset->layers = 1; - sscanf(dcraw_info, "%d %d", &asset->width, &asset->height); -} - - -int FileCR2::read_frame(VFrame *frame, char *path) -{ -//printf("FileCR2::read_frame\n"); - - if(frame->get_color_model() == BC_RGBA_FLOAT) - dcraw_alpha = 1; - else - dcraw_alpha = 0; - -// Want to disable interpolation if an interpolation plugin is on, but -// this is impractical because of the amount of caching. The interpolation -// could not respond to a change in the plugin settings and it could not -// reload the frame after the plugin was added. Also, since an 8 bit -// PBuffer would be required, it could never have enough resolution. -// int interpolate = 0; -// if(!strcmp(frame->get_next_effect(), "Interpolate Pixels")) -// interpolate = 0; - - -// printf("FileCR2::read_frame %d\n", interpolate); -// frame->dump_stacks(); -// output to stdout - int argc = 0; - char *argv[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - argv[argc++] = (char*)"dcraw"; -// write to stdout - argv[argc++] = (char*)"-c"; -// no rotation - argv[argc++] = (char*)"-j"; - -// printf("FileCR2::read_frame %d interpolate=%d white_balance=%d\n", -// __LINE__, -// file->interpolate_raw, -// file->white_balance_raw); - -// Use camera white balance. -// Before 2006, DCraw had no Canon white balance. -// In 2006 DCraw seems to support Canon white balance. -// Still no gamma support. -// Need to toggle this in preferences because it defeats dark frame subtraction. - if(file->white_balance_raw) - argv[argc++] = (char*)"-w"; - - - if(!file->interpolate_raw) - { -// Trying to do everything but interpolate doesn't work because convert_to_rgb -// doesn't work with bayer patterns. -// Use document mode and hack dcraw to apply white balance in the write_ function. - argv[argc++] = (char*)"-d"; - } - -printf("FileCR2::read_frame %d %s\n", __LINE__, path); - argv[argc++] = path; - - dcraw_data = (float**)frame->get_rows(); - -//Timer timer; - int result = dcraw_main(argc, (const char**) argv); - -// This was only used by the bayer interpolate plugin, which itself created -// too much complexity to use effectively. -// It required bypassing the cache any time a plugin parameter changed -// to store the color matrix from dcraw in the frame stack along with the new -// plugin parameters. The cache couldn't know if a parameter in the stack came -// from dcraw or a plugin & replace it. - char string[BCTEXTLEN]; - sprintf(string, - "%f %f %f %f %f %f %f %f %f\n", - dcraw_matrix[0], - dcraw_matrix[1], - dcraw_matrix[2], - dcraw_matrix[3], - dcraw_matrix[4], - dcraw_matrix[5], - dcraw_matrix[6], - dcraw_matrix[7], - dcraw_matrix[8]); - - - frame->get_params()->update("DCRAW_MATRIX", string); - -// frame->dump_params(); - - return result; -} - -int FileCR2::colormodel_supported(int colormodel) -{ - if(colormodel == BC_RGB_FLOAT || - colormodel == BC_RGBA_FLOAT) - return colormodel; - return BC_RGB_FLOAT; -} - - -// Be sure to add a line to File::get_best_colormodel -int FileCR2::get_best_colormodel(Asset *asset, int driver) -{ -//printf("FileCR2::get_best_colormodel %d\n", __LINE__); - return BC_RGB_FLOAT; -} - -// int64_t FileCR2::get_memory_usage() -// { -// int64_t result = asset->width * asset->height * sizeof(float) * 3; -// //printf("FileCR2::get_memory_usage %d " _LD "\n", __LINE__, result); -// return result; -// } - - -int FileCR2::use_path() -{ - return 1; -} - - - - -