aboutsummaryrefslogtreecommitdiff
path: root/Src/f263/mkv_f263_decoder.cpp
blob: a2c111f07ec2169411c7aba6172540b91e1cd4d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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