8 #include "libavutil/imgutils.h" 11 #define LOC QString("CrystalHD: ") 12 #define ERR QString("CrystalHD Err: ") 13 #define WARN QString("CrystalHD Warn: ") 18 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Starting Fetcher thread."));
21 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Stopping Fetcher thread."));
33 #define INIT_ST BC_STATUS st; bool ok = true 35 ok &= (st == BC_STS_SUCCESS); \ 37 LOG(VB_GENERAL, LOG_ERR, LOC + QString("Error at %1:%2 (#%3, %4)") \ 38 .arg(__FILE__).arg( __LINE__).arg(st) \ 39 .arg(bcmerr_to_string(st))) 43 opts.decoders->append(
"crystalhd");
44 (*
opts.equiv_decoders)[
"crystalhd"].append(
"nuppel");
45 (*
opts.equiv_decoders)[
"crystalhd"].append(
"ffmpeg");
46 (*
opts.equiv_decoders)[
"crystalhd"].append(
"dummy");
50 : m_device(nullptr), m_device_type(
BC_70012),
51 m_pix_fmt(OUTPUT_MODE_INVALID), m_decoded_frames_lock(QMutex::Recursive),
52 m_fetcher_thread(nullptr), m_fetcher_pause(
false), m_fetcher_paused(
false),
53 m_fetcher_stop(
false), m_frame(nullptr), m_filter(nullptr)
65 LOG(VB_PLAYBACK, LOG_WARNING,
LOC +
66 "Waited 100ms for Fetcher to stop");
69 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to stop Fetcher.");
71 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
"Stopped frame Fetcher.");
85 st = DtsFlushRxCapture(
m_device,
false);
97 AVCodecContext *avctx)
100 !avctx || getenv(
"NO_CRYSTALHD"))
103 static bool debugged =
false;
105 uint32_t well_documented = DTS_PLAYBACK_MODE | DTS_LOAD_FILE_PLAY_FW |
106 DTS_SKIP_TX_CHK_CPB |
107 DTS_PLAYBACK_DROP_RPT_MODE |
108 DTS_DFLT_RESOLUTION(vdecRESOLUTION_CUSTOM);
110 st = DtsDeviceOpen(&
m_device, well_documented);
114 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to open CrystalHD device");
118 _BC_INFO_CRYSTAL_ info;
119 st = DtsCrystalHDVersion(
m_device, &info);
123 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to get device info.");
131 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Device: %1")
133 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Library : %1.%2.%3")
134 .arg(info.dilVersion.dilMajor)
135 .arg(info.dilVersion.dilMinor)
136 .arg(info.dilVersion.version));
137 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Driver : %1.%2.%3")
138 .arg(info.drvVersion.drvMajor)
139 .arg(info.drvVersion.drvMinor)
140 .arg(info.drvVersion.version));
141 LOG(VB_GENERAL, LOG_INFO,
LOC + QString(
"Firmware: %1.%2.%3")
142 .arg(info.fwVersion.fwMajor)
143 .arg(info.fwVersion.fwMinor)
144 .arg(info.fwVersion.version));
149 LOG(VB_GENERAL, LOG_ERR,
LOC +
150 "BCM70012 device is currently unsupported.");
156 st = DtsGetCapabilities(
m_device, &hw_caps);
160 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to get device capabilities");
165 OUTPUT_MODE422_YUY2 : OUTPUT_MODE420;
167 for (
int i = 0; i < hw_caps.ColorCaps.Count; i++)
169 if (m_desired_fmt == hw_caps.ColorCaps.OutFmt[i])
173 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
174 QString(
"Supported output format: %1")
180 LOG(VB_PLAYBACK, LOG_ERR,
LOC +
181 "Failed to find correct output format.");
184 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Using: %1")
187 codecs = hw_caps.DecCaps;
190 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"H.264 support: %1")
191 .arg((
bool)(codecs & BC_DEC_FLAGS_H264)));
192 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"MPEG2 support: %1")
193 .arg((
bool)(codecs & BC_DEC_FLAGS_MPEG2)));
194 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"VC1 support: %1")
195 .arg((
bool)(codecs & BC_DEC_FLAGS_VC1)));
196 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"MPEG4 support: %1")
197 .arg((
bool)(codecs & BC_DEC_FLAGS_M4P2)));
201 BC_MEDIA_SUBTYPE sub_type = BC_MSUBTYPE_INVALID;
203 switch (avctx->codec_id)
205 case AV_CODEC_ID_MPEG4:
206 if (codecs & BC_DEC_FLAGS_M4P2)
207 sub_type = BC_MSUBTYPE_DIVX;
209 case AV_CODEC_ID_MPEG1VIDEO:
210 if (codecs & BC_DEC_FLAGS_MPEG2)
211 sub_type = BC_MSUBTYPE_MPEG1VIDEO;
213 case AV_CODEC_ID_MPEG2VIDEO:
214 if (codecs & BC_DEC_FLAGS_MPEG2)
215 sub_type = BC_MSUBTYPE_MPEG2VIDEO;
217 case AV_CODEC_ID_VC1:
218 if (codecs & BC_DEC_FLAGS_VC1)
220 if (avctx->codec_tag == MKTAG(
'W',
'V',
'C',
'1'))
221 sub_type = BC_MSUBTYPE_WVC1;
223 sub_type = BC_MSUBTYPE_VC1;
226 case AV_CODEC_ID_WMV3:
227 if (codecs & BC_DEC_FLAGS_VC1)
228 sub_type = BC_MSUBTYPE_WMV3;
230 case AV_CODEC_ID_H264:
231 if (codecs & BC_DEC_FLAGS_H264)
233 if (avctx->extradata[0] == 0x01)
237 LOG(VB_PLAYBACK, LOG_ERR,
LOC +
238 "Failed to create stream filter");
241 sub_type = BC_MSUBTYPE_AVC1;
244 sub_type = BC_MSUBTYPE_H264;
251 if (sub_type == BC_MSUBTYPE_INVALID)
253 LOG(VB_PLAYBACK, LOG_ERR,
LOC + QString(
"Codec %1 not supported")
254 .arg(ff_codec_id_string(avctx->codec_id)));
259 if (avctx->codec_id == AV_CODEC_ID_H264)
261 LOG(VB_PLAYBACK, LOG_INFO,
LOC +
262 QString(
"H.264 Profile: %1 RefFrames: %2 Codec tag: %3")
263 .arg(avctx->profile).arg(avctx->refs)
265 if (avctx->extradata[0] == 1)
267 nalsize = (avctx->extradata[4] & 0x03) + 1;
268 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"avcC nal size: %1")
274 memset(&fmt, 0,
sizeof(BC_INPUT_FORMAT));
275 fmt.OptFlags = 0x80000000 | vdecFrameRateUnknown;
276 fmt.width = avctx->coded_width;
277 fmt.height = avctx->coded_height;
280 fmt.MetaDataEnable = 0;
281 fmt.metaDataSz = avctx->extradata_size;
282 fmt.pMetaData = avctx->extradata;
283 fmt.startCodeSz = nalsize;
284 fmt.mSubtype = sub_type;
286 st = DtsSetInputFormat(
m_device, &fmt);
290 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to set decoder input format");
294 st = DtsOpenDecoder(
m_device, BC_STREAM_TYPE_ES);
298 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to open CrystalHD decoder");
305 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to set decoder output format");
312 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to start decoder");
319 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to start capture");
325 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Created decoder %1 %2x%3")
326 .arg(ff_codec_id_string(avctx->codec_id))
327 .arg(avctx->coded_width).arg(avctx->coded_height));
333 int nalsize = (avctx->extradata[4] & 0x3) + 1;
334 if (!nalsize || nalsize == 3 || nalsize > 4)
336 LOG(VB_PLAYBACK, LOG_ERR,
LOC + QString(
"Invalid nal size (%1)")
341 static const uint8_t testnal[] = { 0,0,0,2,0,0 };
342 AVBitStreamFilterContext *bsfc =
343 av_bitstream_filter_init(
"h264_mp4toannexb");
349 const uint8_t *test = testnal;
352 uint8_t *outbuf =
nullptr;
353 int res = av_bitstream_filter_filter(
m_filter, avctx,
nullptr, &outbuf,
354 &outbuf_size, test, testsize, 0);
364 av_freep(&frame->
buf);
366 av_freep(&frame->
priv[0]);
376 av_freep(&buffer->buf);
390 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to pause fetcher thread");
436 buffer1->buf = (
unsigned char*)
av_malloc(pkt->size);
437 buffer1->size = pkt->size;
438 buffer1->pts = pkt->pts;
439 memcpy(buffer1->buf, pkt->data, pkt->size);
442 LOG(VB_PLAYBACK, LOG_DEBUG,
LOC +
455 uint8_t* buf = buffer2->buf;
456 int size = buffer2->size;
457 bool free_buf =
false;
459 uint8_t *outbuf =
nullptr;
463 int res = av_bitstream_filter_filter(
m_filter, avctx,
nullptr, &outbuf,
464 &outbuf_size, buf, size, 0);
467 static int count = 0;
469 LOG(VB_GENERAL, LOG_ERR,
LOC +
470 QString(
"Failed to convert packet (%1)").arg(res));
476 if (outbuf && (outbuf_size > 0))
478 free_buf = outbuf != buf;
485 uint64_t chd_timestamp = 0;
486 if (buffer2->pts != AV_NOPTS_VALUE)
487 chd_timestamp = (uint64_t)(av_q2d(stream->time_base) *
488 buffer2->pts * 10000000);
489 LOG(VB_TIMESTAMP, LOG_DEBUG,
LOC +
490 QString(
"decoder input timecode %1 ms (pts %2)")
491 .arg(chd_timestamp / 10000).arg(buffer2->pts));
495 st = DtsProcInput(
m_device, buf, size, chd_timestamp,
false);
502 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to send packet to decoder.");
504 result = buffer2->size;
513 int *got_picture_ptr,
517 if (!stream || !
m_device || !picture)
525 if (pkt && pkt->size)
538 if (avctx->get_buffer2(avctx, picture, 0) < 0)
540 LOG(VB_GENERAL, LOG_ERR,
LOC +
541 QString(
"%1 decoded frames available but no video buffers.")
550 *got_picture_ptr = 1;
551 picture->reordered_opaque = (int64_t)(frame->
timecode /
552 av_q2d(stream->time_base) / 10000000);
553 LOG(VB_TIMESTAMP, LOG_DEBUG,
LOC +
554 QString(
"decoder output timecode %1 ms (pts %2)")
555 .arg(frame->
timecode / 10000).arg(picture->reordered_opaque));
559 memcpy(picture->atsc_cc_buf, frame->
priv[0], frame->
qstride);
560 picture->atsc_cc_len = frame->
qstride;
581 BC_DTS_STATUS status;
582 st = DtsGetDriverStatus(
m_device, &status);
585 if (!status.ReadyListCount)
589 memset(&out, 0,
sizeof(BC_DTS_PROC_OUT));
590 st = DtsProcOutputNoCopy(
m_device, valid ? 2000 : 20, &out);
592 if (BC_STS_FMT_CHANGE == st)
594 LOG(VB_GENERAL, LOG_INFO,
LOC +
"Decoder reported format change.");
603 LOG(VB_GENERAL, LOG_ERR,
LOC +
"Failed to fetch decoded frame");
607 if (ok && valid && (out.PoutFlags & BC_POUT_FLAGS_PIB_VALID))
609 st = DtsReleaseOutputBuffs(
m_device,
nullptr,
false);
631 bool second_field =
false;
636 LOG(VB_PLAYBACK, LOG_WARNING,
LOC +
"Missing second field");
645 int in_width = out->PicInfo.width;
646 int in_height = out->PicInfo.height;
647 int out_width = (in_width + 15) & (~0xf);
648 int out_height = in_height;
649 uint8_t* src = out->Ybuff;
654 unsigned char* buf = (
unsigned char*)
av_malloc(size);
665 int size = out->UserDataSz > 1024 ? 1024 : out->UserDataSz;
671 AVPixelFormat out_fmt = AV_PIX_FMT_YUV420P;
675 av_image_fill_arrays(img_in.data, img_in.linesize,
678 if (!(out->PicInfo.flags & VDEC_FLAG_INTERLACED_SRC))
689 img_out.linesize[0] *= 2;
690 img_out.linesize[1] *= 2;
691 img_out.linesize[2] *= 2;
693 int field = out->PoutFlags & BC_POUT_FLAGS_FLD_BOT;
696 img_out.data[0] += out_width;
697 img_out.data[1] += out_width >> 1;
698 img_out.data[2] += out_width >> 1;
700 m_copyCtx.
Copy(&img_out, out_fmt, &img_in, in_fmt, in_width, in_height / 2);
710 LOG(VB_PLAYBACK, LOG_DEBUG,
LOC + QString(
"Decoded frame queue size %1")
718 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut Ybuf : %1")
719 .arg((uintptr_t)out->Ybuff));
720 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut Ybuffsz : %1")
722 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut Ybuffdnsz : %1")
723 .arg(out->YBuffDoneSz));
724 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut Ubuf : %1")
725 .arg((uintptr_t)out->UVbuff));
726 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut Ubuffsz : %1")
727 .arg(out->UVbuffSz));
728 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut Ubuffdnsz : %1")
729 .arg(out->UVBuffDoneSz));
730 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut StrideSz : %1")
731 .arg(out->StrideSz));
732 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut Flags : %1")
734 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut DiscCnt : %1")
736 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut usrdatasz : %1")
737 .arg(out->UserDataSz));
738 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut DropFrames: %1")
739 .arg(out->DropFrames));
740 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut b422Mode : %1")
742 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut bPIBenc : %1")
744 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut revertscra: %1")
745 .arg(out->bRevertScramble));
751 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut PicInfo timestamp: %1")
752 .arg(out->PicInfo.timeStamp));
753 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut PicInfo picnumber: %1")
754 .arg(out->PicInfo.picture_number));
755 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut PicInfo width : %1")
756 .arg(out->PicInfo.width));
757 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut PicInfo height : %1")
758 .arg(out->PicInfo.height));
759 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut PicInfo chromafmt: %1")
760 .arg(out->PicInfo.chroma_format));
761 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut PicInfo pulldown : %1")
763 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut PicInfo flags : %1")
765 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut PicInfo framerate: %1")
766 .arg(out->PicInfo.frame_rate));
767 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut PicInfo aspectrat: %1")
768 .arg(out->PicInfo.colour_primaries));
769 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut PicInfo metapaylo: %1")
770 .arg(out->PicInfo.picture_meta_payload));
771 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut PicInfo sess_num : %1")
772 .arg(out->PicInfo.sess_num));
773 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut PicInfo ycom : %1")
774 .arg(out->PicInfo.ycom));
775 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut PicInfo customasp: %1")
776 .arg(out->PicInfo.custom_aspect_ratio_width_height));
777 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ProcOut PicInfo ndrop : %1")
778 .arg(out->PicInfo.n_drop));
783 BC_DTS_STATUS status;
784 status.cpbEmptySize = 0x00000000;
786 st = DtsGetDriverStatus(
m_device, &status);
791 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"ReadyListCount : %1")
792 .arg(status.ReadyListCount));
793 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"FreeListCount : %1")
794 .arg(status.FreeListCount));
795 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"PowerStateChange: %1")
796 .arg(status.PowerStateChange));
797 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"FrameDropped : %1")
798 .arg(status.FramesDropped));
799 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"FramesCaptured : %1")
800 .arg(status.FramesCaptured));
801 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"FramesRepeated : %1")
802 .arg(status.FramesRepeated));
803 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"InputCount : %1")
804 .arg(status.InputCount));
805 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"InputTotalSize : %1")
806 .arg(status.InputTotalSize));
807 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"InputBusyCount : %1")
808 .arg(status.InputBusyCount));
809 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"PIBMissCount : %1")
810 .arg(status.PIBMissCount));
811 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"cpbEmptySize : %1")
812 .arg(status.cpbEmptySize));
813 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"NextTimeStamp : %1")
814 .arg(status.NextTimeStamp));
815 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"PicNumFlags : %1")
816 .arg(status.picNumFlags));
821 BC_DTS_STATUS status;
823 status.cpbEmptySize = 0xC0000000;
825 status.cpbEmptySize = 0x40000000;
827 st = DtsGetDriverStatus(
m_device, &status);
832 return status.cpbEmptySize;
849 case BC_STS_INV_ARG:
return "Invalid argument";
850 case BC_STS_BUSY:
return "Busy";
851 case BC_STS_NOT_IMPL:
return "Not implemented";
852 case BC_STS_PGM_QUIT:
return "PGM quit";
853 case BC_STS_NO_ACCESS:
return "No access";
854 case BC_STS_INSUFF_RES:
return "Insufficient resources";
855 case BC_STS_IO_ERROR:
return "I/O error";
856 case BC_STS_NO_DATA:
return "No data";
857 case BC_STS_VER_MISMATCH:
return "Version mismatch";
858 case BC_STS_TIMEOUT:
return "Timeout";
859 case BC_STS_FW_CMD_ERR:
return "Command error";
860 case BC_STS_DEC_NOT_OPEN:
return "Decoder not open";
861 case BC_STS_ERR_USAGE:
return "Usage error";
862 case BC_STS_IO_USER_ABORT:
return "I/O user abort";
863 case BC_STS_IO_XFR_ERROR:
return "I/O transfer error";
864 case BC_STS_DEC_NOT_STARTED:
return "Decoder not started";
865 case BC_STS_FWHEX_NOT_FOUND:
return "FirmwareHex not found";
866 case BC_STS_FMT_CHANGE:
return "Format change";
867 case BC_STS_HIF_ACCESS:
return "HIF access";
868 case BC_STS_CMD_CANCELLED:
return "Command cancelled";
869 case BC_STS_FW_AUTH_FAILED:
return "Firmware authorisation failed";
870 case BC_STS_BOOTLOADER_FAILED:
return "Bootloader failed";
871 case BC_STS_CERT_VERIFY_ERROR:
return "Certificate verify error";
872 case BC_STS_DEC_EXIST_OPEN:
return "Decoder exist open (?)";
873 case BC_STS_PENDING:
return "Pending";
874 case BC_STS_ERROR:
return "Unknown";
877 return "Unknown error";
884 case OUTPUT_MODE420:
return "YUV420P";
885 case OUTPUT_MODE422_YUY2:
return "YUYV422";
886 case OUTPUT_MODE422_UYVY:
return "UYVY422";
896 case vdecNoPulldownInfo:
return "Unknown";
897 case vdecTop:
return "Top";
898 case vdecBottom:
return "Bottom";
899 case vdecTopBottom:
return "TopBottom";
900 case vdecBottomTop:
return "BottomTop";
901 case vdecTopBottomTop:
return "TopBottomTop";
902 case vdecBottomTopBottom:
return "BottomTopBottom";
903 case vdecFrame_X2:
return "X2";
904 case vdecFrame_X3:
return "X3";
905 case vdecFrame_X1:
return "X1";
906 case vdecFrame_X4:
return "X4";
914 if (flags & VDEC_FLAG_EOS) res +=
"EndOfStream ";
915 if (flags & VDEC_FLAG_FIELDPAIR) res +=
"FieldPair ";
916 if (flags & VDEC_FLAG_TOPFIELD) res +=
"TopField ";
917 if (flags & VDEC_FLAG_BOTTOMFIELD) res +=
"BottomField ";
918 if (flags & VDEC_FLAG_INTERLACED_SRC) res +=
"InterlacedSource ";
919 if (flags & VDEC_FLAG_UNKNOWN_SRC) res +=
"UnknownSource ";
920 if (flags & VDEC_FLAG_BOTTOM_FIRST) res +=
"BottomFirst ";
921 if (flags & VDEC_FLAG_LAST_PICTURE) res +=
"LastPicture ";
922 if (flags & VDEC_FLAG_PICTURE_META_DATA_PRESENT) res +=
"MetaDataPresent ";
929 if (flags & BC_POUT_FLAGS_YV12) res +=
"YV12 ";
930 if (flags & BC_POUT_FLAGS_STRIDE) res +=
"STRIDE ";
931 if (flags & BC_POUT_FLAGS_SIZE) res +=
"SIZE ";
932 if (flags & BC_POUT_FLAGS_INTERLACED) res +=
"INTERLACED ";
933 if (flags & BC_POUT_FLAGS_INTERLEAVED) res +=
"INTERLEAVED ";
934 if (flags & BC_POUT_FLAGS_STRIDE_UV) res +=
"UVSTRIDE ";
935 if (flags & BC_POUT_FLAGS_MODE) res +=
"APPMODE ";
936 if (flags & BC_POUT_FLAGS_FMT_CHANGE) res +=
"FORMATCHANGED ";
937 if (flags & BC_POUT_FLAGS_PIB_VALID) res +=
"PIBVALID ";
938 if (flags & BC_POUT_FLAGS_ENCRYPTED) res +=
"ENCRYPTED ";
939 if (flags & BC_POUT_FLAGS_FLD_BOT) res +=
"FIELDBOTTOM ";
947 case OUTPUT_MODE420:
return AV_PIX_FMT_YUV420P;
948 case OUTPUT_MODE422_YUY2:
return AV_PIX_FMT_YUYV422;
949 case OUTPUT_MODE422_UYVY:
return AV_PIX_FMT_UYVY422;
952 return AV_PIX_FMT_YUV420P;
struct PacketBuffer_ PacketBuffer
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
void start(QThread::Priority=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
bool StartFetcherThread(void)
QMutex m_decoded_frames_lock
void run(void) override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
void CheckProcOutput(BC_DTS_PROC_OUT *out)
int Copy(VideoFrame *dst, const VideoFrame *src)
int ProcessPacket(AVStream *stream, AVPacket *pkt)
friend class FetcherThread
QString poutflags_to_string(int flags)
bool wait(unsigned long time=ULONG_MAX)
Wait for the MThread to exit, with a maximum timeout.
bool HasBufferedFrames(void) override
void free_buffer(PacketBuffer *buffer)
QList< PacketBuffer * > m_packet_buffers
QList< VideoFrame * > m_decoded_frames
static char * fourcc_str(int i)
void FillFrame(BC_DTS_PROC_OUT *out)
unsigned char * priv[4]
random empty storage
long long copy(QFile &dst, QFile &src, uint block_size)
Copies src file to dst file.
int GetTxFreeSize(bool hwsel)
PrivateDecoderCrystalHD * m_dec
BC_DEVICE_TYPE m_device_type
bool CreateFilter(AVCodecContext *avctx)
static void init(VideoFrame *vf, VideoFrameType _codec, unsigned char *_buf, int _width, int _height, int _size, const int *p=nullptr, const int *o=nullptr, float _aspect=-1.0f, double _rate=-1.0f, int _aligned=64)
QString decoderflags_to_string(int flags)
int AVPictureFill(AVFrame *pic, const VideoFrame *frame, AVPixelFormat fmt)
AVPictureFill Initialise AVFrame pic with content from VideoFrame frame.
MythCodecMap * gCodecMap
This global variable contains the MythCodecMap instance for the app.
AVBitStreamFilterContext * m_filter
void AddFrameToQueue(void)
AVPixelFormat bcmpixfmt_to_pixfmt(BC_OUTPUT_FORMAT fmt)
QString device_to_string(BC_DEVICE_TYPE device)
bool isRunning(void) const
void CheckPicInfo(BC_DTS_PROC_OUT *out)
FetcherThread * m_fetcher_thread
int GetFrame(AVStream *stream, AVFrame *picture, int *got_picture_ptr, AVPacket *pkt) override
QString bcmpixfmt_to_string(BC_OUTPUT_FORMAT fmt)
PrivateDecoderCrystalHD()
int top_field_first
1 if top field is first.
AVCodecContext * getCodecContext(const AVStream *, const AVCodec *pCodec=nullptr, bool nullCodec=false)
void * av_malloc(unsigned int size)
void free_frame(VideoFrame *frame)
virtual ~PrivateDecoderCrystalHD()
#define LOG(_MASK_, _LEVEL_, _STRING_)
static void GetDecoders(render_opts &opts)
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
struct VideoFrame_ VideoFrame
bool Reset(void) override
static uint buffersize(VideoFrameType type, int width, int height, int _aligned=64)
int interlaced_frame
1 if interlaced.
bool Init(const QString &decoder, PlayerFlags flags, AVCodecContext *avctx) override
QString bcmerr_to_string(BC_STATUS err)
QString pulldown_to_string(int pulldown)
BC_OUTPUT_FORMAT m_pix_fmt