Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decoded frames are in wrong order #17

Closed
zillevdr opened this issue Apr 12, 2017 · 10 comments
Closed

decoded frames are in wrong order #17

zillevdr opened this issue Apr 12, 2017 · 10 comments

Comments

@zillevdr
Copy link

Hello,
the decoded frames are in wrong order. PresentationTimeStamp are ordered but the frames not. The picture on the screen jumps forward and backward. The packet from stream (decoder in) are not in the order for presentation. There is an tutorial that explain that.
This are the pts in and out decoder:

CodecVideoDecode: pts decoder in 1476218481 pts decoder out 1476186081
CodecVideoDecode: pts decoder in 1476211281 pts decoder out 1476187881
CodecVideoDecode: pts decoder in 1476205881 pts decoder out 1476189681
CodecVideoDecode: pts decoder in 1476207681 pts decoder out 1476191481
CodecVideoDecode: pts decoder in 1476209481 pts decoder out 1476193281
CodecVideoDecode: pts decoder in 1476213081 pts decoder out 1476195081
CodecVideoDecode: pts decoder in 1476214881 pts decoder out 1476196881
CodecVideoDecode: pts decoder in 1476216681 pts decoder out 1476198681
CodecVideoDecode: pts decoder in 1476232881 pts decoder out 1476200481
CodecVideoDecode: pts decoder in 1476225681 pts decoder out 1476202281
CodecVideoDecode: pts decoder in 1476220281 pts decoder out 1476204081
CodecVideoDecode: pts decoder in 1476222081 pts decoder out 1476205881

The frames should be sorted by pts not sorted the pts to the frames in incoming order. Or leave the pts to the decoded frame. Then can sorting in user space.

Best regards zillevdr

@timkingh
Copy link
Contributor

Hi, the decoded frames are in display order, and sorting can be done in MPP only, but not user space.

@zillevdr
Copy link
Author

zillevdr commented Apr 13, 2017

Why jumps the picture forward and backward? It looks like the decoded frames are in wrong order.
Please re-open this thread.

@WainDing
Copy link
Contributor

hi, zillevdr
As you said, "PresentationTimeStamp are ordered but the frames not. The picture on the screen jumps forward and backward." Can you give me the bitstream for my analysis?

@zillevdr
Copy link
Author

Hi XiaoleoDing,
yes, when I come home. It's a DVB-S TV stream H264 decoded.

@zillevdr
Copy link
Author

Hi XiaoleoDing,
you can download the stream from there
https://c.gmx.net/@324833219872561205/NfuYVQAdRDG9ZmpmUeCIYA
Regards zillevdr

@hizukiayaka
Copy link
Contributor

I have downloaded your video sample, it works fine with Gstreamer rockchip at RK3288 ASUS Tinker.

@hizukiayaka
Copy link
Contributor

Also there are some error in your stream, it usually happens when you are using a not well designed parser when you are packing your stream.
To handle this kind of issue, please reference to the implementation of Gstreamer Rockchip.
https://github.com/rockchip-linux/gstreamer-rockchip/blob/develop/gst/rockchipmpp/gstmppdecbufferpool.c#L244

@WainDing
Copy link
Contributor

hi, zillevdr
As hizukiayaka said, when mpp_frame_get_errorinfo(frame) !=0, current frame output must drop and not to dispaly. The reason is that, a fault tolerance mechanism is adopted, when find poc is less than the first I frame. In some demand, we need to show immediately, can not to wait. So, dispaly the first I frame immediately and mark poc less than the first I frame error.
like that:
Line 1214: 01-02 08:16:43.710 I/vpu_api_legacy( 3818): get one frame pts 88544427566, fd 0x30, poc 2, errinfo 0, discard 0, eos 0, verr 0
Line 1278: 01-02 08:16:43.710 I/vpu_api_legacy( 3818): get one frame pts 88544367566, fd 0x31, poc -4, errinfo 1, discard 0, eos 0, verr 1
Line 1324: 01-02 08:16:43.730 I/vpu_api_legacy( 3818): get one frame pts 88544307566, fd 0x32, poc -10, errinfo 0, discard 1, eos 0, verr 1
Line 1328: 01-02 08:16:43.730 I/vpu_api_legacy( 3818): get one frame pts 88544327566, fd 0x33, poc -8, errinfo 0, discard 1, eos 0, verr 1
Line 1332: 01-02 08:16:43.730 I/vpu_api_legacy( 3818): get one frame pts 88544347566, fd 0x34, poc -6, errinfo 0, discard 1, eos 0, verr 1
Line 1336: 01-02 08:16:43.730 I/vpu_api_legacy( 3818): get one frame pts 88544407566, fd 0x36, poc 0, errinfo 0, discard 1, eos 0, verr 1
Line 1340: 01-02 08:16:43.730 I/vpu_api_legacy( 3818): get one frame pts 88544387566, fd 0x35, poc -2, errinfo 0, discard 1, eos 0, verr 1
Line 1382: 01-02 08:16:43.770 I/vpu_api_legacy( 3818): get one frame pts 88544447566, fd 0x39, poc 4, errinfo 0, discard 0, eos 0, verr 0
Line 1384: 01-02 08:16:43.770 I/vpu_api_legacy( 3818): get one frame pts 88544467566, fd 0x3a, poc 6, errinfo 0, discard 0, eos 0, verr 0
Line 1386: 01-02 08:16:43.770 I/vpu_api_legacy( 3818): get one frame pts 88544487566, fd 0x38, poc 8, errinfo 0, discard 0, eos 0, verr 0
Line 1392: 01-02 08:16:43.770 I/vpu_api_legacy( 3818): get one frame pts 88544507566, fd 0x3b, poc 10, errinfo 0, discard 0, eos 0, verr 0
Line 1398: 01-02 08:16:43.770 I/vpu_api_legacy( 3818): get one frame pts 88544527566, fd 0x3c, poc 12, errinfo 0, discard 0, eos 0, verr 0
Line 1400: 01-02 08:16:43.770 I/vpu_api_legacy( 3818): get one frame pts 88544547566, fd 0x3d, poc 14, errinfo 0, discard 0, eos 0, verr 0
Line 1402: 01-02 08:16:43.780 I/vpu_api_legacy( 3818): get one frame pts 88544567566, fd 0x3e, poc 16, errinfo 0, discard 0, eos 0, verr 0
Line 1422: 01-02 08:16:43.780 I/vpu_api_legacy( 3818): get one frame pts 88544587566, fd 0x37, poc 18, errinfo 0, discard 0, eos 0, verr 0

@zillevdr
Copy link
Author

Hello,
the issue was in my app. I had freed the buffer after page flip. The DRM driver need 10 ms to render the frame on screen. In this time had the decoder over written the frame. Sorry for the trouble.
Thank you for your help! Best regards
zillevdr

@hizukiayaka
Copy link
Contributor

You should have a look on the Gstreamer rockchip to know how to release and reference a frame buffer correctly.

HermanChen added a commit that referenced this issue Feb 6, 2024
BUG is reported from https://redmine.rock-chips.com/issues/464206

Thread 18 (LWP 2440):
#0  __lll_lock_wait (futex=0x7f34000d48, private=0) at lowlevellock.c:52
#1  0x0000007fab5b1540 in __GI___pthread_mutex_lock (mutex=0x7f34000d48) at pthread_mutex_lock.c:115
#2  0x0000007fa9e0299c in dec_vproc_signal (ctx=0x7f34001260) at ../git/mpp/vproc/mpp_dec_vproc.cpp:929
#3  0x0000007fa9df5bdc in mpp_dec_notify (ctx=0x7f602be600, flag=1088) at ../git/mpp/codec/mpp_dec.cpp:956
#4  0x0000007fa9e0ef30 in mpp_buffer_ref_dec (buffer=0x7f6403f6c8, caller=caller@entry=0x7fa9ee300c "mpp_frame_deinit") at ../git/mpp/base/mpp_buffer_impl.cpp:509
#5  0x0000007fa9e0fb84 in mpp_buffer_put_with_caller (buffer=<optimized out>, caller=caller@entry=0x7fa9ee300c "mpp_frame_deinit") at ../git/mpp/base/mpp_buffer.cpp:105
#6  0x0000007fa9e11820 in mpp_frame_deinit (frame=frame@entry=0x7f602ec340) at ../git/mpp/base/mpp_frame.cpp:85
#7  0x0000007fabd6bf4c in rkmpp_release_frame (opaque=<optimized out>, data=0x7f602ba600 <error: Cannot access memory at address 0x7f602ba600>) at src/libavcodec/rkmppdec.c:339
#8  0x0000007fab9547dc in buffer_replace (src=0x0, dst=<optimized out>) at src/libavutil/buffer.c:133
#9  av_buffer_unref (buf=<optimized out>) at src/libavutil/buffer.c:144
#10 0x0000007fac714bb8 in mp_image_destructor (ptr=0x7f60252c80) at ../../../../../../sources/mpv/video/mp_image.c:209
#11 0x0000007fac748d40 in ta_free (ptr=0x7f60252c80) at ../../../../../../sources/mpv/ta/ta.c:244
#12 0x0000007fac715178 in mp_image_unrefp (p_img=p_img@entry=0x7f4c00bfc0) at ../../../../../../sources/mpv/video/mp_image.c:472
#13 0x0000007fac73396c in wlbuf_pool_entry_release (data=0x7f4c00bfa0, wl_buffer=<optimized out>) at ../../../../../../sources/mpv/video/out/wlbuf_pool.c:132
#14 0x0000007fb4cfe328 in ffi_call_SYSV () at ../libffi-3.3/src/aarch64/sysv.S:114
#15 0x0000007fb4cfdb44 in ffi_call_int (cif=cif@entry=0x7f70fdec80, fn=0x7f70fdeca0, orig_rvalue=orig_rvalue@entry=0x0, avalue=0x10, avalue@entry=0x7f70fded50, closure=0x200000001, closure@entry=0x0) at ../libffi-3.3/src/aarch64/ffi.c:747
#16 0x0000007fb4cfdf24 in ffi_call (cif=cif@entry=0x7f70fdec80, fn=<optimized out>, rvalue=rvalue@entry=0x0, avalue=avalue@entry=0x7f70fded50) at ../libffi-3.3/src/aarch64/ffi.c:756
#17 0x0000007faa49c7c0 in wl_closure_invoke (closure=0x7f4c00bff0, flags=<optimized out>, target=<optimized out>, opcode=0, data=<optimized out>) at ../wayland-1.22.0/src/connection.c:1025
#18 0x0000007faa499df0 in dispatch_event (display=display@entry=0x7f4c001d40, queue=<optimized out>) at ../wayland-1.22.0/src/wayland-client.c:1644
#19 0x0000007faa49b2c8 in dispatch_queue (queue=0x7f4c001e30, display=0x7f4c001d40) at ../wayland-1.22.0/src/wayland-client.c:1790
#20 wl_display_dispatch_queue_pending (display=0x7f4c001d40, queue=0x7f4c001e30) at ../wayland-1.22.0/src/wayland-client.c:2032
#21 0x0000007faa49b2f4 in wl_display_dispatch_pending (display=<optimized out>) at ../wayland-1.22.0/src/wayland-client.c:2095
#22 0x0000007fac73e2cc in vo_wayland_dispatch_events (wl=0x7f4c000e40, nfds=nfds@entry=2, timeout=timeout@entry=100) at ../../../../../../sources/mpv/video/out/wayland_common.c:1933
#23 0x0000007fac741d7c in vo_wayland_wait_events_timeout (vo=vo@entry=0x7f600abed0, timeout_ms=timeout_ms@entry=100) at ../../../../../../sources/mpv/video/out/wayland_common.c:2594
#24 0x0000007fac73baf4 in draw_frame (vo=0x7f600abed0, frame=0x7f302063b0) at ../../../../../../sources/mpv/video/out/vo_dmabuf_wayland.c:1113
#25 0x0000007fac7360c4 in render_frame (vo=0x7f600abed0) at ../../../../../../sources/mpv/video/out/vo.c:984
#26 vo_thread (ptr=0x7f600abed0) at ../../../../../../sources/mpv/video/out/vo.c:1123
#27 0x0000007fab5af370 in start_thread (arg=0x7f72ffbe06) at pthread_create.c:477
#28 0x0000007fab51bedc in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78

Thread 14 (LWP 3455):
#0  __lll_lock_wait (futex=0x7f60208040, private=0) at lowlevellock.c:52
#1  0x0000007fab5b1540 in __GI___pthread_mutex_lock (mutex=mutex@entry=0x7f60208040) at pthread_mutex_lock.c:115
#2  0x0000007fa9e0ef48 in mpp_buffer_ref_dec (buffer=0x7f6406fee8, caller=caller@entry=0x7fa9ee1ae7 "check_entry_unused") at ../git/mpp/base/mpp_buffer_impl.cpp:503
#3  0x0000007fa9e0fb84 in mpp_buffer_put_with_caller (buffer=<optimized out>, caller=caller@entry=0x7fa9ee1ae7 "check_entry_unused") at ../git/mpp/base/mpp_buffer.cpp:105
#4  0x0000007fa9e0bf1c in check_entry_unused (entry=0x7f601ef530, impl=0x7f60263ec0) at ../git/mpp/base/mpp_buf_slot.cpp:627
#5  mpp_buf_slot_clr_flag (slots=0x7f60263ec0, index=<optimized out>, type=type@entry=SLOT_QUEUE_USE) at ../git/mpp/base/mpp_buf_slot.cpp:919
#6  0x0000007fa9e00eb0 in dec_vproc_clr_prev0 (ctx=ctx@entry=0x7f34001260) at ../git/mpp/vproc/mpp_dec_vproc.cpp:149
#7  0x0000007fa9e00fd0 in dec_vproc_clr_prev (ctx=ctx@entry=0x7f34001260) at ../git/mpp/vproc/mpp_dec_vproc.cpp:180
#8  0x0000007fa9e012b8 in dec_vproc_thread (data=0x7f34001260) at ../git/mpp/vproc/mpp_dec_vproc.cpp:631
#9  0x0000007fab5af370 in start_thread (arg=0x7f47ffdf16) at pthread_create.c:477
#10 0x0000007fab51bedc in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78

Signed-off-by: Herman Chen <[email protected]>
Change-Id: I742e55e745c46a4adb229e2f6f0e2a2c3498e369
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants