RgbaOutputFile::RgbaOutputFile (const char name[], const Imath::Box2i &displayWindow, const Imath::Box2i &dataWindow, RgbaChannels rgbaChannels, float pixelAspectRatio, const Imath::V2f screenWindowCenter, float screenWindowWidth, LineOrder lineOrder, Compression compression): _outputFile (0) { Header hd (displayWindow, dataWindow.isEmpty()? displayWindow: dataWindow, pixelAspectRatio, screenWindowCenter, screenWindowWidth, lineOrder, compression); ChannelList ch; if (rgbaChannels & WRITE_R) ch.insert ("R", Channel (HALF, 1, 1)); if (rgbaChannels & WRITE_G) ch.insert ("G", Channel (HALF, 1, 1)); if (rgbaChannels & WRITE_B) ch.insert ("B", Channel (HALF, 1, 1)); if (rgbaChannels & WRITE_A) ch.insert ("A", Channel (HALF, 1, 1)); hd.channels() = ch; _outputFile = new OutputFile (name, hd); }
RgbaOutputFile::RgbaOutputFile (const char name[], int width, int height, RgbaChannels rgbaChannels, float pixelAspectRatio, const Imath::V2f screenWindowCenter, float screenWindowWidth, LineOrder lineOrder, Compression compression): _outputFile (0) { Header hd (width, height, pixelAspectRatio, screenWindowCenter, screenWindowWidth, lineOrder, compression); ChannelList ch; if (rgbaChannels & WRITE_R) ch.insert ("R", Channel (HALF, 1, 1)); if (rgbaChannels & WRITE_G) ch.insert ("G", Channel (HALF, 1, 1)); if (rgbaChannels & WRITE_B) ch.insert ("B", Channel (HALF, 1, 1)); if (rgbaChannels & WRITE_A) ch.insert ("A", Channel (HALF, 1, 1)); hd.channels() = ch; _outputFile = new OutputFile (name, hd); }
MPEGCodec::MPEGCodec(const MoxMxf::VideoDescriptor &descriptor, Header &header, ChannelList &channels) : VideoCodec(descriptor, header, channels), _descriptor(dynamic_cast<const MoxMxf::MPEGDescriptor &>(descriptor)) { assert(header.width() == _descriptor.getStoredWidth()); assert(header.height() == _descriptor.getStoredHeight()); channels.insert("R", Channel(MoxFiles::UINT8)); channels.insert("G", Channel(MoxFiles::UINT8)); channels.insert("B", Channel(MoxFiles::UINT8)); }
JPEGCodec::JPEGCodec(const MoxMxf::VideoDescriptor &descriptor, Header &header, ChannelList &channels) : VideoCodec(descriptor, header, channels), _descriptor(dynamic_cast<const MoxMxf::RGBADescriptor &>(descriptor)) { assert(_descriptor.getVideoCodec() == MoxMxf::VideoDescriptor::VideoCodecJPEG); const MoxMxf::RGBADescriptor::RGBALayout &pixelLayout = _descriptor.getPixelLayout(); assert(pixelLayout.size() == 3 && pixelLayout.at(0).depth == 8); channels.insert("R", UINT8); channels.insert("G", UINT8); channels.insert("B", UINT8); }
ChannelList channelInAllViews (const string &channelName, const ChannelList &channelList, const StringVector &multiView) { // // Given the name of a channel, return a // list of the same channel in all views. // ChannelList q; for (ChannelList::ConstIterator i=channelList.begin(); i != channelList.end(); ++i) { if (i.name() == channelName || areCounterparts (i.name(), channelName, multiView)) { q.insert (i.name(), i.channel()); } } return q; }
ChannelList channelsInView (const string & viewName, const ChannelList & channelList, const StringVector & multiView) { // // Return a list of all channels belonging to view viewName. // ChannelList q; for (ChannelList::ConstIterator i = channelList.begin(); i != channelList.end(); ++i) { // // Get view name for this channel // string view = viewFromChannelName (i.name(), multiView); // // Insert channel into q if it's a member of view viewName // if (view == viewName) q.insert (i.name(), i.channel()); } return q; }
void CBouquet::moveService(const unsigned int oldPosition, const unsigned int newPosition, const unsigned char serviceType) { ChannelList* channels = &tvChannels; switch (serviceType) { case ST_DIGITAL_TELEVISION_SERVICE: case ST_NVOD_REFERENCE_SERVICE: case ST_NVOD_TIME_SHIFTED_SERVICE: channels = &tvChannels; break; case ST_DIGITAL_RADIO_SOUND_SERVICE: channels = &radioChannels; break; } if ((oldPosition < channels->size()) && (newPosition < channels->size())) { ChannelList::iterator it = channels->begin(); advance(it, oldPosition); CZapitChannel* tmp = *it; channels->erase(it); it = channels->begin(); advance(it, newPosition); channels->insert(it, tmp); } }
DPXCodec::DPXCodec(const MoxMxf::VideoDescriptor &descriptor, Header &header, ChannelList &channels) : VideoCodec(descriptor, header, channels), _descriptor(dynamic_cast<const MoxMxf::RGBADescriptor &>(descriptor)), _pixelAspectRatio(header.pixelAspectRatio()), _frameRate(header.frameRate()), _depth(DPX_10), _channels(DPX_RGB) { assert(_descriptor.getVideoCodec() == MoxMxf::VideoDescriptor::VideoCodecDPX); const MoxMxf::RGBADescriptor::RGBALayout &pixelLayout = _descriptor.getPixelLayout(); for(MoxMxf::RGBADescriptor::RGBALayout::const_iterator i = pixelLayout.begin(); i != pixelLayout.end(); ++i) { const MoxMxf::RGBADescriptor::RGBALayoutItem &item = *i; if(item.code == 'A') _channels = DPX_RGBA; if(item.depth == 8) _depth = DPX_8; else if(item.depth == 10) _depth = DPX_10; else if(item.depth == 12) _depth = DPX_12; else if(item.depth == 16) _depth = DPX_16; else throw MoxMxf::InputExc("Unexpected bit depth"); } const PixelType pixel_type = (_depth == DPX_8 ? UINT8 : _depth == DPX_10 ? UINT10 : _depth == DPX_12 ? UINT12 : _depth == DPX_16 ? UINT16 : UINT10); channels.insert("R", Channel(pixel_type)); channels.insert("G", Channel(pixel_type)); channels.insert("B", Channel(pixel_type)); if(_channels == DPX_RGBA) channels.insert("A", Channel(pixel_type)); }
RgbaOutputFile::RgbaOutputFile (const char name[], const Header &header, RgbaChannels rgbaChannels): _outputFile (0) { Header hd (header); ChannelList ch; if (rgbaChannels & WRITE_R) ch.insert ("R", Channel (HALF, 1, 1)); if (rgbaChannels & WRITE_G) ch.insert ("G", Channel (HALF, 1, 1)); if (rgbaChannels & WRITE_B) ch.insert ("B", Channel (HALF, 1, 1)); if (rgbaChannels & WRITE_A) ch.insert ("A", Channel (HALF, 1, 1)); hd.channels() = ch; _outputFile = new OutputFile (name, hd); }
ChannelList ChannelData::channelList(int sourceId) { ChannelList retList; ChannelInfoList channelList = ChannelUtil::GetChannels(sourceId, false); ChannelInfoList::iterator it = channelList.begin(); for ( ; it != channelList.end(); ++it) { QString chanName = (*it).name; QString key = normalizeChannelKey(chanName); retList.insert(key, *it); } return retList; }
Channel * ChannelMgr::GetCreateChannel(const char *name, Player * p, uint32 type_id) { ChannelList::iterator itr; ChannelList * cl = &Channels[0]; Channel * chn; uint32 cid; if( seperatechannels && p != NULL ) cl = &Channels[p->GetTeam()]; lock.Acquire(); for(itr = cl->begin(); itr != cl->end(); ++itr) { if(!stricmp(name, itr->first.c_str())) { lock.Release(); return itr->second; } } // make sure the name isn't banned m_confSettingLock.Acquire(); for(vector<string>::iterator itr = m_bannedChannels.begin(); itr != m_bannedChannels.end(); ++itr) { if(!strnicmp( name, itr->c_str(), itr->size() ) ) { lock.Release(); m_confSettingLock.Release(); return NULL; } } m_confSettingLock.Release(); cid = ++m_idHigh; chn = new Channel(name, ( seperatechannels && p != NULL ) ? p->GetTeam() : 0, type_id, cid); cl->insert(make_pair(chn->m_name, chn)); m_idToChannel.insert(make_pair(cid, chn)); lock.Release(); return chn; }
Channel* ChannelMgr::GetCreateChannel(const char* name, Player* p, uint32 type_id) { ChannelList::iterator itr; ChannelList* cl = &Channels[0]; Channel* chn; if(seperatechannels && p != NULL && stricmp(name, sWorld.getGmClientChannel().c_str())) cl = &Channels[p->GetTeam()]; lock.Acquire(); for(itr = cl->begin(); itr != cl->end(); ++itr) { if(!stricmp(name, itr->first.c_str())) { lock.Release(); return itr->second; } } // make sure the name isn't banned m_confSettingLock.Acquire(); for(vector<string>::iterator itr2 = m_bannedChannels.begin(); itr2 != m_bannedChannels.end(); ++itr2) { if(!strnicmp(name, itr2->c_str(), itr2->size())) { lock.Release(); m_confSettingLock.Release(); return NULL; } } chn = new Channel(name, (seperatechannels && p != NULL) ? p->GetTeam() : 0, type_id); m_confSettingLock.Release();//Channel::Channel() reads configs so we release the lock after we create the Channel. cl->insert(make_pair(chn->m_name, chn)); lock.Release(); return chn; }
void EXRImageFileWriter::write( const char* filename, const ICanvas& image, const ImageAttributes& image_attributes) { try { // Retrieve canvas properties. const CanvasProperties& props = image.properties(); // todo: lift this limitation. assert(props.m_channel_count <= 4); // Figure out the pixel type, based on the pixel format of the image. PixelType pixel_type = FLOAT; switch (props.m_pixel_format) { case PixelFormatUInt32: pixel_type = UINT; break; case PixelFormatHalf: pixel_type = HALF; break; case PixelFormatFloat: pixel_type = FLOAT; break; default: throw ExceptionUnsupportedImageFormat(); } // Construct TileDescription object. const TileDescription tile_desc( static_cast<unsigned int>(props.m_tile_width), static_cast<unsigned int>(props.m_tile_height), ONE_LEVEL); // Construct ChannelList object. ChannelList channels; for (size_t c = 0; c < props.m_channel_count; ++c) channels.insert(ChannelName[c], Channel(pixel_type)); // Construct Header object. Header header( static_cast<int>(props.m_canvas_width), static_cast<int>(props.m_canvas_height)); header.setTileDescription(tile_desc); header.channels() = channels; // Add image attributes to the Header object. add_attributes(image_attributes, header); // Create the output file. TiledOutputFile file(filename, header, m_thread_count); // Write tiles. for (size_t y = 0; y < props.m_tile_count_y; ++y) { for (size_t x = 0; x < props.m_tile_count_x; ++x) { const int ix = static_cast<int>(x); const int iy = static_cast<int>(y); const Box2i range = file.dataWindowForTile(ix, iy); const Tile& tile = image.tile(x, y); const size_t channel_size = Pixel::size(tile.get_pixel_format()); const size_t stride_x = channel_size * props.m_channel_count; const size_t stride_y = stride_x * tile.get_width(); const size_t tile_origin = range.min.x * stride_x + range.min.y * stride_y; const char* tile_base = reinterpret_cast<const char*>(tile.pixel(0, 0)) - tile_origin; // Construct FrameBuffer object. FrameBuffer framebuffer; for (size_t c = 0; c < props.m_channel_count; ++c) { const char* base = tile_base + c * channel_size; framebuffer.insert( ChannelName[c], Slice( pixel_type, const_cast<char*>(base), stride_x, stride_y)); } // Write tile. file.setFrameBuffer(framebuffer); file.writeTile(ix, iy); } } } catch (const BaseExc& e) { // I/O error. throw ExceptionIOError(e.what()); } }
// Open an image file for writing. void ProgressiveEXRImageFileWriter::open( const char* filename, const CanvasProperties& props, const ImageAttributes& attrs) { assert(filename); assert(!is_open()); try { // todo: lift this limitation. assert(props.m_channel_count <= 4); // Figure out the pixel type, based on the pixel format of the image. impl->m_pixel_type = FLOAT; switch (props.m_pixel_format) { case PixelFormatUInt32: impl->m_pixel_type = UINT; break; case PixelFormatHalf: impl->m_pixel_type = HALF; break; case PixelFormatFloat: impl->m_pixel_type = FLOAT; break; default: throw ExceptionUnsupportedImageFormat(); } // Construct TileDescription object. const TileDescription tile_desc( static_cast<unsigned int>(props.m_tile_width), static_cast<unsigned int>(props.m_tile_height), ONE_LEVEL); // Construct ChannelList object. ChannelList channels; for (size_t c = 0; c < props.m_channel_count; ++c) channels.insert(ChannelName[c], Channel(impl->m_pixel_type)); // Construct Header object. Header header( static_cast<int>(props.m_canvas_width), static_cast<int>(props.m_canvas_height), static_cast<float>(props.m_canvas_width) / props.m_canvas_height); header.setTileDescription(tile_desc); header.channels() = channels; // Add image attributes to the Header object. add_attributes(attrs, header); // Create the output file. impl->m_file.reset( new TiledOutputFile( filename, header, impl->m_thread_count)); // Store the canvas properties. impl->m_props = props; } catch (const BaseExc& e) { // I/O error. throw ExceptionIOError(e.what()); } }