Hello,
I am using H.264 HP encoder for C66x DSP version DEV.100.V.H264HP.E.C66X.01.00.00.00.
For some reason H.264 HP encoder produces wrong H.264 elementary stream that is not playable (we use ffmpeg to play it):
ffplay -f h264 output.264
avplay version 0.8.4-6:0.8.4-0ubuntu0.12.10.1, Copyright (c) 2003-2012 the Libav developers
built on Nov 6 2012 16:51:11 with gcc 4.7.2
[h264 @ 0x7fee54000e00] non-existing PPS referenced
[h264 @ 0x7fee54000e00] non-existing PPS 0 referenced
[h264 @ 0x7fee54000e00] decode_slice_header error
[h264 @ 0x7fee54000e00] no frame!
[h264 @ 0x7fee54000e00] sps_id out of range
[h264 @ 0x7fee54000e00] non-existing PPS referenced
[h264 @ 0x7fee54000e00] sps_id out of range
[h264 @ 0x7fee54000e00] non-existing PPS 0 referenced
[h264 @ 0x7fee54000e00] decode_slice_header error
[h264 @ 0x7fee54000e00] no frame!
[h264 @ 0x7fee54000e00] non-existing PPS referenced
[h264 @ 0x7fee54000e00] non-existing PPS 0 referenced
[h264 @ 0x7fee54000e00] decode_slice_header error
[h264 @ 0x7fee54000e00] no frame!
As we see most likely IDR frame is missing.
At the same time demo that goes with H.264 encoder produces correct streams.
I created test that shows how we use H.264 encoder. I did totally the same call order to the encoder API (including all not mandatory calls) in my test as in original demo that goes with the encoder. Input parameters are also the same - you can compare demo_params.txt and test_params.txt files that contains copy of the param and dynamic params of test and original demo.
Some details about test:
- By default test encodes YUV that consists of all zeros - a green image. This is to speed-up testing because reading input YUV files is slow.
- Also you can use "input.yuv" file as an input. Just uncomment "fopen" code in test_task.c
- For simplicity test does not use caching
- For simplicity test does not have a buffer manager. We just never free allocated input/output buffers. So with time it ends with out of memory error.
- For simplicity no IPC. Only one core is used.
- Shared Memory Manager implemented using SYS/BIOS Heap
- Test outputs encoded stream to "output.264" file
Call order:
algNumAlloc
algAlloc
algInit
algActivate
control XDM_GETVERSION
algDeactivate
algActivate
control XDM_GETBUFINFO
algDeactivate
algActivate
RMAN_assignResources
RMAN_activateAllResources
algDeactivate
loop {
algActivate
control XDM_SETPARAMS
algDeactivate
algActivate
process
algActivate
control XDM_GETSTATUS
algDeactivate
}
Results are interesting - frame type changes correctly, starting from IDR frame, but encoder doesn't generate any data:
[C66xx_0] main() on CORE=0
Initialize RMAN
Start SYS/BIOS
test_task
Create encoder
Version: DEV.100.V.H264HP.E.C66X.01.00.00.00
Configure encoder2 buffers
minNumInBufs 3
minNumOutBufs 1
minInBufSize[0] 101376 0
minInBufSize[1] 25344 0
minInBufSize[2] 25344 0
minOutBufSize[0] 3145728 0
Input buffers size (bytes in YUV frame) = 152064
Output buffers size = 3145728
Configure encoder resources
Encoder created and configured
Allocating input and output buffers
Encoding frame
Frame type: -1 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: -1 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: 3 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: 1 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: 2 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: 2 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: 1 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: 2 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: 2 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: 1 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: 2 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: 2 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: 1 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: 2 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: 2 Bytes generated 0
Allocating input and output buffers
Encoding frame
....
Also with little different call order encoder is able to generate bytes so I am attaching generated data for you to compare:
output.264 - generated by test (with little different call order)
airshow_p352x288.264 - generated by original demo
Log of test with changed call order:
...
Encoder created and configured
Allocating input and output buffers
Encoding frame
Frame type: -1 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: -1 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: 3 Bytes generated 0
Allocating input and output buffers
Encoding frame
Frame type: 1 Bytes generated 103
Output 103 bytes from 0 buffer
Allocating input and output buffers
Encoding frame
Frame type: 2 Bytes generated 16
Output 16 bytes from 0 buffer
Allocating input and output buffers
Encoding frame
Frame type: 2 Bytes generated 14
Output 14 bytes from 0 buffer
Allocating input and output buffers
Encoding frame
Frame type: 1 Bytes generated 14
Output 14 bytes from 0 buffer
Allocating input and output buffers
Encoding frame
Frame type: 2 Bytes generated 16
Output 16 bytes from 0 buffer
Allocating input and output buffers
Encoding frame
As you see in this case Bytest generated = 0, when Frame type = 3 (IDR) so most likely IDR frame just missing.
I can not understand where is the problem because H.264 HP encoder is a black box for me and all the "magic" that generates bytes is in it.
Can you clarify the reason of this strange encoder behaviour?
Regards,
Andrey Lisnevich