ListNode * HandleRest(ListNode * resthead, ParkingLot * parkinglot, int timeunit, FILE * outputfile) { Rest * rest; ListNode * aux; int i=0; /*Get the head of the restricion list to the aux pointer for the first while comparation*/ aux = resthead; if(aux == NULL) return NULL; /*Get the first restriction*/ rest = (Rest*) getItemLinkedList(aux); while(aux != NULL && GetRestTime(rest) == timeunit) { if(GetRestFlag(rest) == 'p') { i = FindIP(GetVertices(parkinglot), GetRestCoord(rest, 'x'), GetRestCoord(rest, 'y'), GetRestCoord(rest, 'z'), GetDecoder(parkinglot) ); if(GetIP_Flagres(i, GetDecoder(parkinglot) ) == 1) { ReleasePos(i, GetDecoder(parkinglot) ); IncFreeSpots(parkinglot); if( GetFreeSpots(parkinglot) != 0) HandleQueue(parkinglot, outputfile, timeunit); } else { RestrictPos(i, GetDecoder(parkinglot) ); DecFreeSpots(parkinglot); } } else if(GetRestFlag(rest) == 'f') { if( IsFloorRestricted( GetRestCoord(rest, 'z'), parkinglot ) ) { ReleaseWholeFloor(i, parkinglot ); /* la dento temos de fazer bue release spots */ if( GetFreeSpots(parkinglot) != 0) HandleQueue(parkinglot, outputfile, timeunit); } else RestrictWholeFloor( GetRestCoord(rest, 'z'), parkinglot ); } aux = getNextNodeLinkedList(aux); rest = (Rest*) getItemLinkedList(aux); } /*Return the new head of the linked list*/ return aux; }
int IsFloorRestricted( int z, ParkingLot * parkinglot) { int i; int vertices = GetVertices(parkinglot); for(i = 0; (i < vertices) && (GetIP_Coord(i, 'z', GetDecoder(parkinglot) ) <= z) ; i++) { if( (GetIP_Coord(i, 'z', GetDecoder(parkinglot)) == z) && (GetIP_Flagres(i, GetDecoder(parkinglot)) == 0) && (GetIP_Type(i, GetDecoder(parkinglot)) == '.') ) return 0; } return 1; }
void RestrictWholeFloor( int z, ParkingLot * parkinglot ) { int i; int vertices = GetVertices(parkinglot); for(i = 0; (i < vertices) && (GetIP_Coord(i, 'z', GetDecoder(parkinglot) ) <= z) ; i++) { if( (GetIP_Coord(i, 'z', GetDecoder(parkinglot)) == z) && (GetIP_Flagres(i, GetDecoder(parkinglot)) == 0) && (GetIP_Type(i, GetDecoder(parkinglot)) == '.' )) { RestrictPos(i, GetDecoder(parkinglot) ); DecFreeSpots(parkinglot); } } }
/* static */ already_AddRefed<Decoder> DecoderFactory::CreateAnimationDecoder(DecoderType aType, RasterImage* aImage, SourceBuffer* aSourceBuffer, DecoderFlags aDecoderFlags, SurfaceFlags aSurfaceFlags, const IntSize& aResolution) { if (aType == DecoderType::UNKNOWN) { return nullptr; } MOZ_ASSERT(aType == DecoderType::GIF || aType == DecoderType::PNG, "Calling CreateAnimationDecoder for non-animating DecoderType"); nsRefPtr<Decoder> decoder = GetDecoder(aType, aImage, /* aIsRedecode = */ true); MOZ_ASSERT(decoder, "Should have a decoder now"); // Initialize the decoder. decoder->SetMetadataDecode(false); decoder->SetIterator(aSourceBuffer->Iterator()); decoder->SetDecoderFlags(aDecoderFlags | DecoderFlags::IS_REDECODE); decoder->SetSurfaceFlags(aSurfaceFlags); decoder->SetResolution(aResolution); decoder->Init(); if (NS_FAILED(decoder->GetDecoderError())) { return nullptr; } return decoder.forget(); }
/* static */ already_AddRefed<Decoder> DecoderFactory::CreateMetadataDecoder(DecoderType aType, RasterImage* aImage, SourceBuffer* aSourceBuffer, int aSampleSize, const IntSize& aResolution) { if (aType == DecoderType::UNKNOWN) { return nullptr; } nsRefPtr<Decoder> decoder = GetDecoder(aType, aImage, /* aIsRedecode = */ false); MOZ_ASSERT(decoder, "Should have a decoder now"); // Initialize the decoder. decoder->SetMetadataDecode(true); decoder->SetIterator(aSourceBuffer->Iterator()); decoder->SetSampleSize(aSampleSize); decoder->SetResolution(aResolution); decoder->Init(); if (NS_FAILED(decoder->GetDecoderError())) { return nullptr; } return decoder.forget(); }
/* static */ already_AddRefed<IDecodingTask> DecoderFactory::CreateAnimationDecoder(DecoderType aType, NotNull<RasterImage*> aImage, NotNull<SourceBuffer*> aSourceBuffer, DecoderFlags aDecoderFlags, SurfaceFlags aSurfaceFlags) { if (aType == DecoderType::UNKNOWN) { return nullptr; } MOZ_ASSERT(aType == DecoderType::GIF || aType == DecoderType::PNG, "Calling CreateAnimationDecoder for non-animating DecoderType"); RefPtr<Decoder> decoder = GetDecoder(aType, aImage, /* aIsRedecode = */ true); MOZ_ASSERT(decoder, "Should have a decoder now"); // Initialize the decoder. decoder->SetMetadataDecode(false); decoder->SetIterator(aSourceBuffer->Iterator()); decoder->SetDecoderFlags(aDecoderFlags | DecoderFlags::IS_REDECODE); decoder->SetSurfaceFlags(aSurfaceFlags); decoder->Init(); if (NS_FAILED(decoder->GetDecoderError())) { return nullptr; } RefPtr<IDecodingTask> task = new DecodingTask(WrapNotNull(decoder)); return task.forget(); }
/* static */ already_AddRefed<IDecodingTask> DecoderFactory::CreateMetadataDecoder(DecoderType aType, NotNull<RasterImage*> aImage, NotNull<SourceBuffer*> aSourceBuffer, int aSampleSize) { if (aType == DecoderType::UNKNOWN) { return nullptr; } RefPtr<Decoder> decoder = GetDecoder(aType, aImage, /* aIsRedecode = */ false); MOZ_ASSERT(decoder, "Should have a decoder now"); // Initialize the decoder. decoder->SetMetadataDecode(true); decoder->SetIterator(aSourceBuffer->Iterator()); decoder->SetSampleSize(aSampleSize); decoder->Init(); if (NS_FAILED(decoder->GetDecoderError())) { return nullptr; } RefPtr<IDecodingTask> task = new MetadataDecodingTask(WrapNotNull(decoder)); return task.forget(); }
bool PDMFactory::SupportsMimeType(const nsACString& aMimeType) const { if (mEMEPDM) { return mEMEPDM->SupportsMimeType(aMimeType); } RefPtr<PlatformDecoderModule> current = GetDecoder(aMimeType); return !!current; }
void FreeParkingLot(ParkingLot * parkinglot) { FreeDecoder( GetDecoder( parkinglot ), GetVertices( parkinglot ) ); FreeGraph( GetGraph( parkinglot ) ) ; freeLinkedList( GetAccesses( parkinglot) ); freeLinkedList( GetQueueHead(parkinglot) ); FreeParkedCars( GetParkedListHead(parkinglot) ); free(parkinglot); }
bool PDMFactory::Supports(const TrackInfo& aTrackInfo, DecoderDoctorDiagnostics* aDiagnostics) const { if (mEMEPDM) { return mEMEPDM->Supports(aTrackInfo, aDiagnostics); } RefPtr<PlatformDecoderModule> current = GetDecoder(aTrackInfo, aDiagnostics); return !!current; }
/* static */ already_AddRefed<IDecodingTask> DecoderFactory::CreateDecoder(DecoderType aType, NotNull<RasterImage*> aImage, NotNull<SourceBuffer*> aSourceBuffer, const IntSize& aIntrinsicSize, const IntSize& aOutputSize, DecoderFlags aDecoderFlags, SurfaceFlags aSurfaceFlags) { if (aType == DecoderType::UNKNOWN) { return nullptr; } // Create an anonymous decoder. Interaction with the SurfaceCache and the // owning RasterImage will be mediated by DecodedSurfaceProvider. RefPtr<Decoder> decoder = GetDecoder(aType, nullptr, bool(aDecoderFlags & DecoderFlags::IS_REDECODE)); MOZ_ASSERT(decoder, "Should have a decoder now"); // Initialize the decoder. decoder->SetMetadataDecode(false); decoder->SetIterator(aSourceBuffer->Iterator()); decoder->SetOutputSize(aOutputSize); decoder->SetDecoderFlags(aDecoderFlags | DecoderFlags::FIRST_FRAME_ONLY); decoder->SetSurfaceFlags(aSurfaceFlags); if (NS_FAILED(decoder->Init())) { return nullptr; } // Create a DecodedSurfaceProvider which will manage the decoding process and // make this decoder's output available in the surface cache. SurfaceKey surfaceKey = RasterSurfaceKey(aOutputSize, aSurfaceFlags, PlaybackType::eStatic); auto provider = MakeNotNull<RefPtr<DecodedSurfaceProvider>>( aImage, surfaceKey, WrapNotNull(decoder)); if (aDecoderFlags & DecoderFlags::CANNOT_SUBSTITUTE) { provider->Availability().SetCannotSubstitute(); } // Attempt to insert the surface provider into the surface cache right away so // we won't trigger any more decoders with the same parameters. if (SurfaceCache::Insert(provider) != InsertOutcome::SUCCESS) { return nullptr; } // Return the surface provider in its IDecodingTask guise. RefPtr<IDecodingTask> task = provider.get(); return task.forget(); }
/* static */ already_AddRefed<IDecodingTask> DecoderFactory::CreateAnimationDecoder(DecoderType aType, NotNull<RasterImage*> aImage, NotNull<SourceBuffer*> aSourceBuffer, const IntSize& aIntrinsicSize, DecoderFlags aDecoderFlags, SurfaceFlags aSurfaceFlags) { if (aType == DecoderType::UNKNOWN) { return nullptr; } MOZ_ASSERT(aType == DecoderType::GIF || aType == DecoderType::PNG, "Calling CreateAnimationDecoder for non-animating DecoderType"); // Create an anonymous decoder. Interaction with the SurfaceCache and the // owning RasterImage will be mediated by AnimationSurfaceProvider. RefPtr<Decoder> decoder = GetDecoder(aType, nullptr, /* aIsRedecode = */ true); MOZ_ASSERT(decoder, "Should have a decoder now"); // Initialize the decoder. decoder->SetMetadataDecode(false); decoder->SetIterator(aSourceBuffer->Iterator()); decoder->SetDecoderFlags(aDecoderFlags | DecoderFlags::IS_REDECODE); decoder->SetSurfaceFlags(aSurfaceFlags); if (NS_FAILED(decoder->Init())) { return nullptr; } // Create an AnimationSurfaceProvider which will manage the decoding process // and make this decoder's output available in the surface cache. SurfaceKey surfaceKey = RasterSurfaceKey(aIntrinsicSize, aSurfaceFlags, PlaybackType::eAnimated); auto provider = MakeNotNull<RefPtr<AnimationSurfaceProvider>>( aImage, surfaceKey, WrapNotNull(decoder)); // Attempt to insert the surface provider into the surface cache right away so // we won't trigger any more decoders with the same parameters. if (SurfaceCache::Insert(provider) != InsertOutcome::SUCCESS) { return nullptr; } // Return the surface provider in its IDecodingTask guise. RefPtr<IDecodingTask> task = provider.get(); return task.forget(); }
/* static */ already_AddRefed<Decoder> DecoderFactory::CreateAnonymousDecoder(DecoderType aType, NotNull<SourceBuffer*> aSourceBuffer, const Maybe<IntSize>& aTargetSize, SurfaceFlags aSurfaceFlags) { if (aType == DecoderType::UNKNOWN) { return nullptr; } RefPtr<Decoder> decoder = GetDecoder(aType, /* aImage = */ nullptr, /* aIsRedecode = */ false); MOZ_ASSERT(decoder, "Should have a decoder now"); // Initialize the decoder. decoder->SetMetadataDecode(false); decoder->SetIterator(aSourceBuffer->Iterator()); // Anonymous decoders are always transient; we don't want to optimize surfaces // or do any other expensive work that might be wasted. DecoderFlags decoderFlags = DecoderFlags::IMAGE_IS_TRANSIENT; // Without an image, the decoder can't store anything in the SurfaceCache, so // callers will only be able to retrieve the most recent frame via // Decoder::GetCurrentFrame(). That means that anonymous decoders should // always be first-frame-only decoders, because nobody ever wants the *last* // frame. decoderFlags |= DecoderFlags::FIRST_FRAME_ONLY; decoder->SetDecoderFlags(decoderFlags); decoder->SetSurfaceFlags(aSurfaceFlags); // Set a target size for downscale-during-decode if applicable. if (aTargetSize) { DebugOnly<nsresult> rv = decoder->SetTargetSize(*aTargetSize); MOZ_ASSERT(NS_SUCCEEDED(rv), "Bad downscale-during-decode target size?"); } decoder->Init(); if (NS_FAILED(decoder->GetDecoderError())) { return nullptr; } return decoder.forget(); }
/* static */ already_AddRefed<Decoder> DecoderFactory::CreateDecoder(DecoderType aType, RasterImage* aImage, SourceBuffer* aSourceBuffer, const Maybe<IntSize>& aTargetSize, uint32_t aFlags, bool aIsRedecode, bool aImageIsTransient, bool aImageIsLocked) { if (aType == DecoderType::UNKNOWN) { return nullptr; } nsRefPtr<Decoder> decoder = GetDecoder(aType, aImage, aIsRedecode); MOZ_ASSERT(decoder, "Should have a decoder now"); // Initialize the decoder. decoder->SetMetadataDecode(false); decoder->SetIterator(aSourceBuffer->Iterator()); decoder->SetFlags(aFlags); decoder->SetSendPartialInvalidations(!aIsRedecode); decoder->SetImageIsTransient(aImageIsTransient); if (aImageIsLocked) { decoder->SetImageIsLocked(); } // Set a target size for downscale-during-decode if applicable. if (aTargetSize) { DebugOnly<nsresult> rv = decoder->SetTargetSize(*aTargetSize); MOZ_ASSERT(nsresult(rv) != NS_ERROR_NOT_AVAILABLE, "We're downscale-during-decode but decoder doesn't support it?"); MOZ_ASSERT(NS_SUCCEEDED(rv), "Bad downscale-during-decode target size?"); } decoder->Init(); if (NS_FAILED(decoder->GetDecoderError())) { return nullptr; } return decoder.forget(); }
/* static */ already_AddRefed<Decoder> DecoderFactory::CreateDecoder(DecoderType aType, RasterImage* aImage, SourceBuffer* aSourceBuffer, const Maybe<IntSize>& aTargetSize, DecoderFlags aDecoderFlags, SurfaceFlags aSurfaceFlags, int aSampleSize, const IntSize& aResolution) { if (aType == DecoderType::UNKNOWN) { return nullptr; } nsRefPtr<Decoder> decoder = GetDecoder(aType, aImage, bool(aDecoderFlags & DecoderFlags::IS_REDECODE)); MOZ_ASSERT(decoder, "Should have a decoder now"); // Initialize the decoder. decoder->SetMetadataDecode(false); decoder->SetIterator(aSourceBuffer->Iterator()); decoder->SetDecoderFlags(aDecoderFlags | DecoderFlags::FIRST_FRAME_ONLY); decoder->SetSurfaceFlags(aSurfaceFlags); decoder->SetSampleSize(aSampleSize); decoder->SetResolution(aResolution); // Set a target size for downscale-during-decode if applicable. if (aTargetSize) { DebugOnly<nsresult> rv = decoder->SetTargetSize(*aTargetSize); MOZ_ASSERT(nsresult(rv) != NS_ERROR_NOT_AVAILABLE, "We're downscale-during-decode but decoder doesn't support it?"); MOZ_ASSERT(NS_SUCCEEDED(rv), "Bad downscale-during-decode target size?"); } decoder->Init(); if (NS_FAILED(decoder->GetDecoderError())) { return nullptr; } return decoder.forget(); }
MMBoardSoundFile::MMBoardSoundFile(const wxString& filename) : MMBoardFile() { m_input_stream = new wxFileInputStream(filename); m_output_stream = MMBoardManager::OpenSoundStream(); m_file_stream = GetDecoder(); if (!m_file_stream) { SetError(MMBoard_UnknownFile); return; } // Compute length wxUint32 length, seconds; length = m_file_stream->GetLength(); seconds = m_file_stream->GetSoundFormat().GetTimeFromBytes(length); m_length.seconds = seconds % 60; m_length.minutes = (seconds / 60) % 60; m_length.hours = seconds / 3600; }
/* static */ already_AddRefed<IDecodingTask> DecoderFactory::CreateDecoder(DecoderType aType, NotNull<RasterImage*> aImage, NotNull<SourceBuffer*> aSourceBuffer, const Maybe<IntSize>& aTargetSize, DecoderFlags aDecoderFlags, SurfaceFlags aSurfaceFlags, int aSampleSize) { if (aType == DecoderType::UNKNOWN) { return nullptr; } RefPtr<Decoder> decoder = GetDecoder(aType, aImage, bool(aDecoderFlags & DecoderFlags::IS_REDECODE)); MOZ_ASSERT(decoder, "Should have a decoder now"); // Initialize the decoder. decoder->SetMetadataDecode(false); decoder->SetIterator(aSourceBuffer->Iterator()); decoder->SetDecoderFlags(aDecoderFlags | DecoderFlags::FIRST_FRAME_ONLY); decoder->SetSurfaceFlags(aSurfaceFlags); decoder->SetSampleSize(aSampleSize); // Set a target size for downscale-during-decode if applicable. if (aTargetSize) { DebugOnly<nsresult> rv = decoder->SetTargetSize(*aTargetSize); MOZ_ASSERT(NS_SUCCEEDED(rv), "Bad downscale-during-decode target size?"); } decoder->Init(); if (NS_FAILED(decoder->GetDecoderError())) { return nullptr; } RefPtr<IDecodingTask> task = new DecodingTask(WrapNotNull(decoder)); return task.forget(); }
/* static */ already_AddRefed<Decoder> DecoderFactory::CreateAnonymousMetadataDecoder(DecoderType aType, NotNull<SourceBuffer*> aSourceBuffer) { if (aType == DecoderType::UNKNOWN) { return nullptr; } RefPtr<Decoder> decoder = GetDecoder(aType, /* aImage = */ nullptr, /* aIsRedecode = */ false); MOZ_ASSERT(decoder, "Should have a decoder now"); // Initialize the decoder. decoder->SetMetadataDecode(true); decoder->SetIterator(aSourceBuffer->Iterator()); decoder->SetDecoderFlags(DecoderFlags::FIRST_FRAME_ONLY); if (NS_FAILED(decoder->Init())) { return nullptr; } return decoder.forget(); }
static void RowCallback(png_structp png_ptr, png_bytep row, png_uint_32 rowNum, int /*pass*/) { GetDecoder(png_ptr)->rowCallback(row, rowNum); }
void PrintPath(FILE * outputfile, ListNode * carpath, ListNode * footpath, char * carname, int entrytime, ParkingLot * parkinglot, int pathweight) { ListNode * carpathaux, * footpathaux; int x = 0, y = 0, z = 0, time = -1, timecompare, px = -1, py = -1, pz = -1; /*px, py, px are the coordenates that resulted from the previous iteration*/ int position, parkingtime; Array decoder = GetDecoder(parkinglot); char direction = 'a', pdirection = 'a'; carpathaux = carpath; position = *( (int*) getItemLinkedList(carpathaux) ); px = GetIP_Coord(position, 'x', decoder); py = GetIP_Coord(position, 'y', decoder); pz = GetIP_Coord(position, 'z', decoder); for( carpathaux = getNextNodeLinkedList(carpathaux); carpathaux !=NULL; carpathaux = getNextNodeLinkedList(carpathaux) ) { time++; position = *( (int*) getItemLinkedList(carpathaux) ); x = GetIP_Coord(position, 'x', decoder); y = GetIP_Coord(position, 'y', decoder); z = GetIP_Coord(position, 'z', decoder); if( (x - px) != 0 ) direction = 'x'; else if( (y - py) != 0 ) direction = 'y'; else if( (z - pz) != 0 ) direction = 'z'; /*We dont write to the file in the first iteration after the car leaves the entry, but we need to find the direction*/ if( direction != pdirection && time != 0) { escreve_saida( outputfile, carname, entrytime + time, px , py , pz, 'm'); if(GetIP_Type(position, decoder) == 'u' || GetIP_Type(position, decoder) == 'd') time++; } px = x; py = y; pz = z; pdirection = direction; } time++; timecompare = time; parkingtime = entrytime + time; escreve_saida( outputfile, carname, entrytime + time, px, py, pz, 'e'); AddParkedCar(carname, x, y, z, parkinglot); time--; for( footpathaux = footpath; footpathaux !=NULL; footpathaux = getNextNodeLinkedList(footpathaux) ) { time++; position = *( (int*) getItemLinkedList(footpathaux) ); x = GetIP_Coord(position, 'x', decoder); y = GetIP_Coord(position, 'y', decoder); z = GetIP_Coord(position, 'z', decoder); if( (x - px) != 0 ) direction = 'x'; else if( (y - py) != 0 ) direction = 'y'; else if( (z - pz) != 0 ) direction = 'z'; if( (direction != pdirection && time != timecompare) || (time == timecompare+1) ) { escreve_saida( outputfile, carname, entrytime + time, px , py , pz, 'p'); if(GetIP_Type(position, decoder) == 'u' || GetIP_Type(position, decoder) == 'd') time++; } px = x; py = y; pz = z; pdirection = direction; } time++; escreve_saida( outputfile, carname, entrytime + time, px, py, pz, 'a'); /*Writes the balance of the path*/ escreve_saida( outputfile, carname, entrytime, parkingtime, entrytime + time, pathweight, 'x'); }
already_AddRefed<MediaDataDecoder> PDMFactory::CreateDecoder(const TrackInfo& aConfig, FlushableTaskQueue* aTaskQueue, MediaDataDecoderCallback* aCallback, layers::LayersBackend aLayersBackend, layers::ImageContainer* aImageContainer) { nsRefPtr<PlatformDecoderModule> current = (mEMEPDM && aConfig.mCrypto.mValid) ? mEMEPDM : GetDecoder(aConfig.mMimeType); if (!current) { return nullptr; } nsRefPtr<MediaDataDecoder> m; if (aConfig.GetAsAudioInfo()) { m = current->CreateAudioDecoder(*aConfig.GetAsAudioInfo(), aTaskQueue, aCallback); return m.forget(); } if (!aConfig.GetAsVideoInfo()) { return nullptr; } MediaDataDecoderCallback* callback = aCallback; nsRefPtr<DecoderCallbackFuzzingWrapper> callbackWrapper; if (sEnableFuzzingWrapper) { callbackWrapper = new DecoderCallbackFuzzingWrapper(aCallback); callbackWrapper->SetVideoOutputMinimumInterval( TimeDuration::FromMilliseconds(sVideoOutputMinimumInterval_ms)); callbackWrapper->SetDontDelayInputExhausted(sDontDelayInputExhausted); callback = callbackWrapper.get(); } if (H264Converter::IsH264(aConfig)) { nsRefPtr<H264Converter> h = new H264Converter(current, *aConfig.GetAsVideoInfo(), aLayersBackend, aImageContainer, aTaskQueue, callback); const nsresult rv = h->GetLastError(); if (NS_SUCCEEDED(rv) || rv == NS_ERROR_NOT_INITIALIZED) { // The H264Converter either successfully created the wrapped decoder, // or there wasn't enough AVCC data to do so. Otherwise, there was some // problem, for example WMF DLLs were missing. m = h.forget(); } } else { m = current->CreateVideoDecoder(*aConfig.GetAsVideoInfo(), aLayersBackend, aImageContainer, aTaskQueue, callback); } if (callbackWrapper && m) { m = new DecoderFuzzingWrapper(m.forget(), callbackWrapper.forget()); } return m.forget(); }