Skip to content

Commit ab0f2ff

Browse files
committed
Some fixes regarding snapshots on Rockchip, RTP fragmented unit packets
1 parent 5c1f4bb commit ab0f2ff

File tree

5 files changed

+26
-20
lines changed

5 files changed

+26
-20
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
- name: Build
1919
run: |
20-
list="arm-glibc arm-musl3 arm-musl4 arm9-musl3 arm9-musl4 arm9-uclibc armhf-glibc armhf-musl mips-musl"
20+
list="arm-glibc arm-musl3 arm-musl4 arm9-musl3 arm9-musl4 arm9-uclibc armhf-glibc armhf-musl armhf-uclibc mips-musl"
2121
for lib in $list; do
2222
sh build.sh $lib
2323
zip $lib divinus*

src/compat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ float __expf_finite(float x) { return expf(x); }
5555
int __fgetc_unlocked(FILE *stream) { return fgetc(stream); }
5656
double __log_finite(double x) { return log(x); }
5757

58-
#if !defined(__riscv) || !defined(__riscv__)
58+
#if !defined(__riscv) && !defined(__riscv__)
5959
void *mmap(void *start, size_t len, int prot, int flags, int fd, uint32_t off) {
6060
return (void*)syscall(SYS_mmap2, start, len, prot, flags, fd, off >> 12);
6161
}

src/hal/plus/rk_hal.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -614,15 +614,15 @@ int rk_video_snapshot_grab(char index, hal_jpegdata *jpeg)
614614
{
615615
int ret;
616616

617-
if (ret = rk_channel_bind(index)) {
618-
HAL_DANGER("rk_venc", "Binding the encoder channel "
617+
unsigned int count = 1;
618+
if (rk_venc.fnStartReceivingEx(index, &count)) {
619+
HAL_DANGER("rk_venc", "Requesting one frame "
619620
"%d failed with %#x!\n", index, ret);
620621
goto abort;
621622
}
622623

623-
unsigned int count = 1;
624-
if (rk_venc.fnStartReceivingEx(index, &count)) {
625-
HAL_DANGER("rk_venc", "Requesting one frame "
624+
if (ret = rk_channel_bind(index)) {
625+
HAL_DANGER("rk_venc", "Binding the encoder channel "
626626
"%d failed with %#x!\n", index, ret);
627627
goto abort;
628628
}
@@ -644,7 +644,7 @@ int rk_video_snapshot_grab(char index, hal_jpegdata *jpeg)
644644

645645
if (FD_ISSET(fd, &readFds)) {
646646
rk_venc_stat stat;
647-
if (rk_venc.fnQuery(index, &stat)) {
647+
/*if (rk_venc.fnQuery(index, &stat)) {
648648
HAL_DANGER("rk_venc", "Querying the encoder channel "
649649
"%d failed with %#x!\n", index, ret);
650650
goto abort;
@@ -653,7 +653,7 @@ int rk_video_snapshot_grab(char index, hal_jpegdata *jpeg)
653653
if (!stat.curPacks) {
654654
HAL_DANGER("rk_venc", "Current frame is empty, skipping it!\n");
655655
goto abort;
656-
}
656+
}*/stat.curPacks = 1;
657657

658658
rk_venc_strm strm;
659659
memset(&strm, 0, sizeof(strm));
@@ -667,8 +667,6 @@ int rk_video_snapshot_grab(char index, hal_jpegdata *jpeg)
667667
if (ret = rk_venc.fnGetStream(index, &strm, 40)) {
668668
HAL_DANGER("rk_venc", "Getting the stream on "
669669
"channel %d failed with %#x!\n", index, ret);
670-
free(strm.packet);
671-
strm.packet = NULL;
672670
goto abort;
673671
}
674672

@@ -689,16 +687,20 @@ int rk_video_snapshot_grab(char index, hal_jpegdata *jpeg)
689687
}
690688
}
691689

692-
abort:
693690
rk_venc.fnFreeStream(index, &strm);
691+
abort:
692+
if (strm.packet) {
693+
free(strm.packet);
694+
strm.packet = NULL;
695+
}
694696
}
695697

696698
rk_venc.fnFreeDescriptor(index);
697699

698-
rk_venc.fnStopReceiving(index);
699-
700700
rk_channel_unbind(index);
701701

702+
rk_venc.fnStopReceiving(index);
703+
702704
return ret;
703705
}
704706

@@ -823,8 +825,10 @@ void *rk_video_thread(void)
823825
"channel %d failed with %#x!\n", i, ret);
824826
}
825827
free:
826-
free(stream.packet);
827-
stream.packet = NULL;
828+
if (stream.packet) {
829+
free(stream.packet);
830+
stream.packet = NULL;
831+
}
828832
}
829833
}
830834
}

src/jpeg.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ int jpeg_init() {
4141
case HAL_PLATFORM_I6: ret = i6_video_create(jpeg_index, &config); break;
4242
case HAL_PLATFORM_I6C: ret = i6c_video_create(jpeg_index, &config); break;
4343
case HAL_PLATFORM_M6: ret = m6_video_create(jpeg_index, &config); break;
44+
case HAL_PLATFORM_RK: ret = rk_video_create(jpeg_index, &config); break;
4445
#elif defined(__ARM_PCS)
4546
case HAL_PLATFORM_V1: ret = v1_video_create(jpeg_index, &config); break;
4647
case HAL_PLATFORM_V2: ret = v2_video_create(jpeg_index, &config); break;
@@ -79,6 +80,7 @@ void jpeg_deinit() {
7980
case HAL_PLATFORM_I6: i6_video_destroy(jpeg_index); break;
8081
case HAL_PLATFORM_I6C: i6c_video_destroy(jpeg_index); break;
8182
case HAL_PLATFORM_M6: m6_video_destroy(jpeg_index); break;
83+
case HAL_PLATFORM_RK: rk_video_destroy(jpeg_index); break;
8284
#elif defined(__ARM_PCS)
8385
case HAL_PLATFORM_GM: goto active;
8486
case HAL_PLATFORM_V1: v1_video_destroy(jpeg_index); break;
@@ -118,6 +120,7 @@ int jpeg_get(short width, short height, char quality, char grayscale,
118120
case HAL_PLATFORM_I6: ret = i6_video_snapshot_grab(jpeg_index, quality, jpeg); break;
119121
case HAL_PLATFORM_I6C: ret = i6c_video_snapshot_grab(jpeg_index, quality, jpeg); break;
120122
case HAL_PLATFORM_M6: ret = m6_video_snapshot_grab(jpeg_index, quality, jpeg); break;
123+
case HAL_PLATFORM_RK: ret = rk_video_snapshot_grab(jpeg_index, jpeg); break;
121124
#elif defined(__ARM_PCS)
122125
case HAL_PLATFORM_GM: ret = gm_video_snapshot_grab(width, height, quality, jpeg); break;
123126
case HAL_PLATFORM_V1: ret = v1_video_snapshot_grab(jpeg_index, jpeg); break;
@@ -131,9 +134,8 @@ int jpeg_get(short width, short height, char quality, char grayscale,
131134
case HAL_PLATFORM_CVI: ret = cvi_video_snapshot_grab(jpeg_index, jpeg); break;
132135
#endif
133136
}
134-
if (ret) {
135-
if (jpeg->data)
136-
free(jpeg->data);
137+
if (ret && jpeg->data) {
138+
free(jpeg->data);
137139
jpeg->data = NULL;
138140
}
139141

src/rtsp/rtp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static inline int __transfer_nal_h26x(struct list_head_t *trans_list, unsigned c
116116
/* intended xor. blame vim :( */
117117
payload[head - 1] &= 0xFF ^ (1<<7);
118118

119-
rtp.rtpsize = nalsize + sizeof(rtp_hdr_t);
119+
rtp.rtpsize = nalsize + sizeof(rtp_hdr_t) + head;
120120

121121
memcpy(&(payload[head]), nalptr, nalsize);
122122

0 commit comments

Comments
 (0)