Ticket #6655: hdpvr-simplify-profiles.patch
File hdpvr-simplify-profiles.patch, 11.5 KB (added by , 15 years ago) |
---|
-
libs/libmythtv/mpegrecorder.cpp
old new extern "C" { 42 42 #include "ivtv_myth.h" 43 43 } 44 44 45 const int MAX_HDPVR_VBR_RATE = 20200; 46 45 47 #define IVTV_KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 46 48 47 49 #define LOC QString("MPEGRec(%1): ").arg(videodevice) … … MpegRecorder::MpegRecorder(TVRec *rec) : 99 101 audbitratel1(14), audbitratel2(14), 100 102 audbitratel3(10), 101 103 audvolume(80), language(0), 102 low_mpeg4avgbitrate(4500), low_mpeg4peakbitrate(6000), 103 medium_mpeg4avgbitrate(9000), medium_mpeg4peakbitrate(13500), 104 high_mpeg4avgbitrate(13500), high_mpeg4peakbitrate(20200), 104 low_mpeg4bitrate(4500), medium_mpeg4bitrate(9000), 105 high_mpeg4bitrate(13500), bitrateType(0), 105 106 // Input file descriptors 106 107 chanfd(-1), readfd(-1), 107 108 _device_read_buffer(NULL), … … void MpegRecorder::SetOption(const QStri 198 199 else if (opt.right(16) == "_mpeg4avgbitrate") 199 200 { 200 201 if (opt.left(3) == "low") 201 low_mpeg4 avgbitrate = value;202 low_mpeg4bitrate = value; 202 203 else if (opt.left(6) == "medium") 203 medium_mpeg4 avgbitrate = value;204 medium_mpeg4bitrate = value; 204 205 else if (opt.left(4) == "high") 205 high_mpeg4 avgbitrate = value;206 high_mpeg4bitrate = value; 206 207 else 207 208 RecorderBase::SetOption(opt, value); 208 209 } 209 else if (opt.right(1 7) == "_mpeg4peakbitrate")210 else if (opt.right(12) == "_bitrateType") 210 211 { 211 212 if (opt.left(3) == "low") 212 low_ mpeg4peakbitrate= value;213 low_cbr = value; 213 214 else if (opt.left(6) == "medium") 214 medium_ mpeg4peakbitrate= value;215 medium_cbr = value; 215 216 else if (opt.left(4) == "high") 216 high_ mpeg4peakbitrate= value;217 high_cbr = value; 217 218 else 218 219 RecorderBase::SetOption(opt, value); 219 220 } … … void MpegRecorder::SetOptionsFromProfile 342 343 SetIntOption(profile, "height"); 343 344 344 345 SetIntOption(profile, "low_mpeg4avgbitrate"); 345 SetIntOption(profile, "low_ mpeg4peakbitrate");346 SetIntOption(profile, "low_bitrateType"); 346 347 SetIntOption(profile, "medium_mpeg4avgbitrate"); 347 SetIntOption(profile, "medium_ mpeg4peakbitrate");348 SetIntOption(profile, "medium_bitrateType"); 348 349 SetIntOption(profile, "high_mpeg4avgbitrate"); 349 SetIntOption(profile, "high_ mpeg4peakbitrate");350 SetIntOption(profile, "high_bitrateType"); 350 351 351 352 SetStrOption(profile, "audiocodec"); 352 353 } … … bool MpegRecorder::SetV4L2DeviceOptions( 828 829 } 829 830 else 830 831 { 831 maxbitrate = high_mpeg4peakbitrate;832 bitrate = high_mpeg4 avgbitrate;832 maxbitrate = MAX_HDPVR_VBR_RATE; 833 bitrate = high_mpeg4bitrate; 833 834 } 834 835 maxbitrate = std::max(maxbitrate, bitrate); 835 836 836 837 if (driver == "hdpvr") 837 838 { 838 839 add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE_MODE, 839 ( maxbitrate == bitrate) ?840 (high_cbr) ? 840 841 V4L2_MPEG_VIDEO_BITRATE_MODE_CBR : 841 842 V4L2_MPEG_VIDEO_BITRATE_MODE_VBR); 842 843 } … … void MpegRecorder::StartRecording(void) 1043 1044 if (curRecording->recgroup == "LiveTV") 1044 1045 { 1045 1046 // Don't bother checking resolution, always use best bitrate 1046 int maxbitrate = std::max(high_mpeg4peakbitrate, 1047 high_mpeg4avgbitrate); 1048 SetBitrate(high_mpeg4avgbitrate, maxbitrate, "LiveTV"); 1047 SetBitrate(high_mpeg4bitrate, high_cbr, "LiveTV"); 1049 1048 } 1050 1049 1051 1050 int progNum = 1; … … bool MpegRecorder::WaitFor_HDPVR(void) 1674 1673 return false; 1675 1674 } 1676 1675 1677 void MpegRecorder::SetBitrate(int bitrate, int maxbitrate, 1678 const QString & reason) 1676 void MpegRecorder::SetBitrate(int rate, bool type, const QString & reason) 1679 1677 { 1680 if (maxbitrate == bitrate) 1681 { 1682 VERBOSE(VB_RECORD, LOC + QString("%1 bitrate %2 kbps CBR") 1683 .arg(reason).arg(bitrate)); 1684 } 1685 else 1686 { 1687 VERBOSE(VB_RECORD, LOC + QString("%1 bitrate %2/%3 kbps VBR") 1688 .arg(reason).arg(bitrate).arg(maxbitrate)); 1689 } 1678 VERBOSE(VB_RECORD, LOC + QString("%1 bitrate %2 Kbps %3") 1679 .arg(reason).arg(rate).arg(type ? "CBR" : "VBR")); 1690 1680 1691 1681 vector<struct v4l2_ext_control> ext_ctrls; 1692 1682 add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE_MODE, 1693 (maxbitrate == bitrate)?1683 type ? 1694 1684 V4L2_MPEG_VIDEO_BITRATE_MODE_CBR : 1695 1685 V4L2_MPEG_VIDEO_BITRATE_MODE_VBR); 1696 1686 1697 add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE, 1698 bitrate * 1000); 1699 1687 add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE, rate * 1000); 1700 1688 add_ext_ctrl(ext_ctrls, V4L2_CID_MPEG_VIDEO_BITRATE_PEAK, 1701 maxbitrate* 1000);1689 MAX_HDPVR_VBR_RATE * 1000); 1702 1690 1703 1691 set_ctrls(readfd, ext_ctrls); 1704 1692 } … … void MpegRecorder::HandleResolutionChang 1727 1715 return; // nothing to do, we don't have a resolution yet 1728 1716 } 1729 1717 1730 int old_max = maxbitrate, old_avg = bitrate;1731 1718 if (pix <= 768*568) 1732 1719 { 1733 maxbitrate = low_mpeg4peakbitrate;1734 bitrate = low_mpeg4avgbitrate;1720 bitrate = low_mpeg4bitrate; 1721 bitrateType = low_cbr; 1735 1722 } 1736 1723 else if (pix >= 1920*1080) 1737 1724 { 1738 maxbitrate = high_mpeg4peakbitrate;1739 bitrate = high_mpeg4avgbitrate;1725 bitrate = high_mpeg4bitrate; 1726 bitrateType = high_cbr; 1740 1727 } 1741 1728 else 1742 1729 { 1743 maxbitrate = medium_mpeg4peakbitrate;1744 bitrate = medium_mpeg4avgbitrate;1730 bitrate = medium_mpeg4bitrate; 1731 bitrateType = medium_cbr; 1745 1732 } 1746 maxbitrate = std::max(maxbitrate, bitrate);1747 1733 1748 if ((old_max != maxbitrate) || (old_avg != bitrate)) 1749 { 1750 if (old_max == old_avg) 1751 { 1752 VERBOSE(VB_RECORD, LOC + 1753 QString("Old bitrate %1 CBR").arg(old_avg)); 1754 } 1755 else 1756 { 1757 VERBOSE(VB_RECORD, LOC + 1758 QString("Old bitrate %1/%2 VBR") 1759 .arg(old_avg).arg(old_max)); 1760 } 1761 1762 SetBitrate(bitrate, maxbitrate, "New"); 1763 } 1734 SetBitrate(bitrate, bitrateType, "Recording"); 1764 1735 } -
libs/libmythtv/mpegrecorder.h
old new class MpegRecorder : public DTVRecorder, 87 87 void ResetForNewFile(void); 88 88 89 89 bool WaitFor_HDPVR(void); 90 void SetBitrate(int bitrate, int maxbitrate, const QString & reason);90 void SetBitrate(int bitrate, bool type, const QString & reason); 91 91 void HandleResolutionChanges(void); 92 92 93 93 inline bool CheckCC(uint pid, uint cc); … … class MpegRecorder : public DTVRecorder, 115 115 bool cleartimeonpause; 116 116 117 117 // Encoding info 118 int width, height;119 int bitrate, maxbitrate, streamtype, aspectratio;120 int audtype, audsamplerate, audbitratel1, audbitratel2, audbitratel3;121 int audvolume;118 int width, height; 119 int bitrate, maxbitrate, streamtype, aspectratio; 120 int audtype, audsamplerate, audbitratel1, audbitratel2, audbitratel3; 121 int audvolume; 122 122 unsigned int language; ///< 0 is Main Lang; 1 is SAP Lang; 2 is Dual 123 unsigned int low_mpeg4avgbitrate; 124 unsigned int low_mpeg4peakbitrate; 125 unsigned int medium_mpeg4avgbitrate; 126 unsigned int medium_mpeg4peakbitrate; 127 unsigned int high_mpeg4avgbitrate; 128 unsigned int high_mpeg4peakbitrate; 123 unsigned int low_mpeg4bitrate; 124 bool low_cbr; 125 unsigned int medium_mpeg4bitrate; 126 bool medium_cbr; 127 unsigned int high_mpeg4bitrate; 128 bool high_cbr; 129 bool bitrateType; 129 130 130 131 // Input file descriptors 131 132 int chanfd; -
libs/libmythtv/recordingprofile.cpp
old new class EncodingThreadCount : public Slide 668 668 }; 669 669 }; 670 670 671 class BitrateType : public ComboBoxSetting, public CodecParamStorage 672 { 673 public: 674 BitrateType(const RecordingProfile &parent, 675 QString setting = "bitrateType") : 676 ComboBoxSetting(this), CodecParamStorage(this, parent, setting) 677 { 678 setLabel(QObject::tr("Type")); 679 680 addSelection(QObject::tr("Variable"), "0"); 681 addSelection(QObject::tr("Constant"), "1"); 682 683 setValue(0); 684 setHelpText(QObject::tr("Should bitrate be constant or an average?")); 685 }; 686 }; 687 671 688 class AverageBitrate : public SliderSetting, public CodecParamStorage 672 689 { 673 690 public: … … class VideoCompressionSettings : public 877 894 878 895 params = new VerticalConfigurationGroup(false); 879 896 params->setLabel(QObject::tr("MPEG-4 AVC Hardware Encoder")); 880 ConfigurationGroup *h0 = new HorizontalConfigurationGroup (881 true, false, true, true);882 h0->setLabel(QObject::tr("Low Resolution "));897 ConfigurationGroup *h0 = new HorizontalConfigurationGroup 898 (true, false, true, true); 899 h0->setLabel(QObject::tr("Low Resolution ( <= 768x568 )")); 883 900 h0->addChild(new AverageBitrate(parent, "low_mpeg4avgbitrate", 884 1000, 13500, 4500, 500)); 885 h0->addChild(new PeakBitrate(parent, "low_mpeg4peakbitrate", 886 1100, 20200, 6000, 500)); 901 1000, 13500, 4500, 500, "Bitrate")); 902 h0->addChild(new BitrateType(parent, "low_bitrateType")); 887 903 params->addChild(h0); 888 ConfigurationGroup *h1 = new HorizontalConfigurationGroup (889 true, false, true, true);890 h1->setLabel(QObject::tr("Medium Resolution "));904 ConfigurationGroup *h1 = new HorizontalConfigurationGroup 905 (true, false, true, true); 906 h1->setLabel(QObject::tr("Medium Resolution ( 768x568 <> 1920x1080 )")); 891 907 h1->addChild(new AverageBitrate(parent, "medium_mpeg4avgbitrate", 892 1000, 13500, 9000, 500)); 893 h1->addChild(new PeakBitrate(parent, "medium_mpeg4peakbitrate", 894 1100, 20200, 11000, 500)); 908 1000, 13500, 9000, 500, "Bitrate")); 909 h1->addChild(new BitrateType(parent, "medium_bitrateType")); 895 910 params->addChild(h1); 896 ConfigurationGroup *h2 = new HorizontalConfigurationGroup (897 true, false, true, true);898 h2->setLabel(QObject::tr("High Resolution "));911 ConfigurationGroup *h2 = new HorizontalConfigurationGroup 912 (true, false, true, true); 913 h2->setLabel(QObject::tr("High Resolution ( >= 1920x1080 )")); 899 914 h2->addChild(new AverageBitrate(parent, "high_mpeg4avgbitrate", 900 1000, 13500, 13500, 500)); 901 h2->addChild(new PeakBitrate(parent, "high_mpeg4peakbitrate", 902 1100, 20200, 20200, 500)); 915 1000, 13500, 13500, 500, "Bitrate")); 916 h2->addChild(new BitrateType(parent, "high_bitrateType")); 903 917 params->addChild(h2); 904 918 addTarget("MPEG-4 AVC Hardware Encoder", params); 905 919 }