Ticket #7252: mythtv_decoder_reorder_pts_v3.diff

File mythtv_decoder_reorder_pts_v3.diff, 8.9 KB (added by tralph11@…, 15 years ago)

fix indentation

  • libs/libmythtv/avformatdecoder.cpp

     
    6565
    6666static const int max_video_queue_size = 180;
    6767
     68static const int decoder_reorder_pts = 1;
     69
    6870static int cc608_parity(uint8_t byte);
    6971static int cc608_good_parity(const int *parity_table, uint16_t data);
    7072static void cc608_build_parity_table(int *parity_table);
     
    21442146
    21452147    pic->age = 256 * 256 * 256 * 64;
    21462148
     2149    pic->reordered_opaque = c->reordered_opaque;
     2150
    21472151    return 1;
    21482152}
    21492153
     
    22902294    render->state |= FF_VDPAU_STATE_USED_FOR_REFERENCE;
    22912295#endif
    22922296
     2297    pic->reordered_opaque = c->reordered_opaque;
     2298
    22932299    return 0;
    22942300}
    22952301
     
    38603866                    }
    38613867
    38623868                    AVCodecContext *context = curstream->codec;
    3863                     AVFrame mpa_pic;
    3864                     bzero(&mpa_pic, sizeof(AVFrame));
     3869                    AVFrame *mpa_pic= avcodec_alloc_frame();
    38653870
    38663871                    int gotpicture = 0;
    38673872
     
    38743879                            // HACK
    38753880                            while (!gotpicture && count < 5)
    38763881                            {
    3877                                 ret = d->DecodeMPEG2Video(context, &mpa_pic,
     3882                                ret = d->DecodeMPEG2Video(context, mpa_pic,
    38783883                                                  &gotpicture, ptr, len);
    38793884                                count++;
    38803885                            }
    38813886                        }
    38823887                        else
    38833888                        {
    3884                             ret = d->DecodeMPEG2Video(context, &mpa_pic,
     3889                            ret = d->DecodeMPEG2Video(context, mpa_pic,
    38853890                                                &gotpicture, ptr, len);
    38863891                        }
    38873892                    }
    38883893                    else
    38893894                    {
    3890                         ret = avcodec_decode_video(context, &mpa_pic,
     3895                        curstream->codec->reordered_opaque = pkt->pts;
     3896                        ret = avcodec_decode_video(context, mpa_pic,
    38913897                                                   &gotpicture, ptr, len);
    38923898                        // Reparse it to not drop the DVD still frame
    38933899                        if (decodeStillFrame)
    3894                             ret = avcodec_decode_video(context, &mpa_pic,
     3900                            ret = avcodec_decode_video(context, mpa_pic,
    38953901                                                        &gotpicture, ptr, len);
    38963902                    }
    38973903                    avcodeclock.unlock();
     
    39123918                    }
    39133919
    39143920                    // Decode ATSC captions
    3915                     for (uint i = 0; i < (uint)mpa_pic.atsc_cc_len;
    3916                          i += ((mpa_pic.atsc_cc_buf[i] & 0x1f) * 3) + 2)
     3921                    for (uint i = 0; i < (uint)mpa_pic->atsc_cc_len;
     3922                         i += ((mpa_pic->atsc_cc_buf[i] & 0x1f) * 3) + 2)
    39173923                    {
    3918                         DecodeDTVCC(mpa_pic.atsc_cc_buf + i);
     3924                        DecodeDTVCC(mpa_pic->atsc_cc_buf + i);
    39193925                    }
    39203926
    39213927                    // Decode DVB captions from MPEG user data
    3922                     if (mpa_pic.dvb_cc_len > 0)
     3928                    if (mpa_pic->dvb_cc_len > 0)
    39233929                    {
    39243930                        unsigned long long utc = lastccptsu;
    39253931
    3926                         for (uint i = 0; i < (uint)mpa_pic.dvb_cc_len; i += 2)
     3932                        for (uint i = 0; i < (uint)mpa_pic->dvb_cc_len; i += 2)
    39273933                        {
    3928                             uint8_t cc_lo = mpa_pic.dvb_cc_buf[i];
    3929                             uint8_t cc_hi = mpa_pic.dvb_cc_buf[i+1];
     3934                            uint8_t cc_lo = mpa_pic->dvb_cc_buf[i];
     3935                            uint8_t cc_hi = mpa_pic->dvb_cc_buf[i+1];
    39303936
    39313937                            uint16_t cc_dt = (cc_hi << 8) | cc_lo;
    39323938
     
    39393945                        lastccptsu = utc;
    39403946                    }
    39413947
    3942                     VideoFrame *picframe = (VideoFrame *)(mpa_pic.opaque);
     3948                    VideoFrame *picframe = (VideoFrame *)(mpa_pic->opaque);
    39433949
    39443950                    if (!directrendering)
    39453951                    {
     
    39583964
    39593965                        myth_sws_img_convert(
    39603966                            &tmppicture, PIX_FMT_YUV420P,
    3961                                     (AVPicture *)&mpa_pic,
     3967                                    (AVPicture *)mpa_pic,
    39623968                                    context->pix_fmt,
    39633969                                    context->width,
    39643970                                    context->height);
     
    39673973                        {
    39683974                            // Set the frame flags, but then discard it
    39693975                            // since we are not using it for display.
    3970                             xf->interlaced_frame = mpa_pic.interlaced_frame;
    3971                             xf->top_field_first = mpa_pic.top_field_first;
     3976                            xf->interlaced_frame = mpa_pic->interlaced_frame;
     3977                            xf->top_field_first = mpa_pic->top_field_first;
    39723978                            xf->frameNumber = framesPlayed;
    39733979                            GetNVP()->DiscardVideoFrame(xf);
    39743980                        }
    39753981                    }
    39763982
     3983                    if ((decoder_reorder_pts || pkt->dts == AV_NOPTS_VALUE) &&
     3984                        mpa_pic->reordered_opaque != AV_NOPTS_VALUE)
     3985                    {
     3986                        pts = (long long)mpa_pic->reordered_opaque;
     3987                    }
     3988                    else if (pkt->dts != AV_NOPTS_VALUE)
     3989                    {
     3990                        pts = (long long)pkt->dts;
     3991                    }
     3992                    else
     3993                    {
     3994                        pts = 0;
     3995                    }
     3996                    pts = (long long)(av_q2d(curstream->time_base) * pts * 1000);
     3997
    39773998                    long long temppts = pts;
    39783999
    39794000                    // Validate the video pts against the last pts. If it's
     
    39864007                        temppts = lastvpts;
    39874008                        temppts += (long long)(1000 * av_q2d(context->time_base));
    39884009                        // MPEG2 frames can be repeated, update pts accordingly
    3989                         temppts += (long long)(mpa_pic.repeat_pict * 500
     4010                        temppts += (long long)(mpa_pic->repeat_pict * 500
    39904011                                      * av_q2d(curstream->codec->time_base));
    39914012                    }
    39924013
     
    39964017                            .arg(lastvpts));
    39974018
    39984019/* XXX: Broken.
    3999                     if (mpa_pic.qscale_table != NULL && mpa_pic.qstride > 0 &&
     4020                    if (mpa_pic->qscale_table != NULL && mpa_pic->qstride > 0 &&
    40004021                        context->height == picframe->height)
    40014022                    {
    4002                         int tblsize = mpa_pic.qstride *
     4023                        int tblsize = mpa_pic->qstride *
    40034024                                      ((picframe->height + 15) / 16);
    40044025
    4005                         if (picframe->qstride != mpa_pic.qstride ||
     4026                        if (picframe->qstride != mpa_pic->qstride ||
    40064027                            picframe->qscale_table == NULL)
    40074028                        {
    4008                             picframe->qstride = mpa_pic.qstride;
     4029                            picframe->qstride = mpa_pic->qstride;
    40094030                            if (picframe->qscale_table)
    40104031                                delete [] picframe->qscale_table;
    40114032                            picframe->qscale_table = new unsigned char[tblsize];
    40124033                        }
    40134034
    4014                         memcpy(picframe->qscale_table, mpa_pic.qscale_table,
     4035                        memcpy(picframe->qscale_table, mpa_pic->qscale_table,
    40154036                               tblsize);
    40164037                    }
    40174038*/
    40184039
    4019                     picframe->interlaced_frame = mpa_pic.interlaced_frame;
    4020                     picframe->top_field_first = mpa_pic.top_field_first;
    4021                     picframe->repeat_pict = mpa_pic.repeat_pict;
     4040                    picframe->interlaced_frame = mpa_pic->interlaced_frame;
     4041                    picframe->top_field_first = mpa_pic->top_field_first;
     4042                    picframe->repeat_pict = mpa_pic->repeat_pict;
    40224043
    40234044                    picframe->frameNumber = framesPlayed;
    40244045                    GetNVP()->ReleaseNextVideoFrame(picframe, temppts);
    4025                     if (d->HasMPEG2Dec() && mpa_pic.data[3])
    4026                         context->release_buffer(context, &mpa_pic);
     4046                    if (d->HasMPEG2Dec() && mpa_pic->data[3])
     4047                        context->release_buffer(context, mpa_pic);
    40274048
    40284049                    decoded_video_frame = picframe;
    40294050                    gotvideo = 1;
    40304051                    framesPlayed++;
    40314052
    40324053                    lastvpts = temppts;
     4054
     4055                    if (mpa_pic)
     4056                        av_free(mpa_pic);
     4057
    40334058                    break;
    40344059                }
    40354060                case CODEC_TYPE_SUBTITLE: