Ticket #12054: scte.patch

File scte.patch, 2.5 KB (added by Jim Stichnoth, 5 years ago)
  • mythtv/libs/libmythtv/avformatdecoder.cpp

    diff --git a/mythtv/libs/libmythtv/avformatdecoder.cpp b/mythtv/libs/libmythtv/avformatdecoder.cpp
    index 9a13205..25096fc 100644
    a b AvFormatDecoder::AvFormatDecoder(MythPlayer *parent, 
    397397      video_codec_id(kCodec_NONE),
    398398      maxkeyframedist(-1),
    399399      // Closed Caption & Teletext decoders
    400       ignore_scte(false),
     400      ignore_scte(0),
    401401      invert_scte_field(0),
    402402      last_scte_field(0),
    403403      ccd608(new CC608Decoder(parent->GetCC608Reader())),
    bool AvFormatDecoder::ProcessVideoFrame(AVStream *stream, AVFrame *mpa_pic) 
    36233623{
    36243624    AVCodecContext *context = stream->codec;
    36253625
     3626    // We need to mediate between ATSC and SCTE data when both are present.  If
     3627    // both are present, we generally want to prefer ATSC.  However, there may
     3628    // be large sections of the recording where ATSC is used and other sections
     3629    // where SCTE is used.  In that case, we want to allow a natural transition
     3630    // from ATSC back to SCTE.  We do this by allowing 10 consecutive SCTE
     3631    // frames, without an intervening ATSC frame, to cause a switch back to
     3632    // considering SCTE frames.  The number 10 is somewhat arbitrarily chosen.
     3633
    36263634    uint cc_len = (uint) max(mpa_pic->scte_cc_len,0);
    36273635    uint8_t *cc_buf = mpa_pic->scte_cc_buf;
    36283636    bool scte = true;
    36293637
     3638    // If we saw SCTE, then decrement a nonzero ignore_scte count.
     3639    if (cc_len > 0 && ignore_scte)
     3640        --ignore_scte;
     3641
    36303642    // If both ATSC and SCTE caption data are available, prefer ATSC
    36313643    if ((mpa_pic->atsc_cc_len > 0) || ignore_scte)
    36323644    {
    3633         ignore_scte = true;
    36343645        cc_len = (uint) max(mpa_pic->atsc_cc_len, 0);
    36353646        cc_buf = mpa_pic->atsc_cc_buf;
    36363647        scte = false;
     3648        // If we explicitly saw ATSC, then reset ignore_scte count.
     3649        if (cc_len > 0)
     3650            ignore_scte = 10;
    36373651    }
    36383652
    36393653    // Decode CEA-608 and CEA-708 captions
  • mythtv/libs/libmythtv/avformatdecoder.h

    diff --git a/mythtv/libs/libmythtv/avformatdecoder.h b/mythtv/libs/libmythtv/avformatdecoder.h
    index d434f14..46e93d9 100644
    a b class AvFormatDecoder : public DecoderBase 
    330330    int maxkeyframedist;
    331331
    332332    // Caption/Subtitle/Teletext decoders
    333     bool             ignore_scte;
     333    uint             ignore_scte;
    334334    uint             invert_scte_field;
    335335    uint             last_scte_field;
    336336    CC608Decoder     *ccd608;