mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2025-07-01 15:25:35 +00:00
Further bugfixes and improvements for AML decoder
This commit is contained in:
parent
a8d5f7e2e7
commit
00c28f53d8
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
#define SYNC_OUTSIDE 0x02
|
#define SYNC_OUTSIDE 0x02
|
||||||
#define UCODE_IP_ONLY_PARAM 0x08
|
#define UCODE_IP_ONLY_PARAM 0x08
|
||||||
#define MAX_WRITE_ATTEMPTS 3
|
#define MAX_WRITE_ATTEMPTS 5
|
||||||
#define EAGAIN_SLEEP_TIME 2 * 1000
|
#define EAGAIN_SLEEP_TIME 2 * 1000
|
||||||
|
|
||||||
static codec_para_t codecParam = { 0 };
|
static codec_para_t codecParam = { 0 };
|
||||||
@ -82,10 +82,16 @@ int aml_setup(int videoFormat, int width, int height, int redrawRate, void* cont
|
|||||||
codecParam.has_video = 1;
|
codecParam.has_video = 1;
|
||||||
codecParam.noblock = 0;
|
codecParam.noblock = 0;
|
||||||
codecParam.stream_type = STREAM_TYPE_ES_VIDEO;
|
codecParam.stream_type = STREAM_TYPE_ES_VIDEO;
|
||||||
codecParam.dec_mode = STREAM_TYPE_FRAME;
|
|
||||||
codecParam.video_path = FRAME_BASE_PATH_AMLVIDEO_AMVIDEO;
|
|
||||||
codecParam.am_sysinfo.param = 0;
|
codecParam.am_sysinfo.param = 0;
|
||||||
|
|
||||||
|
#ifdef STREAM_TYPE_FRAME
|
||||||
|
codecParam.dec_mode = STREAM_TYPE_FRAME;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef FRAME_BASE_PATH_AMLVIDEO_AMVIDEO
|
||||||
|
codecParam.video_path = FRAME_BASE_PATH_AMLVIDEO_AMVIDEO;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (videoFormat & VIDEO_FORMAT_MASK_H264) {
|
if (videoFormat & VIDEO_FORMAT_MASK_H264) {
|
||||||
if (width > 1920 || height > 1080) {
|
if (width > 1920 || height > 1080) {
|
||||||
codecParam.video_type = VFORMAT_H264_4K2K;
|
codecParam.video_type = VFORMAT_H264_4K2K;
|
||||||
@ -166,7 +172,7 @@ int aml_submit_decode_unit(PDECODE_UNIT decodeUnit) {
|
|||||||
|
|
||||||
ensure_buf_size(&pkt_buf, &pkt_buf_size, decodeUnit->fullLength);
|
ensure_buf_size(&pkt_buf, &pkt_buf_size, decodeUnit->fullLength);
|
||||||
|
|
||||||
int result = DR_OK, written = 0, length = 0, errCounter = 0;
|
int written = 0, length = 0, errCounter = 0, api;
|
||||||
PLENTRY entry = decodeUnit->bufferList;
|
PLENTRY entry = decodeUnit->bufferList;
|
||||||
do {
|
do {
|
||||||
memcpy(pkt_buf+length, entry->data, entry->length);
|
memcpy(pkt_buf+length, entry->data, entry->length);
|
||||||
@ -175,27 +181,27 @@ int aml_submit_decode_unit(PDECODE_UNIT decodeUnit) {
|
|||||||
} while (entry != NULL);
|
} while (entry != NULL);
|
||||||
|
|
||||||
codec_checkin_pts(&codecParam, decodeUnit->presentationTimeMs);
|
codec_checkin_pts(&codecParam, decodeUnit->presentationTimeMs);
|
||||||
do {
|
while (length > 0) {
|
||||||
written = codec_write(&codecParam, pkt_buf+written, length);
|
api = codec_write(&codecParam, pkt_buf+written, length);
|
||||||
if (written < 0) {
|
if (api < 0) {
|
||||||
written = 0;
|
|
||||||
if (errno != EAGAIN) {
|
if (errno != EAGAIN) {
|
||||||
fprintf(stderr, "codec_write error: %x %d\n", errno, written);
|
fprintf(stderr, "codec_write() error: %x %d\n", errno, api);
|
||||||
codec_reset(&codecParam);
|
codec_reset(&codecParam);
|
||||||
result = DR_NEED_IDR;
|
|
||||||
} else {
|
|
||||||
usleep(EAGAIN_SLEEP_TIME);
|
|
||||||
++errCounter;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
length -= written;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
} while (errCounter < MAX_WRITE_ATTEMPTS);
|
} else {
|
||||||
|
if (++errCounter == MAX_WRITE_ATTEMPTS) {
|
||||||
|
fprintf(stderr, "codec_write() timeout\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
usleep(EAGAIN_SLEEP_TIME);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
written += api;
|
||||||
|
length -= api;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return length ? DR_NEED_IDR : DR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
DECODER_RENDERER_CALLBACKS decoder_callbacks_aml = {
|
DECODER_RENDERER_CALLBACKS decoder_callbacks_aml = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user