胡斌

support rotate of teacher video in one2one mode

parse width and height in record info file
... ... @@ -606,7 +606,37 @@ int CAVTranscoder::open_output_file(const char *filename)
}
if (_teacherFrame) {
fillDestFrame(pDstFrame, _teacherFrame, 0, 0);
if (_teacherFrame->width == SRC_W && _teacherFrame->height == SRC_H) {
if (_teacherFrame->pkt_dts != 90){
fillDestFrame(pDstFrame, _teacherFrame, 0, 0);
}
else {
memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _nOutputHeight / 2);
memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _nOutputHeight / 8);
memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _nOutputHeight / 8);
fillDestFrame(pDstFrame, _teacherFrame, (SRC_W - SRC_H) / 2, 0, (SRC_W - SRC_H) / 2, 0, SRC_H, SRC_H);
}
}
else if (_teacherFrame->width == SRC_H && _teacherFrame->height == SRC_W) {
if (_teacherFrame->pkt_dts == 90){
fillDestFrame(pDstFrame, _teacherFrame, 0, 0);
}
else {
memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _nOutputHeight / 2);
memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _nOutputHeight / 8);
memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _nOutputHeight / 8);
fillDestFrame(pDstFrame, _teacherFrame, (SRC_W - SRC_H) / 2, 0, 0, (SRC_W - SRC_H) / 2, SRC_H, SRC_H);
}
}
else if (_teacherFrame->width == SRC_H && _teacherFrame->height == SRC_H) {
memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _nOutputHeight / 2);
memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _nOutputHeight / 8);
memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _nOutputHeight / 8);
fillDestFrame(pDstFrame, _teacherFrame, (SRC_W - SRC_H) / 2, 0);
}
else {
printf("\nresolution: %dx%d unexpected!", _studentFrame->width, _studentFrame->height);
}
if (_studentFrame) {
if (_studentFrame->width == SRC_W) {
if (_studentFrame->pkt_dts != 90){
... ... @@ -636,7 +666,7 @@ int CAVTranscoder::open_output_file(const char *filename)
fillDestFrame(pDstFrame, _studentFrame, 0, 0);
}
else {
fillDestFrame(pDstFrame, _studentFrame, (SRC_W - SRC_H) / 2, 0, (SRC_W - SRC_H) / 2, 0, SRC_W, SRC_H);
fillDestFrame(pDstFrame, _studentFrame, (SRC_W - SRC_H) / 2, 0, (SRC_W - SRC_H) / 2, 0, SRC_H, SRC_H);
}
}
else if (_studentFrame->width == SRC_H && _studentFrame->height == SRC_W) {
... ... @@ -644,7 +674,7 @@ int CAVTranscoder::open_output_file(const char *filename)
fillDestFrame(pDstFrame, _studentFrame, 0, 0);
}
else {
fillDestFrame(pDstFrame, _studentFrame, (SRC_W - SRC_H) / 2, 0, 0, (SRC_W - SRC_H) / 2, SRC_W, SRC_H);
fillDestFrame(pDstFrame, _studentFrame, (SRC_W - SRC_H) / 2, 0, 0, (SRC_W - SRC_H) / 2, SRC_H, SRC_H);
}
}
else if (_studentFrame->width == SRC_H && _studentFrame->height == SRC_H) {
... ...
... ... @@ -29,6 +29,8 @@ public:
float end_time;
int64_t end_time_ms;
string name;
int width;
int height;
int rotate;
float duration;
... ...
... ... @@ -24,6 +24,8 @@ public:
unsigned int uid;
media_type m_type;
media_role m_role;
int width;
int height;
int rotate; //degree,0,90,180 ...
};
... ... @@ -126,10 +128,12 @@ void addinfo(float t, string name, bool bstart,media_role role,unsigned int uid)
}
}
void addinfo(const char * name, const char * rotation){
void addinfo(const char * name, const char * width, const char * height, const char * rotation){
int i = 0;
for (; i < media_files.size(); i++) {
if (media_files[i].name == name) {
media_files[i].width = atoi(width);
media_files[i].height = atoi(height);
media_files[i].rotate = atoi(rotation);
break;
}
... ... @@ -141,7 +145,20 @@ void addinfo(const char * name, const char * rotation){
}
}
void addinfo(const char * name, const char * rotation){
int i = 0;
for (; i < media_files.size(); i++) {
if (media_files[i].name == name) {
media_files[i].rotate = atoi(rotation);
break;
}
}
if (i == media_files.size())
{
printf("\nerror ,file : %s info but not found!", name);
}
}
void split(string str, string separator, vector<string> &result, bool includeEmptyItem = false) {
result.clear();
... ... @@ -625,6 +642,8 @@ void add_media_infos()
m.t_type = tt_start;
m.duration = f.end_time - f.start_time;
m.type_time = m.start_time;
m.width = f.width;
m.height = f.height;
m.rotate = f.rotate;
m.m_role = f.m_role;
m.uid = f.uid;
... ... @@ -664,7 +683,7 @@ void add_media_infos()
printf("\nsorted file info:");
it = sorted_media_with_end.begin();
for (; it != sorted_media_with_end.end();it++){
printf("\n%2d %8.3f %s %s", it->sorted_index, it->type_time, it->name.c_str(), it->t_type == tt_start ? "start" : "end");
printf("\n%2d %8.3f %s %4d %4d %3d %s", it->sorted_index, it->type_time, it->name.c_str(), it->width, it->height, it->rotate, it->t_type == tt_start ? "start" : "end");
}
printf("\n-------------------------\n");
... ... @@ -843,9 +862,14 @@ int readfile(const char * filename, media_role role)
}
else if (res[2] == "info") {
if (res.size() > 5) {
const char * pInfo = res[5].c_str();
if (!strncmp(pInfo, "rotation=", 9)){
addinfo(res[1].c_str(), pInfo + 9);
const char * pInfoW = res[3].c_str();
const char * pInfoH = res[4].c_str();
const char * pInfoR = res[5].c_str();
if (!strncmp(pInfoW, "width=", 6) && !strncmp(pInfoH, "height=", 7) && !strncmp(pInfoR, "rotation=", 9)){
addinfo(res[1].c_str(), pInfoW + 6, pInfoH + 7, pInfoR + 9);
}
else {
printf("error info: %s,", str);
}
}
}
... ... @@ -855,6 +879,10 @@ int readfile(const char * filename, media_role role)
if (!strncmp(pInfo, "rotation=", 9)){
addinfo(res[1].c_str(), pInfo + 9);
}
else
{
printf("error rotation: %s,", str);
}
}
}
}
... ...