From 9bfe562c05dc65beae74a8b5a38a28052a007f5a Mon Sep 17 00:00:00 2001 From: Mark Kendall Date: Thu, 9 Dec 2010 11:49:54 +0800 Subject: [PATCH 1/2] Left justify CC-608 captions. With thanks to Jim Stichnoth for the patch. Refs #9030 --- mythtv/libs/libmythtv/subtitlescreen.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mythtv/libs/libmythtv/subtitlescreen.cpp b/mythtv/libs/libmythtv/subtitlescreen.cpp index bd56ff73d9d..c09f96538c4 100644 --- a/mythtv/libs/libmythtv/subtitlescreen.cpp +++ b/mythtv/libs/libmythtv/subtitlescreen.cpp @@ -600,7 +600,7 @@ void SubtitleScreen::DisplayCC608Subtitles(void) if (cc && (cc->text != QString::null)) { - int width = font.width(cc->text) + pad_width * 2; + int width = font.width(cc->text) + pad_width; int x = teletextmode ? cc->y : (cc->x + 3); int y = teletextmode ? cc->x : cc->y; x = (int)(((float)x / (float)xscale) * (float)m_safeArea.width()); @@ -612,7 +612,8 @@ void SubtitleScreen::DisplayCC608Subtitles(void) MythUIShape *shape = new MythUIShape(this, QString("cc608bg%1%2%3").arg(cc->x).arg(cc->y).arg(width)); shape->SetFillBrush(bgfill); - shape->SetArea(MythRect(rect)); + QRect bgrect(x - pad_width, y, width + pad_width, height); + shape->SetArea(MythRect(bgrect)); } gTextSubFont->SetColor(clr[max(min(0, cc->color), 7)]); @@ -620,7 +621,7 @@ void SubtitleScreen::DisplayCC608Subtitles(void) cc->text, *gTextSubFont, rect, rect, (MythUIType*)this, QString("cc608txt%1%2%3").arg(cc->x).arg(cc->y).arg(width)); if (text) - text->SetJustification(Qt::AlignCenter); + text->SetJustification(Qt::AlignLeft); m_refreshArea = true; VERBOSE(VB_VBI, QString("x %1 y %2 String: '%3'") .arg(cc->x).arg(cc->y).arg(cc->text)); From ebf9778b46fe607b62c7d85376db65d7c2a029f6 Mon Sep 17 00:00:00 2001 From: "Michael T. Dean" Date: Wed, 8 Dec 2010 23:41:30 -0500 Subject: [PATCH 2/2] Remove libmpeg2 decoder from playback options. Only remaining use of libmpeg2 is in mythtranscode. --- mythtv/libs/libmythtv/avformatdecoder.cpp | 5 - mythtv/libs/libmythtv/libmythtv.pro | 9 +- mythtv/libs/libmythtv/privatedecoder.cpp | 8 - .../libs/libmythtv/privatedecoder_mpeg2.cpp | 182 ------------------ mythtv/libs/libmythtv/privatedecoder_mpeg2.h | 43 ----- mythtv/libs/libmythtv/videodisplayprofile.cpp | 6 - mythtv/libs/libmythtv/videoout_d3d.cpp | 2 - mythtv/libs/libmythtv/videoout_directfb.cpp | 2 - mythtv/libs/libmythtv/videoout_null.cpp | 2 - mythtv/libs/libmythtv/videoout_opengl.cpp | 2 - mythtv/libs/libmythtv/videoout_quartz.cpp | 4 +- mythtv/libs/libmythtv/videoout_vdpau.cpp | 2 - mythtv/libs/libmythtv/videoout_xv.cpp | 6 - .../programs/mythtranscode/mythtranscode.pro | 3 + 14 files changed, 6 insertions(+), 270 deletions(-) delete mode 100644 mythtv/libs/libmythtv/privatedecoder_mpeg2.cpp delete mode 100644 mythtv/libs/libmythtv/privatedecoder_mpeg2.h diff --git a/mythtv/libs/libmythtv/avformatdecoder.cpp b/mythtv/libs/libmythtv/avformatdecoder.cpp index 7719d1f1ba6..6a7252c6fe1 100644 --- a/mythtv/libs/libmythtv/avformatdecoder.cpp +++ b/mythtv/libs/libmythtv/avformatdecoder.cpp @@ -54,11 +54,6 @@ extern const uint8_t *ff_find_start_code(const uint8_t *p, const uint8_t *end, u extern void ff_read_frame_flush(AVFormatContext *s); #include "libavformat/avio.h" #include "libswscale/swscale.h" -#if CONFIG_LIBMPEG2EXTERNAL -#include -#else -#include "../libmythmpeg2/mpeg2.h" -#endif #include "ivtv_myth.h" } diff --git a/mythtv/libs/libmythtv/libmythtv.pro b/mythtv/libs/libmythtv/libmythtv.pro index 66645d5920b..9f796464e85 100644 --- a/mythtv/libs/libmythtv/libmythtv.pro +++ b/mythtv/libs/libmythtv/libmythtv.pro @@ -64,11 +64,6 @@ using_live: LIBS += -L../libmythlivemedia -lmythlivemedia-$$LIBVERSION using_hdhomerun: LIBS += -L../libmythhdhomerun -lmythhdhomerun-$$LIBVERSION using_backend: LIBS += -lmp3lame LIBS += $$EXTRA_LIBS $$QMAKE_LIBS_DYNLOAD -!contains( CONFIG_LIBMPEG2EXTERNAL, yes) { - DEPENDPATH += ../libmythmpeg2 - LIBS += -L../libmythmpeg2 -lmythmpeg2-$$LIBVERSION - TARGETDEPS += ../libmythmpeg2/libmythmpeg2-$${MYTH_LIB_EXT} -} TARGETDEPS += ../libmyth/libmyth-$${MYTH_SHLIB_EXT} TARGETDEPS += ../../external/FFmpeg/libavutil/$$avLibName(avutil) @@ -280,10 +275,10 @@ using_frontend { # A/V decoders HEADERS += decoderbase.h HEADERS += nuppeldecoder.h avformatdecoder.h - HEADERS += privatedecoder.h privatedecoder_mpeg2.h + HEADERS += privatedecoder.h SOURCES += decoderbase.cpp SOURCES += nuppeldecoder.cpp avformatdecoder.cpp - SOURCES += privatedecoder.cpp privatedecoder_mpeg2.cpp + SOURCES += privatedecoder.cpp using_crystalhd { DEFINES += USING_CRYSTALHD diff --git a/mythtv/libs/libmythtv/privatedecoder.cpp b/mythtv/libs/libmythtv/privatedecoder.cpp index a4d4b7c4097..94e2ec0dc93 100644 --- a/mythtv/libs/libmythtv/privatedecoder.cpp +++ b/mythtv/libs/libmythtv/privatedecoder.cpp @@ -1,5 +1,4 @@ #include "privatedecoder.h" -#include "privatedecoder_mpeg2.h" #if defined(Q_OS_MACX) #include "privatedecoder_vda.h" @@ -11,8 +10,6 @@ void PrivateDecoder::GetDecoders(render_opts &opts) { - PrivateDecoderMPEG2::GetDecoders(opts); - #if defined(Q_OS_MACX) PrivateDecoderVDA::GetDecoders(opts); #endif @@ -26,11 +23,6 @@ PrivateDecoder* PrivateDecoder::Create(const QString &decoder, bool no_hardware_decode, AVCodecContext *avctx) { - PrivateDecoderMPEG2 *mpeg2 = new PrivateDecoderMPEG2(); - if (mpeg2 && mpeg2->Init(decoder, no_hardware_decode, avctx)) - return mpeg2; - delete mpeg2; - #if defined(Q_OS_MACX) PrivateDecoderVDA *vda = new PrivateDecoderVDA(); if (vda && vda->Init(decoder, no_hardware_decode, avctx)) diff --git a/mythtv/libs/libmythtv/privatedecoder_mpeg2.cpp b/mythtv/libs/libmythtv/privatedecoder_mpeg2.cpp deleted file mode 100644 index fb01efd0107..00000000000 --- a/mythtv/libs/libmythtv/privatedecoder_mpeg2.cpp +++ /dev/null @@ -1,182 +0,0 @@ -#include "privatedecoder_mpeg2.h" -#include "mythverbose.h" - -#define LOC QString("MPEG2Dec: ") - -void PrivateDecoderMPEG2::GetDecoders(render_opts &opts) -{ - opts.decoders->append("libmpeg2"); - (*opts.equiv_decoders)["libmpeg2"].append("nuppel"); - (*opts.equiv_decoders)["libmpeg2"].append("ffmpeg"); - (*opts.equiv_decoders)["libmpeg2"].append("dummy"); -} - -PrivateDecoderMPEG2::PrivateDecoderMPEG2() : PrivateDecoder(), mpeg2dec(NULL) -{ -} - -PrivateDecoderMPEG2::~PrivateDecoderMPEG2() -{ - if (mpeg2dec) - mpeg2_close(mpeg2dec); - mpeg2dec = NULL; - ClearFrames(); -} - -bool PrivateDecoderMPEG2::Init(const QString &decoder, - bool no_hardware_decode, - AVCodecContext *avctx) -{ - if (!((decoder == "libmpeg2") && - (CODEC_IS_MPEG(avctx->codec_id)))) - return false; - - if (mpeg2dec) - mpeg2_close(mpeg2dec); - ClearFrames(); - mpeg2dec = mpeg2_init(); - if (mpeg2dec) - { - VERBOSE(VB_PLAYBACK, LOC + "Using libmpeg2 for video decoding"); - return true; - } - return false; -} - -bool PrivateDecoderMPEG2::Reset(void) -{ - if (mpeg2dec) - mpeg2_reset(mpeg2dec, 0); - ClearFrames(); - return true; -} - -int PrivateDecoderMPEG2::GetFrame(AVStream *stream, - AVFrame *picture, - int *got_picture_ptr, - AVPacket *pkt) -{ - AVCodecContext *avctx = stream->codec; - *got_picture_ptr = 0; - const mpeg2_info_t *info = mpeg2_info(mpeg2dec); - mpeg2_buffer(mpeg2dec, pkt->data, pkt->data + pkt->size); - while (1) - { - switch (mpeg2_parse(mpeg2dec)) - { - case STATE_SEQUENCE: - // libmpeg2 needs three buffers to do its work. - // We set up two prediction buffers here, from - // the set of available video frames. - mpeg2_custom_fbuf(mpeg2dec, 1); - for (int i = 0; i < 2; i++) - { - avctx->get_buffer(avctx, picture); - mpeg2_set_buf(mpeg2dec, picture->data, picture->opaque); - } - break; - case STATE_PICTURE: - // This sets up the third buffer for libmpeg2. - // We use up one of the three buffers for each - // frame shown. The frames get released once - // they are drawn (outside this routine). - avctx->get_buffer(avctx, picture); - mpeg2_set_buf(mpeg2dec, picture->data, picture->opaque); - break; - case STATE_BUFFER: - // We're finished with the buffer... - if (partialFrames.size()) - { - AVFrame *frm = partialFrames.dequeue(); - *got_picture_ptr = 1; - *picture = *frm; - delete frm; -#if 0 - QString msg(""); - AvFormatDecoder *nd = (AvFormatDecoder *)(avctx->opaque); - if (nd && nd->GetNVP() && nd->GetNVP()->getVideoOutput()) - msg = nd->GetNVP()->getVideoOutput()->GetFrameStatus(); - - VERBOSE(VB_IMPORTANT, "ret frame: "<opaque - <<" "<size; - case STATE_INVALID: - // This is the error state. The decoder must be - // reset on an error. - Reset(); - return -1; - - case STATE_SLICE: - case STATE_END: - case STATE_INVALID_END: - if (info->display_fbuf) - { - bool exists = false; - avframe_q::iterator it = partialFrames.begin(); - for (; it != partialFrames.end(); ++it) - if ((*it)->opaque == info->display_fbuf->id) - exists = true; - - if (!exists) - { - AVFrame *frm = new AVFrame(); - frm->data[0] = info->display_fbuf->buf[0]; - frm->data[1] = info->display_fbuf->buf[1]; - frm->data[2] = info->display_fbuf->buf[2]; - frm->data[3] = NULL; - frm->opaque = info->display_fbuf->id; - frm->type = FF_BUFFER_TYPE_USER; - frm->top_field_first = - !!(info->display_picture->flags & - PIC_FLAG_TOP_FIELD_FIRST); - frm->interlaced_frame = - !(info->display_picture->flags & - PIC_FLAG_PROGRESSIVE_FRAME); - frm->repeat_pict = - !!(info->display_picture->flags & -#if CONFIG_LIBMPEG2EXTERNAL - PIC_FLAG_REPEAT_FIRST_FIELD); -#else - PIC_FLAG_REPEAT_FIELD); -#endif - partialFrames.enqueue(frm); - - } - } - if (info->discard_fbuf) - { - bool exists = false; - avframe_q::iterator it = partialFrames.begin(); - for (; it != partialFrames.end(); ++it) - { - if ((*it)->opaque == info->discard_fbuf->id) - { - exists = true; - (*it)->data[3] = (unsigned char*) 1; - } - } - - if (!exists) - { - AVFrame frame; - frame.opaque = info->discard_fbuf->id; - frame.type = FF_BUFFER_TYPE_USER; - avctx->release_buffer(avctx, &frame); - } - } - break; - default: - break; - } - } -} - -void PrivateDecoderMPEG2::ClearFrames(void) -{ - avframe_q::iterator it = partialFrames.begin(); - for (; it != partialFrames.end(); ++it) - delete (*it); - partialFrames.clear(); -} diff --git a/mythtv/libs/libmythtv/privatedecoder_mpeg2.h b/mythtv/libs/libmythtv/privatedecoder_mpeg2.h deleted file mode 100644 index afd0cb3c788..00000000000 --- a/mythtv/libs/libmythtv/privatedecoder_mpeg2.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef PRIVATEDECODER_MPEG2_H -#define PRIVATEDECODER_MPEG2_H - -// C headers -#include - -// MythTV headers -#include "mythdeque.h" - -extern "C" { -#if CONFIG_LIBMPEG2EXTERNAL -#include -#else -#include "../libmythmpeg2/mpeg2.h" -#endif -} - -#include "privatedecoder.h" - -typedef MythDeque avframe_q; - -class PrivateDecoderMPEG2 : public PrivateDecoder -{ - public: - static void GetDecoders(render_opts &opts); - PrivateDecoderMPEG2(); - virtual ~PrivateDecoderMPEG2(); - virtual QString GetName(void) { return "libmpeg2"; } - virtual bool Init(const QString &decoder, - bool no_hardware_decode, - AVCodecContext *avctx); - virtual bool Reset(void); - virtual int GetFrame(AVStream *stream, - AVFrame *picture, - int *got_picture_ptr, - AVPacket *pkt); - private: - void ClearFrames(void); - mpeg2dec_t *mpeg2dec; - avframe_q partialFrames; -}; - -#endif // PRIVATEDECODER_MPEG2_H diff --git a/mythtv/libs/libmythtv/videodisplayprofile.cpp b/mythtv/libs/libmythtv/videodisplayprofile.cpp index 814148ddab4..580bb30f41b 100644 --- a/mythtv/libs/libmythtv/videodisplayprofile.cpp +++ b/mythtv/libs/libmythtv/videodisplayprofile.cpp @@ -637,7 +637,6 @@ QString VideoDisplayProfile::GetDecoderName(const QString &decoder) if (dec_name.empty()) { dec_name["ffmpeg"] = QObject::tr("Standard"); - dec_name["libmpeg2"] = QObject::tr("libmpeg2"); dec_name["macaccel"] = QObject::tr("Mac hardware acceleration"); dec_name["vdpau"] = QObject::tr("NVidia VDPAU acceleration"); } @@ -664,11 +663,6 @@ QString VideoDisplayProfile::GetDecoderHelp(QString decoder) if (decoder == "ffmpeg") msg += QObject::tr("Standard will use ffmpeg library."); - if (decoder == "libmpeg2") - msg += QObject::tr( - "libmpeg2 is slower on almost all processors than ffmpeg " - "and breaks caption decoding. Use at your own risk!"); - if (decoder == "macaccel") msg += QObject::tr( "Mac hardware will try to use the graphics " diff --git a/mythtv/libs/libmythtv/videoout_d3d.cpp b/mythtv/libs/libmythtv/videoout_d3d.cpp index 5e88a9ae485..badf6afecec 100644 --- a/mythtv/libs/libmythtv/videoout_d3d.cpp +++ b/mythtv/libs/libmythtv/videoout_d3d.cpp @@ -45,8 +45,6 @@ void VideoOutputD3D::GetRenderOptions(render_opts &opts, (*opts.safe_renderers)["nuppel"].append("direct3d"); if (opts.decoders->contains("ffmpeg")) (*opts.safe_renderers)["ffmpeg"].append("direct3d"); - if (opts.decoders->contains("libmpeg2")) - (*opts.safe_renderers)["libmpeg2"].append("direct3d"); if (opts.decoders->contains("crystalhd")) (*opts.safe_renderers)["crystalhd"].append("direct3d"); opts.priorities->insert("direct3d", 55); diff --git a/mythtv/libs/libmythtv/videoout_directfb.cpp b/mythtv/libs/libmythtv/videoout_directfb.cpp index c4aafd51599..417b1c82c04 100644 --- a/mythtv/libs/libmythtv/videoout_directfb.cpp +++ b/mythtv/libs/libmythtv/videoout_directfb.cpp @@ -270,8 +270,6 @@ void VideoOutputDirectfb::GetRenderOptions(render_opts &opts, (*opts.safe_renderers)["nuppel"].append("directfb"); if (opts.decoders->contains("ffmpeg")) (*opts.safe_renderers)["ffmpeg"].append("directfb"); - if (opts.decoders->contains("libmpeg2")) - (*opts.safe_renderers)["libmpeg2"].append("directfb"); if (opts.decoders->contains("crystalhd")) (*opts.safe_renderers)["crystalhd"].append("directfb"); opts.priorities->insert("directfb", 60); diff --git a/mythtv/libs/libmythtv/videoout_null.cpp b/mythtv/libs/libmythtv/videoout_null.cpp index c237538bcab..cd2b17063c8 100644 --- a/mythtv/libs/libmythtv/videoout_null.cpp +++ b/mythtv/libs/libmythtv/videoout_null.cpp @@ -22,8 +22,6 @@ void VideoOutputNull::GetRenderOptions(render_opts &opts, (*opts.safe_renderers)["nuppel"].append("null"); if (opts.decoders->contains("ffmpeg")) (*opts.safe_renderers)["ffmpeg"].append("null"); - if (opts.decoders->contains("libmpeg2")) - (*opts.safe_renderers)["libmpeg2"].append("null"); if (opts.decoders->contains("crystalhd")) (*opts.safe_renderers)["crystalhd"].append("null"); diff --git a/mythtv/libs/libmythtv/videoout_opengl.cpp b/mythtv/libs/libmythtv/videoout_opengl.cpp index 5eecb0cae08..208137efe0e 100644 --- a/mythtv/libs/libmythtv/videoout_opengl.cpp +++ b/mythtv/libs/libmythtv/videoout_opengl.cpp @@ -30,8 +30,6 @@ void VideoOutputOpenGL::GetRenderOptions(render_opts &opts, (*opts.safe_renderers)["nuppel"].append("opengl"); if (opts.decoders->contains("ffmpeg")) (*opts.safe_renderers)["ffmpeg"].append("opengl"); - if (opts.decoders->contains("libmpeg2")) - (*opts.safe_renderers)["libmpeg2"].append("opengl"); if (opts.decoders->contains("vda")) (*opts.safe_renderers)["vda"].append("opengl"); if (opts.decoders->contains("crystalhd")) diff --git a/mythtv/libs/libmythtv/videoout_quartz.cpp b/mythtv/libs/libmythtv/videoout_quartz.cpp index 3485b26d060..f380da03986 100644 --- a/mythtv/libs/libmythtv/videoout_quartz.cpp +++ b/mythtv/libs/libmythtv/videoout_quartz.cpp @@ -1092,8 +1092,6 @@ void VideoOutputQuartz::GetRenderOptions(render_opts &opts, (*opts.safe_renderers)["nuppel"].append("quartz-blit"); if (opts.decoders->contains("ffmpeg")) (*opts.safe_renderers)["ffmpeg"].append("quartz-blit"); - if (opts.decoders->contains("libmpeg2")) - (*opts.safe_renderers)["libmpeg2"].append("quartz-blit"); if (opts.decoders->contains("vda")) (*opts.safe_renderers)["vda"].append("quartz-blit"); if (opts.decoders->contains("crystalhd")) @@ -1764,7 +1762,7 @@ MythCodecID VideoOutputQuartz::GetBestSupportedCodec( VideoDisplayProfile vdp; vdp.SetInput(QSize(width, height)); QString dec = vdp.GetDecoder(); - if ((dec == "libmpeg2") || (dec == "ffmpeg")) + if (dec == "ffmpeg") return (MythCodecID)(kCodec_MPEG1 + (stream_type-1)); return (MythCodecID)(kCodec_MPEG1 + (stream_type-1)); } diff --git a/mythtv/libs/libmythtv/videoout_vdpau.cpp b/mythtv/libs/libmythtv/videoout_vdpau.cpp index df3c31292c7..0317b38ba48 100644 --- a/mythtv/libs/libmythtv/videoout_vdpau.cpp +++ b/mythtv/libs/libmythtv/videoout_vdpau.cpp @@ -30,8 +30,6 @@ void VideoOutputVDPAU::GetRenderOptions(render_opts &opts) (*opts.safe_renderers)["vdpau"].append("vdpau"); if (opts.decoders->contains("ffmpeg")) (*opts.safe_renderers)["ffmpeg"].append("vdpau"); - if (opts.decoders->contains("libmpeg2")) - (*opts.safe_renderers)["libmpeg2"].append("vdpau"); if (opts.decoders->contains("crystalhd")) (*opts.safe_renderers)["crystalhd"].append("vdpau"); (*opts.safe_renderers)["dummy"].append("vdpau"); diff --git a/mythtv/libs/libmythtv/videoout_xv.cpp b/mythtv/libs/libmythtv/videoout_xv.cpp index 53089a692c3..9ce0a99d0fa 100644 --- a/mythtv/libs/libmythtv/videoout_xv.cpp +++ b/mythtv/libs/libmythtv/videoout_xv.cpp @@ -117,12 +117,6 @@ void VideoOutputXv::GetRenderOptions(render_opts &opts, (*opts.safe_renderers)["ffmpeg"].append("xshm"); (*opts.safe_renderers)["ffmpeg"].append("xv-blit"); } - if (opts.decoders->contains("libmpeg2")) - { - (*opts.safe_renderers)["libmpeg2"].append("xlib"); - (*opts.safe_renderers)["libmpeg2"].append("xshm"); - (*opts.safe_renderers)["libmpeg2"].append("xv-blit"); - } if (opts.decoders->contains("crystalhd")) { diff --git a/mythtv/programs/mythtranscode/mythtranscode.pro b/mythtv/programs/mythtranscode/mythtranscode.pro index 13a5e453af4..d7abc6a0b90 100644 --- a/mythtv/programs/mythtranscode/mythtranscode.pro +++ b/mythtv/programs/mythtranscode/mythtranscode.pro @@ -25,5 +25,8 @@ INCLUDEPATH += ../../libs/libavutil INCLUDEPATH += ../../libs/ !contains( CONFIG_LIBMPEG2EXTERNAL, yes) { + DEPENDPATH += ../../libs/libmythmpeg2 INCLUDEPATH += ../../libs/libmythmpeg2 + LIBS += -L../../libs/libmythmpeg2 -lmythmpeg2-$$LIBVERSION + TARGETDEPS += ../../libs/libmythmpeg2/libmythmpeg2-$${MYTH_LIB_EXT} }