Commit graph

45 commits

Author SHA1 Message Date
Yanjun Liao
60dfbcaace refactor[mpp]: Refactor C++ mpp to C
Change-Id: Icfe26b36d066b32355bda919e605e165399c0781
Signed-off-by: Yanjun Liao <yanjun.liao@rock-chips.com>
2025-10-11 09:10:42 +00:00
Hongjin Li
aa6ae2c5f6 refactor[osal]: Refactor more module from C++ to C
Refactor thread, list, queue and time module.

Signed-off-by: Chandler Chen <chandler.chen@rock-chips.com>
Signed-off-by: Hongjin Li <vic.hong@rock-chips.com>
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
Change-Id: I96c07e1549868085867502c8bb974ffd3875ea9d
2025-06-12 18:32:09 +08:00
Johnson Ding
bd8954a8f8 fix[vproc]: fix height out of boundary problem
Some interlaced stream with height not fully aligned to CTU may have
random values at bottom with some height. This part should not be
processed by IEP. Otherwise the output of IEP will have some flaws bottom.

Change-Id: Ia648d50b65511a091dee0701dae6f1b2b8e30407
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
2025-02-13 06:33:22 +00:00
Johnson Ding
fb957ea36a fix[vproc]: fix frame output disorder problem
When frame-field detection result changes from field mode to unknow or
frame mode, source picture will be output disordered.

Change-Id: I77d4da4d09b06e273e9e8b090182811a5e2c6f10
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
2025-01-20 01:47:05 +00:00
Johnson Ding
1d285e9e10 feat[vproc]: Add more log for debugging
Change-Id: I594f796c87d82d346ce1a651eaac3f40812fdfb8
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
2025-01-20 01:47:05 +00:00
Johnson Ding
66b669ef98 fix[vproc]: Fix field disordered problem
Change-Id: I69aa3ce0010eae221dc46fedd05d66b318e623f2
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
2025-01-20 01:47:05 +00:00
Johnson Ding
5b0f01d582 fix[vproc]: Fix error info missed problem
Change-Id: Ic9049ddec01ceaa1c160a7b3c2eada87133c140e
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
2025-01-13 10:00:04 +08:00
Johnson Ding
5e26aa37e0 fix[vproc]: Fix output blank buffer problem
Change-Id: I3934186aa075880283ab1501da15db496a16c600
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
2025-01-13 01:51:51 +00:00
xueman.ruan
518037c606 refactor[vproc]: Refactor iep2 progress
1. solving deinterlace mode changes when video is
   progressive at detection mode. Frame output
   order will be wrong for the first 10 frames.
2. solving the issue that ff_mode judge will not
   be updated when info changes.

Change-Id: I85ef0abe7af972dbe9ee7965f2c17de78330c506
Signed-off-by: xueman.ruan <xueman.ruan@rock-chips.com>
2024-12-05 15:49:43 +08:00
Herman Chen
9431bbc980 fix[vproc]: Fix deadlock in vproc thread
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 <herman.chen@rock-chips.com>
Change-Id: I742e55e745c46a4adb229e2f6f0e2a2c3498e369
2024-02-05 10:33:35 +08:00
Johnson Ding
f07778c8c1 [vproc]: Fix output frame repeated problem
For IEP2, the first two frames will be deinterlaced at I1O1 mode. I5O2
mode only works when the 3rd frame arrived. Thus the 2nd frame will be
deinterlaced twice and PTS will be repeated as following pattern:
-------------------------------------
IEP in  : 0   1   2       3     4
IEP out : 0   1   0.5 1   2.5 3   3.5
-------------------------------------
To fix this, just skip the 2nd frame processing.

Change-Id: I2d66951a941a664da093f1b9edbdd73855c57060
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
2022-12-26 09:02:19 +08:00
Johnson Ding
8d368ce49d [iep2]: fix timestamp incorrect problem
Field order shown at bistream syntax may be conflict with the detection
result of IEP. If there is obvious index showing that the detection
of IEP is right, we should trust IEP.

Change-Id: Ib151c4b538c187afb33e05c6e6a6e8a46c7629eb
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
2022-12-20 11:22:57 +08:00
Herman Chen
c22b65ef22 [vproc]: Simplify reset lock
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
Change-Id: I7f53706e74a16658309b3c027fb7c49817c15d86
2022-12-09 10:16:27 +08:00
Herman Chen
9d317ee674 [vproc]: Fix reset when task still in queue
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
Change-Id: Ic5d89db827024696c79ce51d1eef14d1b4ac415e
2022-12-09 10:07:52 +08:00
Johnson Ding
e10c4c7f3a [iep2]: Uncomonet dumping yuv routine
Change-Id: Ifc21e5c4f9119433c49c6f64ca7eb42b6287a1ef
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
2022-12-06 20:58:43 +08:00
Johnson Ding
4ce2785fd3 [vproc]: Fix dma buffer -1 issue
IEP2 out dst buffer may be NULL if doing reset.
log trace:
    mpp_dma_import_fd:198: dma_buf_get fd 1023 failed(-9)
    rk_vcodec: mpp_task_attach_fd:1679: can't import dma-buf 1023
    rk_vcodec: mpp_process_task_default:566: alloc_task failed.
    rk_vcodec: mpp_wait_result_default:826: session 00000000ca01418f
        pending list is empty!
    rk_vcodec: mpp_msgs_wait:1532: session 540 wait result ret -5

Change-Id: I8a824cd199d703f35d866d800dc7107caf1d76b3
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
2022-11-02 16:46:19 +08:00
Johnson Ding
e2764751b4 [vproc]: Adjust vproc thread flow to fix dead lock
Change-Id: I0ae8e0f44a4a8df03183511086f47e5ba561042a
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
2022-11-02 16:46:19 +08:00
Johnson Ding
293157e10f [iep2]: Frame mode all passed to iep2 for detected
1. Add MPP_VPROC_MODE_DETECTION for user to enable frame/field data
detection for iep2.
2. Use MPP_FRAME_FLAG_DEINTERLACED flag for frame/field data detection
flag in MppFrame.
3. Add vproc version and detection function to dec_vproc module.

Change-Id: I41e36c6df4a09970952b499eda5930091e6f716d
Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
2022-11-02 16:41:07 +08:00
Herman Chen
bb3dd76f91 [hal_task]: Add task stage count on init
Change-Id: Ic983ae423f826e244518e8d5ef06124a5c65c5dc
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2022-05-26 15:09:47 +08:00
Herman Chen
2e25db1a7d [mpp/mpp_enc]: Add async encoder flow
Change-Id: I0e040b8e9b1cdb40be996afc818a7ffb16802d09
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2022-03-02 15:20:57 +08:00
Herman Chen
fc8c86154e [hal_task]: Change hal_task to info with status
1. Split encoder and decoder hal_task defs and infos.
2. Change hal_task to a general info list with status.

Change-Id: I6f26035eeee4772d1ef99a21d85716e9c33eb9a6
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2022-02-18 15:35:56 +08:00
sayon.chen
8aa2a1ed3d [iep2]: Fix width & height set issue
Change-Id: I40eb51dbb7a8f54746fb5d114d1ff961515bb47f
Signed-off-by: sayon.chen <sayon.chen@rock-chips.com>
2021-12-17 18:11:43 +08:00
Herman Chen
3aad89dee8 [mpp_dec]: Add mpp_dec_callback
NOTE: The MppCtx should be restored for external user.

Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
Change-Id: I2a4241ddacb14196f43b29a59b46658131ebfcee
2021-10-13 17:17:56 +08:00
Ding Wei
70d330b271 [vproc]: missing set mode, when 2 in 1 out case
Change-Id: I28241fed2347ad85204c82b8e84c350e49fc42a2
Signed-off-by: Ding Wei <leo.ding@rock-chips.com>
2021-09-23 15:30:24 +08:00
Yandong Lin
baf1efa9f8 [mpp_dec_vproc]: fix err frame output issue
when src frame is err, dst should be set errinfo also.

Signed-off-by: Yandong Lin <yandong.lin@rock-chips.com>
Change-Id: I5d9f090abc3a9ffea8f7e921c1b523242ab1fc69
2021-09-14 16:24:37 +08:00
Siyong Chen
0383d8258d [vproc]: Expose hw feedback information to vproc
Return hw detection result from iep2 hal to vproc.

Change-Id: I53acb5260b5806abb6ba9085b81c967f30ea3f13
Signed-off-by: Alpha Lin <alpha.lin@rock-chips.com>
Signed-off-by: Siyong Chen <sayon.chen@rock-chips.com>
2021-06-11 10:50:20 +08:00
sayon.chen
c6c7498e0a [vproc]: Fix prevfrm free issue
Change-Id: I2305f80a519e06c526cbcfb343ff7558f0fe4a9b
Signed-off-by: sayon.chen <sayon.chen@rock-chips.com>
2020-12-24 16:01:30 +08:00
Herman Chen
11aa95e52f [mpp_log]: Update mpp_log macro
Change-Id: I0e46e93a9a8fa0a7cb7a0e86cec1748503bddcfb
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2020-12-17 16:07:28 +08:00
sayon.chen
e0210723e7 [iep2]: Fix prev_frm0 no free cause mem leak
Change-Id: I14925aa491902f023e026c2ac808d8434aa26a8c
Signed-off-by: sayon.chen <sayon.chen@rock-chips.com>
2020-12-15 15:31:40 +08:00
sayon.chen
660a378f1a [iep2]: Fix iep2 2 in 1 out case cfg issue
Change-Id: I23a7c86c6e54c01b61f9499dedf963a089fc65f6
Signed-off-by: sayon.chen <sayon.chen@rock-chips.com>
2020-12-15 15:30:14 +08:00
Alpha Lin
d9cce8d0e1 Add iep2 HAL library and unit test
Add iep2 HAL library and corresponding unit test.
Add a adapter layer for iep and iep2 compatible.

there will be libiep2.so generated after build.
this library will support direct using iep2 api outside
MPP platform, such as using in analog camera application.

Signed-off-by: Alpha Lin <alpha.lin@rock-chips.com>
Change-Id: Ide9662bf099e5374602dda7417ee6973de64c912
2020-07-24 15:05:06 +08:00
Herman Chen
16e7f330f2 [dec_vproc]: Fix vproc stuck issue on reset
Use semaphore to sync the reset operation.

Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
Change-Id: I7440530a779a7fd5c394e93b30f9addbaf4044d0
2020-01-19 18:02:52 +08:00
Rimon Xu
e36da64e9b [vproc]: set iep deinterlace mode to frame.
Change-Id: I5acd7b202bdbb60afa952f1f1486ae791e0e8cda
Signed-off-by: Rimon Xu <rimon.xu@rock-chips.com>
2019-12-23 14:37:41 +08:00
Grey Li
a9d6b3a994 [mpp_dec_vproc]: Add iep deinterlace capacity judge
Add iep deinterlace capacity judge before process. If iep can't suppurt
I4O2 mode, we always choice I2O1 mode.

Change-Id: I97ba11c6de57b54ac2068f2c1f348ee83e8d001d
Signed-off-by: Grey Li <grey.li@rock-chips.com>
2019-11-29 19:49:08 +08:00
Zhou Jing
d8e0653169 [dec_vproc]: Fix memory leak on iep open failed
Fix MppDecVprocCtxImpl_t memory leak when iep context create failed

Signed-off-by: Zhou Jing <tracy.zhou@rock-chips.com>
Change-Id: I49c791523822cc3551bb05fa74de2f741ee37bde
2019-11-06 08:16:09 +08:00
Herman Chen
6cf33e998b [mpp]: Remove extra signal and thread in mpp
1. Only use notify to communicated between mpp and codec.
2. Remove mpp_enc_impl.h

Change-Id: Ia62757240efa7d245b5215ad79539fa9bbbd1550
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2019-09-20 15:57:17 +08:00
Herman Chen
14076644ea [mpp_dec]: Add MppDecImpl layer
Add MppDecImpl layer for separate encoder and decoder.

Change-Id: I02e04acddf617ae5188572af89312ab20fbf21b6
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2019-09-19 14:54:24 +08:00
Herman Chen
003f8806af [vproc]: Pass HalTask between hal and vproc
Use HalTask to communicate between hal thread and vproc thread.

Change-Id: I4e87b7ca63bdf86e46045e31296ffa69958ae719
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2019-08-19 15:02:13 +08:00
Herman Chen
05bba59fa9 [hal_task]: Change hal task to a general task
Hal task will be changed to a more general task between mpp components.

Change-Id: I8ed46da8d02f530cddcdc785f6f6b3778afac5b9
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2019-08-19 14:56:13 +08:00
Rimon Xu
b4199f0c84 [vproc]: close iep config: dei_high_freq_en = 0
We need to turn off this switch to prevent some areas
of the video from flickering, but there may be other effects.
However, a choice needs to be made.

Change-Id: Ia52a604eed21e381f7310b1c85fe1c0434a1db13
Signed-off-by: Rimon Xu <rimon.xu@rock-chips.com>
2018-12-05 10:42:04 +08:00
Herman Chen
44f0ee0353 [mpp_dec]: Add post-process path to mpp_dec
1. Unify the hal thread output process to mpp_dec_put_frame
2. Add vproc path for field source.
3. Reserve one more buffer when deinterlace is enabled.
4. Default enable for normal mpp path but disable on vpuapi path for the
reason that rk_ffplayer has done deinterlace process internally.

Change-Id: I02e7cece844fde01c2d249dafe6f7ce6a325593f
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-06-05 15:10:39 +08:00
Herman Chen
e01b5376f0 [vproc]: Fix memory leak on mpp_dec_vproc reset
When mpp_dec_vproc reset buffer slot index should be dequeue and release
its MppFrame property to insure MppBuffer is not leaked.

Change-Id: I2dc35505306135907fe812b18ae3b8178adb942b
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-05-28 09:52:12 +08:00
Herman Chen
038cd1da10 [mpp_dec_vproc]: Fix Linux compile error
Change-Id: Iec85735fcc202f7867222ffb0aea0e92f39ffd43
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-05-21 12:01:51 +08:00
Herman Chen
c04421a94d [vproc]: Add iep function to mpp_dec_vproc
Add iep context and iep function to the mpp_dec_vproc.

Change-Id: I0e4819cccb068fc665d1d3cac89e0d4bcda032a5
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-05-21 11:08:07 +08:00
Herman Chen
e8c1db2556 [mpp_dec_vproc]: Add post process module
Add mpp dec post-process thread and functions.

Change-Id: I2a03e6ddfd6c746d272dd58b629e81f98b530c4a
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2018-05-14 14:49:59 +08:00