Go to the documentation of this file.
7 #include "libmythbase/mythconfig.h"
12 #include "libavcodec/avcodec.h"
13 #include "libavformat/avformat.h"
16 #if CONFIG_LIBMPEG2EXTERNAL
17 #include <mpeg2dec/mpeg2.h>
19 #include "libmythmpeg2/mpeg2.h"
31 #include <QStringList>
52 void set_pkt(AVPacket *newpkt)
const;
75 void SetNextPTS(int64_t newPTS, int64_t atPTS);
76 void SetNextPos(int64_t newPTS, AVPacket *pkt);
77 int64_t
Get(
int idx, AVPacket *pkt);
78 int64_t
UpdateOrigPTS(
int idx, int64_t &origPTS, AVPacket *pkt);
125 MPEG2fixup(
const QString &inf,
const QString &outf,
127 bool fixPTS,
int maxf,
bool showprog,
int otype,
128 void (*update_func)(
float) =
nullptr,
int (*check_func)() =
nullptr);
137 static void dec2x33(int64_t *pts1, int64_t pts2);
138 static void inc2x33(int64_t *pts1, int64_t pts2);
139 static int64_t
udiff2x33(int64_t pts1, int64_t pts2);
140 static int64_t
diff2x33(int64_t pts1, int64_t pts2);
141 static int64_t
add2x33(int64_t pts1, int64_t pts2);
142 static int cmp2x33(int64_t pts1, int64_t pts2);
149 static int FindMPEG2Header(
const uint8_t *buf,
int size, uint8_t code);
153 bool InitAV(
const QString& inputfile,
const char *
type, int64_t offset);
160 bool BuildFrame(AVPacket *pkt,
const QString& fname);
166 static void SetRepeat(uint8_t *ptr,
int size,
int fields,
bool topff);
174 int64_t ptsIncrement, int64_t initPTS);
178 int64_t &PTSdiscrep,
int numframes,
bool fix)
const;
186 return frame->
m_mpeg2_pic.flags & PIC_MASK_CODING_TYPE;
205 return (
m_inputFC->streams[
id]->codecpar->codec_id == AV_CODEC_ID_AC3) ?
206 AV_CODEC_ID_AC3 : AV_CODEC_ID_MP2;
218 return av_stream_get_parser(
m_inputFC->streams[
id]);
280 #define LOG(mask,level,args...) \
282 if ((verboseMask & mask) != 0) \
284 cout << args << endl; \
290 #define GENERIC_EXIT_OK 0
291 #define GENERIC_EXIT_NOT_OK 128
292 #define GENERIC_EXIT_WRITE_FRAME_ERROR 149
293 #define GENERIC_EXIT_DEADLOCK 150
MPEG2fixup(const QString &inf, const QString &outf, frm_dir_map_t *deleteMap, const char *fmt, bool norp, bool fixPTS, int maxf, bool showprog, int otype, void(*update_func)(float)=nullptr, int(*check_func)()=nullptr)
void FrameInfo(MPEG2frame *f)
static void SetFrameNum(uint8_t *ptr, int num)
AudioFrameArray m_extframe
mpeg2_sequence_t m_mpeg2_seq
static int cmp2x33(int64_t pts1, int64_t pts2)
static void * ReplexStart(void *data)
int InsertFrame(int frameNum, int64_t deltaPTS, int64_t ptsIncrement, int64_t initPTS)
AVCodecContext * GetCodecContext(const AVStream *Stream, const AVCodec *Codec=nullptr, bool NullCodec=false)
std::array< int, N_AUDIO > ExtTypeIntArray
int AddFrame(MPEG2frame *f)
static void WriteYUV(const QString &filename, const mpeg2_info_t *info)
std::array< audio_frame_t, N_AUDIO > AudioFrameArray
static int64_t udiff2x33(int64_t pts1, int64_t pts2)
bool InitAV(const QString &inputfile, const char *type, int64_t offset)
QMap< int, FrameList * > FrameMap
static void WriteData(const QString &filename, uint8_t *data, int size)
static int GetFrameNum(const MPEG2frame *frame)
static FrameList ReorderDTStoPTS(FrameList *dtsOrder, int pos)
static char GetFrameTypeT(const MPEG2frame *frame)
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
AVFormatContext * m_inputFC
QList< MPEG2frame * > FrameList
QMap< int, QList< poq_idx_t > > m_offset
void SetNextPos(int64_t newPTS, AVPacket *pkt)
int BuildKeyframeIndex(const QString &file, frm_pos_map_t &posMap, frm_pos_map_t &durMap)
int ConvertToI(FrameList *orderedFrames, int headPos)
int64_t Get(int idx, AVPacket *pkt)
void AddSequence(MPEG2frame *frame1, MPEG2frame *frame2)
QMap< int, QList< poq_idx_t > > m_orig
static int FindMPEG2Header(const uint8_t *buf, int size, uint8_t code)
void ensure_size(int size) const
void WriteFrame(const QString &filename, MPEG2frame *f)
mpeg2dec_t * m_headerDecoder
void SetAllAudio(bool keep)
mpeg2_picture_t m_mpeg2_pic
static void dumpList(FrameList *list)
static int64_t add2x33(int64_t pts1, int64_t pts2)
ExtTypeIntArray m_exttype
static int GetFrameTypeN(const MPEG2frame *frame)
int ProcessVideo(MPEG2frame *vf, mpeg2dec_t *dec)
void set_pkt(AVPacket *newpkt) const
static int64_t diff2x33(int64_t pts1, int64_t pts2)
void(* m_updateStatus)(float percent_done)
static void ShowRangeMap(frm_dir_map_t *mapPtr, QString msg)
MPEG2frame * DecodeToFrame(int frameNum, int skip_reset)
AVCodecParserContext * getCodecParserContext(uint id)
void InitialPTSFixup(MPEG2frame *curFrame, int64_t &origvPTS, int64_t &PTSdiscrep, int numframes, bool fix) const
QMap< long long, long long > frm_pos_map_t
Frame # -> File offset map.
PTSOffsetQueue(int vidid, QList< int > keys, int64_t initPTS)
static void inc2x33(int64_t *pts1, int64_t pts2)
void AddRangeList(const QStringList &rangelist, int type)
QMap< int, int > m_audMap
static int GetNbFields(const MPEG2frame *frame)
static void dec2x33(int64_t *pts1, int64_t pts2)
int GetFrame(AVPacket *pkt)
int64_t UpdateOrigPTS(int idx, int64_t &origPTS, AVPacket *pkt)
MPEG2frame * FindFrameNum(int frameNum)
ExtTypeIntArray m_exttypcnt
void SetNextPTS(int64_t newPTS, int64_t atPTS)
QQueue< MPEG2frame * > FrameQueue
bool BuildFrame(AVPacket *pkt, const QString &fname)
int GetStreamType(int id) const
FrameQueue m_unreadFrames
uint64_t m_lastWrittenPos
RingbufferArray m_extrbuf
mpeg2dec_t * m_imgDecoder
RingbufferArray m_indexExtrbuf
std::array< ringbuffer, N_AUDIO > RingbufferArray
AVCodecContext * getCodecContext(uint id)
MPEG2frame * GetPoolFrame(AVPacket *pkt)
void RenumberFrames(int start_pos, int delta)
static void SetRepeat(MPEG2frame *vf, int nb_fields, bool topff)