aboutsummaryrefslogtreecommitdiff
path: root/Src/f263/mkv_f263_decoder.cpp
diff options
context:
space:
mode:
authorJean-Francois Mauguit <jfmauguit@mac.com>2024-09-24 09:03:25 -0400
committerGitHub <noreply@github.com>2024-09-24 09:03:25 -0400
commitbab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/f263/mkv_f263_decoder.cpp
parent4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff)
parent20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff)
downloadwinamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/f263/mkv_f263_decoder.cpp')
-rw-r--r--Src/f263/mkv_f263_decoder.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/Src/f263/mkv_f263_decoder.cpp b/Src/f263/mkv_f263_decoder.cpp
new file mode 100644
index 00000000..a2c111f0
--- /dev/null
+++ b/Src/f263/mkv_f263_decoder.cpp
@@ -0,0 +1,94 @@
+#include "mkv_f263_decoder.h"
+#include "lib.h"
+
+int MKVDecoderCreator::CreateVideoDecoder(const char *codec_id, const nsmkv::TrackEntryData *track_entry_data, const nsmkv::VideoData *video_data, ifc_mkvvideodecoder **decoder)
+{
+ if (!strcmp(codec_id, "V_MS/VFW/FOURCC"))
+ {
+ if (track_entry_data->codec_private && track_entry_data->codec_private_len)
+ {
+ const BITMAPINFOHEADER *header = (const BITMAPINFOHEADER *)track_entry_data->codec_private;
+ if (header->biCompression == '1VLF')
+ {
+ void *ctx = F263_CreateDecoder();
+ *decoder = new MKVFLV1(ctx);
+ return CREATEDECODER_SUCCESS;
+ }
+ }
+ return CREATEDECODER_NOT_MINE;
+ }
+ else
+ {
+ return CREATEDECODER_NOT_MINE;
+ }
+}
+
+
+#define CBCLASS MKVDecoderCreator
+START_DISPATCH;
+CB(CREATE_VIDEO_DECODER, CreateVideoDecoder)
+END_DISPATCH;
+#undef CBCLASS
+
+
+
+MKVFLV1::MKVFLV1(void *ctx) : decoder(ctx)
+{
+
+}
+
+int MKVFLV1::GetOutputProperties(int *x, int *y, int *color_format, double *aspect_ratio)
+{
+ if (width && height)
+ {
+ *x = width;
+ *y = height;
+ *color_format = '21VY';
+ *aspect_ratio=1.0;
+ return MKV_SUCCESS;
+ }
+ return MKV_FAILURE;
+}
+
+int MKVFLV1::DecodeBlock(const void *inputBuffer, size_t inputBufferBytes, uint64_t timestamp)
+{
+ last_timestamp = (int32_t)timestamp;
+ int keyframe;
+
+ int ret = F263_DecodeFrame(decoder, const_cast<void *>(inputBuffer), inputBufferBytes, &yv12, &width, &height, &keyframe);
+ if (ret == F263_OK)
+ {
+ decoded=1;
+ return MKV_SUCCESS;
+ }
+ else
+ return MKV_FAILURE;
+}
+
+void MKVFLV1::Flush()
+{
+}
+
+int MKVFLV1::GetPicture(void **data, void **decoder_data, uint64_t *timestamp)
+{
+ if (decoded)
+ {
+ *timestamp = last_timestamp;
+ *decoder_data = 0;
+ *data = &yv12;
+ decoded=0;
+ return MKV_SUCCESS;
+ }
+ return MKV_FAILURE;
+}
+
+
+#define CBCLASS MKVFLV1
+START_DISPATCH;
+CB(GET_OUTPUT_PROPERTIES, GetOutputProperties)
+CB(DECODE_BLOCK, DecodeBlock)
+VCB(FLUSH, Flush)
+CB(GET_PICTURE, GetPicture)
+END_DISPATCH;
+#undef CBCLASS
+