# with system_build
cinstall:
cd bin; $(inst_sh) "$(DESTDIR)$(bindir)" "$(WANT_CIN)" \
- cin_db mpeg3{cat,cc2txt,ifochk,show,toc}
+ cin_db zmpeg3{cat,cc2txt,ifochk,show,toc}
cd bin; $(inst_sh) "$(DESTDIR)$(WANT_CINLIB_DIR)" \
bdwrite cutads hveg2enc mpeg2enc mplex mplexlo
cd bin; $(inst_sh) "$(DESTDIR)$(datadir)/$(WANT_CIN)" \
cuninstall:
rm -f "$(DESTDIR)$(bindir)/$(WANT_CIN)"
- rm -f "$(DESTDIR)$(bindir)"/mpeg3{cat,cc2txt,ifochk,show,toc}
+ rm -f "$(DESTDIR)$(bindir)"/zmpeg3{cat,cc2txt,ifochk,show,toc}
rm -f "$(DESTDIR)$(bindir)/cin_db"
rm -rf "$(DESTDIR)$(WANT_CINLIB_DIR)"
rm -rf "$(DESTDIR)$(datadir)/$(WANT_CIN)"
$(CXX) `cat $(OBJDIR)/c_flags` -O3 -c $< -o $@
$(DCRAW): dcraw.c
- $(GCC) `cat $(OBJDIR)/c_flags` -O4 -Wno-misleading-indentation dcraw.c -c -o $*.o
+ $(GCC) `cat $(OBJDIR)/c_flags` $(if $(findstring -ggdb,$(CFLAGS)),,-O4) -c -o $*.o \
+ -Wno-misleading-indentation -Wno-sign-compare -Wno-narrowing dcraw.c
$(THEME_DATA):
cd $(OBJDIR) && \
y += operation[CWINDOW_TOOL_WINDOW]->get_h();
subwindow->add_subwindow(operation[CWINDOW_TITLESAFE] = new CPanelTitleSafe(mwindow, this, x, y));
y += operation[CWINDOW_TITLESAFE]->get_h();
- x += (w - BC_Slider::get_span(1)) / 2;
- subwindow->add_subwindow(cpanel_zoom = new CPanelZoom(mwindow, this, x, y+15, h-y-15));
+ x += (w - BC_Slider::get_span(1)) / 2; y += 15;
+ subwindow->add_subwindow(cpanel_zoom = new CPanelZoom(mwindow, this, x, y, h-y-20));
}
-void CPanel::reposition_buttons(int x, int y)
+void CPanel::reposition_buttons(int x, int y, int h)
{
this->x = x;
this->y = y;
+ this->h = h;
for(int i = 0; i < CPANEL_OPERATIONS; i++)
{
y += operation[i]->get_h();
}
x += (w - BC_Slider::get_span(1)) / 2;
- cpanel_zoom->reposition_window(x, y+15);
+ y += 15;
+ h = this->h - this->y;
+ cpanel_zoom->reposition_window(x, y, w, h-y-20);
+ cpanel_zoom->set_pointer_motion_range(h);
}
}
CPanelZoom::CPanelZoom(MWindow *mwindow, CPanel *gui, int x, int y, int h)
- : BC_FSlider(x, y, 1, h-30, h, -2., 2., 0, 0)
+ : BC_FSlider(x, y, 1, h, h, -2., 2., 0, 0)
{
this->mwindow = mwindow;
this->gui = gui;
~CPanel();
void create_objects();
- void reposition_buttons(int x, int y);
+ void reposition_buttons(int x, int y, int h);
void set_operation(int value);
MWindow *mwindow;
flash(0);
composite_panel->reposition_buttons(mwindow->theme->ccomposite_x,
- mwindow->theme->ccomposite_y);
+ mwindow->theme->ccomposite_y, mwindow->theme->ccomposite_h);
canvas->reposition_window(mwindow->edl,
mwindow->theme->ccanvas_x,
#define ULIM(x,y,z) ((y) < (z) ? LIM(x,y,z) : LIM(x,z,y))
#define CLIP(x) LIM((int)(x),0,65535)
#define SWAP(a,b) { a=a+b; b=a-b; a=a-b; }
-
/*
In order to inline this calculation, I make the risky
assumption that all filter patterns can be described
// CINELERRA
static void reset()
{
- shot_select=0;
- multi_out=0;
- aber[0]=1; aber[1]=1; aber[2]=1; aber[3]=1;
- gamm[0]=0.45; gamm[1]=4.5; gamm[2]=0; gamm[3]=0; gamm[4]=0; gamm[5]=0;
- bright=1;
- user_mul[0]=0; user_mul[1]=0; user_mul[2]=0; user_mul[3]=0;
- threshold=0;
- half_size=0;
- four_color_rgb=0;
- document_mode=0;
- highlight=0;
- verbose=0;
- use_auto_wb=0;
- use_camera_wb=0;
- use_camera_matrix=1;
- output_color=1;
- output_bps=8;
- output_tiff=0;
- med_passes=0;
- no_auto_bright=0;
- greybox[0]=0; greybox[1]=0; greybox[2]=UINT_MAX; greybox[3]=UINT_MAX;
+// uninitialized
+#define ZERO(var) memset(&var, 0, sizeof var);
+ aperture = 0;
+ ZERO(artist);
+ black = 0;
+ ZERO(cam_mul)
+ canon_ev = 0;
+ ZERO(cblack);
+ ZERO(cmatrix);
+ ZERO(cdesc);
+ colors = 0;
+ ZERO(cr2_slice);
+ ZERO(curve);
+ data_error = 0;
+ data_offset = 0;
+ dng_version = 0;
+ exif_cfa = 0;
+ ZERO(failure);
+ filters = 0;
+ ZERO(first_decode);
+ flash_used = 0;
+ flip = 0;
+ focal_len = 0;
+ fuji_layout = 0;
+ fuji_width = 0;
+ ZERO(gpsdata);
+ height = 0;
+ ZERO(histogram);
+ ifname = 0;
+ ifp = 0;
+ iheight = 0;
+ is_foveon = 0;
+ iso_speed = 0;
+ is_raw = 0;
+ iwidth = 0;
+ kodak_cbpp = 0;
+ left_margin = 0;
+ load_flags = 0;
+ load_raw = 0;
+ maximum = 0;
+ meta_data = 0;
+ meta_length = 0;
+ meta_offset = 0;
+ mix_green = 0;
+ ZERO(model);
+ ZERO(model2);
+ ofp = 0;
+ oprof = 0;
+ order = 0;
+ ZERO(ph1);
+ pixel_aspect = 0;
+ memset(pre_mul, 0, sizeof pre_mul);
+ profile_length = 0;
+ profile_offset = 0;
+ raw_color = 0;
+ raw_height = 0;
+ raw_width = 0;
+ raw_image = 0;
+ memset(rgb_cam, 0, sizeof rgb_cam);
+ shot_order = 0;
+ shrink = 0;
+ shutter = 0;
+ strip_offset = 0;
+ thumb_height = 0;
+ thumb_length = 0;
+ thumb_load_raw = 0;
+ thumb_misc = 0;
+ thumb_offset = 0;
+ thumb_width = 0;
+ tiff_bps = 0;
+ tiff_compress = 0;
+ tiff_flip = 0;
+ tiff_nifds = 0;
+ tiff_samples = 0;
+ tile_length = 0;
+ tile_width = 0;
+ timestamp = 0;
+ top_margin = 0;
+ unique_id = 0;
+ ZERO(white);
+ width = 0;
+ zero_after_ff = 0;
+ zero_is_bad = 0;
+
+// initializer data
+ shot_select = 0;
+ multi_out = 0;
+ aber[0] = aber[1] = aber[2] = aber[3] = 1;
+ gamm[0] = 0.45; gamm[1] = 4.5; gamm[2] = 0;
+ gamm[3] = 0; gamm[4] = 0; gamm[5] = 0;
+ bright = 1;
+ ZERO(user_mul);
+ threshold = 0;
+ half_size = 0;
+ four_color_rgb = 0;
+ document_mode = 0;
+ highlight = 0;
+ verbose = 0;
+ use_auto_wb = 0;
+ use_camera_wb = 0;
+ use_camera_matrix = 1;
+ output_color = 1;
+ output_bps = 8;
+ output_tiff = 0;
+ med_passes = 0;
+ no_auto_bright = 0;
+ greybox[0] = 0; greybox[1] = 0;
+ greybox[2] = UINT_MAX; greybox[3] = UINT_MAX;
}
#if 0
{
void *dp;
unsigned dim[3];
-// CINELERRA
- memset (ptr, 0, size*4);
+
if (!name) return 0;
dp = foveon_camf_matrix (dim, name);
if (!dp) return 0;
if (flip == UINT_MAX) flip = 0;
// CINELERRA
- if (flip & 4)
- sprintf(dcraw_info, "%d %d", height, width);
+{ unsigned flp = flip;
+ switch ((flp+3600) % 360) {
+ case 270: flp = 5; break;
+ case 180: flp = 3; break;
+ case 90: flp = 6;
+ }
+ if( (flp & 4) )
+ sprintf(dcraw_info, "%d %d", height, width);
else
- sprintf(dcraw_info, "%d %d", width, height);
+ sprintf(dcraw_info, "%d %d", width, height); }
}
#ifndef NO_LCMS
}
// CINELERRA
-void CLASS write_cinelerra (FILE *ofp)
-{
- int row, col;
- float *output;
-
- for (row = 0; row < height; row++)
- {
- output = dcraw_data[row];
-
- if(document_mode)
- {
- for (col = 0; col < width; col++)
- {
- ushort *pixel = image[row * width + col];
-
- *output++ = (float)pixel[0] / 0xffff;
- *output++ = (float)pixel[1] / 0xffff;
- *output++ = (float)pixel[2] / 0xffff;
-
- if(dcraw_alpha) *output++ = 1.0;
+void CLASS write_cinelerra()
+{
+ int c, row, col, soff, cstep, rstep;
+ float scale = 1. / 0xffff;
+ iheight = height; iwidth = width;
+ if( (flip & 4) != 0 ) SWAP(height,width);
+ soff = flip_index(0, 0);
+ cstep = flip_index(0, 1) - soff;
+ rstep = flip_index(1, 0) - flip_index(0, width);
+ if( document_mode ) {
+ for( row=0; row<height; ++row, soff += rstep ) {
+ float *output = dcraw_data[row];
+ for( col=0; col<width; ++col, soff += cstep ) {
+ ushort *pixel = image[soff];
+ FORC3 *output++ = (float)*pixel++ * scale;
+ if( dcraw_alpha ) *output++ = 1.0;
}
}
- else
- {
- for (col = 0; col < width; col++)
- {
- ushort *pixel = image[row * width + col];
-
- *output++ = (float)pixel[0] / 0xffff;
- *output++ = (float)pixel[1] / 0xffff;
- *output++ = (float)pixel[2] / 0xffff;
-
- if(dcraw_alpha) *output++ = 1.0;
+ }
+ else {
+ int val, total, white=0x2000;
+ int perc = width * height * 0.01; /* 99th percentile white level */
+ if( fuji_width ) perc /= 2;
+ if( !((highlight & ~2) || no_auto_bright) ) {
+ for( white=c=0; c < colors; ++c ) {
+ for( val=0x2000, total=0; --val > 32; )
+ if( (total += histogram[c][val]) > perc ) break;
+ if( white < val ) white = val;
+ }
+ }
+ gamma_curve(gamm[0], gamm[1], 2, (white << 3)/bright);
+ for( row=0; row<height; ++row, soff += rstep ) {
+ float *output = dcraw_data[row];
+ for( col=0; col<width; ++col, soff += cstep ) {
+ ushort *pixel = image[soff];
+ FORC3 *output++ = (float)curve[*pixel++] * scale;
+ if( dcraw_alpha ) *output++ = 1.0;
}
}
- }
+ }
}
// CINELERRA
}
// CINELERRA
// write_fun = &CLASS write_ppm_tiff;
- write_fun = write_cinelerra;
+ write_fun = &CLASS write_cinelerra;
if (thumbnail_only) {
if ((status = !thumb_offset)) {
static void CLASS tiff_head(struct tiff_hdr *th,int full);
static void CLASS jpeg_thumb(void);
static void CLASS write_ppm_tiff(void);
-static void CLASS write_cinelerra(FILE *ofp);
+static void CLASS write_cinelerra(void);
int dcraw_main (int argc, const char **argv);
}
-static int dcraw_run(int argc, const char **argv)
+Mutex FileCR2::dcraw_lock;
+
+int FileCR2::dcraw_run(FileCR2 *file, int argc, const char **argv, VFrame *frame)
{
- static Mutex dcraw_lock;
dcraw_lock.lock("dcraw_run");
+ memset(dcraw_info, 0, sizeof(dcraw_info));
+ memset(dcraw_matrix, 0, sizeof(dcraw_matrix));
+ dcraw_data = !frame ? 0 : (float**) frame->get_rows();
+ dcraw_alpha = !frame ? 0 :
+ frame->get_color_model() == BC_RGBA_FLOAT ? 1 : 0;
int result = dcraw_main(argc, argv);
+ if( !result && file )
+ file->format_to_asset(dcraw_info);
+ if( !result && frame ) {
+// 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();
+ }
+
dcraw_lock.unlock();
return result;
}
if(ptr) return 0;
//printf("FileCR2::check_sig %d\n", __LINE__);
FILE *stream = fopen(asset->path, "rb");
-
- if(stream)
- {
+ 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;
- }
+ if( !strncmp("CR2LIST",test,6) ) 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_run(argc, argv);
-
+ const char *argv[4] = { "dcraw", "-i", string, 0 };
+ int argc = 3;
+ int result = dcraw_run(0, 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_run(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_run(argc, argv);
- if(!result) format_to_asset();
-
-//printf("FileCR2::read_frame_header %d %d\n", __LINE__, result);
+ const char *argv[4] = { "dcraw", "-i", path, 0 };
+ int result = dcraw_run(this, argc, argv);
return result;
}
// return 0;
// }
//
-void FileCR2::format_to_asset()
+void FileCR2::format_to_asset(const char *info)
{
asset->video_data = 1;
asset->layers = 1;
- sscanf(dcraw_info, "%d %d", &asset->width, &asset->height);
+ sscanf(info, "%d %d", &asset->width, &asset->height);
}
// 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";
+ int argc = 0; const char *argv[10];
+ argv[argc++] = "dcraw";
+ argv[argc++] = "-c"; // output to stdout
+ argv[argc++] = "-j"; // no rotation
// printf("FileCR2::read_frame %d interpolate=%d white_balance=%d\n",
-// __LINE__,
-// file->interpolate_raw,
-// file->white_balance_raw);
+// __LINE__, file->interpolate_raw, file->white_balance_raw);
// Use camera white balance.
// Before 2006, DCraw had no 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";
+ argv[argc++] = "-w";
- if(!file->interpolate_raw)
- {
+ 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";
+ argv[argc++] = "-d";
}
//printf("FileCR2::read_frame %d %s\n", __LINE__, path);
argv[argc++] = path;
-
- dcraw_data = (float**)frame->get_rows();
+ argv[argc] = 0;
//Timer timer;
- int result = dcraw_run(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();
-
+ int result = dcraw_run(0, argc, argv, frame);
return result;
}
class FileCR2 : public FileList
{
+ static Mutex dcraw_lock;
+ static int dcraw_run(FileCR2 *file, int argc, const char **argv, VFrame *frame=0);
+ void format_to_asset(const char *info);
public:
FileCR2(Asset *asset, File *file);
~FileCR2();
static int get_best_colormodel(Asset *asset, int driver);
// int64_t get_memory_usage();
int read_frame_header(char *path);
-
-private:
- void format_to_asset();
};
if(test[0] == 'I' && test[1] == 'I')
{
+ // Reject cr2, libtiff fails with it
+ if( test[4] == 0x10 && !test[5] && !test[6] && !test[7] &&
+ test[8] == 'C' && test[9] == 'R' )
+ return 0;
return 1;
}
else
$(shell mkdir -p $(DIRS) )
OUTPUT = $(OBJDIR)/libzmpeg3.a
-UTILS += $(OBJDIR)/mpeg3toc
-UTILS += $(OBJDIR)/mpeg3show
-UTILS += $(OBJDIR)/mpeg3cat
-UTILS += $(OBJDIR)/mpeg3ifochk
-UTILS += $(OBJDIR)/mpeg3cc2txt
+UTILS += $(OBJDIR)/zmpeg3toc
+UTILS += $(OBJDIR)/zmpeg3show
+UTILS += $(OBJDIR)/zmpeg3cat
+UTILS += $(OBJDIR)/zmpeg3ifochk
+UTILS += $(OBJDIR)/zmpeg3cc2txt
LIBS = -lm -lpthread
ar rcs $(OUTPUT) `cat $(OBJDIR)/objs`
-mpeg3% $(OBJDIR)/mpeg3%: $(OUTPUT) mpeg3%.C
- $(CXX) `cat $(OBJDIR)/c_flags` -o $(OBJDIR)/$(notdir $@) $(notdir $@).C $(OUTPUT) $(LIBS)
+zmpeg3% $(OBJDIR)/zmpeg3%: $(OUTPUT) mpeg3%.C
+ $(CXX) `cat $(OBJDIR)/c_flags` -o $(OBJDIR)/$(notdir $@) mpeg3$*.C $(OUTPUT) $(LIBS)
tags:
ctags -R .