代码拉取完成,页面将自动刷新
#include "codec.h"
/* proprietary gopro codec.
* Contains:
* 8 FirmwareVersion
23 SerialNumber
87 OtherSerialNumber
102 Model
always starts with GP, but I have no idea how to guess the length of the packet.
maybe follows a pattern? 264, 152 16 16 16...
https://github.com/stilldavid/gopro-utils can parse the gpmd codec.
*/
#include <iostream>
using namespace std;
Match Codec::fdscSearch(const unsigned char *start, int maxlength) {
Match match;
const unsigned char *end = start + maxlength - 8;
const unsigned char *current = start;
while(current < end) {
if(current[0] == 'G' && current[1] == 'P') {
match.chances = 1<<20;
match.offset = current - start;
return match;
}
current++;
}
return match;
}
Match Codec::fdscMatch(const unsigned char *start, int maxlength) {
Match match;
if(start[0] != 'G' || start[1] != 'P')
return match;
match.chances = 1<<16;
match.length = 0;
if(start[2] == 'R' && start[3] == 'O') {
match.length = *(uint16_t *)(start + 4);
return match;
}
uint8_t type = start[2]; //assuming it's a single byte and actualy is a type.
//type 00 seems to be followed always by 03
match.length = 16;
if(type == 0) {
//this seems to be a marker for the next sample.
uint32_t next_sample_length = readBE<int>(start +4);
}
if(type == 3) { //it seems this is a thumbnail type pointing to the first frame of the video, similar to type 0, but longer.
//match.length = 16;
//match.length += 4 + readBE<int>(start +16); //maybe here is a lenght, but it's not the last one. and padding is possible,
match.length = 152; //found 152 in the single sample I got.
}
if(type == 4 || type == 5) { //contains some data.
//a length is int32 at byte 4, don't kwnow which data.
match.length = 16;
}
if(type == 15) //another wild guess.
match.length = 220;
/*
static int idx = -1;
idx++;
if (idx == 0) {
for(auto pos = start + 4; maxlength > 0; pos += 4, maxlength -= 4) {
if (pos[0] == 'G' && pos[1] == 'P') {
match.length = pos - start;
break;
}
}
} else if (idx == 1) {
match.length = 152;
} else
match.length = 16; */
return match;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。