Ticket #6824: 6824-v1.patch
File 6824-v1.patch, 15.0 KB (added by , 15 years ago) |
---|
-
libs/libmythtv/NuppelVideoPlayer.cpp
1256 1256 SetDecoder(new AvFormatDecoder(this, *player_ctx->playingInfo, 1257 1257 using_null_videoout, 1258 1258 allow_libmpeg2, 1259 no_hardware_decoders)); 1259 no_hardware_decoders, 1260 player_ctx->GetSpecialDecode())); 1260 1261 } 1261 1262 player_ctx->UnlockPlayingInfo(__FILE__, __LINE__); 1262 1263 if (GetDecoder()) -
libs/libmythtv/avformatdecoder.cpp
75 75 int *nblks, int *sfreq); 76 76 static int encode_frame(bool dts, unsigned char* data, int len, 77 77 short *samples, int &samples_size); 78 static QSize get_video_dim(const AVCodecContext &ctx) 79 { 80 return QSize(ctx.width >> ctx.lowres, ctx.height >> ctx.lowres); 81 } 82 static float get_aspect(const AVCodecContext &ctx) 83 { 84 float aspect_ratio = 0.0f; 78 85 86 if (ctx.sample_aspect_ratio.num && ctx.height) 87 { 88 aspect_ratio = av_q2d(ctx.sample_aspect_ratio) * (float) ctx.width; 89 aspect_ratio /= (float) ctx.height; 90 } 91 92 if (aspect_ratio <= 0.0f || aspect_ratio > 6.0f) 93 { 94 if (ctx.height) 95 aspect_ratio = (float)ctx.width / (float)ctx.height; 96 else 97 aspect_ratio = 4.0f / 3.0f; 98 } 99 100 return aspect_ratio; 101 } 102 79 103 int get_avf_buffer_xvmc(struct AVCodecContext *c, AVFrame *pic); 80 104 int get_avf_buffer(struct AVCodecContext *c, AVFrame *pic); 81 105 void release_avf_buffer(struct AVCodecContext *c, AVFrame *pic); … … 432 456 const ProgramInfo &pginfo, 433 457 bool use_null_videoout, 434 458 bool allow_libmpeg2, 435 bool no_hardware_decode) 459 bool no_hardware_decode, 460 AVSpecialDecode special_decoding) 436 461 : DecoderBase(parent, pginfo), 437 462 d(new AvFormatDecoderPrivate(allow_libmpeg2)), 438 463 is_db_ignored(gContext->IsDatabaseIgnored()), … … 450 475 using_null_videoout(use_null_videoout), 451 476 video_codec_id(kCodec_NONE), 452 477 no_hardware_decoders(no_hardware_decode), 478 special_decode(special_decoding), 453 479 maxkeyframedist(-1), 454 480 // Closed Caption & Teletext decoders 455 481 ccd608(new CC608Decoder(parent)), … … 490 516 cc608_build_parity_table(cc608_parity_table); 491 517 492 518 no_dts_hack = false; 519 520 int x = gContext->GetNumSetting("CommFlagFast", 0); 521 if (x) 522 special_decode = (AVSpecialDecode) x; 523 VERBOSE(VB_IMPORTANT, "commflagging_speedups: " << special_decode); 493 524 } 494 525 495 526 AvFormatDecoder::~AvFormatDecoder() … … 1173 1204 <<") type ("<<codec_type_string(enc->codec_type) 1174 1205 <<")."); 1175 1206 1176 float aspect_ratio = 0.0;1177 1178 1207 if (ringBuffer->isDVD()) 1179 1208 directrendering = false; 1180 1209 1181 if (selectedStream)1182 {1183 fps = normalized_fps(stream, enc);1184 1185 if (enc->sample_aspect_ratio.num == 0)1186 aspect_ratio = 0.0f;1187 else1188 aspect_ratio = av_q2d(enc->sample_aspect_ratio) *1189 enc->width / enc->height;1190 1191 if (aspect_ratio <= 0.0f || aspect_ratio > 6.0f)1192 aspect_ratio = (float)enc->width / (float)enc->height;1193 1194 current_width = enc->width;1195 current_height = enc->height;1196 current_aspect = aspect_ratio;1197 }1198 1199 1210 enc->opaque = (void *)this; 1200 1211 enc->get_buffer = avcodec_default_get_buffer; 1201 1212 enc->release_buffer = avcodec_default_release_buffer; … … 1264 1275 directrendering = true; 1265 1276 } 1266 1277 1278 if (special_decode) 1279 { 1280 if (special_decode & kAVSpecialDecode_SingleThreaded) 1281 enc->thread_count = 1; 1282 1283 enc->flags |= CODEC_FLAG2_FAST; 1284 1285 if ((CODEC_ID_MPEG2VIDEO == codec->id) || 1286 (CODEC_ID_MPEG1VIDEO == codec->id)) 1287 { 1288 if (special_decode & kAVSpecialDecode_FewBlocks) 1289 { 1290 uint total_blocks = (enc->height+15) / 16; 1291 enc->skip_top = (total_blocks+3) / 4; 1292 enc->skip_bottom = (total_blocks+3) / 4; 1293 } 1294 1295 if (special_decode & kAVSpecialDecode_LowRes) 1296 enc->lowres = 2; // 1 = 1/2 size, 2 = 1/4 size 1297 } 1298 else if (CODEC_ID_H264 == codec->id) 1299 { 1300 if (special_decode & kAVSpecialDecode_NoLoopFilter) 1301 { 1302 enc->flags &= ~CODEC_FLAG_LOOP_FILTER; 1303 enc->skip_loop_filter = AVDISCARD_ALL; 1304 } 1305 } 1306 1307 if (special_decode & kAVSpecialDecode_NoDecode) 1308 { 1309 enc->skip_idct = AVDISCARD_ALL; 1310 } 1311 } 1312 1267 1313 if (selectedStream) 1268 1314 { 1269 uint width = enc->width; 1270 uint height = enc->height; 1315 fps = normalized_fps(stream, enc); 1316 QSize dim = get_video_dim(*enc); 1317 int width = current_width = dim.width(); 1318 int height = current_height = dim.height(); 1319 float aspect = current_aspect = get_aspect(*enc); 1271 1320 1272 if ( width == 0 && height == 0)1321 if (!width || !height) 1273 1322 { 1274 1323 VERBOSE(VB_PLAYBACK, LOC + "InitVideoCodec " 1275 1324 "invalid dimensions, resetting decoder."); 1276 width = 640;1325 width = 640; 1277 1326 height = 480; 1278 fps = 29.97;1279 aspect _ratio = 4.0 / 3;1327 fps = 29.97f; 1328 aspect = 4.0f / 3.0f; 1280 1329 } 1281 1330 1282 1331 GetNVP()->SetVideoParams(width, height, fps, 1283 keyframedist, aspect _ratio, kScan_Detect,1332 keyframedist, aspect, kScan_Detect, 1284 1333 dvd_video_codec_changed); 1285 1334 } 1286 1335 } … … 1610 1659 d->DestroyMPEG2(); 1611 1660 m_h264_parser->Reset(); 1612 1661 1613 uint width = max(enc->width, 16); 1614 uint height = max(enc->height, 16); 1662 QSize dim = get_video_dim(*enc); 1663 uint width = max(dim.width(), 16); 1664 uint height = max(dim.height(), 16); 1615 1665 QString dec = "ffmpeg"; 1616 1666 uint thread_count = 1; 1617 1667 … … 2564 2614 SequenceHeader *seq = reinterpret_cast<SequenceHeader*>( 2565 2615 const_cast<uint8_t*>(bufptr)); 2566 2616 2567 uint width = seq->width() ;2568 uint height = seq->height() ;2617 uint width = seq->width() >> context->lowres; 2618 uint height = seq->height() >> context->lowres; 2569 2619 float aspect = seq->aspect(context->sub_id == 1); 2570 2620 float seqFPS = seq->fps(); 2571 2621 2572 bool changed = (seqFPS > fps+0.01 ) || (seqFPS < fps-0.01);2622 bool changed = (seqFPS > fps+0.01f) || (seqFPS < fps-0.01f); 2573 2623 changed |= (width != (uint)current_width ); 2574 2624 changed |= (height != (uint)current_height); 2575 2625 changed |= fabs(aspect - current_aspect) > eps; … … 2593 2643 2594 2644 // fps debugging info 2595 2645 float avFPS = normalized_fps(stream, context); 2596 if ((seqFPS > avFPS+0.01 ) || (seqFPS < avFPS-0.01))2646 if ((seqFPS > avFPS+0.01f) || (seqFPS < avFPS-0.01f)) 2597 2647 { 2598 2648 VERBOSE(VB_PLAYBACK, LOC + 2599 2649 QString("avFPS(%1) != seqFPS(%2)") … … 2632 2682 || m_h264_parser->FieldType() == H264Parser::FIELD_BOTTOM) 2633 2683 continue; 2634 2684 2635 float aspect_ratio; 2636 if (context->sample_aspect_ratio.num == 0) 2637 aspect_ratio = 0.0f; 2638 else 2639 aspect_ratio = av_q2d(context->sample_aspect_ratio) * 2640 context->width / context->height; 2641 2642 if (aspect_ratio <= 0.0f || aspect_ratio > 6.0f) 2643 aspect_ratio = (float)context->width / context->height; 2644 2645 uint width = context->width; 2646 uint height = context->height; 2685 float aspect_ratio = get_aspect(*context); 2686 QSize dim = get_video_dim(*context); 2687 uint width = dim.width(); 2688 uint height = dim.height(); 2647 2689 float seqFPS = normalized_fps(stream, context); 2648 2690 2649 bool changed = (seqFPS > fps+0.01 ) || (seqFPS < fps-0.01);2691 bool changed = (seqFPS > fps+0.01f) || (seqFPS < fps-0.01f); 2650 2692 changed |= (width != (uint)current_width ); 2651 2693 changed |= (height != (uint)current_height); 2652 2694 changed |= fabs(aspect_ratio - current_aspect) > eps; … … 2668 2710 2669 2711 // fps debugging info 2670 2712 float avFPS = normalized_fps(stream, context); 2671 if ((seqFPS > avFPS+0.01 ) || (seqFPS < avFPS-0.01))2713 if ((seqFPS > avFPS+0.01f) || (seqFPS < avFPS-0.01f)) 2672 2714 { 2673 2715 VERBOSE(VB_PLAYBACK, LOC + 2674 2716 QString("avFPS(%1) != seqFPS(%2)") … … 3420 3462 3421 3463 if (!d->HasMPEG2Dec()) 3422 3464 { 3423 int current_width = curstream->codec->width; 3465 int current_width = curstream->codec->width; // TODO CHECKME 3424 3466 int video_width = GetNVP()->GetVideoSize().width(); 3425 3467 if (dvd_xvmc_enabled && GetNVP() && GetNVP()->getVideoOutput()) 3426 3468 { … … 3928 3970 tmppicture.linesize[1] = picframe->pitches[1]; 3929 3971 tmppicture.linesize[2] = picframe->pitches[2]; 3930 3972 3973 QSize dim = get_video_dim(*context); 3931 3974 myth_sws_img_convert( 3932 3975 &tmppicture, PIX_FMT_YUV420P, 3933 (AVPicture *)&mpa_pic, 3934 context->pix_fmt, 3935 context->width, 3936 context->height); 3976 (AVPicture *)&mpa_pic, 3977 context->pix_fmt, 3978 dim.width(), dim.height()); 3937 3979 3938 3980 if (xf) 3939 3981 { -
libs/libmythtv/playercontext.cpp
35 35 PlayerContext::PlayerContext(const QString &inUseID) : 36 36 recUsage(inUseID), nvp(NULL), nvpUnsafe(false), recorder(NULL), 37 37 tvchain(NULL), buffer(NULL), playingInfo(NULL), 38 playingLen(0), specialDecode(kAVSpecialDecode_None), 38 39 nohardwaredecoders(false), 39 40 decoding(false), last_cardid(-1), last_framerate(30.0f), 40 41 // Fast forward state -
libs/libmythtv/videoouttypes.h
114 114 kVisibility_Embedded, 115 115 } WindowVisibility; 116 116 117 typedef enum AVSpecialDecode 118 { 119 kAVSpecialDecode_None = 0x00, 120 kAVSpecialDecode_LowRes = 0x01, 121 kAVSpecialDecode_SingleThreaded = 0x02, 122 kAVSpecialDecode_FewBlocks = 0x04, 123 kAVSpecialDecode_NoLoopFilter = 0x08, 124 kAVSpecialDecode_NoDecode = 0x10, 125 } AVSpecialDecode; 126 117 127 class DisplayInfo 118 128 { 119 129 public: -
libs/libmythtv/playercontext.h
97 97 void SetPIPState(PIPState change) { pipState = change; } 98 98 void SetNVPChangingBuffers(bool val) { nvpUnsafe = val; } 99 99 void SetNoHardwareDecoders(void) { nohardwaredecoders = true; } 100 void SetSpecialDecode(AVSpecialDecode sp) { specialDecode = sp; } 100 101 101 102 // Gets 102 103 QRect GetStandAlonePIPRect(void); … … 108 109 QString GetFilters(const QString &baseFilters) const; 109 110 QString GetPlayMessage(void) const; 110 111 TVState GetState(void) const; 112 AVSpecialDecode GetSpecialDecode(void) const { return specialDecode; } 111 113 112 114 // Boolean Gets 113 115 bool IsPIPSupported(void) const; … … 144 146 RingBuffer *buffer; 145 147 ProgramInfo *playingInfo; ///< Currently playing info 146 148 long long playingLen; ///< Initial CalculateLength() 149 AVSpecialDecode specialDecode; 147 150 bool nohardwaredecoders; // < Disable use of VDPAU decoding 148 151 bool decoding; ///< Video decoder thread started 149 152 pthread_t decode; ///< Video decoder thread -
libs/libmythtv/avformatdecoder.h
1 1 #ifndef AVFORMATDECODER_H_ 2 2 #define AVFORMATDECODER_H_ 3 3 4 #include < qstring.h>5 #include < qmap.h>4 #include <QString> 5 #include <QMap> 6 6 #include <QList> 7 7 8 8 #include "programinfo.h" … … 77 77 public: 78 78 AvFormatDecoder(NuppelVideoPlayer *parent, const ProgramInfo &pginfo, 79 79 bool use_null_video_out, bool allow_libmpeg2 = true, 80 bool no_hardware_decode = false); 80 bool no_hardware_decode = false, 81 AVSpecialDecode av_special_decode = kAVSpecialDecode_None); 81 82 ~AvFormatDecoder(); 82 83 83 84 void CloseCodecs(); … … 241 242 bool using_null_videoout; 242 243 MythCodecID video_codec_id; 243 244 bool no_hardware_decoders; 245 AVSpecialDecode special_decode; 244 246 245 247 int maxkeyframedist; 246 248 -
programs/mythcommflag/main.cpp
138 138 NuppelVideoPlayer *nvp = new NuppelVideoPlayer(); 139 139 140 140 PlayerContext *ctx = new PlayerContext("seektable rebuilder"); 141 ctx->SetSpecialDecode(kAVSpecialDecode_NoDecode); 141 142 ctx->SetPlayingInfo(program_info); 142 143 ctx->SetRingBuffer(tmprbuf); 143 144 ctx->SetNVP(nvp); … … 696 697 NuppelVideoPlayer *nvp = new NuppelVideoPlayer(); 697 698 698 699 PlayerContext *ctx = new PlayerContext("flagger"); 700 701 AVSpecialDecode sp = (AVSpecialDecode) 702 (kAVSpecialDecode_LowRes | 703 kAVSpecialDecode_SingleThreaded | 704 kAVSpecialDecode_NoLoopFilter); 705 706 #if 0 /* blank detector needs to be only sample center for this optimization. */ 707 if ((COMM_DETECT_BLANKS == commDetectMethod) || 708 (COMM_DETECT_2_BLANK == commDetectMethod)) 709 { 710 sp = (AVSpecialDecode) (sp | kAVSpecialDecode_FewBlocks); 711 } 712 #endif 713 714 ctx->SetSpecialDecode(sp); 715 699 716 ctx->SetPlayingInfo(program_info); 700 717 ctx->SetRingBuffer(tmprbuf); 701 718 ctx->SetNVP(nvp);