Go to the documentation of this file.
   48 #include "config_components.h" 
   50 #define _XOPEN_SOURCE 600 
   55 #include <libcrystalhd/bc_dts_types.h> 
   56 #include <libcrystalhd/bc_dts_defs.h> 
   57 #include <libcrystalhd/libcrystalhd_if.h> 
   72 #define OUTPUT_PROC_TIMEOUT 50 
   74 #define TIMESTAMP_UNIT 100000 
  113     { 
"crystalhd_downscale_width",
 
  114       "Turn on downscaling to the specified width",
 
  130         return BC_MSUBTYPE_DIVX;
 
  132         return BC_MSUBTYPE_DIVX311;
 
  134         return BC_MSUBTYPE_MPEG2VIDEO;
 
  136         return BC_MSUBTYPE_VC1;
 
  138         return BC_MSUBTYPE_WMV3;
 
  140         return BC_MSUBTYPE_H264;
 
  142         return BC_MSUBTYPE_INVALID;
 
  154            output->PicInfo.timeStamp);
 
  156            output->PicInfo.picture_number);
 
  162            output->PicInfo.chroma_format);
 
  164            output->PicInfo.pulldown);
 
  168            output->PicInfo.frame_rate);
 
  170            output->PicInfo.aspect_ratio);
 
  172            output->PicInfo.colour_primaries);
 
  174            output->PicInfo.picture_meta_payload);
 
  176            output->PicInfo.sess_num);
 
  180            output->PicInfo.custom_aspect_ratio_width_height);
 
  184            output->PicInfo.other.h264.valid);
 
  197                "Unable to allocate new node in OpaqueList.\n");
 
  202         priv->
head              = newNode;
 
  207     priv->
tail = newNode;
 
  226                "CrystalHD: Attempted to query non-existent timestamps.\n");
 
  264            "CrystalHD: Couldn't match fake_timestamp.\n");
 
  281     DtsFlushInput(priv->
dev, 4);
 
  291     DtsStopDecoder(device);
 
  292     DtsCloseDecoder(device);
 
  293     DtsDeviceClose(device);
 
  312     BC_INPUT_FORMAT 
format = {
 
  315         .OptFlags    = 0x80000000 | vdecFrameRate59_94 | 0x40,
 
  320     BC_MEDIA_SUBTYPE subtype;
 
  322     uint32_t 
mode = DTS_PLAYBACK_MODE |
 
  323                     DTS_LOAD_FILE_PLAY_FW |
 
  324                     DTS_SKIP_TX_CHK_CPB |
 
  325                     DTS_PLAYBACK_DROP_RPT_MODE |
 
  326                     DTS_SINGLE_THREADED_MODE |
 
  327                     DTS_DFLT_RESOLUTION(vdecRESOLUTION_1080p23_976);
 
  333            "be removed. Please contact the developers if you are interested in " 
  334            "maintaining it.\n");
 
  346     case BC_MSUBTYPE_H264:
 
  349     case BC_MSUBTYPE_VC1:
 
  350     case BC_MSUBTYPE_WVC1:
 
  351     case BC_MSUBTYPE_WMV3:
 
  352     case BC_MSUBTYPE_WMVA:
 
  353     case BC_MSUBTYPE_MPEG2VIDEO:
 
  354     case BC_MSUBTYPE_DIVX:
 
  355     case BC_MSUBTYPE_DIVX311:
 
  363     format.mSubtype = subtype;
 
  366         format.bEnableScaling = 1;
 
  374     if (
ret != BC_STS_SUCCESS) {
 
  380     if (
ret != BC_STS_SUCCESS) {
 
  382                "CrystalHD: DtsCrystalHDVersion failed\n");
 
  388         (subtype == BC_MSUBTYPE_DIVX || subtype == BC_MSUBTYPE_DIVX311)) {
 
  390                "CrystalHD: BCM70012 doesn't support MPEG4-ASP/DivX/Xvid\n");
 
  395     if (
ret != BC_STS_SUCCESS) {
 
  400     ret = DtsOpenDecoder(priv->
dev, BC_STREAM_TYPE_ES);
 
  401     if (
ret != BC_STS_SUCCESS) {
 
  406     ret = DtsSetColorSpace(priv->
dev, OUTPUT_MODE422_YUY2);
 
  407     if (
ret != BC_STS_SUCCESS) {
 
  411     ret = DtsStartDecoder(priv->
dev);
 
  412     if (
ret != BC_STS_SUCCESS) {
 
  416     ret = DtsStartCapture(priv->
dev);
 
  417     if (
ret != BC_STS_SUCCESS) {
 
  437     BC_DTS_STATUS decoder_status = { 0, };
 
  443     uint8_t bottom_field = (
output->PicInfo.flags & VDEC_FLAG_BOTTOMFIELD) ==
 
  444                            VDEC_FLAG_BOTTOMFIELD;
 
  445     uint8_t bottom_first = !!(
output->PicInfo.flags & VDEC_FLAG_BOTTOM_FIRST);
 
  455     if (
output->PicInfo.timeStamp != 0) {
 
  470                output->PicInfo.timeStamp);
 
  473     ret = DtsGetDriverStatus(priv->
dev, &decoder_status);
 
  474     if (
ret != BC_STS_SUCCESS) {
 
  476                "CrystalHD: GetDriverStatus failed: %u\n", 
ret);
 
  501         else if (
width <= 1280)
 
  523     *((uint32_t *)
src) = *((uint32_t *)(
src + sStride));
 
  538         for (sY = 0; sY < 
height; dY++, sY++) {
 
  539             memcpy(&(dst[dY * dStride]), &(
src[sY * sStride]), bwidth);
 
  574     BC_DTS_PROC_OUT 
output = {
 
  575         .PicInfo.width  = avctx->
width,
 
  576         .PicInfo.height = avctx->
height,
 
  579     HANDLE dev       = priv->
dev;
 
  585     if (
ret == BC_STS_FMT_CHANGE) {
 
  589         switch ( 
output.PicInfo.aspect_ratio ) {
 
  590         case vdecAspectRatioSquare:
 
  593         case vdecAspectRatio12_11:
 
  596         case vdecAspectRatio10_11:
 
  599         case vdecAspectRatio16_11:
 
  602         case vdecAspectRatio40_33:
 
  605         case vdecAspectRatio24_11:
 
  608         case vdecAspectRatio20_11:
 
  611         case vdecAspectRatio32_11:
 
  614         case vdecAspectRatio80_33:
 
  617         case vdecAspectRatio18_11:
 
  620         case vdecAspectRatio15_11:
 
  623         case vdecAspectRatio64_33:
 
  626         case vdecAspectRatio160_99:
 
  629         case vdecAspectRatio4_3:
 
  632         case vdecAspectRatio16_9:
 
  635         case vdecAspectRatio221_1:
 
  640     } 
else if (
ret == BC_STS_SUCCESS) {
 
  642         if (
output.PoutFlags & BC_POUT_FLAGS_PIB_VALID) {
 
  654         DtsReleaseOutputBuffs(dev, 
NULL, FALSE);
 
  657     } 
else if (
ret == BC_STS_BUSY) {
 
  669     HANDLE dev         = priv->
dev;
 
  674     if (avpkt && avpkt->
size) {
 
  692                "input \"pts\": %"PRIu64
"\n", 
pts);
 
  693         bc_ret = DtsProcInput(dev, avpkt->
data, avpkt->
size, 
pts, 0);
 
  694         if (bc_ret == BC_STS_BUSY) {
 
  696                    "CrystalHD: ProcInput returned busy\n");
 
  699         } 
else if (bc_ret != BC_STS_SUCCESS) {
 
  701                    "CrystalHD: ProcInput failed: %u\n", 
ret);
 
  718     BC_DTS_STATUS decoder_status = { 0, };
 
  722     HANDLE dev         = priv->
dev;
 
  733     while (
pkt->
size > DtsTxFreeSize(dev)) {
 
  753         bc_ret = DtsGetDriverStatus(dev, &decoder_status);
 
  754         if (bc_ret != BC_STS_SUCCESS) {
 
  759         if (decoder_status.ReadyListCount == 0) {
 
  771     } 
else if (got_frame == 0) {
 
  778 #define DEFINE_CRYSTALHD_DECODER(x, X, bsf_name) \ 
  779     static const AVClass x##_crystalhd_class = { \ 
  780         .class_name = #x "_crystalhd", \ 
  781         .item_name = av_default_item_name, \ 
  783         .version = LIBAVUTIL_VERSION_INT, \ 
  785     const FFCodec ff_##x##_crystalhd_decoder = { \ 
  786         .p.name         = #x "_crystalhd", \ 
  787         CODEC_LONG_NAME("CrystalHD " #X " decoder"), \ 
  788         .p.type         = AVMEDIA_TYPE_VIDEO, \ 
  789         .p.id           = AV_CODEC_ID_##X, \ 
  790         .priv_data_size = sizeof(CHDContext), \ 
  791         .p.priv_class   = &x##_crystalhd_class, \ 
  794         FF_CODEC_RECEIVE_FRAME_CB(crystalhd_receive_frame), \ 
  797         .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, \ 
  798         .caps_internal  = FF_CODEC_CAP_NOT_INIT_THREADSAFE | \ 
  799                           FF_CODEC_CAP_SETS_FRAME_PROPS, \ 
  800         .p.pix_fmts     = (const enum AVPixelFormat[]){AV_PIX_FMT_YUYV422, AV_PIX_FMT_NONE}, \ 
  801         .p.wrapper_name = "crystalhd", \ 
  804 #if CONFIG_H264_CRYSTALHD_DECODER 
  808 #if CONFIG_MPEG2_CRYSTALHD_DECODER 
  812 #if CONFIG_MPEG4_CRYSTALHD_DECODER 
  816 #if CONFIG_MSMPEG4_CRYSTALHD_DECODER 
  820 #if CONFIG_VC1_CRYSTALHD_DECODER 
  824 #if CONFIG_WMV3_CRYSTALHD_DECODER 
  
static const AVOption options[]
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define FF_ENABLE_DEPRECATION_WARNINGS
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding.
#define AV_LOG_WARNING
Something somehow does not look correct.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define AV_OPT_FLAG_VIDEO_PARAM
int64_t duration
Duration of the frame, in the same units as pts.
#define AVERROR_EOF
End of file.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AV_LOG_VERBOSE
Detailed information.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
static BC_MEDIA_SUBTYPE id2subtype(CHDContext *priv, enum AVCodecID id)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
const struct AVCodec * codec
static CopyRet copy_frame(AVCodecContext *avctx, BC_DTS_PROC_OUT *output, AVFrame *frame, int *got_frame)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define OUTPUT_PROC_TIMEOUT
Timeout parameter passed to DtsProcOutput() in us.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
attribute_deprecated int pkt_size
size of the corresponding packet containing the compressed frame.
uint64_t reordered_opaque
Describe the class of an AVClass context structure.
@ AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Rational number (pair of numerator and denominator).
struct AVCodecInternal * internal
Private context used for internal data.
static CopyRet receive_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame)
static av_cold int init(AVCodecContext *avctx)
static uint64_t opaque_list_push(CHDContext *priv, uint64_t reordered_opaque)
AVCodecID
Identify the syntax and semantics of the bitstream.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_NOPTS_VALUE
Undefined timestamp value.
attribute_deprecated int64_t pkt_pos
reordered pos from the last AVPacket that has been input into the decoder
static int crystalhd_decode_packet(AVCodecContext *avctx, const AVPacket *avpkt)
static OpaqueList * opaque_list_pop(CHDContext *priv, uint64_t fake_timestamp)
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AV_LOG_INFO
Standard information.
int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane)
Compute the size of an image line with format pix_fmt and width width for the plane plane.
#define DEFINE_CRYSTALHD_DECODER(x, X, bsf_name)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVPacket * in_pkt
This packet is used to hold the packet given to decoders implementing the .decode API; it is unused b...
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
main external API structure.
#define FF_DISABLE_DEPRECATION_WARNINGS
static int crystalhd_receive_frame(AVCodecContext *avctx, AVFrame *frame)
#define TIMESTAMP_UNIT
Step between fake timestamps passed to hardware in units of 100ns.
This structure stores compressed data.
int width
picture width / height.
static void flush(AVCodecContext *avctx)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
static av_cold int uninit(AVCodecContext *avctx)
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
static void print_frame_info(CHDContext *priv, BC_DTS_PROC_OUT *output)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
uint8_t need_second_field