From 635576972024319c15141645d3304db8cd1d1e19 Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Mon, 8 Aug 2022 13:50:34 -0400 Subject: basic bezier path system added --- ffmpeg_backend.cpp | 123 ++--------------------------------------------------- 1 file changed, 4 insertions(+), 119 deletions(-) (limited to 'ffmpeg_backend.cpp') diff --git a/ffmpeg_backend.cpp b/ffmpeg_backend.cpp index 1f920ba..bece065 100644 --- a/ffmpeg_backend.cpp +++ b/ffmpeg_backend.cpp @@ -210,7 +210,8 @@ void AV_GetPTSAverage(source *Source, av_info *AV, int32 *err) av_seek_frame(AV->FileFormatContext, -1, 0, AVSEEK_FLAG_BACKWARD); } -bool32 AV_LoadVideoFrame(source *Source, layer_bitmap_info *BitmapInfo, memory *Memory, int32 TimelineFrame) + +cached_bitmap * AV_LoadVideoFrame(source *Source, layer_bitmap_info *BitmapInfo, memory *Memory, int32 TimelineFrame) { av_info *AV = (av_info *)BitmapInfo->AVInfo; int32 *CurrentlyRenderedFrame = &BitmapInfo->CurrentFrame; @@ -272,81 +273,9 @@ bool32 AV_LoadVideoFrame(source *Source, layer_bitmap_info *BitmapInfo, memory * uint16 BytesPerPixel = Source->Info.BytesPerPixel; int32 Pitch = Width*BytesPerPixel; - memory_table *Table = &Memory->Slot[B_LoadedBitmaps]; - - // First check whether we'd run over the buffer at the current - // position, and reset it if so. - uint64 Size = Bitmap_CalcTotalBytes(Width, Height, BytesPerPixel); - if (Table->CurrentPosition + Size > Table->Size) { - Table->CurrentPosition = 0; - Table->PointerIndex = 0; - } - cached_bitmap *Bitmap = &Memory->Bitmap[Table->PointerIndex]; - - // Next, if there's a pointer in front of the current position, - // check whether it's far away enough so that the size fits. - bool32 BS = true; - if (Bitmap->Data) { - uint64 BytesBetween = (uint8 *)Bitmap->Data - ((uint8 *)Table->Address + Table->CurrentPosition); - if (BytesBetween > Size) { - int16 StopAt = Table->NumberOfPointers - 1; - while (StopAt > Table->PointerIndex - 1) { - Memory->Bitmap[StopAt + 1] = Memory->Bitmap[StopAt]; - StopAt--; - } - Table->NumberOfPointers++; - BS = false; - } - } - // If it doesn't fit, then we need to dereference the pointers - // until we have enough space. - if ((Table->PointerIndex < Table->NumberOfPointers) && BS) - { - bool32 Avail = false; - void *AddressStart = (void *)((uint8 *)Table->Address + Table->CurrentPosition); - uint32 Amount = 0; - while(!Avail) { - // Bail out if we're on the last index, as we don't need to do anything else. - if (Table->PointerIndex != Table->NumberOfPointers - 1) { - void *Data2 = Memory->Bitmap[Table->PointerIndex+1].Data; - uint64 BytesBetween = (uint8 *)Data2 - (uint8 *)AddressStart; - if (BytesBetween < Size) { - int16 StopAt = Table->PointerIndex; - while (StopAt < Table->NumberOfPointers - 1) { - Memory->Bitmap[StopAt] = Memory->Bitmap[StopAt + 1]; - StopAt++; - } - Amount++; - Table->NumberOfPointers--; - if (Amount > 2) { - Amount += 0; - } - } else { - Avail = true; - } - } else { - Avail = true; - } - } - } - // Increment the total number of pointers if the bitmap is - // empty, i.e. we're at the first iteration of the buffer loop. - if (!Bitmap->Data) { - Table->NumberOfPointers++; - } - Bitmap->Data = AllocateMemory(Memory, Size, B_LoadedBitmaps); - if (!Bitmap->Data) { - Assert(0); - } - Bitmap->SourceOwner = Source; - Bitmap->Frame = FrameToSeek; - Table->PointerIndex++; + cached_bitmap *Bitmap = Memory_RollingBitmap(Memory, Source, FrameToSeek); void *Buffer = Bitmap->Data; - // No two pointers on the table should hold the same data - // address or be empty. - Debug_Memory_Assert_Cohesion(Memory, Table); - int out_linesize[4] = { Pitch, Pitch, Pitch, Pitch }; uint8 *dst_data[4] = { (uint8 *)Buffer, (uint8 *)Buffer + Width*Height*BytesPerPixel, (uint8 *)Buffer + Width*Height*BytesPerPixel*2, (uint8 *)Buffer + Width*Height*BytesPerPixel*3 }; @@ -366,14 +295,7 @@ bool32 AV_LoadVideoFrame(source *Source, layer_bitmap_info *BitmapInfo, memory * av_frame_unref(AV->VideoFrame); Assert(BitmapInfo->BitmapBuffer); - void *DestBuffer = BitmapInfo->BitmapBuffer; - Bitmap_ConvertPacking(Buffer, DestBuffer, Width, Height, BytesPerPixel, 0); - // void *Buffer2 = AllocateMemory(Memory, Bitmap_CalcTotalBytes(Width, Height, BytesPerPixel), B_LoadedBitmaps); - // uint64 test = &Buffer2 - &Buffer; - // CopyToBuffer(Buffer, 1); - // Bitmap_Clear(Buffer, Source->Info.Width, Source->Info.Height, Source->Info.BytesPerPixel); - - return 1; + return Bitmap; } else { @@ -383,42 +305,5 @@ bool32 AV_LoadVideoFrame(source *Source, layer_bitmap_info *BitmapInfo, memory * av_frame_unref(AV->VideoFrame); } } - /* - for (int p = 0; p < 8000; p++) { - av_packet_unref(AV->VideoPacket); - int i = 0; - while (i < 5) - { - err = avcodec_send_packet(AV->VideoCodecContext, AV->VideoPacket); - if (err < 0) - { - fprintf(stderr, "Libav error: (%s)\n", av_err2str(err)); - Assert(0); - } - err = avcodec_receive_frame(AV->VideoCodecContext, AV->VideoFrame); - if (err >= 0) { - break; - } else if (err < 0) { - fprintf(stderr, "Libav error: (%s)\n", av_err2str(err)); - } - i++; - } - } - */ - - - /* - uint8 *Test = pFrame->data[0]; - - for (int16 Y = 0; Y < Buffer.Height; Y++) { - for (int16 X = 0; X < Buffer.Width; X++) { - uint8 *Row = (uint8 *)Buffer.OriginalBuffer + Buffer.Pitch*Y; - uint32 *Pixel = (uint32 *)Row + X; - *Pixel = (uint32)((0xFF << 24) | *Test); - Test++; - } - } - */ - return 0; } -- cgit v1.2.3