implement using the height of student and teacher when merge one to one layout
it is to be improved in one to many case if the size of each student frame is different
正在显示
3 个修改的文件
包含
86 行增加
和
60 行删除
| 1 | #include "AVTranscoder.h" | 1 | #include "AVTranscoder.h" |
| 2 | #include "tools.h" | 2 | #include "tools.h" |
| 3 | +#include <minmax.h> | ||
| 3 | 4 | ||
| 4 | extern "C" { | 5 | extern "C" { |
| 5 | #include <libswscale/swscale.h> | 6 | #include <libswscale/swscale.h> |
| @@ -13,7 +14,7 @@ uint8_t blank_r = 0x16; | @@ -13,7 +14,7 @@ uint8_t blank_r = 0x16; | ||
| 13 | uint8_t blank_g = 0x5a; | 14 | uint8_t blank_g = 0x5a; |
| 14 | uint8_t blank_b = 0x82; | 15 | uint8_t blank_b = 0x82; |
| 15 | 16 | ||
| 16 | -CAVTranscoder::CAVTranscoder(bool bOne2One,int width,int height): | 17 | +CAVTranscoder::CAVTranscoder(bool bOne2One, int width_teacher, int height_teacher, int width_student, int height_student) : |
| 17 | _start_time(INT64_MAX), | 18 | _start_time(INT64_MAX), |
| 18 | _all_processed(true), | 19 | _all_processed(true), |
| 19 | _nOutputWidth(320), | 20 | _nOutputWidth(320), |
| @@ -30,22 +31,25 @@ _last_videos_got(-1), | @@ -30,22 +31,25 @@ _last_videos_got(-1), | ||
| 30 | _teacherFrame(NULL), | 31 | _teacherFrame(NULL), |
| 31 | _studentFrame(NULL) | 32 | _studentFrame(NULL) |
| 32 | { | 33 | { |
| 33 | - _src_width = width; | ||
| 34 | - _src_height = height; | ||
| 35 | - _scaled_width = _src_width * 10 / 32; | ||
| 36 | - _scaled_height = _src_height * 10 / 32; | 34 | + _teacher_width = width_teacher; |
| 35 | + _teacher_height = height_teacher; | ||
| 36 | + _student_width = width_student; | ||
| 37 | + _student_height = height_student; | ||
| 38 | + | ||
| 39 | + _scaled_width = _teacher_width * 10 / 32; | ||
| 40 | + _scaled_height = _teacher_height * 10 / 32; | ||
| 37 | _one2one = bOne2One; | 41 | _one2one = bOne2One; |
| 38 | if (_one2one) { | 42 | if (_one2one) { |
| 39 | - _nOutputWidth = _src_width; | ||
| 40 | - _nOutputHeight = _src_height * 2; | 43 | + _nOutputWidth = max(_teacher_width, _student_width); |
| 44 | + _nOutputHeight = _teacher_height + _student_height; | ||
| 41 | } | 45 | } |
| 42 | else { | 46 | else { |
| 43 | - _nOutputWidth = _src_width; | ||
| 44 | - _nOutputHeight = _src_height; | 47 | + _nOutputWidth = _teacher_width; |
| 48 | + _nOutputHeight = _teacher_height; | ||
| 45 | 49 | ||
| 46 | - init_scale_context(&_sws_ctx_w_h, &_scaled_frame_w_h, _src_width, _src_height, _scaled_width, _scaled_height); | ||
| 47 | - init_scale_context(&_sws_ctx_h_w, &_scaled_frame_h_w, _src_height, _src_width, _scaled_height, _scaled_width); | ||
| 48 | - init_scale_context(&_sws_ctx_h_h, &_scaled_frame_h_h, _src_height, _src_height, _scaled_height, _scaled_height); | 50 | + init_scale_context(&_sws_ctx_w_h, &_scaled_frame_w_h, _student_width, _student_height, _scaled_width, _scaled_height); |
| 51 | + init_scale_context(&_sws_ctx_h_w, &_scaled_frame_h_w, _student_height, _student_width, _scaled_height, _scaled_width); | ||
| 52 | + init_scale_context(&_sws_ctx_h_h, &_scaled_frame_h_h, _student_height, _student_height, _scaled_height, _scaled_height); | ||
| 49 | } | 53 | } |
| 50 | RGB2YUV(blank_r, blank_g, blank_b, &_blank_y, &_blank_u, &_blank_v); | 54 | RGB2YUV(blank_r, blank_g, blank_b, &_blank_y, &_blank_u, &_blank_v); |
| 51 | } | 55 | } |
| @@ -370,7 +374,7 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -370,7 +374,7 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 370 | continue; | 374 | continue; |
| 371 | } | 375 | } |
| 372 | int h = 0; | 376 | int h = 0; |
| 373 | - if (pFrame->width == _src_width && pFrame->height == _src_height) { | 377 | + if (pFrame->width == _student_width && pFrame->height == _student_height) { |
| 374 | h = sws_scale(_sws_ctx_w_h, pFrame->data, pFrame->linesize, 0, pFrame->height, | 378 | h = sws_scale(_sws_ctx_w_h, pFrame->data, pFrame->linesize, 0, pFrame->height, |
| 375 | _scaled_frame_w_h->data, _scaled_frame_w_h->linesize); | 379 | _scaled_frame_w_h->data, _scaled_frame_w_h->linesize); |
| 376 | if (h <= 0){ | 380 | if (h <= 0){ |
| @@ -378,9 +382,9 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -378,9 +382,9 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 378 | continue; | 382 | continue; |
| 379 | } | 383 | } |
| 380 | _scaled_frame_w_h->pkt_dts = pFrame->pkt_dts;//pass rotation | 384 | _scaled_frame_w_h->pkt_dts = pFrame->pkt_dts;//pass rotation |
| 381 | - fillDestFrame(pDstFrame, _scaled_frame_w_h, _src_width - (imageIdx % 4 + 1) * (_scaled_height + 5) + 4, _src_height - _scaled_height + 3 - (_scaled_height + 1)*(imageIdx / 4), (_scaled_width - _scaled_height) / 2, 0, _scaled_height - 3, _scaled_height - 3); | 385 | + fillDestFrame(pDstFrame, _scaled_frame_w_h, _teacher_width - (imageIdx % 4 + 1) * (_scaled_height + 5) + 4, _teacher_height - _scaled_height + 3 - (_scaled_height + 1)*(imageIdx / 4), (_scaled_width - _scaled_height) / 2, 0, _scaled_height - 3, _scaled_height - 3); |
| 382 | } | 386 | } |
| 383 | - else if (pFrame->width == _src_height && pFrame->height == _src_width) { | 387 | + else if (pFrame->width == _student_height && pFrame->height == _student_width) { |
| 384 | h = sws_scale(_sws_ctx_h_w, pFrame->data, pFrame->linesize, 0, pFrame->height, | 388 | h = sws_scale(_sws_ctx_h_w, pFrame->data, pFrame->linesize, 0, pFrame->height, |
| 385 | _scaled_frame_h_w->data, _scaled_frame_h_w->linesize); | 389 | _scaled_frame_h_w->data, _scaled_frame_h_w->linesize); |
| 386 | if (h <= 0){ | 390 | if (h <= 0){ |
| @@ -388,10 +392,10 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -388,10 +392,10 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 388 | continue; | 392 | continue; |
| 389 | } | 393 | } |
| 390 | _scaled_frame_h_w->pkt_dts = pFrame->pkt_dts;//pass rotation | 394 | _scaled_frame_h_w->pkt_dts = pFrame->pkt_dts;//pass rotation |
| 391 | - fillDestFrame(pDstFrame, _scaled_frame_h_w, _src_width - (imageIdx % 4 + 1) * (_scaled_height + 5) + 4, _src_height - _scaled_height + 3 - (_scaled_height + 1)*(imageIdx / 4), 0, (_scaled_width - _scaled_height) / 2, _scaled_height - 3, _scaled_height - 3); | 395 | + fillDestFrame(pDstFrame, _scaled_frame_h_w, _teacher_width - (imageIdx % 4 + 1) * (_scaled_height + 5) + 4, _teacher_height - _scaled_height + 3 - (_scaled_height + 1)*(imageIdx / 4), 0, (_scaled_width - _scaled_height) / 2, _scaled_height - 3, _scaled_height - 3); |
| 392 | 396 | ||
| 393 | } | 397 | } |
| 394 | - else if (pFrame->width == _src_height && pFrame->height == _src_height) { | 398 | + else if (pFrame->width == _student_height && pFrame->height == _student_height) { |
| 395 | h = sws_scale(_sws_ctx_h_h, pFrame->data, pFrame->linesize, 0, pFrame->height, | 399 | h = sws_scale(_sws_ctx_h_h, pFrame->data, pFrame->linesize, 0, pFrame->height, |
| 396 | _scaled_frame_h_h->data, _scaled_frame_h_h->linesize); | 400 | _scaled_frame_h_h->data, _scaled_frame_h_h->linesize); |
| 397 | if (h <= 0){ | 401 | if (h <= 0){ |
| @@ -399,7 +403,7 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -399,7 +403,7 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 399 | continue; | 403 | continue; |
| 400 | } | 404 | } |
| 401 | _scaled_frame_h_h->pkt_dts = pFrame->pkt_dts;//pass rotation | 405 | _scaled_frame_h_h->pkt_dts = pFrame->pkt_dts;//pass rotation |
| 402 | - fillDestFrame(pDstFrame, _scaled_frame_h_h, _src_width - (imageIdx % 4 + 1) * (_scaled_height + 5) + 4, _src_height - _scaled_height + 3 - (_scaled_height + 1)*(imageIdx / 4), 0, 0, _scaled_height - 3, _scaled_height - 3); | 406 | + fillDestFrame(pDstFrame, _scaled_frame_h_h, _teacher_width - (imageIdx % 4 + 1) * (_scaled_height + 5) + 4, _teacher_height - _scaled_height + 3 - (_scaled_height + 1)*(imageIdx / 4), 0, 0, _scaled_height - 3, _scaled_height - 3); |
| 403 | } | 407 | } |
| 404 | else { | 408 | else { |
| 405 | printf("\nthe frame resolution %dx%d is unexpected! ignored!", pFrame->width, pFrame->height); | 409 | printf("\nthe frame resolution %dx%d is unexpected! ignored!", pFrame->width, pFrame->height); |
| @@ -609,90 +613,110 @@ int CAVTranscoder::open_output_file(const char *filename) | @@ -609,90 +613,110 @@ int CAVTranscoder::open_output_file(const char *filename) | ||
| 609 | } | 613 | } |
| 610 | 614 | ||
| 611 | if (_teacherFrame) { | 615 | if (_teacherFrame) { |
| 612 | - if (_teacherFrame->width == _src_width && _teacherFrame->height == _src_height) { | 616 | + if (_teacherFrame->width == _teacher_width && _teacherFrame->height == _teacher_height) { |
| 613 | if (_teacherFrame->pkt_dts != 90){ | 617 | if (_teacherFrame->pkt_dts != 90){ |
| 618 | + if (_teacher_width < _nOutputWidth) { | ||
| 619 | + memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _teacher_height); | ||
| 620 | + memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _teacher_height / 4); | ||
| 621 | + memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _teacher_height / 4); | ||
| 622 | + } | ||
| 614 | fillDestFrame(pDstFrame, _teacherFrame, 0, 0); | 623 | fillDestFrame(pDstFrame, _teacherFrame, 0, 0); |
| 615 | } | 624 | } |
| 616 | else { | 625 | else { |
| 617 | - memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _nOutputHeight / 2); | ||
| 618 | - memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _nOutputHeight / 8); | ||
| 619 | - memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _nOutputHeight / 8); | ||
| 620 | - fillDestFrame(pDstFrame, _teacherFrame, (_src_width - _src_height) / 2, 0, (_src_width - _src_height) / 2, 0, _src_height, _src_height); | 626 | + memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _teacher_height); |
| 627 | + memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _teacher_height / 4); | ||
| 628 | + memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _teacher_height / 4); | ||
| 629 | + fillDestFrame(pDstFrame, _teacherFrame, (_nOutputWidth - _teacher_height) / 2, 0, (_teacher_width - _teacher_height) / 2, 0, _teacher_height, _teacher_height); | ||
| 621 | } | 630 | } |
| 622 | } | 631 | } |
| 623 | - else if (_teacherFrame->width == _src_height && _teacherFrame->height == _src_width) { | 632 | + else if (_teacherFrame->width == _teacher_height && _teacherFrame->height == _teacher_width) { |
| 624 | if (_teacherFrame->pkt_dts == 90){ | 633 | if (_teacherFrame->pkt_dts == 90){ |
| 634 | + if (_teacher_width < _nOutputWidth) { | ||
| 635 | + memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _teacher_height); | ||
| 636 | + memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _teacher_height / 4); | ||
| 637 | + memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _teacher_height / 4); | ||
| 638 | + } | ||
| 625 | fillDestFrame(pDstFrame, _teacherFrame, 0, 0); | 639 | fillDestFrame(pDstFrame, _teacherFrame, 0, 0); |
| 626 | } | 640 | } |
| 627 | else { | 641 | else { |
| 628 | - memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _nOutputHeight / 2); | ||
| 629 | - memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _nOutputHeight / 8); | ||
| 630 | - memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _nOutputHeight / 8); | ||
| 631 | - fillDestFrame(pDstFrame, _teacherFrame, (_src_width - _src_height) / 2, 0, 0, (_src_width - _src_height) / 2, _src_height, _src_height); | 642 | + memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _teacher_height); |
| 643 | + memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _teacher_height / 4); | ||
| 644 | + memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _teacher_height / 4); | ||
| 645 | + fillDestFrame(pDstFrame, _teacherFrame, (_nOutputWidth - _teacher_height) / 2, 0, 0, (_teacher_width - _teacher_height) / 2, _teacher_height, _teacher_height); | ||
| 632 | } | 646 | } |
| 633 | } | 647 | } |
| 634 | - else if (_teacherFrame->width == _src_height && _teacherFrame->height == _src_height) { | ||
| 635 | - memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _nOutputHeight / 2); | ||
| 636 | - memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _nOutputHeight / 8); | ||
| 637 | - memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _nOutputHeight / 8); | ||
| 638 | - fillDestFrame(pDstFrame, _teacherFrame, (_src_width - _src_height) / 2, 0); | 648 | + else if (_teacherFrame->width == _teacher_height && _teacherFrame->height == _teacher_height) { |
| 649 | + memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _teacher_height); | ||
| 650 | + memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _teacher_height / 4); | ||
| 651 | + memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _teacher_height / 4); | ||
| 652 | + fillDestFrame(pDstFrame, _teacherFrame, (_nOutputWidth - _teacher_height) / 2, 0); | ||
| 639 | } | 653 | } |
| 640 | else { | 654 | else { |
| 641 | //printf("\nresolution: %dx%d unexpected!", _teacherFrame->width, _teacherFrame->height); | 655 | //printf("\nresolution: %dx%d unexpected!", _teacherFrame->width, _teacherFrame->height); |
| 642 | - memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _nOutputHeight / 2); | ||
| 643 | - memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _nOutputHeight / 8); | ||
| 644 | - memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _nOutputHeight / 8); | 656 | + memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _teacher_height); |
| 657 | + memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _teacher_height / 4); | ||
| 658 | + memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _teacher_height / 4); | ||
| 645 | 659 | ||
| 646 | fillDestFrame(pDstFrame, _teacherFrame, 0, 0); | 660 | fillDestFrame(pDstFrame, _teacherFrame, 0, 0); |
| 647 | } | 661 | } |
| 648 | if (_studentFrame) { | 662 | if (_studentFrame) { |
| 649 | - if (_studentFrame->width == _src_width) { | 663 | + if (_studentFrame->width == _student_width) { |
| 650 | if (_studentFrame->pkt_dts != 90){ | 664 | if (_studentFrame->pkt_dts != 90){ |
| 651 | - fillDestFrame(pDstFrame, _studentFrame, 0, _src_height); | 665 | + if (_student_width < _nOutputWidth) { |
| 666 | + memset(pDstFrame->data[0] + _teacher_height * pDstFrame->linesize[0], _blank_y, _nOutputWidth * _student_height); | ||
| 667 | + memset(pDstFrame->data[1] + _teacher_height / 2 * pDstFrame->linesize[1], _blank_u, _nOutputWidth * _student_height / 4); | ||
| 668 | + memset(pDstFrame->data[2] + _teacher_height / 2 * pDstFrame->linesize[2], _blank_v, _nOutputWidth * _student_height / 4); | ||
| 669 | + } | ||
| 670 | + fillDestFrame(pDstFrame, _studentFrame, 0, _teacher_height); | ||
| 652 | } | 671 | } |
| 653 | else { | 672 | else { |
| 654 | - memset(pDstFrame->data[0] + _src_height * pDstFrame->linesize[0], _blank_y, _nOutputWidth * _nOutputHeight / 2); | ||
| 655 | - memset(pDstFrame->data[1] + _src_height / 2 * pDstFrame->linesize[1], _blank_u, _nOutputWidth * _nOutputHeight / 8); | ||
| 656 | - memset(pDstFrame->data[2] + _src_height / 2 * pDstFrame->linesize[2], _blank_v, _nOutputWidth * _nOutputHeight / 8); | ||
| 657 | - fillDestFrame(pDstFrame, _studentFrame, (_src_width - _src_height) / 2, _src_height, (_src_width - _src_height) / 2, 0, _src_height, _src_height); | 673 | + memset(pDstFrame->data[0] + _teacher_height * pDstFrame->linesize[0], _blank_y, _nOutputWidth * _student_height); |
| 674 | + memset(pDstFrame->data[1] + _teacher_height / 2 * pDstFrame->linesize[1], _blank_u, _nOutputWidth * _student_height / 4); | ||
| 675 | + memset(pDstFrame->data[2] + _teacher_height / 2 * pDstFrame->linesize[2], _blank_v, _nOutputWidth * _student_height / 4); | ||
| 676 | + fillDestFrame(pDstFrame, _studentFrame, (_nOutputWidth - _student_height) / 2, _teacher_height, (_student_width - _student_height) / 2, 0, _student_height, _student_height); | ||
| 658 | } | 677 | } |
| 659 | } | 678 | } |
| 660 | else if (_studentFrame->pkt_dts == 90){ | 679 | else if (_studentFrame->pkt_dts == 90){ |
| 661 | - fillDestFrame(pDstFrame, _studentFrame, 0, _src_height); | 680 | + if (_student_width < _nOutputWidth) { |
| 681 | + memset(pDstFrame->data[0] + _teacher_height * pDstFrame->linesize[0], _blank_y, _nOutputWidth * _student_height); | ||
| 682 | + memset(pDstFrame->data[1] + _teacher_height / 2 * pDstFrame->linesize[1], _blank_u, _nOutputWidth * _student_height / 4); | ||
| 683 | + memset(pDstFrame->data[2] + _teacher_height / 2 * pDstFrame->linesize[2], _blank_v, _nOutputWidth * _student_height / 4); | ||
| 684 | + } | ||
| 685 | + fillDestFrame(pDstFrame, _studentFrame, 0, _teacher_height); | ||
| 662 | } | 686 | } |
| 663 | else { | 687 | else { |
| 664 | - memset(pDstFrame->data[0] + _src_height * pDstFrame->linesize[0], _blank_y, _nOutputWidth * _nOutputHeight / 2); | ||
| 665 | - memset(pDstFrame->data[1] + _src_height / 2 * pDstFrame->linesize[1], _blank_u, _nOutputWidth * _nOutputHeight / 8); | ||
| 666 | - memset(pDstFrame->data[2] + _src_height / 2 * pDstFrame->linesize[2], _blank_v, _nOutputWidth * _nOutputHeight / 8); | ||
| 667 | - fillDestFrame(pDstFrame, _studentFrame, (_src_width - _src_height) / 2, _src_height, 0, (_src_width - _src_height) / 2, _src_height, _src_height); | 688 | + memset(pDstFrame->data[0] + _teacher_height * pDstFrame->linesize[0], _blank_y, _nOutputWidth * _student_height); |
| 689 | + memset(pDstFrame->data[1] + _teacher_height / 2 * pDstFrame->linesize[1], _blank_u, _nOutputWidth * _student_height / 4); | ||
| 690 | + memset(pDstFrame->data[2] + _teacher_height / 2 * pDstFrame->linesize[2], _blank_v, _nOutputWidth * _student_height / 4); | ||
| 691 | + fillDestFrame(pDstFrame, _studentFrame, (_nOutputWidth - _student_height) / 2, _teacher_height, 0, (_student_width - _student_height) / 2, _student_height, _student_height); | ||
| 668 | } | 692 | } |
| 669 | } | 693 | } |
| 670 | } | 694 | } |
| 671 | else if (_studentFrame) { | 695 | else if (_studentFrame) { |
| 672 | - if (_studentFrame->width == _src_width && _studentFrame->height == _src_height) { | 696 | + if (_studentFrame->width == _student_width && _studentFrame->height == _student_height) { |
| 673 | if (_studentFrame->pkt_dts != 90){ | 697 | if (_studentFrame->pkt_dts != 90){ |
| 674 | fillDestFrame(pDstFrame, _studentFrame, 0, 0); | 698 | fillDestFrame(pDstFrame, _studentFrame, 0, 0); |
| 675 | } | 699 | } |
| 676 | else { | 700 | else { |
| 677 | - fillDestFrame(pDstFrame, _studentFrame, (_src_width - _src_height) / 2, 0, (_src_width - _src_height) / 2, 0, _src_height, _src_height); | 701 | + fillDestFrame(pDstFrame, _studentFrame, (_nOutputWidth - _student_height) / 2, 0, (_student_width - _student_height) / 2, 0, _student_height, _student_height); |
| 678 | } | 702 | } |
| 679 | } | 703 | } |
| 680 | - else if (_studentFrame->width == _src_height && _studentFrame->height == _src_width) { | 704 | + else if (_studentFrame->width == _student_height && _studentFrame->height == _student_width) { |
| 681 | if (_studentFrame->pkt_dts == 90){ | 705 | if (_studentFrame->pkt_dts == 90){ |
| 682 | fillDestFrame(pDstFrame, _studentFrame, 0, 0); | 706 | fillDestFrame(pDstFrame, _studentFrame, 0, 0); |
| 683 | } | 707 | } |
| 684 | else { | 708 | else { |
| 685 | - fillDestFrame(pDstFrame, _studentFrame, (_src_width - _src_height) / 2, 0, 0, (_src_width - _src_height) / 2, _src_height, _src_height); | 709 | + fillDestFrame(pDstFrame, _studentFrame, (_nOutputWidth - _student_height) / 2, 0, 0, (_student_width - _student_height) / 2, _student_height, _student_height); |
| 686 | } | 710 | } |
| 687 | } | 711 | } |
| 688 | - else if (_studentFrame->width == _src_height && _studentFrame->height == _src_height) { | ||
| 689 | - fillDestFrame(pDstFrame, _studentFrame, (_src_width - _src_height) / 2, 0); | 712 | + else if (_studentFrame->width == _student_height && _studentFrame->height == _student_height) { |
| 713 | + fillDestFrame(pDstFrame, _studentFrame, (_nOutputWidth - _student_height) / 2, 0); | ||
| 690 | } | 714 | } |
| 691 | else { | 715 | else { |
| 692 | //printf("\nresolution: %dx%d unexpected!", _studentFrame->width, _studentFrame->height); | 716 | //printf("\nresolution: %dx%d unexpected!", _studentFrame->width, _studentFrame->height); |
| 693 | - memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _nOutputHeight / 2); | ||
| 694 | - memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _nOutputHeight / 8); | ||
| 695 | - memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _nOutputHeight / 8); | 717 | + memset(pDstFrame->data[0], _blank_y, _nOutputWidth * _student_height); |
| 718 | + memset(pDstFrame->data[1], _blank_u, _nOutputWidth * _student_height / 4); | ||
| 719 | + memset(pDstFrame->data[2], _blank_v, _nOutputWidth * _student_height / 4); | ||
| 696 | fillDestFrame(pDstFrame, _studentFrame, 0, 0); | 720 | fillDestFrame(pDstFrame, _studentFrame, 0, 0); |
| 697 | } | 721 | } |
| 698 | } | 722 | } |
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | class CAVTranscoder | 5 | class CAVTranscoder |
| 6 | { | 6 | { |
| 7 | public: | 7 | public: |
| 8 | - CAVTranscoder(bool bOne2One, int width, int height); | 8 | + CAVTranscoder(bool bOne2One, int width_teacher, int height_teacher, int student_width,int student_height); |
| 9 | virtual ~CAVTranscoder(); | 9 | virtual ~CAVTranscoder(); |
| 10 | 10 | ||
| 11 | int add(media_info & info); | 11 | int add(media_info & info); |
| @@ -46,8 +46,10 @@ private: | @@ -46,8 +46,10 @@ private: | ||
| 46 | int _max_audio; | 46 | int _max_audio; |
| 47 | int _scaled_width; | 47 | int _scaled_width; |
| 48 | int _scaled_height; | 48 | int _scaled_height; |
| 49 | - int _src_width; | ||
| 50 | - int _src_height; | 49 | + int _teacher_width; |
| 50 | + int _teacher_height; | ||
| 51 | + int _student_width; | ||
| 52 | + int _student_height; | ||
| 51 | struct SwsContext * _sws_ctx_w_h; | 53 | struct SwsContext * _sws_ctx_w_h; |
| 52 | struct SwsContext * _sws_ctx_h_w; | 54 | struct SwsContext * _sws_ctx_h_w; |
| 53 | struct SwsContext * _sws_ctx_h_h; | 55 | struct SwsContext * _sws_ctx_h_h; |
| @@ -1123,7 +1123,7 @@ int process_av_files(char * record_info, int piptype) | @@ -1123,7 +1123,7 @@ int process_av_files(char * record_info, int piptype) | ||
| 1123 | } | 1123 | } |
| 1124 | } | 1124 | } |
| 1125 | 1125 | ||
| 1126 | - CAVTranscoder videoTranscoder(one2one, width, height); | 1126 | + CAVTranscoder videoTranscoder(one2one, width_teacher, height_teacher,width_student, height_student); |
| 1127 | videoTranscoder.set_max_audio(max_audio); | 1127 | videoTranscoder.set_max_audio(max_audio); |
| 1128 | 1128 | ||
| 1129 | int64_t cur_time = 0; | 1129 | int64_t cur_time = 0; |
-
请 注册 或 登录 后发表评论