Media (Intel® Video Processing Library, Intel Media SDK)
Access community support with transcoding, decoding, and encoding in applications using media tools like Intel® oneAPI Video Processing Library and Intel® Media SDK
Announcements
The Intel Media SDK project is no longer active. For continued support and access to new features, Intel Media SDK users are encouraged to read the transition guide on upgrading from Intel® Media SDK to Intel® Video Processing Library (VPL), and to move to VPL as soon as possible.
For more information, see the VPL website.
3058 Discussions

MFXVideoDECODE_DecodeHeader Cannot Read TIFF File Header

cabrerae
Beginner
1,106 Views

As the subject says, I have cpp code that tries to read the header off of a TIFF file using MFXVideoDECODE_DecodeHeader.  It does not error out but the FrameInfo data (FourCC, ChromaFormat, Width, and Height) and all 0.

For the input mfxVideoParam, I set mfx.CodecId=MFX_CODEC_HEVC and IOPattern=MFX_IOPATTERN_OUT_SYSTEM_MEMORY.  What am I missing here?

 

0 Kudos
7 Replies
AayushiR_Intel
Moderator
1,071 Views

Hi,


Thanks for posting in Intel Communities.


Could you please share the below details so that we can assist you better.

  1. The MediaSDk version you are using.
  2. The OS in which you are trying out.
  3. The complete steps to reproduce it with screenshot of the same


Thanks,

Aayushi



0 Kudos
cabrerae
Beginner
1,047 Views

1.  oneVPL version 2022.2.0

2.  Running on RHEL version 8.6

3.

////////////////////////////////////////////////////////////////////////////////

static mfxStatus readEncodedStream(
    FILE *in_file_p,
    mfxBitstream &in_out_bs,
    std::string &out_message
)
{
    mfxStatus ret_status = MFX_ERR_NONE; // Returned status.
    const std::string method = "readEncodedStream";
    mfxU8 *p0 = in_out_bs.Data;
    mfxU8 *p1 = in_out_bs.Data + in_out_bs.DataOffset;

    if (in_out_bs.DataOffset > in_out_bs.MaxLength - 1)
    {
        ret_status = MFX_ERR_NOT_ENOUGH_BUFFER;
    }

    else if (in_out_bs.DataLength + in_out_bs.DataOffset > in_out_bs.MaxLength)
    {
        ret_status = MFX_ERR_NOT_ENOUGH_BUFFER;
    }

    else
    {
        for (mfxU32 i = 0; i < in_out_bs.DataLength; i++)
         {
            *(p0++) = *(p1++);
        }

        in_out_bs.DataOffset = 0;
        in_out_bs.DataLength += (mfxU32) fread(
        (in_out_bs.Data + in_out_bs.DataLength), 1,
        (in_out_bs.MaxLength - in_out_bs.DataLength), in_file_p);

        if (in_out_bs.DataLength == 0)
        {
            ret_status = MFX_ERR_MORE_DATA;
        }
    }

    return ret_status;
}

////////////////////////////////////////////////////////////////////////////////

UTILS_Status_Type UTILS_ImageProcessor::process(
    std::list<std::string> &in_image_files,
    std::string &out_video_file,
    std::string &out_message
)
{
    UTILS_Status_Type ret_status = SUCCESS; // Returned status.
    const std::string method = "UTILS_ImageProcessor::process";
    mfxStatus mfx_status = MFX_ERR_NONE;
    std::list<std::string>::iterator it; // in_image_files iterator.
    FILE *file_p = (FILE *) NULL;

    mfxBitstream bs_decoder = {};
    bs_decoder.MaxLength = p_decoder_params.MaxLength; // Set to 2048000
    bs_decoder.CodecId = p_decoder_params.CodecId; // Set to MFX_CODEC_HEVC

    mfxBitstream bs_encoder = {};
    bs_encoder.MaxLength = p_decoder_params.MaxLength; // Set to 2048000

    // Header information from the decoder for use by the encoder.
    mfxVideoParam frame_info = {};
    frame_info.mfx.CodecId = p_decoder_params.CodecId; // Set to MFX_CODEC_HEVC
    frame_info.IOPattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;

    bool is_pre_parse = true; // Perform pre-parsing initializations.

    if ((bs_decoder.Data = (mfxU8 *) calloc(bs_decoder.MaxLength, sizeof(mfxU8)))
        == (mfxU8 *) NULL)
    {
        ret_status = FAILURE;
    }

    else if ((bs_encoder.Data = (mfxU8 *) calloc(bs_encoder.MaxLength,
        sizeof(mfxU8))) == (mfxU8 *) NULL)
    {
        ret_status = FAILURE;
    }

    else for (it = in_image_files.begin();
        it != in_image_files.end() && ret_status == SUCCESS;
        it++)
    {
        if (p_is_debug)
            (void) fprintf(stdout, "%s: Decoding %s\n", method.c_str(),
                (*it).c_str());

        if ((file_p = fopen((*it).c_str(), "r")) == (FILE *) NULL)
        {
            ret_status = FAILURE;
        }

        else if (is_pre_parse == true)
        {
            // It is a fatal error if the pre-parsing of the stream failed.
            if ((mfx_status = readEncodedStream(file_p, bs_decoder, out_message))
                != MFX_ERR_NONE)
            {
                ret_status = FAILURE;
            }

            else if ((mfx_status = MFXVideoDECODE_DecodeHeader(p_session,
                &bs_decoder, &frame_info)) != MFX_ERR_NONE)
            {
                ret_status = FAILURE;
            }

            else
            {
                if (p_is_debug)
                    (void) fprintf(stdout, "%s: Frame Info: FourCC(%d) "
                        "ChromaFormat(%d) Width(%d) Height(%d)\n",
                        method.c_str(),
                        frame_info.mfx.FrameInfo.FourCC,
                        frame_info.mfx.FrameInfo.ChromaFormat,
                        frame_info.mfx.FrameInfo.Width,
                        frame_info.mfx.FrameInfo.Height);

                        // More code follows.
            }

            is_pre_parse = false;
        }

        if (file_p != (FILE *) NULL)
        {
            fclose(file_p);
        }
    }

    return ret_status;
}
///////////////////////////////////////////////////////////////////////////////

 

0 Kudos
cabrerae
Beginner
1,047 Views

Debug output:

Decoding 135339-173_e0238_h265.tif

UTILS_ImageProcessor::process: Frame Info: FourCC(0) ChromaFormat(0) Width(0) Height(0)

 

0 Kudos
cabrerae
Beginner
1,047 Views

Info on the tiff file:

$ ffprobe -hide_banner -show_format -show_frames 135339-173_e0238_h265.tif
[tiff_pipe @ 0x558c0818f740] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, tiff_pipe, from '135339-173_e0238_h265.tif':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: tiff, gray16le, 6576x4384 [SAR 1:1 DAR 3:2], 25 tbr, 25 tbn, 25 tbc
[FRAME]
media_type=video
stream_index=0
key_frame=1
pkt_pts=0
pkt_pts_time=0.000000
pkt_dts=0
pkt_dts_time=0.000000
best_effort_timestamp=0
best_effort_timestamp_time=0.000000
pkt_duration=1
pkt_duration_time=0.040000
pkt_pos=0
pkt_size=58083822
width=6576
height=4384
pix_fmt=gray16le
sample_aspect_ratio=1:1
pict_type=?
coded_picture_number=0
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
color_range=unknown
color_space=unknown
color_primaries=unknown
color_transfer=unknown
chroma_location=unspecified
TAG:software=Lavc58.54.100
[/FRAME]
[FORMAT]
filename=135339-173_e0238_h265.tif
nb_streams=1
nb_programs=0
format_name=tiff_pipe
format_long_name=piped tiff sequence
start_time=N/A
duration=N/A
size=58083822
bit_rate=N/A
probe_score=51
[/FORMAT]

0 Kudos
AayushiR_Intel
Moderator
914 Views

Hi,


We are not able to reproduce the issue from our side as we are getting some errors while compiling and running. Could you please provide the executables which you created so that we can try to reproduce the issue.


Thanks,

Aayushi


0 Kudos
cabrerae
Beginner
897 Views

I gave up on trying to decode TIFF file.  Instead, I used ffmpeg to convert the TIFF file to a raw video so I don't have to deal with the decoder.  But I am now running into another issue with the encoder where the call to MFXVideoENCODE_Init fails with error -15 (MFX_ERR_INVALID_VIDEO_PARAM) whenever the mfxVideoParam that is passed to it where mfx.FrameInfo.CropH is set to any value more than 4320.  Doesn't matter what CropW is set to.

BTW the source rawvideo file dimension is 7920x6004.

I will start another topic with this problem.  In the meantime I guess we can close this unresolved topic.

 

 

0 Kudos
AayushiR_Intel
Moderator
784 Views

Hi,

 

Sorry for the inconvenience caused.

 

As you already know, the TIFF format is not supported for decoder.

Regarding the issue you are facing with encoder we will be handling in the below thread which you raised recently.

 

https://community.intel.com/t5/Media-Intel-oneAPI-Video/MFXVideoENCODE-Init-Cannot-Handle-Height-Greater-than-4320/m-p/1423826#M14359

 

If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.

 

Thanks,

Aayushi

 

0 Kudos
Reply