Intel® Integrated Performance Primitives
Community support and discussions relating to developing high-performance vision, signal, security, and storage applications.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
6593 Discussions

I,P, and B Frame VC1Encoder and VC1Decoder example(s)

Dennis_W
Beginner
198 Views
Is there any example code of how to encode and decode a set of frames as a block set up to use a non-zero number of B Frames, preferably with the VC1Encoder and VC1Decoder, but an example with any of the UMC encoder/decoder classes would be helpful?

Thanks
Dennis
0 Kudos
10 Replies
oxydius
New Contributor I
198 Views
Quoting - Dennis W
Is there any example code of how to encode and decode a set of frames as a block set up to use a non-zero number of B Frames, preferably with the VC1Encoder and VC1Decoder, but an example with any of the UMC encoder/decoder classes would be helpful?

Thanks
Dennis

Something like this would work :

UMC::VC1EncoderParams videoParams;
videoParams.profile = UMC_VC1_ENCODER::VC1_ENC_PROFILE_A;
videoParams.info.clip_info.width = 1920;
videoParams.info.clip_info.height = 1080;
videoParams.info.color_format = UMC::YUV420;
videoParams.m_uiGOPLength = 12;
videoParams.m_uiBFrmLength = n;

UMC::VC1VideoEncoder encoder;
encoder.Init(&videoParams);
Dennis_W
Beginner
198 Views
I understand the basic settings of the parameters. I was looking for an broader example of the flow of calls to the encoder and decoder GetFrame methods

oxydius
New Contributor I
198 Views
After that encoder Init call, you must do the following :

UMC::VideoData input;
input.Init(1920, 1080, 3, 8);
input.SetColorFormat(UMC::YUV420);
...
input.SetPlanePointer && input.SetPlanePitch
...

UMC::MediaData vc1;

UMC::Status status = encoder.GetFrame(&input, &vc1);

status may be UMC::UMC_ERR_NOT_ENOUGH_BUFFER if you didn't make vc1 large enough.
it may be UMC::UMC_OK if there's an output frame in the vc1 buffer.
otherwise, it may be UMC::UMC_ERR_NOT_ENOUGH_DATA if it needs more input frames before outputting your B frames.
At the end of the encode process, you'll need to call encoder.GetFrame(0, &vc1) to flush such pending frames.
Dennis_W
Beginner
198 Views
Quoting - oxydius
After that encoder Init call, you must do the following : ...


I have the encoder working and it basically works with the VC1Decoder when I couple it with a splitter.

I set the decoder params to basically the same params as the encoder including the advanced profile.

The problem with the splitter is that basically there is only a FileReader that comes as is with Intel samples.
Basically what I want to do issimulate where I use GOP and BFrames but I want to "stream' the frames to the decoder as they become available from the decoder. For example, I may have a 100 frame clip but I want to process it in groups of 10 frames with 5 BFrames but I want to "stream" individual frames to the decoder as they are available from the encoder, and as frames are available from the decoder, render them.

The issue that I ran into is that a FileWriter with the encoder and a FileReader with the decoder splitter cannot write and read in tandem so I have to encode in blocks of 10 and then decode and render in blocks of 10.

For the long term I can develop a StreamWriter and StreamReader, but the for the short term I would like to attempt to use the existing UMC classes. Is it necessary to use a VC1Splitter with the VC1Decoder in advanced profile? I get an exception when I tried. Can I decode each individual output from the encoder when using GOP and BFrames and how do I do it?

Thanks

Dennis

oxydius
New Contributor I
198 Views
Each UMC::MediaData element is a standalone frame which can be passed to the decoder as is. Basically, if you refer to the VC-1 standard, they are raw BDU's, or Bitstream Data Units with their own header.

You could do :
encoder.GetFrame(&in, &out);
decoder.GetFrame(&out, &in);

without ever using the splitter or file I/O classes.
Dennis_W
Beginner
198 Views
Quoting - oxydius
Each UMC::MediaData element is a standalone frame which can be passed to the decoder as is. Basically, if you refer to the VC-1 standard, they are raw BDU's, or Bitstream Data Units with their own header.

You could do :
encoder.GetFrame(&in, &out);
decoder.GetFrame(&out, &in);

without ever using the splitter or file I/O classes.

Will that work in the advanced profile, I thought that in that case the decoder used the splitter to possibly reconstruct frames from more that one MediaData instance? But I will try it.
oxydius
New Contributor I
198 Views
Quoting - Dennis W

Will that work in the advanced profile, I thought that in that case the decoder used the splitter to possibly reconstruct frames from more that one MediaData instance? But I will try it.
Advanced profile is the VC-1 standard; other profiles are actually WMV and do not lend themselves to being used outside a proprietary ASF container. In the advanced/VC-1 mode, each MediaData has its own 001 delimiter and frame header, telling you whether it's a I, P or B frame.

The only reconstruction done by the decoder is holding on to B frames until the subsequent MediaData is fed to transform the B frame into a raw YUV image.
Dennis_W
Beginner
198 Views
Quoting - oxydius
The only reconstruction done by the decoder is holding on to B frames until the subsequent MediaData is fed to transform the B frame into a raw YUV image.

When I tried to pass the MediaData output from theVC1Encoder::GetFrame to the VC1Decoder::GetFrame only UMC_ERR_NOT_ENOUGH_DATA was returned, never UMC::UMC_OK. I initialized the encoder and decoder with the same parameters when I was trying the splitter which worked.
Dennis_W
Beginner
198 Views
Quoting - Dennis W

When I tried to pass the MediaData output from theVC1Encoder::GetFrame to the VC1Decoder::GetFrame only UMC_ERR_NOT_ENOUGH_DATA was returned, never UMC::UMC_OK. I initialized the encoder and decoder with the same parameters when I was trying the splitter which worked.

I solved that with some code changes, and I get through the clip, however, I am getting some flickering from frame to frame which varies on the value of GOPLength and BFrmLength. This flickers between complete frames, blocky frames and purple background. It appears I have something out of sync in my code.
Dennis_W
Beginner
198 Views
Quoting - Dennis W

I solved that with some code changes, and I get through the clip, however, I am getting some flickering from frame to frame which varies on the value of GOPLength and BFrmLength. This flickers between complete frames, blocky frames and purple background. It appears I have something out of sync in my code.

It appears that the flickering problem goes away when the BFrmLength is one less than GOPLength, say GOPLength=4 and BFrmLength=3. I need to read the VC-1 specification to become more familiar with the options.
Reply