I am trying to extract Closed Caption data from SEI message in AVC stream. Hence i used the sample code (simple_decode project), in which i added following snippet after mfxDEC.DecodeFrameAsync to check on SEI data.
dec_payload.NumBit = 100;
mfxStatus mfx_param_flag = mfxDEC.GetPayload(&ts,&dec_payload);
if((mfx_param_flag == MFX_ERR_NONE) && (dec_payload.Type == 4))
Where added variables are :
dec_payload.Data = new mfxU8;
When i check on dec_payload.Data memory by breaking at printf(""); i see different data than that was expected. I am not really sure if there is format issue here.
Although i am getting ATSC Identifier and Country code ,Provider code and user identifier properly such 0xB5, 0x0031, "GA94" etc. But once CC data starts after 0xFF, thats when i see different data . So in a way i am getting starting 12 bytes of each payload, properly. The remaining Actually CC data is mismatch from my reference . And also i am not getting Time stamp which was parameter to this function, as it always returns 0 .
Please let me know if i have done anything wrong or some interpretation problem. Please let me know.
I am attaching bin of dumps from my reference and from sample code with added snippet as shown for your reference.
Please HEX editors or Hex compare using Beyond compare.
CC_ref --> reference
CC_MFX--> MFX output.
I have added a new article on this topic, it may be of use to you. https://software.intel.com/en-us/blogs/2014/08/18/how-to-add-closed-caption-messages-in-avc-and-mpeg2-streams
If your code still does not work, we may have to look at how you are encoding the stream as well (assuming it is based off of a tutorial or sample code).
Regarding the timestamps - You need to set the timestamp before the DecodeFrameSync() function call in mfxBS.TimeStamp. When you do that, the GetPayload() function does return the correct timestamp in its TimeStamp variable.
(One thing to note in simple_decode() tutorial is that we are populating only the mfxBS->Data pointer by doing an fread(). So, the TimeStamp field is going to be 0 unless you populate it with a value).
Let me know if you have more questions.