Video stream decoding method and apparatus, terminal device, and storage medium
View Patent ↗A video stream decoding method is provided. The video stream decoding method is performed by a terminal device. The method includes receiving a plurality of video streams from a monitoring device; generating a plurality of threads in a thread pool corresponding to a graphics processing unit (GPU); and transmitting, according to the plurality of threads, the plurality of video streams to the GPU for video decoding processing to obtain a plurality of pieces of decoded video data.
1 . A video stream decoding method comprising:
receiving a plurality of video streams;
generating a plurality of threads in a thread pool corresponding to a graphics processing unit (GPU);
transmitting, according to the plurality of threads, the plurality of video streams to the GPU for video decoding processing to obtain a plurality of pieces of decoded video data, the plurality of pieces of decoded video data comprise a first number of pieces of first decoded video data and a second number of pieces of second decoded video data;
identifying a first memory corresponding to the first number of pieces of first decoded video data, and a second memory corresponding to the second number of pieces of second decoded video data, the first memory and the second memory being located outside of the GPU; and
outputting, by using the GPU, the first number of pieces of first decoded video data to the first memory and outputting the second number of pieces of second decoded video data to the second memory.
2 . The video stream decoding method according to claim 1 , wherein the generating a plurality of threads in a thread pool corresponding to a GPU comprises:
obtaining an inputted thread quantity; and
generating the threads in the thread pool corresponding to the GPU according to the thread quantity.
3 . The video stream decoding method according to claim 1 , wherein the generating a plurality of threads in a thread pool corresponding to a GPU comprises:
obtaining a video stream quantity of the plurality of video streams; and
generating threads in the thread pool corresponding to the GPU, a quantity of the threads being the same as the video stream quantity.
4 . The video stream decoding method according to claim 3 , wherein the transmitting, according to the plurality of threads, the plurality of video streams to the GPU for video decoding processing to obtain a plurality of pieces of decoded video data comprises:
allocating one thread in the plurality of threads for each video stream in the plurality of video streams in a one-to-one correspondence;
identifying a thread among the plurality of threads as a target thread, and inputting a target video stream into the GPU by using the target thread, the target video stream being a video stream corresponding to the target thread among the plurality of video streams; and
decoding the target video stream by using the GPU to obtain target decoded video data.
5 . The video stream decoding method according to claim 4 , wherein the decoding the target video stream by using the GPU to obtain target decoded video data comprises:
sequentially using each frame of image in the target video stream as a target image, and decoding the target image by using the GPU; and
determining to frame-skip the target image when the target image does not comprise a preset type of object.
6 . The video stream decoding method according to claim 4 , wherein the method further comprises:
restarting the target thread, inputting the target video stream into the GPU by reusing the target thread when the target video stream needs to be replayed, and decoding the target video stream by using the GPU to obtain the target decoded video data.
7 . The video stream decoding method according to claim 4 , wherein the method further comprises:
collecting the target thread when decoding of the target video stream ends and the target video stream does not need to be replayed.
8 . The video stream decoding method according to claim 1 , wherein the plurality of pieces of decoded video data further comprises third number of pieces of decoded video data, and the method further comprises:
identifying a third memory corresponding to the third number of pieces of decoded video data, the third memory being external to the GPU; and
outputting, by using the GPU, the third number of pieces of decoded video data to the third memory.
9 . The video stream decoding method according to claim 1 , wherein the first and second memories are identified from memories coupled to the GPU, and the memories coupled to the GPU comprise at least one of a system memory, a shared memory, or a disk.
10 . The video stream decoding method according to claim 1 , further comprising:
obtaining address codes of memories corresponding to the plurality of pieces of decoded video data;
performing a memory map according to the address codes to determine target memories corresponding to the plurality of pieces of decoded video data; and
outputting the plurality of pieces of decoded video data to the respective corresponding target memories.
11 . The method according to claim 1 , wherein at least one of the first number and the second number is an integer greater than 1.
12 . A video stream decoding apparatus, comprising a memory and at least one processor, the memory storing computer-readable instructions, the computer-readable instructions, when executed by the at least one processor, causing the at least one processor to:
receive a plurality of video streams;
generate a plurality of threads in a thread pool corresponding to a graphics processing unit (GPU);
transmit, according to the plurality of threads, the plurality of video streams to the GPU for video decoding processing to obtain a plurality of pieces of decoded video data, the plurality of pieces of decoded video data comprise a first number of pieces of first decoded video data and a second number of pieces of second decoded video data;
identify a first memory corresponding to the first number of pieces of first decoded video data, and a second memory corresponding to the second number of pieces of second decoded video data, the first memory and the second memory being located outside of the GPU; and
output, by using the GPU, the first number of pieces of first decoded video data to the first memory and outputting the second number of pieces of second decoded video data to the second memory.
13 . The video stream decoding apparatus according to claim 12 , wherein the at least one processor is further configured to obtain an inputted thread quantity; and generated the plurality of threads in the thread pool corresponding to the GPU according to the thread quantity, a quantity of the plurality of threads being equal to the thread quantity.
14 . The video stream decoding apparatus according to claim 12 , wherein the at least one processor is further configured to obtain a video stream quantity of the plurality of video streams; and generate threads in the thread pool corresponding to the GPU, a quantity of the threads being the same as the video stream quantity.
15 . The video stream decoding apparatus according to claim 14 , wherein the at least one processor is further configured to:
allocate one thread in the plurality of threads for each video stream in the plurality of video streams in a one-to-one correspondence;
take a thread among the plurality of threads as a target thread, and input a target video stream into the GPU by using the target thread, the target video stream being a video stream corresponding to the target thread among the plurality of video streams; and
decode the target video stream by using the GPU to obtain target decoded video data.
16 . The video stream decoding apparatus according to claim 15 , wherein the at least one processor is further configured to:
sequentially use each frame of image in the target video stream as a target image, and decode the target image by using the GPU; and
determine to frame-skip the target image when the target image does not comprise a preset type of object.
17 . The video stream decoding apparatus according to claim 15 , wherein the at least one processor is further configured to restart the target thread, input the target video stream into the GPU by reusing the target thread, and decode the target video stream by using the GPU to obtain the target decoded video data when decoding of the target video stream ends and the target video stream needs to be replayed.
18 . The video stream decoding apparatus according to claim 15 , wherein the at least one processor is further configured to:
collect the target thread when decoding of the target video stream ends and the target video stream does not need to be replayed.
19 . The video stream decoding apparatus according to claim 12 , wherein the plurality of pieces of decoded video data further comprises third decoded video data, and the at least one processor is further configured to:
obtain address codes of memories corresponding to the plurality of pieces of decoded video data;
perform a memory map according to the address codes to determine target memories corresponding to the plurality of pieces of decoded video data; and
output the plurality of pieces of decoded video data to the respective corresponding target memories.
20 . A non-transitory computer readable storage medium storing computer-readable instructions, the computer-readable instructions, when executed by one or more processors, causing the one or more processors to perform operations comprising:
receiving a plurality of video streams;
generating a plurality of threads in a thread pool corresponding to a graphics processing unit (GPU);
transmitting, according to the plurality of threads, the plurality of video streams to the GPU for video decoding processing to obtain a plurality of pieces of decoded video data, the plurality of pieces of decoded video data comprise a first number of pieces of first decoded video data and a second number of pieces of second decoded video data;
identifying a first memory corresponding to the first number of pieces of first decoded video data, and a second memory corresponding to the second number of pieces of second decoded video data, the first memory and the second memory being located outside of the GPU; and
outputting, by using the GPU, the first number of pieces of first decoded video data to the first memory and outputting the second number of pieces of second decoded video data to the second memory.