diff options
author | Rainer Hochecker <fernetmenta@online.de> | 2018-03-29 22:12:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-29 22:12:17 +0200 |
commit | 1e4ae5e4173d1605af5e203ec95598e0c16791ea (patch) | |
tree | f14981b56f2c2e0fbd3715f0f00d7452c5d3752d | |
parent | 4c4a55286ed8c9efb48dc85ad6266c7127186401 (diff) | |
parent | d1a8f39989580ac371fb1e78c174830002549660 (diff) |
Merge pull request #13711 from FernetMenta/vtb
VideoPlayer: vtb - have ffmpeg do detection of interlaced material
-rw-r--r-- | xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h | 1 | ||||
-rw-r--r-- | xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 5 | ||||
-rw-r--r-- | xbmc/cores/VideoPlayer/DVDCodecs/Video/VTB.cpp | 28 | ||||
-rw-r--r-- | xbmc/utils/BitstreamConverter.cpp | 83 | ||||
-rw-r--r-- | xbmc/utils/BitstreamConverter.h | 1 |
5 files changed, 9 insertions, 109 deletions
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h index 14871481f5..81af64dfba 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h @@ -122,6 +122,7 @@ public: { VC_NONE = 0, VC_ERROR, //< an error occured, no other messages will be returned + VC_FATAL, //< non recoverable error VC_BUFFER, //< the decoder needs more data VC_PICTURE, //< the decoder got a picture, call Decode(NULL, 0) again to parse the rest of the data VC_FLUSHED, //< the decoder lost it's state, we need to restart decoding again diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp index 44c30b74e2..8ed84ceabd 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp @@ -796,6 +796,11 @@ CDVDVideoCodec::VCReturn CDVDVideoCodecFFmpeg::GetPicture(VideoPicture* pVideoPi Reset(); return ret; } + else if (ret == VC_FATAL) + { + m_decoderState = STATE_HW_FAILED; + return VC_REOPEN; + } else if (ret == VC_PICTURE) { if (m_pHardware->GetPicture(m_pCodecContext, pVideoPicture)) diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VTB.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VTB.cpp index c8954836d8..23f7d42f26 100644 --- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VTB.cpp +++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VTB.cpp @@ -25,8 +25,6 @@ #include "DVDCodecs/DVDFactoryCodec.h" #include "utils/log.h" #include "VTB.h" -#include "utils/BitstreamConverter.h" -#include "utils/BitstreamReader.h" #include "settings/Settings.h" #include "threads/SingleLock.h" #include "ServiceBroker.h" @@ -181,29 +179,6 @@ bool CDecoder::Open(AVCodecContext *avctx, AVCodecContext* mainctx, enum AVPixel if (!CServiceBroker::GetSettings().GetBool(CSettings::SETTING_VIDEOPLAYER_USEVTB)) return false; - if (avctx->codec_id == AV_CODEC_ID_H264) - { - CBitstreamConverter bs; - if (!bs.Open(avctx->codec_id, (uint8_t*)avctx->extradata, avctx->extradata_size, false)) - { - return false; - } - CFDataRef avcCData = CFDataCreate(kCFAllocatorDefault, - (const uint8_t*)bs.GetExtraData(), bs.GetExtraSize()); - bool interlaced = true; - int max_ref_frames; - uint8_t *spc = (uint8_t*)CFDataGetBytePtr(avcCData) + 6; - uint32_t sps_size = BS_RB16(spc); - if (sps_size) - bs.parseh264_sps(spc+3, sps_size-1, &interlaced, &max_ref_frames); - CFRelease(avcCData); - if (interlaced) - { - CLog::Log(LOGNOTICE, "%s - possible interlaced content.", __FUNCTION__); - return false; - } - } - if (av_videotoolbox_default_init(avctx) < 0) return false; @@ -229,6 +204,9 @@ CDVDVideoCodec::VCReturn CDecoder::Decode(AVCodecContext* avctx, AVFrame* frame) if(frame) { + if (frame->interlaced_frame) + return CDVDVideoCodec::VC_FATAL; + if (m_renderBuffer) m_renderBuffer->Release(); m_renderBuffer = dynamic_cast<CVideoBufferVTB*>(m_videoBufferPool->Get()); diff --git a/xbmc/utils/BitstreamConverter.cpp b/xbmc/utils/BitstreamConverter.cpp index 0f335fdccf..c5cff00a48 100644 --- a/xbmc/utils/BitstreamConverter.cpp +++ b/xbmc/utils/BitstreamConverter.cpp @@ -1224,86 +1224,3 @@ bool CBitstreamConverter::mpeg2_sequence_header(const uint8_t *data, const uint3 return changed; } -void CBitstreamConverter::parseh264_sps(const uint8_t *sps, const uint32_t sps_size, bool *interlaced, int32_t *max_ref_frames) -{ - nal_bitstream bs; - sps_info_struct sps_info; - - nal_bs_init(&bs, sps, sps_size); - - sps_info.profile_idc = nal_bs_read(&bs, 8); - nal_bs_read(&bs, 1); // constraint_set0_flag - nal_bs_read(&bs, 1); // constraint_set1_flag - nal_bs_read(&bs, 1); // constraint_set2_flag - nal_bs_read(&bs, 1); // constraint_set3_flag - nal_bs_read(&bs, 4); // reserved - sps_info.level_idc = nal_bs_read(&bs, 8); - sps_info.sps_id = nal_bs_read_ue(&bs); - - if (sps_info.profile_idc == 100 || - sps_info.profile_idc == 110 || - sps_info.profile_idc == 122 || - sps_info.profile_idc == 244 || - sps_info.profile_idc == 44 || - sps_info.profile_idc == 83 || - sps_info.profile_idc == 86) - { - sps_info.chroma_format_idc = nal_bs_read_ue(&bs); - if (sps_info.chroma_format_idc == 3) - sps_info.separate_colour_plane_flag = nal_bs_read(&bs, 1); - sps_info.bit_depth_luma_minus8 = nal_bs_read_ue(&bs); - sps_info.bit_depth_chroma_minus8 = nal_bs_read_ue(&bs); - sps_info.qpprime_y_zero_transform_bypass_flag = nal_bs_read(&bs, 1); - - sps_info.seq_scaling_matrix_present_flag = nal_bs_read (&bs, 1); - if (sps_info.seq_scaling_matrix_present_flag) - { - //! @todo unfinished - } - } - sps_info.log2_max_frame_num_minus4 = nal_bs_read_ue(&bs); - if (sps_info.log2_max_frame_num_minus4 > 12) - { // must be between 0 and 12 - return; - } - sps_info.pic_order_cnt_type = nal_bs_read_ue(&bs); - if (sps_info.pic_order_cnt_type == 0) - { - sps_info.log2_max_pic_order_cnt_lsb_minus4 = nal_bs_read_ue(&bs); - } - else if (sps_info.pic_order_cnt_type == 1) - { //! @todo unfinished - /* - delta_pic_order_always_zero_flag = gst_nal_bs_read (bs, 1); - offset_for_non_ref_pic = gst_nal_bs_read_se (bs); - offset_for_top_to_bottom_field = gst_nal_bs_read_se (bs); - - num_ref_frames_in_pic_order_cnt_cycle = gst_nal_bs_read_ue (bs); - for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ ) - offset_for_ref_frame[i] = gst_nal_bs_read_se (bs); - */ - } - - sps_info.max_num_ref_frames = nal_bs_read_ue(&bs); - sps_info.gaps_in_frame_num_value_allowed_flag = nal_bs_read(&bs, 1); - sps_info.pic_width_in_mbs_minus1 = nal_bs_read_ue(&bs); - sps_info.pic_height_in_map_units_minus1 = nal_bs_read_ue(&bs); - - sps_info.frame_mbs_only_flag = nal_bs_read(&bs, 1); - if (!sps_info.frame_mbs_only_flag) - sps_info.mb_adaptive_frame_field_flag = nal_bs_read(&bs, 1); - - sps_info.direct_8x8_inference_flag = nal_bs_read(&bs, 1); - - sps_info.frame_cropping_flag = nal_bs_read(&bs, 1); - if (sps_info.frame_cropping_flag) - { - sps_info.frame_crop_left_offset = nal_bs_read_ue(&bs); - sps_info.frame_crop_right_offset = nal_bs_read_ue(&bs); - sps_info.frame_crop_top_offset = nal_bs_read_ue(&bs); - sps_info.frame_crop_bottom_offset = nal_bs_read_ue(&bs); - } - - *interlaced = !sps_info.frame_mbs_only_flag; - *max_ref_frames = sps_info.max_num_ref_frames; -} diff --git a/xbmc/utils/BitstreamConverter.h b/xbmc/utils/BitstreamConverter.h index 0e5be3123d..caa865473b 100644 --- a/xbmc/utils/BitstreamConverter.h +++ b/xbmc/utils/BitstreamConverter.h @@ -109,7 +109,6 @@ public: void ResetStartDecode(void); bool CanStartDecode() const; - static void parseh264_sps(const uint8_t *sps, const uint32_t sps_size, bool *interlaced, int32_t *max_ref_frames); static bool mpeg2_sequence_header(const uint8_t *data, const uint32_t size, mpeg2_sequence *sequence); protected: |