X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fvframe.C;h=241a773f639d0509b8f8d7d853195720e929f0db;hb=ccd23c15fae578be22d48b1a1e8b09cb43d593ae;hp=1cfeb58b8c988b8daae95244f259f09618dd6088;hpb=48c313de28fe6d39d9431dbe2dca6ffb176541ff;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/guicast/vframe.C b/cinelerra-5.1/guicast/vframe.C index 1cfeb58b..241a773f 100644 --- a/cinelerra-5.1/guicast/vframe.C +++ b/cinelerra-5.1/guicast/vframe.C @@ -131,11 +131,13 @@ VFrame::VFrame(VFrame &frame) { reset_parameters(1); params = new BC_Hash; + use_shm = frame.use_shm; allocate_data(0, -1, 0, 0, 0, frame.w, frame.h, frame.color_model, frame.bytes_per_line); - copy_from(&frame); + copy_vframe(&frame); } + VFrame::VFrame(int w, int h, int color_model, long bytes_per_line) { reset_parameters(1); @@ -278,7 +280,8 @@ int VFrame::reset_parameters(int do_opengl) timestamp = -1.; is_keyframe = 0; draw_point = 0; - set_pixel_color(BLACK); + pixel_rgb = 0x000000; // BLACK + pixel_yuv = 0x008080; stipple = 0; if(do_opengl) @@ -352,6 +355,7 @@ if( memory_type != VFrame::SHARED ) case BC_YUV444P: case BC_RGB_FLOATP: case BC_RGBA_FLOATP: + case BC_GBRP: break; default: @@ -443,6 +447,12 @@ void VFrame::create_row_pointers() this->u_offset = sz; this->v_offset = sz + sz; break; + case BC_GBRP: + if( this->v_offset ) break; + this->y_offset = 0; + this->u_offset = sz * sizeof(uint8_t); + this->v_offset = 2 * sz * sizeof(uint8_t); + break; case BC_RGBA_FLOATP: if( this->v_offset || a ) break; a = this->data + 3 * sz * sizeof(float); @@ -504,7 +514,8 @@ int VFrame::allocate_data(unsigned char *data, int shmid, this->data = 0; int size = calculate_data_size(this->w, this->h, this->bytes_per_line, this->color_model); - if(BC_WindowBase::get_resources()->use_vframe_shm() && use_shm) { + if( use_shm && size >= SHM_MIN_SIZE && + BC_WindowBase::get_resources()->use_vframe_shm() ) { this->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | 0777); if( this->shmid >= 0 ) { this->data = (unsigned char*)shmat(this->shmid, NULL, 0); @@ -520,7 +531,7 @@ int VFrame::allocate_data(unsigned char *data, int shmid, } } // Have to use malloc for libpng - if( !data ) { + if( !this->data ) { this->data = (unsigned char *)malloc(size); this->shmid = -1; } @@ -899,6 +910,12 @@ int VFrame::clear_frame() bzero(get_v(), sz / 2); break; + case BC_GBRP: + bzero(get_y(), sz); + bzero(get_u(), sz); + bzero(get_b(), sz); + break; + case BC_RGBA_FLOATP: if( a ) { float *ap = (float *)a; for( int i=sz; --i>=0; ++ap ) *ap = 1.f; } @@ -1025,14 +1042,12 @@ void VFrame::rotate270() void VFrame::flip_vert() { - unsigned char *temp = new unsigned char[bytes_per_line]; - for(int i = 0, j = h - 1; i < j; i++, j--) - { + unsigned char temp[bytes_per_line]; + for( int i=0, j=h; --j>i; ++i ) { memcpy(temp, rows[j], bytes_per_line); memcpy(rows[j], rows[i], bytes_per_line); memcpy(rows[i], temp, bytes_per_line); } - delete [] temp; } void VFrame::flip_horiz() @@ -1116,18 +1131,19 @@ int VFrame::copy_from(VFrame *frame) break; } - params->copy_from(frame->params); return 0; } int VFrame::transfer_from(VFrame *that, int bg_color, int in_x, int in_y, int in_w, int in_h) { + timestamp = that->timestamp; + copy_params(that); + if( this->get_color_model() == that->get_color_model() && this->get_w() == that->get_w() && this->get_h() == that->get_h() && this->get_bytes_per_line() == that->get_bytes_per_line() ) return this->copy_from(that); - timestamp = that->timestamp; #if 0 BC_CModels::transfer( this->get_rows(), that->get_rows(), // Packed data out/in @@ -1168,7 +1184,6 @@ int VFrame::transfer_from(VFrame *that, int bg_color, int in_x, int in_y, int in that->get_bytes_per_line(), bg_color); #endif - params->copy_from(that->params); return 0; } @@ -1267,22 +1282,20 @@ void VFrame::copy_stacks(VFrame *src) { clear_stacks(); - for(int i = 0; i < src->next_effects.total; i++) - { - char *ptr; - next_effects.append(ptr = new char[strlen(src->next_effects.values[i]) + 1]); - strcpy(ptr, src->next_effects.values[i]); - } - for(int i = 0; i < src->prev_effects.total; i++) - { - char *ptr; - prev_effects.append(ptr = new char[strlen(src->prev_effects.values[i]) + 1]); - strcpy(ptr, src->prev_effects.values[i]); - } + for( int i=0; i < src->next_effects.total; ++i ) + next_effects.append(cstrdup(src->next_effects[i])); + for( int i=0; i < src->prev_effects.total; ++i ) + prev_effects.append(cstrdup(src->prev_effects[i])); copy_params(src); } +int VFrame::copy_vframe(VFrame *frame) +{ + copy_stacks(frame); + return copy_from(frame); +} + int VFrame::equal_stacks(VFrame *src) { for(int i = 0; i < src->next_effects.total && i < next_effects.total; i++) @@ -1335,7 +1348,7 @@ void VFrame::set_pixel_color(int rgb) int ir = 0xff & (pixel_rgb >> 16); int ig = 0xff & (pixel_rgb >> 8); int ib = 0xff & (pixel_rgb >> 0); - bc_rgb2yuv(ir,ig,ib, ir,ig,ib); + YUV::yuv.rgb_to_yuv_8(ir, ig, ib); pixel_yuv = (ir<<16) | (ig<<8) | (ib<<0); }