From: Craig S. <cso...@us...> - 2006-03-28 05:15:09
|
Update of /cvsroot/openh323/openh323/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11555/src Modified Files: h261codec.cxx rfc2190avcodec.cxx Log Message: Change video codecs to set grabber capture size rather than grabber size setting codec size Index: h261codec.cxx =================================================================== RCS file: /cvsroot/openh323/openh323/src/h261codec.cxx,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** h261codec.cxx 21 Mar 2006 10:43:35 -0000 1.70 --- h261codec.cxx 28 Mar 2006 05:15:02 -0000 1.71 *************** *** 26,29 **** --- 26,33 ---- * * $Log$ + * Revision 1.71 2006/03/28 05:15:02 csoutheren + * Change video codecs to set grabber capture size rather than + * grabber size setting codec size + * * Revision 1.70 2006/03/21 10:43:35 csoutheren * Ensure bytes per frame is set when writing to video devices *************** *** 419,424 **** ////////////////////////////////////////////////////////////////////////////// ! H323_H261Codec::H323_H261Codec(Direction dir, BOOL isqCIF) ! : H323VideoCodec("H.261", dir) { PTRACE(3, "H261\t" << (isqCIF ? "Q" : "") << "CIF " --- 423,428 ---- ////////////////////////////////////////////////////////////////////////////// ! H323_H261Codec::H323_H261Codec(Direction dir, BOOL _isqCIF) ! : H323VideoCodec("H.261", dir), isqCIF(_isqCIF) { PTRACE(3, "H261\t" << (isqCIF ? "Q" : "") << "CIF " *************** *** 521,529 **** } ! frameWidth = ((PVideoChannel *)rawDataChannel)->GetGrabWidth(); ! frameHeight = ((PVideoChannel *)rawDataChannel)->GetGrabHeight(); ! PTRACE(6, "H261\tVideo grab size is " << frameWidth << "x" << frameHeight); ! if( frameWidth == 0 ) { PTRACE(1,"H261\tVideo grab width is 0 x 0, close down video transmission thread."); length=0; --- 525,532 ---- } ! PINDEX w = ((PVideoChannel *)rawDataChannel)->GetGrabWidth(); ! PINDEX h = ((PVideoChannel *)rawDataChannel)->GetGrabHeight(); ! if (w == 0 ) { PTRACE(1,"H261\tVideo grab width is 0 x 0, close down video transmission thread."); length=0; *************** *** 531,535 **** } ! videoEncoder->SetSize(frameWidth, frameHeight); PINDEX bytesInFrame = (frameWidth * frameHeight * 3) / 2; --- 534,546 ---- } ! if (w != frameWidth || h != frameHeight) { ! w = isqCIF ? QCIF_WIDTH : CIF_WIDTH; ! h = isqCIF ? QCIF_HEIGHT : CIF_HEIGHT; ! ((PVideoChannel *)rawDataChannel)->SetGrabberFrameSize(w, h); ! frameWidth = w; ! frameHeight = h; ! ! videoEncoder->SetSize(frameWidth, frameHeight); ! } PINDEX bytesInFrame = (frameWidth * frameHeight * 3) / 2; Index: rfc2190avcodec.cxx =================================================================== RCS file: /cvsroot/openh323/openh323/src/rfc2190avcodec.cxx,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** rfc2190avcodec.cxx 20 Aug 2005 07:43:05 -0000 1.16 --- rfc2190avcodec.cxx 28 Mar 2006 05:15:02 -0000 1.17 *************** *** 31,34 **** --- 31,38 ---- * * $Log$ + * Revision 1.17 2006/03/28 05:15:02 csoutheren + * Change video codecs to set grabber capture size rather than + * grabber size setting codec size + * * Revision 1.16 2005/08/20 07:43:05 rjongbloed * Fixed compiler warnings *************** *** 257,260 **** --- 261,275 ---- }; + static struct { int width; int height; } s_vidFrameSize[] = { + { 0, 0}, // forbidden + { 128, 96}, // SQCIF + { 176, 144}, // QCIF + { 352, 288}, // CIF + { 704, 576}, // 4CIF + { 1408, 1152}, // 16CIF + { 0, 0}, // reserved + { 0, 0}, // extended PTYPE + }; + ////////////////////////////////////////////////////////////////////////////// *************** *** 756,759 **** --- 771,788 ---- videoFrameRate[CIF4] = _cif4MPI; videoFrameRate[CIF16] = _cif16MPI; + + // all terminals that support H.263 support QCIF (H.323, section 6.2.4) + if (videoFrameRate[QCIF] == 0) { + signed vfr = 0; + if (videoFrameRate[CIF] > 0) + vfr = videoFrameRate[CIF] * 2; + else if (videoFrameRate[SQCIF] > 0) + vfr = videoFrameRate[CIF] / 2; + if (vfr == 0) + videoFrameRate[QCIF] = 1; + else + videoFrameRate[QCIF] = vfr; + } + if (!_cif16MPI && !_cif4MPI && *************** *** 950,960 **** } if (encodedPackets.GetSize() == 0) { - // No data is waiting to be read. Go and get some with the read call. PINDEX width = ((PVideoChannel *)rawDataChannel)->GetGrabWidth(); PINDEX height = ((PVideoChannel *)rawDataChannel)->GetGrabHeight(); - PTRACE(5, "RFC2190H263\tVideo grab size is " << width << "x" << height); - if (width == 0 || height == 0) { PTRACE(1,"RFC2190H263\tVideo grab dimension is 0, close down video transmission thread"); --- 979,988 ---- } + // If no, data is waiting to be read, then go and get some if (encodedPackets.GetSize() == 0) { + // see if grabber has shutdown PINDEX width = ((PVideoChannel *)rawDataChannel)->GetGrabWidth(); PINDEX height = ((PVideoChannel *)rawDataChannel)->GetGrabHeight(); if (width == 0 || height == 0) { PTRACE(1,"RFC2190H263\tVideo grab dimension is 0, close down video transmission thread"); *************** *** 963,970 **** } ! if (!Resize(width, height)) { ! PTRACE(3, "RFC2190H263\tFailed to resize, close down video transmission thread"); ! length=0; ! return FALSE; } --- 991,1042 ---- } ! // see if grabber size is not matched to required size ! if ((frameWidth != width) || (frameHeight != height)) { ! ! // see if grabber size if allowed by codec ! int sizeIndex = GetStdSize(width, height); ! if ((sizeIndex != UnknownStdSize) && (videoFrameRate[sizeIndex] != 0)) { ! PTRACE(5, "RFC2190H263\tVideo grab size " << width << "x" << height << " supported by codec"); ! } ! else { ! // find largest supported size ! PINDEX w, h; ! if (videoFrameRate[CIF16] > 0) { ! w = s_vidFrameSize[CIF16].width; ! h = s_vidFrameSize[CIF16].height; ! } ! else if (videoFrameRate[CIF4] > 0) { ! w = s_vidFrameSize[CIF4].width; ! h = s_vidFrameSize[CIF4].height; ! } ! else if (videoFrameRate[CIF] > 0) { ! w = s_vidFrameSize[CIF].width; ! h = s_vidFrameSize[CIF].height; ! } ! else if (videoFrameRate[QCIF] > 0) { ! w = s_vidFrameSize[QCIF].width; ! h = s_vidFrameSize[QCIF].height; ! } ! else if (videoFrameRate[SQCIF] > 0) { ! w = s_vidFrameSize[SQCIF].width; ! h = s_vidFrameSize[SQCIF].height; ! } ! else { ! PTRACE(5, "RFC2190H263\tCannot find a size supported by the codec"); ! length=0; ! return FALSE; ! } ! PTRACE(5, "RFC2190H263\tVideo grab size " << width << "x" << height << " changed to supported size " << w << "x" << h); ! width = w; ! height = h; ! ((PVideoChannel *)rawDataChannel)->SetGrabberFrameSize(width, height); ! } ! ! // resize everything ! if (!Resize(width, height)) { ! PTRACE(3, "RFC2190H263\tFailed to resize to " << width << "x" << height << " - close down video transmission thread"); ! length=0; ! return FALSE; ! } } *************** *** 1153,1164 **** if (vFRdiv > 0) framesPerSec = 90000 / (vFRdiv * 3003) + 1; else if (vFRdiv < 0) framesPerSec = 1; // actually, less. ! else { PTRACE(3, "RFC2190H263\tCannot resize to " << _width << "x" << _height << " (capability unsupported)"); return FALSE; } ! PTRACE(5, "RFC2190H263\t" << (direction == Encoder ? "En" : "De") << "coder resizing to " << _width << "x" << _height); --- 1225,1239 ---- if (vFRdiv > 0) framesPerSec = 90000 / (vFRdiv * 3003) + 1; + else if (vFRdiv < 0) framesPerSec = 1; // actually, less. ! ! else ! { PTRACE(3, "RFC2190H263\tCannot resize to " << _width << "x" << _height << " (capability unsupported)"); return FALSE; } ! PTRACE(4, "RFC2190H263\t" << (direction == Encoder ? "En" : "De") << "coder resizing to " << _width << "x" << _height); *************** *** 1298,1312 **** } - static struct { int width; int height; } s_vidFrameSize[] = { - { 0, 0}, // forbidden - { 128, 96}, // SQCIF - { 176, 144}, // QCIF - { 352, 288}, // CIF - { 704, 576}, // 4CIF - { 1408, 1152}, // 16CIF - { 0, 0}, // reserved - { 0, 0}, // extended PTYPE - }; - int H323_RFC2190_H263Codec::GetStdSize(int _width, int _height) { --- 1373,1376 ---- |