1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
Index: libs/libmythtv/mpegrecorder.cpp
===================================================================
--- libs/libmythtv/mpegrecorder.cpp.orig
+++ libs/libmythtv/mpegrecorder.cpp
@@ -1109,6 +1109,14 @@ void MpegRecorder::StartRecording(void)
if (driver == "hdpvr")
{
+ if (curRecording->recgroup == "LiveTV")
+ {
+ // Don't bother checking resolution, always use best bitrate
+ int maxbitrate = std::max(high_mpeg4peakbitrate,
+ high_mpeg4avgbitrate);
+ SetBitrate(high_mpeg4avgbitrate, maxbitrate, "LiveTV");
+ }
+
int progNum = 1;
MPEGStreamData *sd = new MPEGStreamData(progNum, true);
sd->SetRecordingType(_recording_type);
@@ -1553,7 +1561,7 @@ bool MpegRecorder::StartEncoding(int fd)
memset(&command, 0, sizeof(struct v4l2_encoder_cmd));
command.cmd = V4L2_ENC_CMD_START;
- if (driver == "hdpvr")
+ if (driver == "hdpvr" && curRecording->recgroup != "LiveTV")
HandleResolutionChanges();
VERBOSE(VB_RECORD, LOC + "StartEncoding");
@@ -1755,6 +1763,35 @@ bool MpegRecorder::WaitFor_HDPVR(void)
return false;
}
+void MpegRecorder::SetBitrate(int bitrate, int maxbitrate,
+ const QString & reason)
+{
+ if (maxbitrate == bitrate)
+ {
+ VERBOSE(VB_RECORD, LOC + QString("%1 bitrate %2 kbps CBR")
+ .arg(reason).arg(bitrate));
+ }
+ else
+ {
+ VERBOSE(VB_RECORD, LOC + QString("%1 bitrate %2/%3 kbps VBR")
+ .arg(reason).arg(bitrate).arg(maxbitrate));
+ }
+
+ vector<struct v4l2_ext_control> ext_ctrls;
+ add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE_MODE,
+ (maxbitrate == bitrate) ?
+ V4L2_MPEG_VIDEO_BITRATE_MODE_CBR :
+ V4L2_MPEG_VIDEO_BITRATE_MODE_VBR);
+
+ add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE,
+ bitrate * 1000);
+
+ add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE_PEAK,
+ maxbitrate * 1000);
+
+ set_ctrls(readfd, ext_ctrls);
+}
+
void MpegRecorder::HandleResolutionChanges(void)
{
VERBOSE(VB_RECORD, LOC + "Checking Resolution");
@@ -1819,30 +1856,7 @@ void MpegRecorder::HandleResolutionChang
.arg(old_avg).arg(old_max));
}
- if (maxbitrate == bitrate)
- {
- VERBOSE(VB_RECORD, LOC + QString("New bitrate %1 kbps CBR")
- .arg(bitrate));
- }
- else
- {
- VERBOSE(VB_RECORD, LOC + QString("New bitrate %1/%2 kbps VBR")
- .arg(bitrate).arg(maxbitrate));
- }
-
- vector<struct v4l2_ext_control> ext_ctrls;
- add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE_MODE,
- (maxbitrate == bitrate) ?
- V4L2_MPEG_VIDEO_BITRATE_MODE_CBR :
- V4L2_MPEG_VIDEO_BITRATE_MODE_VBR);
-
- add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE,
- bitrate * 1000);
-
- add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE_PEAK,
- maxbitrate * 1000);
-
- set_ctrls(readfd, ext_ctrls);
-
+ SetBitrate(bitrate, maxbitrate, "New");
}
}
+
Index: libs/libmythtv/mpegrecorder.h
===================================================================
--- libs/libmythtv/mpegrecorder.h.orig
+++ libs/libmythtv/mpegrecorder.h
@@ -87,6 +87,7 @@ class MpegRecorder : public DTVRecorder,
void ResetForNewFile(void);
bool WaitFor_HDPVR(void);
+ void SetBitrate(int bitrate, int maxbitrate, const QString & reason);
void HandleResolutionChanges(void);
inline bool CheckCC(uint pid, uint cc);
|