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