Ticket #1558: ignore_cc_tc-9409.patch
File ignore_cc_tc-9409.patch, 8.9 KB (added by , 18 years ago) |
---|
-
libs/libmythtv/avformatdecoder.cpp
284 284 bzero(¶ms, sizeof(AVFormatParameters)); 285 285 bzero(prvpkt, 3 * sizeof(char)); 286 286 bzero(audioSamples, AVCODEC_MAX_AUDIO_FRAME_SIZE * sizeof(short int)); 287 ccd608->IgnoreTimecode(); 287 288 288 289 bool debug = (bool)(print_verbose_messages & VB_LIBAV); 289 290 av_log_set_level((debug) ? AV_LOG_DEBUG : AV_LOG_ERROR); -
libs/libmythtv/NuppelVideoPlayer.h
25 25 } 26 26 using namespace std; 27 27 28 #define MAXTBUFFER 2128 #define MAXTBUFFER 60 29 29 30 30 #ifndef LONG_LONG_MIN 31 31 #define LONG_LONG_MIN LLONG_MIN -
libs/libmythtv/ccdecoder.h
21 21 CCDecoder(CCReader *ccr); 22 22 ~CCDecoder(); 23 23 24 void IgnoreTimecode(void) { ignore_tc = true; } 24 25 void FormatCC(int tc, int code1, int code2); 25 26 void FormatCCField(int tc, int field, int data); 27 int FalseDup(int tc, int field, int data); 26 28 27 29 void DecodeVPS(const unsigned char *buf); 28 30 void DecodeWSS(const unsigned char *buf); … … 43 45 44 46 CCReader *reader; 45 47 48 bool ignore_tc; 49 46 50 // per-field 47 51 int badvbi[2]; 48 52 int lasttc[2]; -
libs/libmythtv/ccdecoder.cpp
10 10 11 11 CCDecoder::CCDecoder(CCReader *ccr) 12 12 : reader(ccr), rbuf(new unsigned char[sizeof(ccsubtitle)+255]), 13 ignore_tc(false), 13 14 vps_l(0), 14 15 wss_flags(0), wss_valid(false), 15 16 xds_vchip(false), xds_ptype(false), … … 130 131 131 132 b1 = data & 0x7f; 132 133 b2 = (data >> 8) & 0x7f; 133 // printf("%10d: %02x %02x\n", tc, b1, b2); 134 VERBOSE(VB_VBI, QString("Format CC @%1/%2 = %3 %4") 135 .arg(tc).arg(field) 136 .arg((data&0xff), 2, 16) 137 .arg((data&0xff00)>>8, 2, 16)); 134 138 if (ccmode[field] >= 0) 135 139 { 136 140 mode = field << 2 | … … 144 148 len = 0; 145 149 } 146 150 147 // bttv-0.9 VBI reads are pretty reliable (1 read/33367us). 148 // bttv-0.7 reads don't seem to work as well so if read intervals 149 // vary from this, be more conservative in detecting duplicate 150 // CC codes. 151 int dup_text_fudge, dup_ctrl_fudge; 152 if (badvbi[field] < 100 && b1 != 0 && b2 != 0) 153 { 154 int d = tc - lasttc[field]; 155 if (d < 25 || d > 42) 156 badvbi[field]++; 157 else if (badvbi[field] > 0) 158 badvbi[field]--; 159 } 160 if (badvbi[field] < 4) 161 { 162 // this should pick up all codes 163 dup_text_fudge = -2; 164 // this should pick up 1st, 4th, 6th, 8th, ... codes 165 dup_ctrl_fudge = 33 - 4; 166 } 167 else 168 { 169 dup_text_fudge = 4; 170 dup_ctrl_fudge = 33 - 4; 171 } 151 if (FalseDup(tc, field, data)) 152 goto skip; 172 153 173 if (data == lastcode[field])174 {175 int false_dup = 1;176 if ((b1 & 0x70) == 0x10)177 {178 if (tc > (lastcodetc[field] + 67 + dup_ctrl_fudge))179 false_dup = 0;180 }181 else if (b1)182 {183 // text, XDS184 if (tc > (lastcodetc[field] + 33 + dup_text_fudge))185 false_dup = 0;186 }187 188 if (false_dup)189 goto skip;190 }191 192 154 DecodeXDS(field, b1, b2); 193 155 194 156 if (b1 & 0x60) … … 427 389 style[mode] = CC_STYLE_ROLLUP; 428 390 break; 429 391 case 0x2C: //erase displayed memory 430 if ((tc - lastclr[mode]) > 5000 || 392 if (ignore_tc || 393 (tc - lastclr[mode]) > 5000 || 431 394 lastclr[mode] == 0) 432 395 // don't overflow the frontend with 433 396 // too many redundant erase codes … … 461 424 // flush 462 425 BufferCC(mode, len, 0); 463 426 } 464 else if ((tc - lastclr[mode]) > 5000 || 427 else if (ignore_tc || 428 (tc - lastclr[mode]) > 5000 || 465 429 lastclr[mode] == 0) 466 430 // clear and flush 467 431 BufferCC(mode, len, 1); … … 514 478 for (mode = field*4; mode < (field*4 + 4); mode++) 515 479 { 516 480 len = ccbuf[mode].length(); 517 if (( (tc - timecode[mode]) > 100) &&518 (style[mode] != CC_STYLE_POPUP) && len)481 if ((ignore_tc || ((tc - timecode[mode]) > 100)) && 482 (style[mode] != CC_STYLE_POPUP) && len) 519 483 { 520 484 // flush unfinished line if waiting too long 521 485 // in paint-on or scroll-up mode … … 535 499 lasttc[field] = tc; 536 500 } 537 501 502 int CCDecoder::FalseDup(int tc, int field, int data) 503 { 504 int b1, b2; 505 506 b1 = data & 0x7f; 507 b2 = (data >> 8) & 0x7f; 508 509 if (ignore_tc) 510 { 511 // just suppress duplicate control codes 512 if ((data == lastcode[field]) && 513 ((b1 & 0x70) == 0x10)) 514 return 1; 515 else 516 return 0; 517 } 518 519 // bttv-0.9 VBI reads are pretty reliable (1 read/33367us). 520 // bttv-0.7 reads don't seem to work as well so if read intervals 521 // vary from this, be more conservative in detecting duplicate 522 // CC codes. 523 int dup_text_fudge, dup_ctrl_fudge; 524 if (badvbi[field] < 100 && b1 != 0 && b2 != 0) 525 { 526 int d = tc - lasttc[field]; 527 if (d < 25 || d > 42) 528 badvbi[field]++; 529 else if (badvbi[field] > 0) 530 badvbi[field]--; 531 } 532 if (badvbi[field] < 4) 533 { 534 // this should pick up all codes 535 dup_text_fudge = -2; 536 // this should pick up 1st, 4th, 6th, 8th, ... codes 537 dup_ctrl_fudge = 33 - 4; 538 } 539 else 540 { 541 dup_text_fudge = 4; 542 dup_ctrl_fudge = 33 - 4; 543 } 544 545 if (data == lastcode[field]) 546 { 547 if ((b1 & 0x70) == 0x10) 548 { 549 if (tc > (lastcodetc[field] + 67 + dup_ctrl_fudge)) 550 return 0; 551 } 552 else if (b1) 553 { 554 // text, XDS 555 if (tc > (lastcodetc[field] + 33 + dup_text_fudge)) 556 return 0; 557 } 558 559 return 1; 560 } 561 562 return 0; 563 } 564 538 565 void CCDecoder::ResetCC(int mode) 539 566 { 540 567 // lastrow[mode] = 0; … … 586 613 else 587 614 len = sizeof(ccsubtitle); 588 615 616 VERBOSE(VB_VBI, QString("### %1 %2 %3 %4 %5 %6 %7 -") 617 .arg(timecode[mode], 10) 618 .arg(row[mode], 2).arg(rowcount[mode]) 619 .arg(style[mode]).arg(f, 2, 16) 620 .arg(clr).arg(len, 3)); 621 if ((print_verbose_messages & VB_VBI) != 0 622 && len) 623 { 624 QString dispbuf = QString::fromUtf8(tmpbuf, len); 625 VERBOSE(VB_VBI, QString("%1 '").arg(timecode[mode], 10)); 626 QString vbuf = ""; 627 unsigned int i = 0; 628 while (i < dispbuf.length()) { 629 QChar cp = dispbuf.at(i); 630 switch (cp.unicode()) 631 { 632 case 0x2120 : vbuf += "(SM)"; break; 633 case 0x2122 : vbuf += "(TM)"; break; 634 case 0x2014 : vbuf += "(--)"; break; 635 case 0x201C : vbuf += "``"; break; 636 case 0x201D : vbuf += "''"; break; 637 case 0x250C : vbuf += "|-"; break; 638 case 0x2510 : vbuf += "-|"; break; 639 case 0x2514 : vbuf += "|_"; break; 640 case 0x2518 : vbuf += "_|"; break; 641 case 0x2588 : vbuf += "[]"; break; 642 case 0x266A : vbuf += "o/~"; break; 643 case '\b' : vbuf += "\\b"; break; 644 default : vbuf += cp.latin1(); 645 } 646 i++; 647 } 648 VERBOSE(VB_VBI, vbuf); 649 } 650 589 651 reader->AddTextData(rbuf, len, timecode[mode], 'C'); 590 652 591 653 resumetext[mode] = 0; -
programs/mythcommflag/ClassicCommDetector.cpp
285 285 "NVP: Unable to initialize video for FlagCommercials."); 286 286 return false; 287 287 } 288 nvp->SetCaptionsEnabled(false); 288 289 289 290 if ((commDetectMethod & COMM_DETECT_LOGO) && 290 291 ((nvp->GetLength() == 0) ||