Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove libmpeg2 decoder from playback options.

Only remaining use of libmpeg2 is in mythtranscode.
  • Loading branch information...
commit ebf9778b46fe607b62c7d85376db65d7c2a029f6 1 parent 9bfe562
@sphery sphery authored
View
5 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 <mpeg2dec/mpeg2.h>
-#else
-#include "../libmythmpeg2/mpeg2.h"
-#endif
#include "ivtv_myth.h"
}
View
9 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
View
8 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))
View
182 mythtv/libs/libmythtv/privatedecoder_mpeg2.cpp
@@ -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: "<<picture->opaque
- <<" "<<msg);
-#endif
- }
- return pkt->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();
-}
View
43 mythtv/libs/libmythtv/privatedecoder_mpeg2.h
@@ -1,43 +0,0 @@
-#ifndef PRIVATEDECODER_MPEG2_H
-#define PRIVATEDECODER_MPEG2_H
-
-// C headers
-#include <stdint.h>
-
-// MythTV headers
-#include "mythdeque.h"
-
-extern "C" {
-#if CONFIG_LIBMPEG2EXTERNAL
-#include <mpeg2dec/mpeg2.h>
-#else
-#include "../libmythmpeg2/mpeg2.h"
-#endif
-}
-
-#include "privatedecoder.h"
-
-typedef MythDeque<AVFrame*> 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
View
6 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 "
View
2  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);
View
2  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);
View
2  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");
View
2  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"))
View
4 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));
}
View
2  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");
View
6 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"))
{
View
3  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}
}

6 comments on commit ebf9778

@SoNick

What?!
WHY would you do this?
How does it benefit the project AT ALL?

@rmcnamara

Because we don't need it to decode MPEG-2, and it's use has caused bugs for years. If you thought this would prevent the recording, viewing or parsing of MPEG-2 content, please take more time to learn what you're talking about before leaving a permanent record online.

@kormoc
Collaborator

This doesn't remove mpeg2 support, only libmpeg2, a mpeg2 decoder/encoder optimized for 500 mhz amd processors. It's a large burden to keep it maintained for very very little used hardware. Just use the standard mpeg2 decoder and you won't notice any difference.

@wagnerrp
Collaborator

Carrying around support for multiple decoder libraries means we need to support both decoder libraries, including maintenance of code to use those libraries, and any bugs that arise from use of those libraries.

On the contrary, the libmpeg2 decoder only carried specific optimizations from some old architectures, and bring in all sorts of issues on modern systems. How does removal of libmpeg2 in favor of libav, vdpau, and vaapi harm you AT ALL?

@Beirdo
Owner

The only remaining use is in the mpeg2-mpeg2 "lossless" transcoder, and that only remains as we haven't had time to replace it with the appropriate code using libavcodec yet.

As a project, we are trying to limit the number of library dependencies, and this one has no practical purpose to be remaining in the build when we have viable alternatives that we already need anyways.

@SoNick

Ah, thank you for the explanation; I do realize that I went in a little harsh with my comment that started this chain.
I hadn't kept up with Linux MPEG-2 decoders as the only Linux computer I have is my MythTV box and I (falsely) assumed that libmpeg2 is the main decoder used for those files in that context.
The standoffish comment in Mr. Robert McNamara's response is kind of :rolleyes:, but then I -did- start it by coming in confrontational so it's whatever.

In any case, I do wish you all the best of luck in removing the libmpeg2 dependencies! I'd love to join the project, but with 50-hour work-weeks and my last programming projects being -years- ago I simply don't have the time to get up to speed!

Please sign in to comment.
Something went wrong with that request. Please try again.