Ticket #12893: 0002-Added-decoding-of-A53-captions.patch

File 0002-Added-decoding-of-A53-captions.patch, 2.7 KB (added by gregorio.gervasio@…, 9 years ago)

mythtv patch to add A53 caption decoding

  • mythtv/libs/libmythtv/avformatdecoder.cpp

    From 53f6f28be0084f543e981e98f789087923df2747 Mon Sep 17 00:00:00 2001
    From: "Gregorio Gervasio, Jr" <gregorio.gervasio@gmail.com>
    Date: Sat, 1 Oct 2016 22:48:04 -0700
    Subject: [PATCH 2/2] Added decoding of A53 captions.
    
    ---
     mythtv/libs/libmythtv/avformatdecoder.cpp | 24 ++++++++++++++++++++----
     mythtv/libs/libmythtv/avformatdecoder.h   |  1 +
     2 files changed, 21 insertions(+), 4 deletions(-)
    
    diff --git a/mythtv/libs/libmythtv/avformatdecoder.cpp b/mythtv/libs/libmythtv/avformatdecoder.cpp
    index c7a375a..6e675ac 100644
    a b void AvFormatDecoder::DecodeDTVCC(const uint8_t *buf, uint len, bool scte)  
    30023002    if (len < 2+(3*cc_count))
    30033003        return;
    30043004
     3005    DecodeCCx08(buf+2, cc_count*3, scte);
     3006}
     3007
     3008void AvFormatDecoder::DecodeCCx08(const uint8_t *buf, uint len, bool scte)
     3009{
     3010    if (!len)
     3011        return;
     3012
    30053013    bool had_608 = false, had_708 = false;
    3006     for (uint cur = 0; cur < cc_count; cur++)
     3014    for (uint cur = 0; cur < len; cur += 3)
    30073015    {
    3008         uint cc_code  = buf[2+(cur*3)];
     3016        uint cc_code  = buf[cur];
    30093017        bool cc_valid = cc_code & 0x04;
    30103018
    3011         uint data1    = buf[3+(cur*3)];
    3012         uint data2    = buf[4+(cur*3)];
     3019        uint data1    = buf[cur+1];
     3020        uint data2    = buf[cur+2];
    30133021        uint data     = (data2 << 8) | data1;
    30143022        uint cc_type  = cc_code & 0x03;
    30153023        uint field;
    bool AvFormatDecoder::ProcessVideoFrame(AVStream *stream, AVFrame *mpa_pic)  
    36953703    for (uint i = 0; i < cc_len; i += ((cc_buf[i] & 0x1f) * 3) + 2)
    36963704        DecodeDTVCC(cc_buf + i, cc_len - i, scte);
    36973705
     3706    if (cc_len == 0) {
     3707        // look for A53 captions
     3708        AVFrameSideData *side_data = av_frame_get_side_data(mpa_pic, AV_FRAME_DATA_A53_CC);
     3709        if (side_data && (side_data->size > 0)) {
     3710            DecodeCCx08(side_data->data, side_data->size, false);
     3711        }
     3712    }
     3713
    36983714    VideoFrame *picframe = (VideoFrame *)(mpa_pic->opaque);
    36993715
    37003716    if (FlagIsSet(kDecodeNoDecode))
  • mythtv/libs/libmythtv/avformatdecoder.h

    diff --git a/mythtv/libs/libmythtv/avformatdecoder.h b/mythtv/libs/libmythtv/avformatdecoder.h
    index 8fcc047..cc23957 100644
    a b class AvFormatDecoder : public DecoderBase  
    216216    friend int close_avf(URLContext *h);
    217217
    218218    void DecodeDTVCC(const uint8_t *buf, uint buf_size, bool scte);
     219    void DecodeCCx08(const uint8_t *buf, uint buf_size, bool scte);
    219220    void InitByteContext(bool forceseek = false);
    220221    void InitVideoCodec(AVStream *stream, AVCodecContext *enc,
    221222                        bool selectedStream = false);