diff --git a/mythtv/libs/libmythtv/playercontext.h b/mythtv/libs/libmythtv/playercontext.h
index a4ce9f1..3e97186 100644
|
a
|
b
|
typedef enum
|
| 43 | 43 | typedef deque<QString> StringDeque; |
| 44 | 44 | typedef QHash<QString,QString> InfoMap; |
| 45 | 45 | |
| 46 | | class MTV_PUBLIC PlayerContext : public QObject |
| | 46 | class MTV_PUBLIC PlayerContext |
| 47 | 47 | { |
| 48 | | Q_OBJECT |
| 49 | 48 | public: |
| 50 | 49 | PlayerContext(const QString &inUseID = QString("Unknown")); |
| 51 | 50 | ~PlayerContext(); |
diff --git a/mythtv/programs/mythtranscode/transcode.cpp b/mythtv/programs/mythtranscode/transcode.cpp
index 1c3ea9e..414f2b8 100644
|
a
|
b
|
Transcode::Transcode(ProgramInfo *pginfo) :
|
| 721 | 721 | m_proginfo(pginfo), |
| 722 | 722 | keyframedist(30), |
| 723 | 723 | nvr(NULL), |
| 724 | | player(NULL), |
| 725 | | player_ctx(NULL), |
| 726 | | inRingBuffer(NULL), |
| | 724 | ctx(NULL), |
| 727 | 725 | outRingBuffer(NULL), |
| 728 | 726 | fifow(NULL), |
| 729 | 727 | kfa_table(NULL), |
| … |
… |
Transcode::~Transcode()
|
| 744 | 742 | { |
| 745 | 743 | if (nvr) |
| 746 | 744 | delete nvr; |
| 747 | | if (player_ctx) |
| 748 | | { |
| 749 | | player = NULL; |
| 750 | | inRingBuffer = NULL; |
| 751 | | delete player_ctx; |
| 752 | | } |
| | 745 | SetPlayerContext(NULL); |
| 753 | 746 | if (outRingBuffer) |
| 754 | 747 | delete outRingBuffer; |
| 755 | 748 | if (fifow) |
| … |
… |
bool Transcode::GetProfile(QString profileName, QString encodingType,
|
| 831 | 824 | return true; |
| 832 | 825 | } |
| 833 | 826 | |
| | 827 | void Transcode::SetPlayerContext(PlayerContext *player_ctx) |
| | 828 | { |
| | 829 | if (player_ctx == ctx) |
| | 830 | return; |
| | 831 | |
| | 832 | delete ctx; |
| | 833 | ctx = player_ctx; |
| | 834 | } |
| | 835 | |
| 834 | 836 | static QString get_str_option(RecordingProfile &profile, const QString &name) |
| 835 | 837 | { |
| 836 | 838 | const Setting *setting = profile.byName(name); |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 919 | 921 | } |
| 920 | 922 | |
| 921 | 923 | // Input setup |
| 922 | | if (hls && (hlsStreamID != -1)) |
| 923 | | inRingBuffer = RingBuffer::Create(hls->GetSourceFile(), false, false); |
| 924 | | else |
| 925 | | inRingBuffer = RingBuffer::Create(inputname, false, false); |
| 926 | | |
| 927 | | player = new MythPlayer(kVideoIsNull); |
| 928 | | |
| 929 | | player_ctx = new PlayerContext(kTranscoderInUseID); |
| | 924 | PlayerContext *player_ctx = new PlayerContext(kTranscoderInUseID); |
| 930 | 925 | player_ctx->SetPlayingInfo(m_proginfo); |
| 931 | | player_ctx->SetRingBuffer(inRingBuffer); |
| 932 | | player_ctx->SetPlayer(player); |
| 933 | | player->SetPlayerInfo(NULL, NULL, true, player_ctx); |
| | 926 | player_ctx->SetRingBuffer( |
| | 927 | (hls && (hlsStreamID != -1)) ? |
| | 928 | RingBuffer::Create(hls->GetSourceFile(), false, false) : |
| | 929 | RingBuffer::Create(inputname, false, false)); |
| | 930 | player_ctx->SetPlayer(new MythPlayer(kVideoIsNull)); |
| | 931 | SetPlayerContext(player_ctx); |
| | 932 | GetPlayer()->SetPlayerInfo(NULL, NULL, true, GetPlayerContext()); |
| 934 | 933 | |
| 935 | 934 | if (showprogress) |
| 936 | 935 | { |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 940 | 939 | AudioOutput *audioOutput = new AudioReencodeBuffer(FORMAT_NONE, 0, |
| 941 | 940 | passthru); |
| 942 | 941 | AudioReencodeBuffer *arb = ((AudioReencodeBuffer*)audioOutput); |
| 943 | | player->GetAudio()->SetAudioOutput(audioOutput); |
| 944 | | player->SetTranscoding(true); |
| | 942 | GetPlayer()->GetAudio()->SetAudioOutput(audioOutput); |
| | 943 | GetPlayer()->SetTranscoding(true); |
| 945 | 944 | |
| 946 | | if (player->OpenFile() < 0) |
| | 945 | if (GetPlayer()->OpenFile() < 0) |
| 947 | 946 | { |
| 948 | 947 | LOG(VB_GENERAL, LOG_ERR, "Transcoding aborted, error opening file."); |
| 949 | | if (player_ctx) |
| 950 | | delete player_ctx; |
| | 948 | SetPlayerContext(NULL); |
| 951 | 949 | return REENCODE_ERROR; |
| 952 | 950 | } |
| 953 | 951 | |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 955 | 953 | { |
| 956 | 954 | LOG(VB_GENERAL, LOG_INFO, |
| 957 | 955 | QString("Set audiotrack number to %1").arg(AudioTrackNo)); |
| 958 | | player->GetDecoder()->SetTrack(kTrackTypeAudio, AudioTrackNo); |
| | 956 | GetPlayer()->GetDecoder()->SetTrack(kTrackTypeAudio, AudioTrackNo); |
| 959 | 957 | } |
| 960 | 958 | |
| 961 | | long long total_frame_count = player->GetTotalFrameCount(); |
| | 959 | long long total_frame_count = GetPlayer()->GetTotalFrameCount(); |
| 962 | 960 | long long new_frame_count = total_frame_count; |
| 963 | 961 | if (honorCutList && m_proginfo) |
| 964 | 962 | { |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1005 | 1003 | (JobQueue::IsJobRunning(JOB_COMMFLAG, *m_proginfo))) |
| 1006 | 1004 | { |
| 1007 | 1005 | LOG(VB_GENERAL, LOG_INFO, "Transcoding aborted, cutlist changed"); |
| 1008 | | if (player_ctx) |
| 1009 | | delete player_ctx; |
| | 1006 | SetPlayerContext(NULL); |
| 1010 | 1007 | return REENCODE_CUTLIST_CHANGE; |
| 1011 | 1008 | } |
| 1012 | 1009 | m_proginfo->ClearMarkupFlag(MARK_UPDATED_CUT); |
| 1013 | 1010 | curtime = curtime.addSecs(60); |
| 1014 | 1011 | } |
| 1015 | 1012 | |
| 1016 | | player->GetAudio()->ReinitAudio(); |
| 1017 | | QString encodingType = player->GetEncodingType(); |
| | 1013 | GetPlayer()->GetAudio()->ReinitAudio(); |
| | 1014 | QString encodingType = GetPlayer()->GetEncodingType(); |
| 1018 | 1015 | bool copyvideo = false, copyaudio = false; |
| 1019 | 1016 | |
| 1020 | 1017 | QString vidsetting = NULL, audsetting = NULL, vidfilters = NULL; |
| 1021 | 1018 | |
| 1022 | | QSize buf_size = player->GetVideoBufferSize(); |
| | 1019 | QSize buf_size = GetPlayer()->GetVideoBufferSize(); |
| 1023 | 1020 | int video_width = buf_size.width(); |
| 1024 | 1021 | int video_height = buf_size.height(); |
| 1025 | 1022 | |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1030 | 1027 | "will treat it as such."); |
| 1031 | 1028 | } |
| 1032 | 1029 | |
| 1033 | | DecoderBase* dec = player->GetDecoder(); |
| | 1030 | DecoderBase* dec = GetPlayer()->GetDecoder(); |
| 1034 | 1031 | float video_aspect = dec ? dec->GetVideoAspect() : 4.0f / 3.0f; |
| 1035 | | float video_frame_rate = player->GetFrameRate(); |
| | 1032 | float video_frame_rate = GetPlayer()->GetFrameRate(); |
| 1036 | 1033 | int newWidth = video_width; |
| 1037 | 1034 | int newHeight = video_height; |
| 1038 | 1035 | bool halfFramerate = false; |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1074 | 1071 | { |
| 1075 | 1072 | LOG(VB_GENERAL, LOG_ERR, |
| 1076 | 1073 | "Transcoding aborted, error creating AVFormatWriter."); |
| 1077 | | if (player_ctx) |
| 1078 | | delete player_ctx; |
| | 1074 | SetPlayerContext(NULL); |
| 1079 | 1075 | return REENCODE_ERROR; |
| 1080 | 1076 | } |
| 1081 | 1077 | |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1103 | 1099 | { |
| 1104 | 1100 | LOG(VB_GENERAL, LOG_ERR, "Transcoding aborted, error " |
| 1105 | 1101 | "creating low-bitrate AVFormatWriter."); |
| 1106 | | if (player_ctx) |
| 1107 | | delete player_ctx; |
| | 1102 | SetPlayerContext(NULL); |
| 1108 | 1103 | return REENCODE_ERROR; |
| 1109 | 1104 | } |
| 1110 | 1105 | |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1135 | 1130 | (!hls->InitForWrite())) |
| 1136 | 1131 | { |
| 1137 | 1132 | LOG(VB_GENERAL, LOG_ERR, "hls->InitForWrite() failed"); |
| 1138 | | if (player_ctx) |
| 1139 | | delete player_ctx; |
| | 1133 | SetPlayerContext(NULL); |
| 1140 | 1134 | return REENCODE_ERROR; |
| 1141 | 1135 | } |
| 1142 | 1136 | |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1187 | 1181 | if (!avfw->Init()) |
| 1188 | 1182 | { |
| 1189 | 1183 | LOG(VB_GENERAL, LOG_ERR, "avfw->Init() failed"); |
| 1190 | | if (player_ctx) |
| 1191 | | delete player_ctx; |
| | 1184 | SetPlayerContext(NULL); |
| 1192 | 1185 | return REENCODE_ERROR; |
| 1193 | 1186 | } |
| 1194 | 1187 | |
| 1195 | 1188 | if (!avfw->OpenFile()) |
| 1196 | 1189 | { |
| 1197 | 1190 | LOG(VB_GENERAL, LOG_ERR, "avfw->OpenFile() failed"); |
| 1198 | | if (player_ctx) |
| 1199 | | delete player_ctx; |
| | 1191 | SetPlayerContext(NULL); |
| 1200 | 1192 | return REENCODE_ERROR; |
| 1201 | 1193 | } |
| 1202 | 1194 | |
| 1203 | 1195 | if (avfw2 && !avfw2->Init()) |
| 1204 | 1196 | { |
| 1205 | 1197 | LOG(VB_GENERAL, LOG_ERR, "avfw2->Init() failed"); |
| 1206 | | if (player_ctx) |
| 1207 | | delete player_ctx; |
| | 1198 | SetPlayerContext(NULL); |
| 1208 | 1199 | return REENCODE_ERROR; |
| 1209 | 1200 | } |
| 1210 | 1201 | |
| 1211 | 1202 | if (avfw2 && !avfw2->OpenFile()) |
| 1212 | 1203 | { |
| 1213 | 1204 | LOG(VB_GENERAL, LOG_ERR, "avfw2->OpenFile() failed"); |
| 1214 | | if (player_ctx) |
| 1215 | | delete player_ctx; |
| | 1205 | SetPlayerContext(NULL); |
| 1216 | 1206 | return REENCODE_ERROR; |
| 1217 | 1207 | } |
| 1218 | 1208 | |
| 1219 | 1209 | arb->m_audioFrameSize = avfw->GetAudioFrameSize() * arb->m_channels * 2; |
| 1220 | 1210 | |
| 1221 | | player->SetVideoFilters( |
| | 1211 | GetPlayer()->SetVideoFilters( |
| 1222 | 1212 | gCoreContext->GetSetting("HTTPLiveStreamFilters")); |
| 1223 | 1213 | } |
| 1224 | 1214 | else if (fifodir.isEmpty()) |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1226 | 1216 | if (!GetProfile(profileName, encodingType, video_height, |
| 1227 | 1217 | (int)round(video_frame_rate))) { |
| 1228 | 1218 | LOG(VB_GENERAL, LOG_ERR, "Transcoding aborted, no profile found."); |
| 1229 | | if (player_ctx) |
| 1230 | | delete player_ctx; |
| | 1219 | SetPlayerContext(NULL); |
| 1231 | 1220 | return REENCODE_ERROR; |
| 1232 | 1221 | } |
| 1233 | 1222 | |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1255 | 1244 | get_int_option(profile, "transcodelossless")) |
| 1256 | 1245 | { |
| 1257 | 1246 | LOG(VB_GENERAL, LOG_NOTICE, "Switching to MPEG-2 transcoder."); |
| 1258 | | if (player_ctx) |
| 1259 | | delete player_ctx; |
| | 1247 | SetPlayerContext(NULL); |
| 1260 | 1248 | return REENCODE_MPEG2TRANS; |
| 1261 | 1249 | } |
| 1262 | 1250 | |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1270 | 1258 | { |
| 1271 | 1259 | int actualHeight = (video_height == 1088 ? 1080 : video_height); |
| 1272 | 1260 | |
| 1273 | | player->SetVideoFilters(vidfilters); |
| | 1261 | GetPlayer()->SetVideoFilters(vidfilters); |
| 1274 | 1262 | newWidth = get_int_option(profile, "width"); |
| 1275 | 1263 | newHeight = get_int_option(profile, "height"); |
| 1276 | 1264 | |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1302 | 1290 | .arg(newWidth).arg(newHeight)); |
| 1303 | 1291 | } |
| 1304 | 1292 | else // lossy and no resize |
| 1305 | | player->SetVideoFilters(vidfilters); |
| | 1293 | GetPlayer()->SetVideoFilters(vidfilters); |
| 1306 | 1294 | |
| 1307 | 1295 | // this is ripped from tv_rec SetupRecording. It'd be nice to merge |
| 1308 | 1296 | nvr->SetOption("inpixfmt", FMT_YV12); |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1357 | 1345 | LOG(VB_GENERAL, LOG_ERR, "No video information found!"); |
| 1358 | 1346 | LOG(VB_GENERAL, LOG_ERR, "Please ensure that recording profiles " |
| 1359 | 1347 | "for the transcoder are set"); |
| 1360 | | if (player_ctx) |
| 1361 | | delete player_ctx; |
| | 1348 | SetPlayerContext(NULL); |
| 1362 | 1349 | return REENCODE_ERROR; |
| 1363 | 1350 | } |
| 1364 | 1351 | else |
| 1365 | 1352 | { |
| 1366 | 1353 | LOG(VB_GENERAL, LOG_ERR, |
| 1367 | 1354 | QString("Unknown video codec: %1").arg(vidsetting)); |
| 1368 | | if (player_ctx) |
| 1369 | | delete player_ctx; |
| | 1355 | SetPlayerContext(NULL); |
| 1370 | 1356 | return REENCODE_ERROR; |
| 1371 | 1357 | } |
| 1372 | 1358 | |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1455 | 1441 | cutter = new Cutter(); |
| 1456 | 1442 | cutter->SetCutList(deleteMap); |
| 1457 | 1443 | |
| 1458 | | player->SetCutList(cutter->AdjustedCutList()); |
| | 1444 | GetPlayer()->SetCutList(cutter->AdjustedCutList()); |
| 1459 | 1445 | } |
| 1460 | 1446 | else |
| 1461 | 1447 | { |
| 1462 | 1448 | // Have the player apply the cut list |
| 1463 | | player->SetCutList(deleteMap); |
| | 1449 | GetPlayer()->SetCutList(deleteMap); |
| 1464 | 1450 | } |
| 1465 | 1451 | } |
| 1466 | 1452 | |
| 1467 | | player->InitForTranscode(copyaudio, copyvideo); |
| 1468 | | if (player->IsErrored()) |
| | 1453 | GetPlayer()->InitForTranscode(copyaudio, copyvideo); |
| | 1454 | if (GetPlayer()->IsErrored()) |
| 1469 | 1455 | { |
| 1470 | 1456 | LOG(VB_GENERAL, LOG_ERR, |
| 1471 | 1457 | "Unable to initialize MythPlayer for Transcode"); |
| 1472 | | if (player_ctx) |
| 1473 | | delete player_ctx; |
| | 1458 | SetPlayerContext(NULL); |
| 1474 | 1459 | return REENCODE_ERROR; |
| 1475 | 1460 | } |
| 1476 | 1461 | |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1492 | 1477 | |
| 1493 | 1478 | if (!fifodir.isEmpty()) |
| 1494 | 1479 | { |
| 1495 | | AudioPlayer *aplayer = player->GetAudio(); |
| | 1480 | AudioPlayer *aplayer = GetPlayer()->GetAudio(); |
| 1496 | 1481 | const char *audio_codec_name; |
| 1497 | 1482 | |
| 1498 | 1483 | switch(aplayer->GetCodec()) |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1528 | 1513 | bool is_key; |
| 1529 | 1514 | int did_ff; |
| 1530 | 1515 | frm_dir_map_t::iterator dm_iter; |
| 1531 | | player->TranscodeGetNextFrame(dm_iter, did_ff, is_key, true); |
| | 1516 | GetPlayer()->TranscodeGetNextFrame(dm_iter, did_ff, is_key, true); |
| 1532 | 1517 | |
| 1533 | | QSize buf_size = player->GetVideoBufferSize(); |
| | 1518 | QSize buf_size = GetPlayer()->GetVideoBufferSize(); |
| 1534 | 1519 | video_width = buf_size.width(); |
| 1535 | 1520 | video_height = buf_size.height(); |
| 1536 | | video_aspect = player->GetVideoAspect(); |
| 1537 | | video_frame_rate = player->GetFrameRate(); |
| | 1521 | video_aspect = GetPlayer()->GetVideoAspect(); |
| | 1522 | video_frame_rate = GetPlayer()->GetFrameRate(); |
| 1538 | 1523 | } |
| 1539 | 1524 | |
| 1540 | 1525 | // Display details of the format of the fifo data. |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1558 | 1543 | // Request was for just the format of fifo data, not for |
| 1559 | 1544 | // the actual transcode, so stop here. |
| 1560 | 1545 | unlink(outputname.toLocal8Bit().constData()); |
| 1561 | | if (player_ctx) |
| 1562 | | delete player_ctx; |
| | 1546 | SetPlayerContext(NULL); |
| 1563 | 1547 | return REENCODE_OK; |
| 1564 | 1548 | } |
| 1565 | 1549 | |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1577 | 1561 | LOG(VB_GENERAL, LOG_ERR, |
| 1578 | 1562 | "Error initializing fifo writer. Aborting"); |
| 1579 | 1563 | unlink(outputname.toLocal8Bit().constData()); |
| 1580 | | if (player_ctx) |
| 1581 | | delete player_ctx; |
| | 1564 | SetPlayerContext(NULL); |
| 1582 | 1565 | return REENCODE_ERROR; |
| 1583 | 1566 | } |
| 1584 | 1567 | LOG(VB_GENERAL, LOG_INFO, |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1609 | 1592 | float rateTimeConv = arb->m_eff_audiorate / 1000.0f; |
| 1610 | 1593 | float vidFrameTime = 1000.0f / video_frame_rate; |
| 1611 | 1594 | int wait_recover = 0; |
| 1612 | | VideoOutput *videoOutput = player->GetVideoOutput(); |
| | 1595 | VideoOutput *videoOutput = GetPlayer()->GetVideoOutput(); |
| 1613 | 1596 | bool is_key = 0; |
| 1614 | 1597 | bool first_loop = true; |
| 1615 | 1598 | unsigned char *newFrame = new unsigned char[frame.size]; |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1629 | 1612 | LOG(VB_GENERAL, LOG_INFO, "Transcoding Video and Audio"); |
| 1630 | 1613 | |
| 1631 | 1614 | TranscodeFrameQueue *frameQueue = |
| 1632 | | new TranscodeFrameQueue(player, videoOutput, honorCutList); |
| | 1615 | new TranscodeFrameQueue(GetPlayer(), videoOutput, honorCutList); |
| 1633 | 1616 | MThreadPool::globalInstance()->start(frameQueue, "TranscodeFrameQueue"); |
| 1634 | 1617 | |
| 1635 | 1618 | QTime flagTime; |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1649 | 1632 | { |
| 1650 | 1633 | if (first_loop) |
| 1651 | 1634 | { |
| 1652 | | copyaudio = player->GetRawAudioState(); |
| | 1635 | copyaudio = GetPlayer()->GetRawAudioState(); |
| 1653 | 1636 | first_loop = false; |
| 1654 | 1637 | } |
| 1655 | 1638 | |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1765 | 1748 | } |
| 1766 | 1749 | } |
| 1767 | 1750 | videoOutput->DoneDisplayingFrame(lastDecode); |
| 1768 | | player->GetCC608Reader()->FlushTxtBuffers(); |
| | 1751 | GetPlayer()->GetCC608Reader()->FlushTxtBuffers(); |
| 1769 | 1752 | lasttimecode = frame.timecode; |
| 1770 | 1753 | } |
| 1771 | 1754 | else if (copyaudio) |
| 1772 | 1755 | { |
| 1773 | 1756 | // Encoding from NuppelVideo to NuppelVideo with MP3 audio |
| 1774 | 1757 | // So let's not decode/reencode audio |
| 1775 | | if (!player->GetRawAudioState()) |
| | 1758 | if (!GetPlayer()->GetRawAudioState()) |
| 1776 | 1759 | { |
| 1777 | 1760 | // The Raw state changed during decode. This is not good |
| 1778 | 1761 | LOG(VB_GENERAL, LOG_ERR, "Transcoding aborted, MythPlayer " |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1780 | 1763 | |
| 1781 | 1764 | unlink(outputname.toLocal8Bit().constData()); |
| 1782 | 1765 | delete [] newFrame; |
| 1783 | | if (player_ctx) |
| 1784 | | delete player_ctx; |
| | 1766 | SetPlayerContext(NULL); |
| 1785 | 1767 | if (frameQueue) |
| 1786 | 1768 | frameQueue->stop(); |
| 1787 | 1769 | return REENCODE_ERROR; |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1801 | 1783 | |
| 1802 | 1784 | //need to correct the frame# and timecode here |
| 1803 | 1785 | // Question: Is it necessary to change the timecodes? |
| 1804 | | long sync_offset; |
| 1805 | | sync_offset = player->UpdateStoredFrameNum(curFrameNum); |
| | 1786 | long sync_offset = |
| | 1787 | GetPlayer()->UpdateStoredFrameNum(curFrameNum); |
| 1806 | 1788 | nvr->UpdateSeekTable(num_keyframes, sync_offset); |
| 1807 | 1789 | ReencoderAddKFA(curFrameNum, lastKeyFrame, num_keyframes); |
| 1808 | 1790 | num_keyframes++; |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1821 | 1803 | lasttimecode = frame.timecode; |
| 1822 | 1804 | frame.timecode -= timecodeOffset; |
| 1823 | 1805 | |
| 1824 | | if (! player->WriteStoredData(outRingBuffer, (did_ff == 0), |
| 1825 | | timecodeOffset)) |
| | 1806 | if (!GetPlayer()->WriteStoredData( |
| | 1807 | outRingBuffer, (did_ff == 0), timecodeOffset)) |
| 1826 | 1808 | { |
| 1827 | 1809 | if (video_aspect != new_aspect) |
| 1828 | 1810 | { |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1830 | 1812 | nvr->SetNewVideoParams(video_aspect); |
| 1831 | 1813 | } |
| 1832 | 1814 | |
| 1833 | | QSize buf_size = player->GetVideoBufferSize(); |
| | 1815 | QSize buf_size = GetPlayer()->GetVideoBufferSize(); |
| 1834 | 1816 | |
| 1835 | 1817 | if (video_width != buf_size.width() || |
| 1836 | 1818 | video_height != buf_size.height()) |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1877 | 1859 | |
| 1878 | 1860 | nvr->WriteVideo(&frame, true, writekeyframe); |
| 1879 | 1861 | } |
| 1880 | | player->GetCC608Reader()->FlushTxtBuffers(); |
| | 1862 | GetPlayer()->GetCC608Reader()->FlushTxtBuffers(); |
| 1881 | 1863 | } |
| 1882 | 1864 | else |
| 1883 | 1865 | { |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1896 | 1878 | } |
| 1897 | 1879 | |
| 1898 | 1880 | |
| 1899 | | QSize buf_size = player->GetVideoBufferSize(); |
| | 1881 | QSize buf_size = GetPlayer()->GetVideoBufferSize(); |
| 1900 | 1882 | |
| 1901 | 1883 | if (video_width != buf_size.width() || |
| 1902 | 1884 | video_height != buf_size.height()) |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1979 | 1961 | "NVR::WriteAudio"); |
| 1980 | 1962 | |
| 1981 | 1963 | delete [] newFrame; |
| 1982 | | if (player_ctx) |
| 1983 | | delete player_ctx; |
| | 1964 | SetPlayerContext(NULL); |
| 1984 | 1965 | if (frameQueue) |
| 1985 | 1966 | frameQueue->stop(); |
| 1986 | 1967 | delete ab; |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 1996 | 1977 | } |
| 1997 | 1978 | |
| 1998 | 1979 | if (!avfMode) |
| 1999 | | player->GetCC608Reader()-> |
| | 1980 | { |
| | 1981 | GetPlayer()->GetCC608Reader()-> |
| 2000 | 1982 | TranscodeWriteText(&TranscodeWriteText, (void *)(nvr)); |
| | 1983 | } |
| 2001 | 1984 | lasttimecode = frame.timecode; |
| 2002 | 1985 | frame.timecode -= timecodeOffset; |
| 2003 | 1986 | |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 2066 | 2049 | |
| 2067 | 2050 | unlink(outputname.toLocal8Bit().constData()); |
| 2068 | 2051 | delete [] newFrame; |
| 2069 | | if (player_ctx) |
| 2070 | | delete player_ctx; |
| | 2052 | SetPlayerContext(NULL); |
| 2071 | 2053 | if (frameQueue) |
| 2072 | 2054 | frameQueue->stop(); |
| 2073 | 2055 | return REENCODE_CUTLIST_CHANGE; |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 2082 | 2064 | |
| 2083 | 2065 | unlink(outputname.toLocal8Bit().constData()); |
| 2084 | 2066 | delete [] newFrame; |
| 2085 | | if (player_ctx) |
| 2086 | | delete player_ctx; |
| | 2067 | SetPlayerContext(NULL); |
| 2087 | 2068 | if (frameQueue) |
| 2088 | 2069 | frameQueue->stop(); |
| 2089 | 2070 | return REENCODE_STOPPED; |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 2116 | 2097 | curFrameNum++; |
| 2117 | 2098 | frame.frameNumber = 1 + (curFrameNum << 1); |
| 2118 | 2099 | |
| 2119 | | player->DiscardVideoFrame(lastDecode); |
| | 2100 | GetPlayer()->DiscardVideoFrame(lastDecode); |
| 2120 | 2101 | } |
| 2121 | 2102 | |
| 2122 | 2103 | sws_freeContext(scontext); |
| … |
… |
int Transcode::TranscodeFile(const QString &inputname,
|
| 2175 | 2156 | frameQueue->stop(); |
| 2176 | 2157 | |
| 2177 | 2158 | delete [] newFrame; |
| 2178 | | if (player_ctx) |
| 2179 | | delete player_ctx; |
| | 2159 | SetPlayerContext(NULL); |
| | 2160 | |
| 2180 | 2161 | return REENCODE_OK; |
| 2181 | 2162 | } |
| 2182 | 2163 | |
diff --git a/mythtv/programs/mythtranscode/transcode.h b/mythtv/programs/mythtranscode/transcode.h
index ce5b909..9c5f7a4 100644
|
a
|
b
|
|
| 1 | | #include <QPointer> |
| 2 | 1 | #include "recordingprofile.h" |
| 3 | 2 | #include "fifowriter.h" |
| 4 | 3 | #include "transcodedefs.h" |
| … |
… |
class Transcode : public QObject
|
| 43 | 42 | bool GetProfile(QString profileName, QString encodingType, int height, |
| 44 | 43 | int frameRate); |
| 45 | 44 | void ReencoderAddKFA(long curframe, long lastkey, long num_keyframes); |
| | 45 | void SetPlayerContext(PlayerContext*); |
| | 46 | PlayerContext *GetPlayerContext(void) { return ctx; } |
| | 47 | MythPlayer *GetPlayer(void) { return (ctx) ? ctx->player : NULL; } |
| 46 | 48 | |
| 47 | 49 | private: |
| 48 | 50 | ProgramInfo *m_proginfo; |
| 49 | 51 | RecordingProfile profile; |
| 50 | 52 | int keyframedist; |
| 51 | 53 | NuppelVideoRecorder *nvr; |
| 52 | | MythPlayer *player; |
| 53 | | QPointer<PlayerContext> player_ctx; |
| 54 | | RingBuffer *inRingBuffer; |
| | 54 | PlayerContext *ctx; |
| 55 | 55 | RingBuffer *outRingBuffer; |
| 56 | 56 | FIFOWriter *fifow; |
| 57 | 57 | KFATable *kfa_table; |