-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mdec/movie - simple in-ram bitstream player
- Loading branch information
1 parent
29eca5d
commit 837c334
Showing
10 changed files
with
116,402 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
all: | ||
@$(MAKE) --no-print-directory -f makefile.15bit clean all | ||
@$(MAKE) --no-print-directory -f makefile.24bit clean all | ||
|
||
clean: | ||
@$(MAKE) --no-print-directory -f makefile.15bit clean | ||
@$(MAKE) --no-print-directory -f makefile.24bit clean |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#include <common.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <malloc.h> | ||
#include <io.h> | ||
#include <dma.hpp> | ||
#include <mdec.h> | ||
#include <gpu.h> | ||
|
||
#include "bad_apple.h" | ||
|
||
#define SCR_W 256 | ||
#define SCR_H 240 | ||
|
||
uint32_t* buffer = nullptr; | ||
void decodeAndDisplayFrame(uint8_t* frame, size_t frameLen, uint16_t frameWidth, uint16_t frameHeight) { | ||
const int STRIPE_WIDTH = 16; | ||
const int STRIPE_HEIGHT = frameHeight; | ||
|
||
#ifdef USE_24BIT | ||
const ColorDepth depth = ColorDepth::bit_24; | ||
const int copyWidth = STRIPE_WIDTH * 3/2; | ||
#define BYTES_PER_PIXEL 3 | ||
#else | ||
const ColorDepth depth = ColorDepth::bit_15; | ||
const int copyWidth = STRIPE_WIDTH; | ||
#define BYTES_PER_PIXEL 2 | ||
#endif | ||
|
||
mdec_decodeDma((uint16_t*)frame, frameLen, depth, false, false); | ||
|
||
if (buffer == nullptr) { | ||
buffer = (uint32_t*)malloc(STRIPE_WIDTH * STRIPE_HEIGHT * BYTES_PER_PIXEL / 4 * sizeof(uint32_t)); | ||
} | ||
for (int c = 0; c < frameWidth / STRIPE_WIDTH; c++) { | ||
mdec_readDecodedDma(buffer, STRIPE_WIDTH * STRIPE_HEIGHT * BYTES_PER_PIXEL); | ||
vramWriteDMA(c * copyWidth, 0, copyWidth, STRIPE_HEIGHT, (uint16_t*)buffer); | ||
} | ||
} | ||
|
||
int main() { | ||
SetVideoMode(MODE_NTSC); | ||
initVideo(SCR_W, SCR_H); | ||
printf("\nmdec/frame\n"); | ||
#ifdef USE_24BIT | ||
extern DISPENV disp; | ||
disp.isrgb24 = true; | ||
PutDispEnv(&disp); | ||
printf("Using framebuffer in 24bit mode\n"); | ||
#endif | ||
|
||
clearScreen(); | ||
|
||
mdec_reset(); | ||
mdec_quantTable(quant, true); | ||
mdec_idctTable((int16_t*)idct); | ||
mdec_enableDma(); | ||
|
||
for (int i = 0; i<60*2; i++) { | ||
VSync(0); | ||
} | ||
|
||
for (int i = 0; i<FRAME_COUNT; i++) { | ||
frame_t frame = frames[i]; | ||
decodeAndDisplayFrame(&movieBitstream[frame.offset], frame.size, SCR_W, SCR_H); | ||
VSync(0); | ||
} | ||
|
||
free(buffer); | ||
printf("Done\n"); | ||
|
||
// Stop all pending DMA transfers | ||
write32(DMA::CH_CONTROL_ADDR + 0x10 * (int)DMA::Channel::MDECin, 0); | ||
write32(DMA::CH_CONTROL_ADDR + 0x10 * (int)DMA::Channel::MDECout, 0); | ||
write32(DMA::CH_CONTROL_ADDR + 0x10 * (int)DMA::Channel::GPU, 0); | ||
DMA::masterEnable(DMA::Channel::MDECout, false); | ||
DMA::masterEnable(DMA::Channel::MDECin, false); | ||
DMA::masterEnable(DMA::Channel::GPU, false); | ||
|
||
mdec_reset(); | ||
for (;;) { | ||
VSync(0); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
TARGET = movie-15bit.elf | ||
|
||
include ../../common-test.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
TARGET = movie-24bit.elf | ||
|
||
include ../../common-test.mk | ||
|
||
CFLAGS += -DUSE_24BIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash -e | ||
export PATH=$PATH:/Users/jakub/dev/priv/mdec-tools/cmake-build-relwithdebinfo | ||
ffmpeg -hide_banner -loglevel panic -i bad_apple.mkv -ss 2 -t 00:00:25 -vf "fps=10,scale=256:240" -pix_fmt gray %04d.png | ||
mdec-tools -q=40 --color --movie *.png bad_apple.h | ||
rm *.png |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.